Patchwork [2,of,4,v2] convert: refactor head calculation for hg sources

login
register
mail settings
Submitter Mads Kiilerich
Date Oct. 10, 2013, 6:46 p.m.
Message ID <3951cebb6743fee2b68a.1381430775@mk-desktop>
Download mbox | patch
Permalink /patch/2745/
State Accepted
Commit 9057855d87490cc77a0f9acc42e8bd1718c0c55f
Headers show

Comments

Mads Kiilerich - Oct. 10, 2013, 6:46 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1380816081 -7200
#      Thu Oct 03 18:01:21 2013 +0200
# Node ID 3951cebb6743fee2b68a835d9097cb2d8784d230
# Parent  b8151cd615f0e6407c89cb1cd4454cef3a9802e4
convert: refactor head calculation for hg sources

Patch

diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -260,11 +260,15 @@ 
                                  % startnode)
             startrev = self.repo.changelog.rev(startnode)
             children = {startnode: 1}
-            for rev in self.repo.changelog.descendants([startrev]):
-                children[self.repo.changelog.node(rev)] = 1
+            for r in self.repo.changelog.descendants([startrev]):
+                children[self.repo.changelog.node(r)] = 1
             self.keep = children.__contains__
         else:
             self.keep = util.always
+        if rev:
+            self._heads = [self.repo[rev].node()]
+        else:
+            self._heads = self.repo.heads()
 
     def changectx(self, rev):
         if self.lastrev != rev:
@@ -276,11 +280,7 @@ 
         return [p for p in ctx.parents() if p and self.keep(p.node())]
 
     def getheads(self):
-        if self.rev:
-            heads = [self.repo[self.rev].node()]
-        else:
-            heads = self.repo.heads()
-        return [hex(h) for h in heads if self.keep(h)]
+        return [hex(h) for h in self._heads if self.keep(h)]
 
     def getfile(self, name, rev):
         try: