changeset 30601:d47a01bf0059

convert: allow passing in a revmap Implement `common.setrevmap` which is used to pass in a file with existing revision mappings. This functionality is used by `convertcmd.convert` if it exists and allows implementors such as the p4 converter to make use of an existing mapping. We are using the revmap to abort scanning and the repository for more information if we already have the revision. This means we are allowing incremental imports in cases where a revmap is provided.
author David Soria Parra <davidsp@fb.com>
date Wed, 14 Dec 2016 01:45:57 -0800
parents d584c412c4a4
children b36a0fa7f969
files hgext/convert/p4.py
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/p4.py	Tue Dec 13 21:49:58 2016 -0800
+++ b/hgext/convert/p4.py	Wed Dec 14 01:45:57 2016 -0800
@@ -55,6 +55,7 @@
 
         common.checktool('p4', abort=False)
 
+        self.revmap = {}
         self.p4changes = {}
         self.heads = []
         self.changeset = {}
@@ -77,6 +78,19 @@
                                "multiple revisions"))
         self._parse(ui, path)
 
+    def setrevmap(self, revmap):
+        """Sets the parsed revmap dictionary.
+
+        Revmap stores mappings from a source revision to a target revision.
+        It is set in convertcmd.convert and provided by the user as a file
+        on the commandline.
+
+        Revisions in the map are considered beeing present in the
+        repository and ignored during _parse(). This allows for incremental
+        imports if a revmap is provided.
+        """
+        self.revmap = revmap
+
     def _parse_view(self, path):
         "Read changes affecting the path"
         cmd = 'p4 -G changes -s submitted %s' % util.shellquote(path)
@@ -132,6 +146,10 @@
                 continue
             if self.revs and int(change) > int(self.revs[0]):
                 continue
+            if change in self.revmap:
+                # Ignore already present revisions, but set the parent pointer.
+                lastid = change
+                continue
 
             cmd = "p4 -G describe -s %s" % change
             stdout = util.popen(cmd, mode='rb')