Patchwork D5978: subrepo: use root-repo-relative path from `hg files` with ui.relative-paths=no

login
register
mail settings
Submitter phabricator
Date Feb. 20, 2019, 8:32 p.m.
Message ID <91efd6eb8e1dcf8eea6d8b6f1b0cb7c8@localhost.localdomain>
Download mbox | patch
Permalink /patch/38832/
State Not Applicable
Headers show

Comments

phabricator - Feb. 20, 2019, 8:32 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4fecf4f6524f: subrepo: use root-repo-relative path from `hg files` with ui.relative-paths=no (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5978?vs=14135&id=14151

REVISION DETAIL
  https://phab.mercurial-scm.org/D5978

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/subrepo.py
  tests/test-subrepo.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -36,7 +36,7 @@ 
   $ hg files -S --config ui.relative-paths=no
   .hgsub
   a
-  a
+  s/a
 
   $ hg -R s ci -Ams0
   $ hg sum
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -325,7 +325,7 @@ 
         """Resolve the fileset expression for this repo"""
         return matchmod.never(badfn=badfn)
 
-    def printfiles(self, ui, m, fm, fmt, subrepos):
+    def printfiles(self, ui, m, uipathfn, fm, fmt, subrepos):
         """handle the files command for this subrepo"""
         return 1
 
@@ -795,15 +795,15 @@ 
         return ctx.flags(name)
 
     @annotatesubrepoerror
-    def printfiles(self, ui, m, fm, fmt, subrepos):
+    def printfiles(self, ui, m, uipathfn, fm, fmt, subrepos):
         # If the parent context is a workingctx, use the workingctx here for
         # consistency.
         if self._ctx.rev() is None:
             ctx = self._repo[None]
         else:
             rev = self._state[1]
             ctx = self._repo[rev]
-        return cmdutil.files(ui, ctx, m, fm, fmt, subrepos)
+        return cmdutil.files(ui, ctx, m, uipathfn, fm, fmt, subrepos)
 
     @annotatesubrepoerror
     def matchfileset(self, expr, badfn=None):
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2213,8 +2213,10 @@ 
 
     m = scmutil.match(ctx, pats, opts)
     ui.pager('files')
+    uipathfn = scmutil.getuipathfn(ctx.repo(), legacyrelativevalue=True)
     with ui.formatter('files', opts) as fm:
-        return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
+        return cmdutil.files(ui, ctx, m, uipathfn, fm, fmt,
+                             opts.get('subrepos'))
 
 @command(
     'forget',
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2171,11 +2171,10 @@ 
         forgot.extend(f for f in forget if f not in rejected)
     return bad, forgot
 
-def files(ui, ctx, m, fm, fmt, subrepos):
+def files(ui, ctx, m, uipathfn, fm, fmt, subrepos):
     ret = 1
 
     needsfctx = ui.verbose or {'size', 'flags'} & fm.datahint()
-    uipathfn = scmutil.getuipathfn(ctx.repo(), legacyrelativevalue=True)
     for f in ctx.matches(m):
         fm.startitem()
         fm.context(ctx=ctx)
@@ -2188,11 +2187,13 @@ 
 
     for subpath in sorted(ctx.substate):
         submatch = matchmod.subdirmatcher(subpath, m)
+        subuipathfn = scmutil.subdiruipathfn(subpath, uipathfn)
         if (subrepos or m.exact(subpath) or any(submatch.files())):
             sub = ctx.sub(subpath)
             try:
                 recurse = m.exact(subpath) or subrepos
-                if sub.printfiles(ui, submatch, fm, fmt, recurse) == 0:
+                if sub.printfiles(ui, submatch, subuipathfn, fm, fmt,
+                                  recurse) == 0:
                     ret = 0
             except error.LookupError:
                 ui.status(_("skipping missing subrepository: %s\n")