diff hgsubversion/wrappers.py @ 651:827547493112

clone: allow specifying a start revision. All tests pass, including comprehensive tests.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Tue, 20 Jul 2010 11:55:07 +0200
parents 3ff8666b1479
children 9cf547fc36e8
line wrap: on
line diff
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -210,8 +210,6 @@ def pull(repo, source, heads=[], force=F
     svn_url, heads, checkout = util.parseurl(svn_url, heads)
     old_encoding = util.swap_out_encoding()
 
-    # TODO implement skipto support
-    skipto_rev = 0
     try:
         stopat_rev = int(checkout or 0)
     except ValueError:
@@ -235,13 +233,30 @@ def pull(repo, source, heads=[], force=F
         repo.ui.setconfig('hgsubversion', 'layout', layout)
         repo.ui.note('using %s layout\n' % layout)
 
-    start = max(meta.revmap.youngest, skipto_rev)
-    initializing_repo = meta.revmap.youngest <= 0
     ui = repo.ui
+    start = meta.revmap.youngest
+    origrevcount = len(meta.revmap)
 
-    if initializing_repo and start > 0:
-        raise hgutil.Abort('Revision skipping at repository initialization '
-                           'remains unimplemented.')
+    if start <= 0:
+        # we are initializing a new repository
+        start = repo.ui.config('hgsubversion', 'startrev', 0)
+        if isinstance(start, str) and start.upper() == 'HEAD':
+            start = svn.HEAD
+        else:
+            start = int(start)
+
+        if start > 0:
+            if layout == 'standard':
+                raise hgutil.Abort('non-zero start revisions are only '
+                                   'supported for single-directory clones.')
+            ui.note('starting at revision %d; any prior will be ignored\n'
+                    % start)
+            # fetch all revisions *including* the one specified...
+            start -= 1
+
+        # anything less than zero makes no sense
+        if start < 0:
+            start = 0
 
     oldrevisions = len(meta.revmap)
     if stopat_rev:
@@ -367,6 +382,7 @@ optionmap = {
     'defaultauthors': ('hgsubversion', 'defaultauthors'),
     'usebranchnames': ('hgsubversion', 'usebranchnames'),
     'layout': ('hgsubversion', 'layout'),
+    'startrev': ('hgsubversion', 'startrev'),
 }
 
 dontretain = { 'hgsubversion': set(['authormap', 'filemap', 'layout', ]) }