[PATCH 4 of 6 v2] [convert] Parse perforce changes when needed, not in the constructor

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


# HG changeset patch
# User David Soria Parra <davidsp at fb.com>
# Date 1481139471 28800
#      Wed Dec 07 11:37:51 2016 -0800
# Node ID 4e7c528ec68f36e26535614e9c8ef067305bdbbe
# Parent  e929ae5ce21443ecce43302abb006148c54ed0e3
[convert] Parse perforce changes when needed, not in the constructor

The perforce source is parsing all changes in the constructor and not deferring
it to when needed. This leads to the source parsing changes before the revmap
is available. Let's move the parsing to when we need it the first time.

diff --git a/hgext/convert/p4.py b/hgext/convert/p4.py
--- a/hgext/convert/p4.py
+++ b/hgext/convert/p4.py
@@ -79,7 +79,6 @@
         if revs and len(revs) > 1:
             raise error.Abort(_("p4 source does not support specifying "
                                "multiple revisions"))
-        self._parse(ui, path)
 
     def setrevmap(self, revmap):
         self.revmap = revmap
@@ -224,6 +223,8 @@
             self.heads = [lastid]
 
     def getheads(self):
+        if len(self.p4changes) == 0:
+            self._parse(self.ui, self.path)
         return self.heads
 
     def getfile(self, name, rev):
@@ -299,7 +300,11 @@
         return self.changeset[rev]
 
     def gettags(self):
+        if len(self.p4changes) == 0:
+            self._parse(self.ui, self.path)
         return self.tags
 
     def getchangedfiles(self, rev, i):
+        if len(self.p4changes) == 0:
+            self._parse(self.ui, self.path)
         return sorted([x[0] for x in self.files[rev]])


More information about the Mercurial-devel mailing list