diff mercurial/templatekw.py @ 47198:7531cc34713c

urlutil: make `paths` class old list of `path` We move from a `{name ? path}` mapping to a `{name ? [path]}` mapping. And update all user code accordingly. For now, all the list contains exactly one element, but we are now in a good place to make the config understand a list of url. Differential Revision: https://phab.mercurial-scm.org/D10447
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 15 Apr 2021 16:58:20 +0200
parents 9c4d30b079e0
children d5121df04808
line wrap: on
line diff
--- a/mercurial/templatekw.py	Thu Apr 15 17:15:43 2021 +0200
+++ b/mercurial/templatekw.py	Thu Apr 15 16:58:20 2021 +0200
@@ -667,14 +667,19 @@
     urls = util.sortdict((k, p.rawloc) for k, p in all_paths)
 
     def makemap(k):
-        p = paths[k]
-        d = {b'name': k, b'url': p.rawloc}
-        sub_opts = util.sortdict(sorted(pycompat.iteritems(p.suboptions)))
-        d.update(sub_opts)
+        ps = paths[k]
+        d = {b'name': k}
+        if len(ps) == 1:
+            d[b'url'] = ps[0].rawloc
+            sub_opts = pycompat.iteritems(ps[0].suboptions)
+            sub_opts = util.sortdict(sorted(sub_opts))
+            d.update(sub_opts)
         path_dict = util.sortdict()
-        path_dict[b'url'] = p.rawloc
-        path_dict.update(sub_opts)
-        d[b'urls'] = [path_dict]
+        for p in ps:
+            sub_opts = util.sortdict(sorted(pycompat.iteritems(p.suboptions)))
+            path_dict[b'url'] = p.rawloc
+            path_dict.update(sub_opts)
+            d[b'urls'] = [path_dict]
         return d
 
     def format_one(k):