comparison svncommands.py @ 247:1272e87546ed

Move help, update into svncommands.
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Wed, 08 Apr 2009 18:59:50 +0200
parents 074f27c68818
children c3d5c4ae9c7c
comparison
equal deleted inserted replaced
246:074f27c68818 247:1272e87546ed
13 import svnwrap 13 import svnwrap
14 import stupid as stupidmod 14 import stupid as stupidmod
15 import cmdutil 15 import cmdutil
16 import util 16 import util
17 import utility_commands 17 import utility_commands
18
19 from util import generate_help, svn_subcommands, register_subcommand
18 20
19 21
20 def pull(ui, svn_url, hg_repo_path, skipto_rev=0, stupid=None, 22 def pull(ui, svn_url, hg_repo_path, skipto_rev=0, stupid=None,
21 tag_locations='tags', authors=None, filemap=None, **opts): 23 tag_locations='tags', authors=None, filemap=None, **opts):
22 """pull new revisions from Subversion 24 """pull new revisions from Subversion
327 tagsinfofile = open(os.path.join(svnmetadir, 'tag_info'), 'w') 329 tagsinfofile = open(os.path.join(svnmetadir, 'tag_info'), 'w')
328 pickle.dump(tagsinfo, tagsinfofile) 330 pickle.dump(tagsinfo, tagsinfofile)
329 tagsinfofile.close() 331 tagsinfofile.close()
330 rebuildmeta = util.register_subcommand('rebuildmeta')(rebuildmeta) 332 rebuildmeta = util.register_subcommand('rebuildmeta')(rebuildmeta)
331 rebuildmeta = util.command_needs_no_url(rebuildmeta) 333 rebuildmeta = util.command_needs_no_url(rebuildmeta)
334
335
336 def help(ui, args=None, **opts):
337 """show help for a given subcommands or a help overview
338 """
339 if args:
340 subcommand = args[0]
341 if subcommand not in svn_subcommands:
342 candidates = []
343 for c in svn_subcommands:
344 if c.startswith(subcommand):
345 candidates.append(c)
346 if len(candidates) == 1:
347 subcommand = candidates[0]
348 elif len(candidates) > 1:
349 ui.status('Ambiguous command. Could have been:\n%s\n' %
350 ' '.join(candidates))
351 return
352 doc = svn_subcommands[subcommand].__doc__
353 if doc is None:
354 doc = "No documentation available for %s." % subcommand
355 ui.status(doc.strip(), '\n')
356 return
357 ui.status(generate_help())
358 help = register_subcommand('help')(help)
359
360
361 def update(ui, args, repo, clean=False, **opts):
362 """update to a specified Subversion revision number
363 """
364 assert len(args) == 1
365 rev = int(args[0])
366 path = os.path.join(repo.path, 'svn', 'rev_map')
367 answers = []
368 for k,v in util.parse_revmap(path).iteritems():
369 if k[0] == rev:
370 answers.append((v, k[1]))
371 if len(answers) == 1:
372 if clean:
373 return hg.clean(repo, answers[0][0])
374 return hg.update(repo, answers[0][0])
375 elif len(answers) == 0:
376 ui.status('Revision %s did not produce an hg revision.\n' % rev)
377 return 1
378 else:
379 ui.status('Ambiguous revision!\n')
380 ui.status('\n'.join(['%s on %s' % (node.hex(a[0]), a[1]) for a in
381 answers]+['']))
382 return 1
383 update = register_subcommand('up')(update)