changeset 366:25ebdc16b05b

Simplify pulling revs a bit, unify stupid/replay interfaces.
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Thu, 28 May 2009 10:57:09 +0200
parents e8f5688a0cd9
children ce64d57172a3
files hgsubversion/cmdutil.py hgsubversion/stupid.py hgsubversion/wrappers.py
diffstat 3 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/cmdutil.py
+++ b/hgsubversion/cmdutil.py
@@ -54,7 +54,8 @@ def parentrev(ui, repo, hge, svn_commit_
     return workingctx
 
 
-def replay_convert_rev(hg_editor, svn, r):
+def replay_convert_rev(ui, hg_editor, svn, r):
+    # ui is only passed in for similarity with stupid.convert_rev()
     hg_editor.set_current_rev(r)
     svn.get_replay(r.revnum, hg_editor)
     i = 1
--- a/hgsubversion/stupid.py
+++ b/hgsubversion/stupid.py
@@ -430,7 +430,7 @@ def fetch_branchrev(svn, hg_editor, bran
 
     return files, filectxfn
 
-def svn_server_pull_rev(ui, svn, hg_editor, r):
+def convert_rev(ui, hg_editor, svn, r):
     # this server fails at replay
     branches = hg_editor.branches_in_paths(r.paths, r.revnum, svn.checkpath, svn.list_files)
     deleted_branches = {}
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -19,6 +19,11 @@ import stupid as stupidmod
 import svnwrap
 import util
 
+pullfuns = {
+    True: cmdutil.replay_convert_rev,
+    False: stupidmod.convert_rev,
+}
+
 def parent(orig, ui, repo, *args, **opts):
     """show Mercurial & Subversion parents of the working dir or revision
     """
@@ -217,7 +222,6 @@ def pull(repo, source, heads=[], force=F
                            'remains unimplemented.')
 
     revisions = 0
-
     try:
         # start converting revisions
         for r in svn.revisions(start=start, stop=stopat_rev):
@@ -231,17 +235,12 @@ def pull(repo, source, heads=[], force=F
             while not converted:
                 try:
                     util.describe_revision(ui, r)
-                    if have_replay:
-                        try:
-                            cmdutil.replay_convert_rev(hg_editor, svn, r)
-                        except svnwrap.SubversionRepoCanNotReplay, e: #pragma: no cover
-                            ui.status('%s\n' % e.message)
-                            stupidmod.print_your_svn_is_old_message(ui)
-                            have_replay = False
-                            stupidmod.svn_server_pull_rev(ui, svn, hg_editor, r)
-                    else:
-                        stupidmod.svn_server_pull_rev(ui, svn, hg_editor, r)
+                    pullfuns[have_replay](ui, hg_editor, svn, r)
                     converted = True
+                except svnwrap.SubversionRepoCanNotReplay, e: #pragma: no cover
+                    ui.status('%s\n' % e.message)
+                    stupidmod.print_your_svn_is_old_message(ui)
+                    have_replay = False
                 except core.SubversionException, e: #pragma: no cover
                     if (e.apr_err == core.SVN_ERR_RA_DAV_REQUEST_FAILED
                         and '502' in str(e)