comparison utility_commands.py @ 64:08be8ee73551

Add an hg svn info subsubcommand that prints out what you would expect from svn info.
author Augie Fackler <durin42@gmail.com>
date Fri, 07 Nov 2008 15:02:00 -0600
parents 05800c403321
children 10dd34deac3b
comparison
equal deleted inserted replaced
63:2e30b59a9c19 64:08be8ee73551
1 from mercurial import cmdutil 1 from mercurial import cmdutil
2 from mercurial import node 2 from mercurial import node
3 from mercurial import util as mutil
3 from hgext import rebase 4 from hgext import rebase
4 5
5 import util 6 import util
6 import hg_delta_editor 7 import hg_delta_editor
7 8
8 @util.register_subcommand('url') 9 @util.register_subcommand('url')
9 def print_wc_url(ui, repo, hg_repo_path, **opts): 10 def print_wc_url(ui, repo, hg_repo_path, **opts):
10 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, 11 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path,
11 ui_=ui) 12 ui_=ui)
12 ui.status(hge.url, '\n') 13 ui.status(hge.url, '\n')
14
15
16 @util.register_subcommand('info')
17 def run_svn_info(ui, repo, hg_repo_path, **opts):
18 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path,
19 ui_=ui)
20 svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
21 hge.revmap.iterkeys()))
22 o_r = outgoing_revisions(ui, repo, hge, svn_commit_hashes)
23 ha = repo.parents()[0]
24 if o_r:
25 ha = repo[o_r[-1]].parents()[0]
26 r, br = svn_commit_hashes[ha.node()]
27 if br == None:
28 branchpath = '/trunk'
29 else:
30 branchpath = '/branches/%s' % br
31 url = hge.url
32 if url[-1] == '/':
33 url = url[:-1]
34 url = '%s%s' % (url, branchpath)
35 author = '@'.join(ha.user().split('@')[:-1])
36 ui.status('''URL: %(url)s
37 Repository Root: %(reporoot)s
38 Repository UUID: %(uuid)s
39 Revision: %(revision)s
40 Node Kind: directory
41 Last Changed Author: %(author)s
42 Last Changed Rev: %(revision)s
43 Last Changed Date: %(date)s\n''' %
44 {'reporoot': None,
45 'uuid': open(hge.uuid_file).read(),
46 'url': url,
47 'author': author,
48 'revision': r,
49 # TODO I'd like to format this to the user's local TZ if possible
50 'date': mutil.datestr(ha.date(),
51 '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)')
52 })
13 53
14 54
15 @util.register_subcommand('parent') 55 @util.register_subcommand('parent')
16 def print_parent_revision(ui, repo, hg_repo_path, **opts): 56 def print_parent_revision(ui, repo, hg_repo_path, **opts):
17 """Prints the hg hash and svn revision info for the nearest svn parent of 57 """Prints the hg hash and svn revision info for the nearest svn parent of
34 74
35 75
36 @util.register_subcommand('rebase') 76 @util.register_subcommand('rebase')
37 def rebase_commits(ui, repo, hg_repo_path, **opts): 77 def rebase_commits(ui, repo, hg_repo_path, **opts):
38 """Rebases the current unpushed revisions onto the top of the Subversion branch. 78 """Rebases the current unpushed revisions onto the top of the Subversion branch.
39 79
40 This moves a line of development from making its own head to the top of 80 This moves a line of development from making its own head to the top of
41 Subversion development, linearizing the changes. In order to make sure you 81 Subversion development, linearizing the changes. In order to make sure you
42 rebase on top of the current top of Subversion work, you should probably run 82 rebase on top of the current top of Subversion work, you should probably run
43 'hg svn pull' before running this. 83 'hg svn pull' before running this.
44 """ 84 """
45 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, 85 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path,