# HG changeset patch # User Dirkjan Ochtman # Date 1253714083 -7200 # Node ID a0e69510018bd95e25cc5cba3b97e894beb0e82f # Parent ffaf6074d1bd8e267d140c39c2e2981162a60348# Parent c295a82a020bdd1d000161ee822d9875d480688b merge with crew-stable diff -r ffaf6074d1bd -r a0e69510018b hgext/convert/p4.py --- a/hgext/convert/p4.py Wed Sep 23 15:19:26 2009 +0200 +++ b/hgext/convert/p4.py Wed Sep 23 15:54:43 2009 +0200 @@ -53,7 +53,7 @@ def _parse_view(self, path): "Read changes affecting the path" cmd = 'p4 -G changes -s submitted "%s"' % path - stdout = util.popen(cmd) + stdout = util.popen(cmd, mode='rb') for d in loaditer(stdout): c = d.get("change", None) if c: @@ -72,7 +72,7 @@ views = {"//": ""} else: cmd = 'p4 -G client -o "%s"' % path - clientspec = marshal.load(util.popen(cmd)) + clientspec = marshal.load(util.popen(cmd, mode='rb')) views = {} for client in clientspec: @@ -105,7 +105,7 @@ lastid = None for change in self.p4changes: cmd = "p4 -G describe %s" % change - stdout = util.popen(cmd) + stdout = util.popen(cmd, mode='rb') d = marshal.load(stdout) desc = self.recode(d["desc"]) @@ -147,7 +147,7 @@ def getfile(self, name, rev): cmd = 'p4 -G print "%s#%s"' % (self.depotname[name], rev) - stdout = util.popen(cmd) + stdout = util.popen(cmd, mode='rb') mode = None contents = "" diff -r ffaf6074d1bd -r a0e69510018b mercurial/localrepo.py --- a/mercurial/localrepo.py Wed Sep 23 15:19:26 2009 +0200 +++ b/mercurial/localrepo.py Wed Sep 23 15:54:43 2009 +0200 @@ -1159,17 +1159,24 @@ return [n for (r, n) in sorted(heads)] def branchheads(self, branch=None, start=None, closed=False): + '''return a (possibly filtered) list of heads for the given branch + + Heads are returned in topological order, from newest to oldest. + If branch is None, use the dirstate branch. + If start is not None, return only heads reachable from start. + If closed is True, return heads that are marked as closed as well. + ''' if branch is None: branch = self[None].branch() branches = self.branchmap() if branch not in branches: return [] - bheads = branches[branch] # the cache returns heads ordered lowest to highest - bheads.reverse() + bheads = list(reversed(branches[branch])) if start is not None: # filter out the heads that cannot be reached from startrev - bheads = self.changelog.nodesbetween([start], bheads)[2] + fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) + bheads = [h for h in bheads if h in fbheads] if not closed: bheads = [h for h in bheads if ('close' not in self.changelog.read(h)[5])] diff -r ffaf6074d1bd -r a0e69510018b tests/test-bheads.out --- a/tests/test-bheads.out Wed Sep 23 15:19:26 2009 +0200 +++ b/tests/test-bheads.out Wed Sep 23 15:54:43 2009 +0200 @@ -68,8 +68,8 @@ 3: Adding b branch head 1 0 ------- +6: Merging b branch head 2 and b branch head 3 3: Adding b branch head 1 -6: Merging b branch head 2 and b branch head 3 0 ------- no changes on branch b containing . are reachable from 7