diff utility_commands.py @ 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 7932d098cb5f
line wrap: on
line diff
--- 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])