Hg paths show password

Wesley Leggette wleggette at cleversafe.com
Sat Feb 21 18:06:48 CST 2009


Hi,

The following patch adds a --show-passwords option to the "hg paths"
command. Using this option causes passwords to /not/ be obscured. I've added
this so that the mercurial eclipse plugin can read usernames and passwords
for the push/pull pages so it can remember/pre-populate usernames and
passwords.

For mercurial eclipse the alternative was to directly read the .hg/hgrc
file. This did not seem to be generally desirable, hence this patch.

Wesley Leggette

-----------------------------------------------------------------------

Added a --show-passwords option to hg paths command.

diff -r b8d750daadde mercurial/commands.py
--- a/mercurial/commands.py    Mon Feb 16 19:35:07 2009 -0600
+++ b/mercurial/commands.py    Sat Feb 21 18:05:57 2009 -0600
@@ -2114,7 +2114,7 @@
         if n != nullid:
             displayer.show(repo[n])
 
-def paths(ui, repo, search=None):
+def paths(ui, repo, search=None, **opts):
     """show aliases for remote repositories
 
     Show definition of symbolic path name NAME. If no name is given, show
@@ -2128,13 +2128,19 @@
     if search:
         for name, path in ui.configitems("paths"):
             if name == search:
-                ui.write("%s\n" % url.hidepassword(path))
+                if (opts.get('show_passwords')):
+                    ui.write("%s\n" % path)
+                else:
+                    ui.write("%s\n" % url.hidepassword(path))
                 return
         ui.warn(_("not found!\n"))
         return 1
     else:
         for name, path in ui.configitems("paths"):
-            ui.write("%s = %s\n" % (name, url.hidepassword(path)))
+            if (opts.get('show_passwords')):
+                ui.write("%s = %s\n" % (name, path))
+            else:
+                ui.write("%s = %s\n" % (name, url.hidepassword(path)))
 
 def postincoming(ui, repo, modheads, optupdate, checkout):
     if modheads == 0:
@@ -3287,7 +3293,11 @@
          [('r', 'rev', '', _('show parents from the specified rev')),
          ] + templateopts,
          _('hg parents [-r REV] [FILE]')),
-    "paths": (paths, [], _('[NAME]')),
+    "paths": 
+        (paths,
+         [('', 'show-passwords', None,
+           _('show passwords for remote repositories'))],
+         _('[NAME]')),
     "^pull":
         (pull,
          [('u', 'update', None,



More information about the Mercurial-devel mailing list