# HG changeset patch # User David Soria Parra # Date 1481708757 28800 # Node ID d47a01bf00599b822b488a62277908fb9d5dd5f3 # Parent d584c412c4a4ef99f37ce32cd52196d00b7b3887 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. diff -r d584c412c4a4 -r d47a01bf0059 hgext/convert/p4.py --- 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')