mercurial/commands.py
changeset 11371 4c8842ee97ff
parent 11353 f2b25e8ea6c1
child 11384 c04084753990
--- a/mercurial/commands.py	Wed Jun 16 16:05:19 2010 -0500
+++ b/mercurial/commands.py	Wed Jun 16 16:05:47 2010 -0500
@@ -1082,6 +1082,26 @@
                      ui.configsource(section, name, untrusted))
             ui.write('%s=%s\n' % (sectname, value))
 
+def debugpushkey(ui, repopath, namespace, *keyinfo):
+    '''access the pushkey key/value protocol
+
+    With two args, list the keys in the given namespace.
+
+    With five args, set a key to new if it currently is set to old.
+    Reports success or failure.
+    '''
+
+    target = hg.repository(ui, repopath)
+    if keyinfo:
+        key, old, new = keyinfo
+        r = target.pushkey(namespace, key, old, new)
+        ui.status(str(r) + '\n')
+        return not(r)
+    else:
+        for k, v in target.listkeys(namespace).iteritems():
+            ui.write("%s\t%s\n" % (k.encode('string-escape'),
+                                   v.encode('string-escape')))
+
 def debugrevspec(ui, repo, expr):
     '''parse and apply a revision specification'''
     if ui.verbose:
@@ -4072,6 +4092,7 @@
     "debugindex": (debugindex, [], _('FILE')),
     "debugindexdot": (debugindexdot, [], _('FILE')),
     "debuginstall": (debuginstall, [], ''),
+    "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')),
     "debugrebuildstate":
         (debugrebuildstate,
          [('r', 'rev', '',
@@ -4420,5 +4441,6 @@
 }
 
 norepo = ("clone init version help debugcommands debugcomplete debugdata"
-          " debugindex debugindexdot debugdate debuginstall debugfsinfo")
+          " debugindex debugindexdot debugdate debuginstall debugfsinfo"
+          " debugpushkey")
 optionalrepo = ("identify paths serve showconfig debugancestor debugdag")