comparison util.py @ 253:c3d5c4ae9c7c

Work with simple command table instead of decorators.
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Fri, 10 Apr 2009 23:09:59 +0200
parents 79349fd04836
children 7932d098cb5f
comparison
equal deleted inserted replaced
252:4d3bcd2f26ed 253:c3d5c4ae9c7c
2 import shutil 2 import shutil
3 3
4 from mercurial import hg 4 from mercurial import hg
5 from mercurial import node 5 from mercurial import node
6 from mercurial import util as hgutil 6 from mercurial import util as hgutil
7
8 svn_subcommands = { }
9 def register_subcommand(name):
10 def inner(fn):
11 svn_subcommands[name] = fn
12 return fn
13 return inner
14
15 svn_commands_nourl = set()
16 def command_needs_no_url(fn):
17 svn_commands_nourl.add(fn)
18 return fn
19 7
20 8
21 def version(ui): 9 def version(ui):
22 """Guess the version of hgsubversion. 10 """Guess the version of hgsubversion.
23 """ 11 """
24 # TODO make this say something other than "unknown" for installed hgsubversion 12 # TODO make this say something other than "unknown" for installed hgsubversion
25 repo = hg.repository(ui, os.path.dirname(__file__)) 13 repo = hg.repository(ui, os.path.dirname(__file__))
26 ver = repo.dirstate.parents()[0] 14 ver = repo.dirstate.parents()[0]
27 return node.hex(ver)[:12] 15 return node.hex(ver)[:12]
28
29
30 def generate_help():
31 ret = ['hg svn ...', '',
32 'subcommands for Subversion integration', '',
33 'list of subcommands:', '']
34
35 for name, func in sorted(svn_subcommands.items()):
36 short_description = (func.__doc__ or '').splitlines()[0]
37 ret.append(" %-10s %s" % (name, short_description))
38
39 return "\n".join(ret) + '\n'
40 16
41 17
42 def normalize_url(svn_url): 18 def normalize_url(svn_url):
43 return svn_url.rstrip('/') 19 return svn_url.rstrip('/')
44 20