changeset 254:9ba31af57e4b

Move utility_commands.find_wc_parent_rev() to cmdutil.parentrev().
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Fri, 10 Apr 2009 17:29:45 +0200
parents c3d5c4ae9c7c
children 246aaefb1cc0
files cmdutil.py utility_commands.py
diffstat 2 files changed, 18 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/cmdutil.py
+++ b/cmdutil.py
@@ -5,6 +5,7 @@ from mercurial import util as hgutil
 
 from svn import core
 
+import util
 import svnwrap
 import svnexternals
 
@@ -34,6 +35,17 @@ def filterdiff(diff, base_revision):
     return diff
 
 
+def parentrev(ui, repo, hge, svn_commit_hashes):
+    """Find the svn parent revision of the repo's dirstate.
+    """
+    workingctx = repo.parents()[0]
+    outrev = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes,
+                                     workingctx.node())
+    if outrev:
+        workingctx = repo[outrev[-1]].parents()[0]
+    return workingctx
+
+
 def replay_convert_rev(hg_editor, svn, r):
     hg_editor.set_current_rev(r)
     svn.get_replay(r.revnum, hg_editor)
--- a/utility_commands.py
+++ b/utility_commands.py
@@ -1,12 +1,13 @@
 import os
 
 import mercurial
-from mercurial import cmdutil
+from mercurial import cmdutil as hgcmdutil
 from mercurial import node
 from mercurial import util as hgutil
 from hgext import rebase as hgrebase
 
 import svnwrap
+import cmdutil
 import util
 import hg_delta_editor
 
@@ -18,16 +19,6 @@ def url(ui, repo, hg_repo_path, **opts):
     ui.status(hge.url, '\n')
 
 
-def find_wc_parent_rev(ui, repo, hge, svn_commit_hashes):
-    """Find the svn parent revision of the repo's dirstate.
-    """
-    workingctx = repo.parents()[0]
-    o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, workingctx.node())
-    if o_r:
-        workingctx = repo[o_r[-1]].parents()[0]
-    return workingctx
-
-
 def genignore(ui, repo, hg_repo_path, force=False, **opts):
     """generate .hgignore from svn:ignore properties.
     """
@@ -40,7 +31,7 @@ def genignore(ui, repo, hg_repo_path, fo
                                            ui_=ui)
     svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
                                  hge.revmap.iterkeys()))
-    parent = find_wc_parent_rev(ui, repo, hge, svn_commit_hashes)
+    parent = cmdutil.parentrev(ui, repo, hge, svn_commit_hashes)
     r, br = svn_commit_hashes[parent.node()]
     if br == None:
         branchpath = 'trunk'
@@ -71,7 +62,7 @@ def info(ui, repo, hg_repo_path, **opts)
                                            ui_=ui)
     svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
                                  hge.revmap.iterkeys()))
-    parent = find_wc_parent_rev(ui, repo, hge, svn_commit_hashes)
+    parent = cmdutil.parentrev(ui, repo, hge, svn_commit_hashes)
     pn = parent.node()
     if pn not in svn_commit_hashes:
         ui.status('Not a child of an svn revision.\n')
@@ -118,7 +109,7 @@ def parent(ui, repo, hg_repo_path, **opt
                                            ui_=ui)
     svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
                                  hge.revmap.iterkeys()))
-    ha = find_wc_parent_rev(ui, repo, hge, svn_commit_hashes)
+    ha = cmdutil.parentrev(ui, repo, hge, svn_commit_hashes)
     if ha.node() != node.nullid:
         r, br = svn_commit_hashes[ha.node()]
         ui.status('Working copy parent revision is %s: r%s on %s\n' %
@@ -187,7 +178,7 @@ def outgoing(ui, repo, hg_repo_path, **o
     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)
+    displayer = hgcmdutil.show_changeset(ui, repo, opts, buffered=False)
     for node in reversed(o_r):
         displayer.show(repo[node])