changeset 49480:cdfba684b6a1

status: include `repo` in template context also for resolved paths The `repo` object needs to be in the templater context when using e.g. `relpath`. It has been missing there since it was the unresolved files were added to the templated output in 07ebb567e8bb.
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 12 Aug 2022 14:35:34 -0700
parents 744b341782f4
children 53229e170496
files mercurial/cmdutil.py tests/test-update-branches.t
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Aug 24 15:15:04 2022 -0400
+++ b/mercurial/cmdutil.py	Fri Aug 12 14:35:34 2022 -0700
@@ -832,7 +832,7 @@
 
 @attr.s(frozen=True)
 class morestatus:
-    reporoot = attr.ib()
+    repo = attr.ib()
     unfinishedop = attr.ib()
     unfinishedmsg = attr.ib()
     activemerge = attr.ib()
@@ -876,7 +876,7 @@
             mergeliststr = b'\n'.join(
                 [
                     b'    %s'
-                    % util.pathto(self.reporoot, encoding.getcwd(), path)
+                    % util.pathto(self.repo.root, encoding.getcwd(), path)
                     for path in self.unresolvedpaths
                 ]
             )
@@ -898,6 +898,7 @@
                     # Already output.
                     continue
                 fm.startitem()
+                fm.context(repo=self.repo)
                 # We can't claim to know the status of the file - it may just
                 # have been in one of the states that were not requested for
                 # display, so it could be anything.
@@ -923,7 +924,7 @@
     if activemerge:
         unresolved = sorted(mergestate.unresolved())
     return morestatus(
-        repo.root, unfinishedop, unfinishedmsg, activemerge, unresolved
+        repo, unfinishedop, unfinishedmsg, activemerge, unresolved
     )
 
 
--- a/tests/test-update-branches.t	Wed Aug 24 15:15:04 2022 -0400
+++ b/tests/test-update-branches.t	Fri Aug 12 14:35:34 2022 -0700
@@ -633,6 +633,10 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
+  $ hg status -T '{status} {path} - {relpath(path)}\n'
+  M foo - foo
+   a - a
+
   $ hg status -Tjson
   [
    {