changeset 11371:4c8842ee97ff

pushkey: add debugpushkey command for testing
author Matt Mackall <mpm@selenic.com>
date Wed, 16 Jun 2010 16:05:47 -0500
parents db3f6f0e4e7d
children 735f2d561747
files mercurial/commands.py tests/test-debugcomplete.out
diffstat 2 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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")
--- a/tests/test-debugcomplete.out	Wed Jun 16 16:05:19 2010 -0500
+++ b/tests/test-debugcomplete.out	Wed Jun 16 16:05:47 2010 -0500
@@ -73,6 +73,7 @@
 debugindex
 debugindexdot
 debuginstall
+debugpushkey
 debugrebuildstate
 debugrename
 debugrevspec
@@ -204,6 +205,7 @@
 debugindex: 
 debugindexdot: 
 debuginstall: 
+debugpushkey: 
 debugrebuildstate: rev
 debugrename: rev
 debugrevspec: