Patchwork [default] convert: update hg convert source to accept revsets as revs

login
register
mail settings
Submitter Boris Feld
Date May 23, 2017, 1:21 p.m.
Message ID <1e4860f3409aec9fc81e.1495545719@FB>
Download mbox | patch
Permalink /patch/20861/
State Changes Requested
Headers show

Comments

Boris Feld - May 23, 2017, 1:21 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1495542603 -7200
#      Tue May 23 14:30:03 2017 +0200
# Node ID 1e4860f3409aec9fc81e65a53c8e107d1c9c815a
# Parent  e8c043375b53b30c4b468687f08323cbeeb452ef
# EXP-Topic convert-revset
convert: update hg convert source to accept revsets as revs

My usecase is to pass a revset like (limit(all(), X, 0)) to convert hg source
repositories pieces by pieces as it seems that hg convert leaks memory. This
way we can bypass the problem by processing the repositories small pieces at
the time.

It also makes convert more flexible.
Yuya Nishihara - May 24, 2017, 2:01 p.m.
On Tue, 23 May 2017 15:21:59 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1495542603 -7200
> #      Tue May 23 14:30:03 2017 +0200
> # Node ID 1e4860f3409aec9fc81e65a53c8e107d1c9c815a
> # Parent  e8c043375b53b30c4b468687f08323cbeeb452ef
> # EXP-Topic convert-revset
> convert: update hg convert source to accept revsets as revs
> 
> My usecase is to pass a revset like (limit(all(), X, 0)) to convert hg source
> repositories pieces by pieces as it seems that hg convert leaks memory. This
> way we can bypass the problem by processing the repositories small pieces at
> the time.

Maybe you want --config convert.hg.revs= ?

https://www.mercurial-scm.org/repo/hg/rev/e271970b9821

I don't think it's a conflicting idea to make --rev accept revsets (as long as
it's interpreted as a head revision), but e271970b9821 is worth reading.

Patch

diff -r e8c043375b53 -r 1e4860f3409a hgext/convert/hg.py
--- a/hgext/convert/hg.py	Fri May 19 20:06:45 2017 +0530
+++ b/hgext/convert/hg.py	Tue May 23 14:30:03 2017 +0200
@@ -480,7 +480,8 @@ 
             else:
                 self.keep = util.always
             if revs:
-                self._heads = [self.repo[r].node() for r in revs]
+                revsnumbers = scmutil.revrange(self.repo, revs)
+                self._heads = [self.repo[r].node() for r in revsnumbers]
             else:
                 self._heads = self.repo.heads()
         else:
diff -r e8c043375b53 -r 1e4860f3409a tests/test-convert-hg-source.t
--- a/tests/test-convert-hg-source.t	Fri May 19 20:06:45 2017 +0530
+++ b/tests/test-convert-hg-source.t	Tue May 23 14:30:03 2017 +0200
@@ -200,3 +200,56 @@ 
   a
   c
   d
+
+check that convert accepts revsets and that converting a repository in two times works
+
+  $ hg convert orig revset-multiple -r "limit(all(), 4, 0)" 2>&1 | grep -v 'subversion python bindings could not be loaded'
+  initializing destination revset-multiple repository
+  scanning source...
+  sorting...
+  converting...
+  3 add foo bar
+  2 change foo
+  1 make bar and baz copies of foo
+  0 merge local copy
+  updating bookmarks
+  $ hg convert orig revset-multiple -r "limit(all(), 4, 4)" 2>&1 | grep -v 'subversion python bindings could not be loaded'
+  scanning source...
+  sorting...
+  converting...
+  3 merge remote copy
+  2 Added tag that for changeset 88586c4e9f02
+  1 Removed tag that
+  0 Added tag this for changeset c56a7f387039
+  updating bookmarks
+  $ hg convert orig revset-multiple -r "limit(all(), 4, 8)" 2>&1 | grep -v 'subversion python bindings could not be loaded'
+  scanning source...
+  sorting...
+  converting...
+  2 mark baz executable
+  1 change foo again
+  0 change foo again again
+  updating bookmarks
+  $ hg -R "revset-multiple" log -G -T '{rev} {desc}'
+  o  10 change foo again again
+  |
+  | o  9 change foo again
+  | |
+  | | o  8 mark baz executable
+  | | |
+  | | o  7 Added tag this for changeset c56a7f387039
+  | | |
+  | | o  6 Removed tag that
+  | | |
+  | | o  5 Added tag that for changeset 88586c4e9f02
+  | | |
+  +---o  4 merge remote copy
+  | |/
+  +---o  3 merge local copy
+  | |/
+  o |  2 make bar and baz copies of foo
+  | |
+  | o  1 change foo
+  |/
+  o  0 add foo bar
+