[PATCH] Extend debugconfig command to output more information

Stephen Darnell stephen at darnell.plus.com
Fri May 5 13:49:00 CDT 2006


I discovered that there was debugconfig command that partly did what I was 
wanting, so I chose to extend that rather than add a new command.
The only mention I found was:
http://www.selenic.com/mercurial/wiki/index.cgi/DebuggingFeatures

Regards,
  Stephen 
-------------- next part --------------
# HG changeset patch
# User Stephen Darnell <stephen at darnell.plus.com>
# Node ID 1affedd6db2a14ee43e3a58ea3303b547c0b7c5e
# Parent  7308b2d5c7db4b00b92053eece234013dcaca29a
Extend debugconfig command to output more information
Include a list of configuration files, and key values that are
derived possibly from configuration (username, editor, merge program)

diff -r 7308b2d5c7db -r 1affedd6db2a mercurial/commands.py
--- a/mercurial/commands.py	Thu May 04 14:23:44 2006 +0100
+++ b/mercurial/commands.py	Fri May 05 18:04:35 2006 +0100
@@ -1423,6 +1423,21 @@ def debugcheckstate(ui, repo):
 
 def debugconfig(ui, repo):
     """show combined config settings from all hgrc files"""
+    ui.write(_("username=%s\n") % (ui.username(),))
+    ui.write(_("editor=%s\n") % (ui.editor(),))
+    ui.write(_("merge=%s\n") % (ui.merge(),))
+
+    ui.write(_("\nConfiguration files:\n"))
+    rcfiles = util.rcpath()
+    if repo:
+        rcfiles.append(repo.join("hgrc"))
+    for loc in rcfiles:
+        if os.path.exists(loc):
+            ui.write(_('%s\n') % (loc,))
+        else:
+            ui.write(_('%s (not present)\n') % (loc,))
+
+    ui.write(_("\nConfiguration settings:\n"))
     for section, name, value in ui.walkconfig():
         ui.write('%s.%s=%s\n' % (section, name, value))
 
diff -r 7308b2d5c7db -r 1affedd6db2a mercurial/localrepo.py
--- a/mercurial/localrepo.py	Thu May 04 14:23:44 2006 +0100
+++ b/mercurial/localrepo.py	Fri May 05 18:04:35 2006 +0100
@@ -1840,8 +1840,7 @@ class localrepository(object):
         self.ui.debug(_("file %s: my %s other %s ancestor %s\n") %
                               (fn, short(my), short(other), short(base)))
 
-        cmd = (os.environ.get("HGMERGE") or self.ui.config("ui", "merge")
-               or "hgmerge")
+        cmd = self.ui.merge()
         r = util.system('%s "%s" "%s" "%s"' % (cmd, a, b, c), cwd=self.root,
                         environ={'HG_FILE': fn,
                                  'HG_MY_NODE': p1,
diff -r 7308b2d5c7db -r 1affedd6db2a mercurial/ui.py
--- a/mercurial/ui.py	Thu May 04 14:23:44 2006 +0100
+++ b/mercurial/ui.py	Fri May 05 18:04:35 2006 +0100
@@ -241,6 +241,17 @@ class ui(object):
         if self.verbose: self.write(*msg)
     def debug(self, *msg):
         if self.debugflag: self.write(*msg)
+
+    def editor(self):
+        return (os.environ.get("HGEDITOR") or
+                self.config("ui", "editor") or
+                os.environ.get("EDITOR", "vi"))
+
+    def merge(self):
+        return (os.environ.get("HGMERGE") or
+                self.config("ui", "merge") or
+                "hgmerge")
+
     def edit(self, text, user):
         (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt", text=True)
         try:
@@ -248,11 +259,7 @@ class ui(object):
             f.write(text)
             f.close()
 
-            editor = (os.environ.get("HGEDITOR") or
-                    self.config("ui", "editor") or
-                    os.environ.get("EDITOR", "vi"))
-
-            util.system("%s \"%s\"" % (editor, name),
+            util.system("%s \"%s\"" % (self.editor(), name),
                         environ={'HGUSER': user},
                         onerr=util.Abort, errprefix=_("edit failed"))
 


More information about the Mercurial mailing list