diff hgsubversion/wrappers.py @ 342:76c833526fbc

Use fallbacks in the wrappers for Subversion support, instead of prefixes. The change only applies to the ambiguous URL schemes: file, http and https. The others - svn+ssh and svn - behave the same as previously. For http and https, the wrapping is implemented in 'svnrepo.py': Only when the attempt to create a httprepo instance fails, will the URL be considered for Subversion URL. For file, the ambiguity is treated much like the Mercurial core distinguishes bundle and directories. In this case, a directory that looks like a Subversion repository will *not* be considered for a Mercurial clone. Tthe command lines are more similar to before this refactor. The only option added to push & pull is --stupid; others are only added to clone. Any of these options specified to clone will be added to the generated '.hgrc'. Also, the -r/--rev option now works for clone & push.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Wed, 20 May 2009 18:38:01 +0200
parents cfbd0e563af9
children 4dfab1b8b7be
line wrap: on
line diff
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -202,12 +202,18 @@ def pull(repo, source="default", rev=Non
     url = repo.ui.expandpath(source)
     svn_url = util.normalize_url(url)
 
-    # Split off #rev; TODO: implement --rev/#rev support limiting the pulled/cloned revisions
+    # Split off #rev
     svn_url, revs, checkout = hg.parseurl(svn_url, rev)
     old_encoding = util.swap_out_encoding()
 
     # TODO implement skipto support
     skipto_rev = 0
+    try:
+        stopat_rev = int(checkout or 0)
+    except ValueError:
+        raise hgutil.Abort('unrecognised Subversion revision; '
+                           'only numbers work.')
+
     have_replay = not repo.ui.configbool('hgsubversion', 'stupid')
     if have_replay and not callable(
         delta.svn_txdelta_apply(None, None, None)[0]): #pragma: no cover
@@ -235,8 +241,9 @@ def pull(repo, source="default", rev=Non
 
     revisions = 0
 
-    # start converting revisions
-    for r in svn.revisions(start=start):
+    try:
+      # start converting revisions
+      for r in svn.revisions(start=start, stop=stopat_rev):
         valid = True
         hg_editor.update_branch_tag_map_for_rev(r)
         for p in r.paths:
@@ -270,6 +277,9 @@ def pull(repo, source="default", rev=Non
                     else:
                         raise hgutil.Abort(*e.args)
             revisions += 1
+    except KeyboardInterrupt:
+        pass
+
     util.swap_out_encoding(old_encoding)
 
     if revisions == 0: