[PATCH 3 of 6 v2] [convert] Allow passing in a revmap

David Soria Parra davidsp at fb.com
Wed Dec 7 16:30:45 EST 2016


# HG changeset patch
# User David Soria Parra <davidsp at fb.com>
# Date 1480896014 28800
#      Sun Dec 04 16:00:14 2016 -0800
# Node ID e929ae5ce21443ecce43302abb006148c54ed0e3
# Parent  eca976dd5da759a1fb1a71c648624a240156adb9
[convert] Allow passing in a revmap

Implement `setrevmap` which can be used to pass a map of existing revisions.
This will allow incremental imports.

diff --git a/hgext/convert/p4.py b/hgext/convert/p4.py
--- a/hgext/convert/p4.py
+++ b/hgext/convert/p4.py
@@ -55,6 +55,7 @@
 
         common.checktool('p4', abort=False)
 
+        self.revmap = {}
         self.p4changes = {}
         self.heads = {}
         self.changeset = {}
@@ -80,6 +81,9 @@
                                "multiple revisions"))
         self._parse(ui, path)
 
+    def setrevmap(self, revmap):
+        self.revmap = revmap
+
     def _parse_view(self, path):
         "Read changes affecting the path"
         cmd = 'p4 -G changes -s submitted %s' % util.shellquote(path)
@@ -135,6 +139,9 @@
                 continue
             if self.revs and int(change) > int(self.revs[0]):
                 continue
+            if change in self.revmap:
+                lastid = change
+                continue
 
             cmd = "p4 -G describe -s %s" % change
             stdout = util.popen(cmd, mode='rb')


More information about the Mercurial-devel mailing list