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

Submitter Mads Kiilerich Oct. 2, 2013, 5:56 p.m. <6b53306b03188cb3803a.1380736604@mk-desktop> mbox | patch /patch/2709/ Superseded 9057855d87490cc77a0f9acc42e8bd1718c0c55f show

Mads Kiilerich - Oct. 2, 2013, 5:56 p.m.
```# HG changeset patch
# Date 1380736445 -7200
#      Wed Oct 02 19:54:05 2013 +0200
# Node ID 6b53306b03188cb3803a8957d73ce551ec72b0b9
# Parent  33c6179248c5db3a7b4d978e6b98bc44d42f4dd4
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:

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())]

-        if self.rev:
-            heads = [self.repo[self.rev].node()]
-        else:
-        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:

```