Add commands.debugconfig.
authorBryan O'Sullivan <bos@serpentine.com>
Tue, 23 Aug 2005 21:30:12 -0700
changeset 1028 25e7ea0f2cff
parent 1027 cb31576ed3e4
child 1029 b5f0ccad8917
Add commands.debugconfig. This lets us both view the actual config data that hg is using, and drive editors that need to see this information.
mercurial/commands.py
mercurial/ui.py
--- a/mercurial/commands.py	Tue Aug 23 16:46:10 2005 -0700
+++ b/mercurial/commands.py	Tue Aug 23 21:30:12 2005 -0700
@@ -597,6 +597,13 @@
     if errors:
         raise util.Abort(".hg/dirstate inconsistent with current parent's manifest")
 
+def debugconfig(ui):
+    try:
+        repo = hg.repository(ui)
+    except: pass
+    for section, name, value in ui.walkconfig():
+        ui.write('%s.%s=%s\n' % (section, name, value))
+
 def debugstate(ui, repo):
     """show the contents of the current dirstate"""
     repo.dirstate.read()
@@ -1308,6 +1315,7 @@
          'hg commit [OPTION]... [FILE]...'),
     "copy": (copy, [], 'hg copy SOURCE DEST'),
     "debugcheckstate": (debugcheckstate, [], 'debugcheckstate'),
+    "debugconfig": (debugconfig, [], 'debugconfig'),
     "debugstate": (debugstate, [], 'debugstate'),
     "debugindex": (debugindex, [], 'debugindex FILE'),
     "debugindexdot": (debugindexdot, [], 'debugindexdot FILE'),
@@ -1446,7 +1454,7 @@
               ('', 'time', None, 'time how long the command takes'),
              ]
 
-norepo = "clone init version help debugindex debugindexdot paths"
+norepo = "clone init version help debugconfig debugindex debugindexdot paths"
 
 def find(cmd):
     for e in table.keys():
--- a/mercurial/ui.py	Tue Aug 23 16:46:10 2005 -0700
+++ b/mercurial/ui.py	Tue Aug 23 21:30:12 2005 -0700
@@ -52,6 +52,17 @@
             return self.cdata.items(section)
         return []
 
+    def walkconfig(self):
+        seen = {}
+        for (section, name), value in self.overlay.iteritems():
+            yield section, name, value
+            seen[section, name] = 1
+        for section in self.cdata.sections():
+            for name, value in self.cdata.items(section):
+                if (section, name) in seen: continue
+                yield section, name, value.replace('\n', '\\n')
+                seen[section, name] = 1
+
     def username(self):
         return (os.environ.get("HGUSER") or
                 self.config("ui", "username") or