[PATCH 3 of 4] branch closing: Hide closed branches from "branches" output
John Mulligan
phlogistonjohn at asynchrono.us
Thu Dec 11 14:10:08 CST 2008
# HG changeset patch
# User John Mulligan <phlogistonjohn at asynchrono.us>
# Date 1228956314 18000
# Node ID 60bebc4475e3e1c3e51d286c226cb0d574a3b89c
# Parent 78f9336fe34f3e7920ff1414ca8457a2069686c8
branch closing: Hide closed branches from "branches" output
Remove the closed branches from the output of hg branches
and disallows using the branch name in 'hg co'.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -388,10 +388,19 @@
# this private cache holds all heads (not just tips)
self._ubranchcache = partial
+ def openhead(v):
+ head = None
+ for h in v:
+ if not self.changelog.read(h)[5].get('close'):
+ head = h
+ return head
+
# the branch cache is stored on disk as UTF-8, but in the local
# charset internally
for k, v in partial.items():
- self.branchcache[util.tolocal(k)] = v[-1]
+ head = openhead(v)
+ if head:
+ self.branchcache[util.tolocal(k)] = head
return self.branchcache
def _readbranchcache(self):
@@ -1176,8 +1185,11 @@
def heads(self, start=None):
heads = self.changelog.heads(start)
+ def isclosed(head):
+ extras = self.changelog.read(head)[5]
+ return bool(extras.get('close'))
# sort the output in rev descending order
- heads = [(-self.changelog.rev(h), h) for h in heads]
+ heads = [(-self.changelog.rev(h), h) for h in heads if not isclosed(h)]
return [n for (r, n) in util.sort(heads)]
def branchheads(self, branch=None, start=None):
More information about the Mercurial-devel
mailing list