comparison mercurial/commands.py @ 13724:fe57046e9448

commands: add debugbundle command Lists ids contained in a bundle file. Useful for testing bundle-related commands.
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
date Tue, 22 Mar 2011 09:22:29 +0100
parents e615765fdcc7
children ce47a0c10224
comparison
equal deleted inserted replaced
13723:e615765fdcc7 13724:fe57046e9448
1227 repo = hg.repository(ui, repopath) 1227 repo = hg.repository(ui, repopath)
1228 if not repo.capable('known'): 1228 if not repo.capable('known'):
1229 raise util.Abort("known() not supported by target repository") 1229 raise util.Abort("known() not supported by target repository")
1230 flags = repo.known([bin(s) for s in ids]) 1230 flags = repo.known([bin(s) for s in ids])
1231 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) 1231 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
1232
1233 def debugbundle(ui, bundlepath, all=None, **opts):
1234 """lists the contents of a bundle"""
1235 f = url.open(ui, bundlepath)
1236 try:
1237 gen = changegroup.readbundle(f, bundlepath)
1238 if all:
1239 ui.write("format: id, p1, p2, cset, len(delta)\n")
1240
1241 def showchunks(named):
1242 ui.write("\n%s\n" % named)
1243 while 1:
1244 chunkdata = gen.parsechunk()
1245 if not chunkdata:
1246 break
1247 node = chunkdata['node']
1248 p1 = chunkdata['p1']
1249 p2 = chunkdata['p2']
1250 cs = chunkdata['cs']
1251 delta = chunkdata['data']
1252 ui.write("%s %s %s %s %s\n" % (hex(node), hex(p1), hex(p2), hex(cs), len(delta)))
1253
1254 showchunks("changelog")
1255 showchunks("manifest")
1256 while 1:
1257 fname = gen.chunk()
1258 if not fname:
1259 break
1260 showchunks(fname)
1261 else:
1262 while 1:
1263 chunkdata = gen.parsechunk()
1264 if not chunkdata:
1265 break
1266 node = chunkdata['node']
1267 ui.write("%s\n" % hex(node))
1268 finally:
1269 f.close()
1232 1270
1233 def debugpushkey(ui, repopath, namespace, *keyinfo): 1271 def debugpushkey(ui, repopath, namespace, *keyinfo):
1234 '''access the pushkey key/value protocol 1272 '''access the pushkey key/value protocol
1235 1273
1236 With two args, list the keys in the given namespace. 1274 With two args, list the keys in the given namespace.
4430 ('a', 'appended-file', None, _('add single file all revs append to')), 4468 ('a', 'appended-file', None, _('add single file all revs append to')),
4431 ('o', 'overwritten-file', None, _('add single file all revs overwrite')), 4469 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
4432 ('n', 'new-file', None, _('add new file at each rev')), 4470 ('n', 'new-file', None, _('add new file at each rev')),
4433 ], 4471 ],
4434 _('[OPTION]... TEXT')), 4472 _('[OPTION]... TEXT')),
4473 "debugbundle":
4474 (debugbundle,
4475 [('a', 'all', None, _('show all details')),
4476 ],
4477 _('FILE')),
4435 "debugcheckstate": (debugcheckstate, [], ''), 4478 "debugcheckstate": (debugcheckstate, [], ''),
4436 "debugcommands": (debugcommands, [], _('[COMMAND]')), 4479 "debugcommands": (debugcommands, [], _('[COMMAND]')),
4437 "debugcomplete": 4480 "debugcomplete":
4438 (debugcomplete, 4481 (debugcomplete,
4439 [('o', 'options', None, _('show the command options'))], 4482 [('o', 'options', None, _('show the command options'))],
4822 "version": (version_, []), 4865 "version": (version_, []),
4823 } 4866 }
4824 4867
4825 norepo = ("clone init version help debugcommands debugcomplete" 4868 norepo = ("clone init version help debugcommands debugcomplete"
4826 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs" 4869 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
4827 " debugknown") 4870 " debugknown debugbundle")
4828 optionalrepo = ("identify paths serve showconfig debugancestor debugdag" 4871 optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
4829 " debugdata debugindex debugindexdot") 4872 " debugdata debugindex debugindexdot")