Commits

Marc Simpson committed 221ee18

Initial version.

  • Participants

Comments (0)

Files changed (2)

+syntax: glob
+*.pyc

File prettypaths.py

+'''prettypaths
+
+This extension adds a single switch to the 'hg paths' command,
+
+    --pretty    Pretty print paths
+
+Two default colours are supplied for output:
+
+    paths.name  = green
+    paths.path  = yellow
+
+If you'd like pretty output by default, add the following to your ~/.hgrc:
+
+    [defaults]
+    paths = --pretty
+'''
+
+from hgext import color
+from mercurial import commands, extensions, ui, util
+from mercurial.i18n import _
+
+def show_paths(ui):
+    for name, path in ui.configitems("paths"):
+        if ui.quiet:
+            ui.write("%s\n" % name)
+        else:
+            name = ui.label(str(name).ljust(29), 'paths.name')
+            path = ui.label(util.hidepassword(path), 'paths.path')
+            ui.write("%s %s\n" % (name, path))
+
+def paths_wrapper(orig, ui, repo, *args, **opts):
+    if opts["pretty"] and not args:
+        return show_paths(ui)
+    del(opts["pretty"])
+    res = orig(ui, repo, *args, **opts)
+
+def uisetup(ui):
+    entry = extensions.wrapcommand(commands.table, "paths", paths_wrapper)
+    entry[1].append(('', 'pretty', None, _("Pretty print paths")))
+    color._styles["paths.name"] = "green"
+    color._styles["paths.path"] = "yellow"