changeset 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 685f91015ed6
children c3900ad3bf69
files hgsubversion/__init__.py hgsubversion/wrappers.py
diffstat 2 files changed, 27 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/__init__.py
+++ b/hgsubversion/__init__.py
@@ -72,6 +72,10 @@ wrapcmds = { # cmd: generic, target, fix
         ('', 'layout', 'auto', ('import standard layout or single '
                                 'directory? Can be standard, single, or auto.')),
         ('', 'branchmap', '', 'file containing rules for branch conversion'),
+        ('', 'startrev', '', ('convert Subversion revisions starting at the one '
+                              'specified, either an integer revision or HEAD; '
+                              'HEAD causes only the latest revision to be '
+                              'pulled')),
     ]),
 }
 
--- 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', ]) }