Mercurial > hgsubversion
comparison utility_commands.py @ 99:1da7aafdd323
Refactored outgoing_revisions into util where it really belongs.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Fri, 21 Nov 2008 16:11:24 -0600 |
parents | 10dd34deac3b |
children | a3b717e4abf5 |
comparison
equal
deleted
inserted
replaced
98:c7ac013cf7fd | 99:1da7aafdd323 |
---|---|
18 def run_svn_info(ui, repo, hg_repo_path, **opts): | 18 def run_svn_info(ui, repo, hg_repo_path, **opts): |
19 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, | 19 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, |
20 ui_=ui) | 20 ui_=ui) |
21 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), | 21 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
22 hge.revmap.iterkeys())) | 22 hge.revmap.iterkeys())) |
23 o_r = outgoing_revisions(ui, repo, hge, svn_commit_hashes) | 23 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes) |
24 ha = repo.parents()[0] | 24 ha = repo.parents()[0] |
25 if o_r: | 25 if o_r: |
26 ha = repo[o_r[-1]].parents()[0] | 26 ha = repo[o_r[-1]].parents()[0] |
27 r, br = svn_commit_hashes[ha.node()] | 27 r, br = svn_commit_hashes[ha.node()] |
28 if br == None: | 28 if br == None: |
60 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, | 60 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, |
61 ui_=ui) | 61 ui_=ui) |
62 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), | 62 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
63 hge.revmap.iterkeys())) | 63 hge.revmap.iterkeys())) |
64 ha = repo.parents()[0] | 64 ha = repo.parents()[0] |
65 o_r = outgoing_revisions(ui, repo, hge, svn_commit_hashes) | 65 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes) |
66 if o_r: | 66 if o_r: |
67 ha = repo[o_r[-1]].parents()[0] | 67 ha = repo[o_r[-1]].parents()[0] |
68 if ha.node() != node.nullid: | 68 if ha.node() != node.nullid: |
69 r, br = svn_commit_hashes[ha.node()] | 69 r, br = svn_commit_hashes[ha.node()] |
70 ui.status('Working copy parent revision is %s: r%s on %s\n' % | 70 ui.status('Working copy parent revision is %s: r%s on %s\n' % |
85 """ | 85 """ |
86 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, | 86 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, |
87 ui_=ui) | 87 ui_=ui) |
88 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), | 88 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
89 hge.revmap.iterkeys())) | 89 hge.revmap.iterkeys())) |
90 o_r = outgoing_revisions(ui, repo, hge, svn_commit_hashes) | 90 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes) |
91 if not o_r: | 91 if not o_r: |
92 ui.status('Nothing to rebase!\n') | 92 ui.status('Nothing to rebase!\n') |
93 return 0 | 93 return 0 |
94 if len(repo.parents()[0].children()): | 94 if len(repo.parents()[0].children()): |
95 ui.status('Refusing to rebase non-head commit like a coward\n') | 95 ui.status('Refusing to rebase non-head commit like a coward\n') |
121 """ | 121 """ |
122 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, | 122 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, |
123 ui_=ui) | 123 ui_=ui) |
124 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), | 124 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
125 hge.revmap.iterkeys())) | 125 hge.revmap.iterkeys())) |
126 o_r = outgoing_revisions(ui, repo, hge, svn_commit_hashes) | 126 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes) |
127 if not (o_r and len(o_r)): | 127 if not (o_r and len(o_r)): |
128 ui.status('No outgoing changes found.\n') | 128 ui.status('No outgoing changes found.\n') |
129 return 0 | 129 return 0 |
130 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=False) | 130 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=False) |
131 for node in reversed(o_r): | 131 for node in reversed(o_r): |
132 displayer.show(repo[node]) | 132 displayer.show(repo[node]) |
133 | |
134 | |
135 def outgoing_revisions(ui, repo, hg_editor, reverse_map): | |
136 """Given a repo and an hg_editor, determines outgoing revisions for the | |
137 current working copy state. | |
138 """ | |
139 outgoing_rev_hashes = [] | |
140 working_rev = repo.parents() | |
141 assert len(working_rev) == 1 | |
142 working_rev = working_rev[0] | |
143 if working_rev.node() in reverse_map: | |
144 return | |
145 while (not working_rev.node() in reverse_map | |
146 and working_rev.node() != node.nullid): | |
147 outgoing_rev_hashes.append(working_rev.node()) | |
148 working_rev = working_rev.parents() | |
149 assert len(working_rev) == 1 | |
150 working_rev = working_rev[0] | |
151 if working_rev.node() != node.nullid: | |
152 return outgoing_rev_hashes |