Patchwork convert: remove restriction on multiple --rev in hg source

login
register
mail settings
Submitter Durham Goode
Date Sept. 3, 2015, 6:16 p.m.
Message ID <32124f63ab48a9fbc1f5.1441304189@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/10384/
State Accepted
Headers show

Comments

Durham Goode - Sept. 3, 2015, 6:16 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1441301382 25200
#      Thu Sep 03 10:29:42 2015 -0700
# Node ID 32124f63ab48a9fbc1f5da5c0439a82de48e35c6
# Parent  57d9e187265607c68c39649c24c9f2835700edf0
convert: remove restriction on multiple --rev in hg source

Multiple --rev args on convert is a new feature, and was initially disabled for
all sources. It has since been enabled on git sources, and this patch enables it
on mercurial sources.
Matt Mackall - Sept. 3, 2015, 10:44 p.m.
On Thu, 2015-09-03 at 11:16 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1441301382 25200
> #      Thu Sep 03 10:29:42 2015 -0700
> # Node ID 32124f63ab48a9fbc1f5da5c0439a82de48e35c6
> # Parent  57d9e187265607c68c39649c24c9f2835700edf0
> convert: remove restriction on multiple --rev in hg source

Queued for default, thanks.

Patch

diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -431,9 +431,6 @@  class mercurial_sink(converter_sink):
 class mercurial_source(converter_source):
     def __init__(self, ui, path, revs=None):
         converter_source.__init__(self, ui, path, revs)
-        if revs and len(revs) > 1:
-            raise util.Abort(_("mercurial source does not support specifying "
-                               "multiple revisions"))
         self.ignoreerrors = ui.configbool('convert', 'hg.ignoreerrors', False)
         self.ignored = set()
         self.saverev = ui.configbool('convert', 'hg.saverev', False)
@@ -468,7 +465,7 @@  class mercurial_source(converter_source)
             else:
                 self.keep = util.always
             if revs:
-                self._heads = [self.repo[revs[0]].node()]
+                self._heads = [self.repo[r].node() for r in revs]
             else:
                 self._heads = self.repo.heads()
         else:
diff --git a/tests/test-convert-hg-startrev.t b/tests/test-convert-hg-startrev.t
--- a/tests/test-convert-hg-startrev.t
+++ b/tests/test-convert-hg-startrev.t
@@ -201,4 +201,23 @@  Convert from revset in convert.hg.revs
   |
   o  0 "0: add a b f" files: a b f
   
-  $ cd ..
+Convert from specified revs
+
+  $ hg convert --rev 3 --rev 2 source multiplerevs
+  initializing destination multiplerevs repository
+  scanning source...
+  sorting...
+  converting...
+  3 0: add a b f
+  2 1: add c, move f to d
+  1 2: copy e from a, change b
+  0 3: change a
+  $ glog multiplerevs
+  o  3 "3: change a" files: a
+  |
+  | o  2 "2: copy e from a, change b" files: b e
+  | |
+  | o  1 "1: add c, move f to d" files: c d f
+  |/
+  o  0 "0: add a b f" files: a b f
+