[PATCH 2 of 2] paths: print 'default' and 'default-push' before other paths

Idan Kamara idankk86 at gmail.com
Sat Sep 22 08:54:01 CDT 2012


# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1348321928 -10800
# Branch stable
# Node ID 8391c38ded9d23c446ad090c646d9058c5e547fd
# Parent  575cb6034535925ab0344c1e7f01de601a015625
paths: print 'default' and 'default-push' before other paths

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4448,7 +4448,20 @@
             ui.warn(_("not found!\n"))
         return 1
     else:
-        for name, path in ui.configitems("paths"):
+        paths = ui.configitems("paths")
+
+        # move default and default-push to the front
+        for i, (name, path) in enumerate(paths):
+            if name == 'default':
+                paths.insert(0, paths.pop(i))
+            elif name == 'default-push':
+                # ensure default-push is after default
+                j = 0
+                if paths[0][0] == 'default':
+                    j = 1
+                paths.insert(j, paths.pop(i))
+
+        for name, path in paths:
             if name in ('default', 'default-push'):
                 label = 'paths.default'
             else:


More information about the Mercurial-devel mailing list