changeset 47184:9c4d30b079e0

template: add a `paths` field to all entry in peerurls This make it possible to display multiple path per name in the near future. Differential Revision: https://phab.mercurial-scm.org/D10444
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 15 Apr 2021 12:33:05 +0200
parents df2bf38ac382
children a2632ce1f15b
files mercurial/templatekw.py tests/test-paths.t
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templatekw.py	Tue May 11 18:10:59 2021 +0200
+++ b/mercurial/templatekw.py	Thu Apr 15 12:33:05 2021 +0200
@@ -669,7 +669,12 @@
     def makemap(k):
         p = paths[k]
         d = {b'name': k, b'url': p.rawloc}
-        d.update((o, v) for o, v in sorted(pycompat.iteritems(p.suboptions)))
+        sub_opts = util.sortdict(sorted(pycompat.iteritems(p.suboptions)))
+        d.update(sub_opts)
+        path_dict = util.sortdict()
+        path_dict[b'url'] = p.rawloc
+        path_dict.update(sub_opts)
+        d[b'urls'] = [path_dict]
         return d
 
     def format_one(k):
--- a/tests/test-paths.t	Tue May 11 18:10:59 2021 +0200
+++ b/tests/test-paths.t	Thu Apr 15 12:33:05 2021 +0200
@@ -98,6 +98,9 @@
   expand: $TESTTMP/a/$SOMETHING/bar
   $ hg log -rnull -T '{get(peerurls, "dupe")}\n'
   $TESTTMP/b#tip
+  $ hg log -rnull -T '{peerurls % "{urls|json}\n"}'
+  [{"pushurl": "https://example.com/dupe", "url": "$TESTTMP/b#tip"}]
+  [{"url": "$TESTTMP/a/$SOMETHING/bar"}]
 
  (sub options can be populated by map/dot operation)