comparison mercurial/commands.py @ 11371:4c8842ee97ff

pushkey: add debugpushkey command for testing
author Matt Mackall <mpm@selenic.com>
date Wed, 16 Jun 2010 16:05:47 -0500
parents f2b25e8ea6c1
children c04084753990
comparison
equal deleted inserted replaced
11370:db3f6f0e4e7d 11371:4c8842ee97ff
1079 ui.write(value, '\n') 1079 ui.write(value, '\n')
1080 else: 1080 else:
1081 ui.debug('%s: ' % 1081 ui.debug('%s: ' %
1082 ui.configsource(section, name, untrusted)) 1082 ui.configsource(section, name, untrusted))
1083 ui.write('%s=%s\n' % (sectname, value)) 1083 ui.write('%s=%s\n' % (sectname, value))
1084
1085 def debugpushkey(ui, repopath, namespace, *keyinfo):
1086 '''access the pushkey key/value protocol
1087
1088 With two args, list the keys in the given namespace.
1089
1090 With five args, set a key to new if it currently is set to old.
1091 Reports success or failure.
1092 '''
1093
1094 target = hg.repository(ui, repopath)
1095 if keyinfo:
1096 key, old, new = keyinfo
1097 r = target.pushkey(namespace, key, old, new)
1098 ui.status(str(r) + '\n')
1099 return not(r)
1100 else:
1101 for k, v in target.listkeys(namespace).iteritems():
1102 ui.write("%s\t%s\n" % (k.encode('string-escape'),
1103 v.encode('string-escape')))
1084 1104
1085 def debugrevspec(ui, repo, expr): 1105 def debugrevspec(ui, repo, expr):
1086 '''parse and apply a revision specification''' 1106 '''parse and apply a revision specification'''
1087 if ui.verbose: 1107 if ui.verbose:
1088 tree = revset.parse(expr) 1108 tree = revset.parse(expr)
4070 "debugdata": (debugdata, [], _('FILE REV')), 4090 "debugdata": (debugdata, [], _('FILE REV')),
4071 "debugfsinfo": (debugfsinfo, [], _('[PATH]')), 4091 "debugfsinfo": (debugfsinfo, [], _('[PATH]')),
4072 "debugindex": (debugindex, [], _('FILE')), 4092 "debugindex": (debugindex, [], _('FILE')),
4073 "debugindexdot": (debugindexdot, [], _('FILE')), 4093 "debugindexdot": (debugindexdot, [], _('FILE')),
4074 "debuginstall": (debuginstall, [], ''), 4094 "debuginstall": (debuginstall, [], ''),
4095 "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')),
4075 "debugrebuildstate": 4096 "debugrebuildstate":
4076 (debugrebuildstate, 4097 (debugrebuildstate,
4077 [('r', 'rev', '', 4098 [('r', 'rev', '',
4078 _('revision to rebuild to'), _('REV'))], 4099 _('revision to rebuild to'), _('REV'))],
4079 _('[-r REV] [REV]')), 4100 _('[-r REV] [REV]')),
4418 "verify": (verify, []), 4439 "verify": (verify, []),
4419 "version": (version_, []), 4440 "version": (version_, []),
4420 } 4441 }
4421 4442
4422 norepo = ("clone init version help debugcommands debugcomplete debugdata" 4443 norepo = ("clone init version help debugcommands debugcomplete debugdata"
4423 " debugindex debugindexdot debugdate debuginstall debugfsinfo") 4444 " debugindex debugindexdot debugdate debuginstall debugfsinfo"
4445 " debugpushkey")
4424 optionalrepo = ("identify paths serve showconfig debugancestor debugdag") 4446 optionalrepo = ("identify paths serve showconfig debugancestor debugdag")