Patchwork [8,of,8,v5] convert: return commit objects for revisions in the revmap

login
register
mail settings
Submitter David Soria Parra
Date Dec. 14, 2016, 8:09 p.m.
Message ID <db65134b6228470e0409.1481746169@devbig415.prn1.facebook.com>
Download mbox | patch
Permalink /patch/17917/
State Accepted
Headers show

Comments

David Soria Parra - Dec. 14, 2016, 8:09 p.m.
# HG changeset patch
# User David Soria Parra <davidsp@fb.com>
# Date 1481746043 28800
#      Wed Dec 14 12:07:23 2016 -0800
# Node ID db65134b6228470e0409136b57f1d4f3bdb44a53
# Parent  26ec2474ab06fdaf1aca034c54309245ded267b0
convert: return commit objects for revisions in the revmap

Source revision data that exists in the revmap are ignored when pulling
data from Perforce as we consider them already imported. In case where
the `convertcmd.convert` algorithm requests a commit object for such
a revision we are creating it.  This is usually the case for parent of
the first imported revision.

Patch

diff --git a/hgext/convert/p4.py b/hgext/convert/p4.py
--- a/hgext/convert/p4.py
+++ b/hgext/convert/p4.py
@@ -321,7 +321,13 @@ 
         return marshal.load(stdout)
 
     def getcommit(self, rev):
-        return self.changeset[rev]
+        if rev in self.changeset:
+            return self.changeset[rev]
+        elif rev in self.revmap:
+            d = self._fetch_revision(rev)
+            return self._construct_commit(d, parents=None)
+        raise error.Abort(
+            _("cannot find %s in the revmap or parsed changesets") % rev)
 
     def gettags(self):
         return {}