Mercurial > hgsubversion
changeset 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 | c7ac013cf7fd |
children | 91ce18fa0375 |
files | push_cmd.py util.py utility_commands.py |
diffstat | 3 files changed, 26 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/push_cmd.py +++ b/push_cmd.py @@ -23,8 +23,7 @@ def push_revisions_to_subversion(ui, rep hge.revmap.iterkeys())) # Strategy: # 1. Find all outgoing commits from this head - outgoing = utility_commands.outgoing_revisions(ui, repo, hge, - svn_commit_hashes) + outgoing = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes) if not (outgoing and len(outgoing)): ui.status('No revisions to push.') return 0 @@ -65,8 +64,8 @@ def push_revisions_to_subversion(ui, rep hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, ui_=ui) svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) - outgoing = utility_commands.outgoing_revisions(ui, repo, hge, - svn_commit_hashes) + outgoing = util.outgoing_revisions(ui, repo, hge, + svn_commit_hashes) merc_util._encoding = oldencoding return 0
--- a/util.py +++ b/util.py @@ -65,3 +65,22 @@ class PrefixMatch(object): def __call__(self, fn): return fn.startswith(self.p) + +def outgoing_revisions(ui, repo, hg_editor, reverse_map): + """Given a repo and an hg_editor, determines outgoing revisions for the + current working copy state. + """ + outgoing_rev_hashes = [] + working_rev = repo.parents() + assert len(working_rev) == 1 + working_rev = working_rev[0] + if working_rev.node() in reverse_map: + return + while (not working_rev.node() in reverse_map + and working_rev.node() != node.nullid): + outgoing_rev_hashes.append(working_rev.node()) + working_rev = working_rev.parents() + assert len(working_rev) == 1 + working_rev = working_rev[0] + if working_rev.node() != node.nullid: + return outgoing_rev_hashes
--- a/utility_commands.py +++ b/utility_commands.py @@ -20,7 +20,7 @@ def run_svn_info(ui, repo, hg_repo_path, ui_=ui) svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) - o_r = outgoing_revisions(ui, repo, hge, svn_commit_hashes) + o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes) ha = repo.parents()[0] if o_r: ha = repo[o_r[-1]].parents()[0] @@ -62,7 +62,7 @@ def print_parent_revision(ui, repo, hg_r svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) ha = repo.parents()[0] - o_r = outgoing_revisions(ui, repo, hge, svn_commit_hashes) + o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes) if o_r: ha = repo[o_r[-1]].parents()[0] if ha.node() != node.nullid: @@ -87,7 +87,7 @@ def rebase_commits(ui, repo, hg_repo_pat ui_=ui) svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) - o_r = outgoing_revisions(ui, repo, hge, svn_commit_hashes) + o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes) if not o_r: ui.status('Nothing to rebase!\n') return 0 @@ -123,30 +123,10 @@ def show_outgoing_to_svn(ui, repo, hg_re ui_=ui) svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) - o_r = outgoing_revisions(ui, repo, hge, svn_commit_hashes) + o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes) if not (o_r and len(o_r)): ui.status('No outgoing changes found.\n') return 0 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=False) for node in reversed(o_r): displayer.show(repo[node]) - - -def outgoing_revisions(ui, repo, hg_editor, reverse_map): - """Given a repo and an hg_editor, determines outgoing revisions for the - current working copy state. - """ - outgoing_rev_hashes = [] - working_rev = repo.parents() - assert len(working_rev) == 1 - working_rev = working_rev[0] - if working_rev.node() in reverse_map: - return - while (not working_rev.node() in reverse_map - and working_rev.node() != node.nullid): - outgoing_rev_hashes.append(working_rev.node()) - working_rev = working_rev.parents() - assert len(working_rev) == 1 - working_rev = working_rev[0] - if working_rev.node() != node.nullid: - return outgoing_rev_hashes