[PATCH 2 of 3] branch closing: Hide closed branches from "heads" and "branches"

John Mulligan phlogistonjohn at asynchrono.us
Sat Oct 4 15:28:28 CDT 2008


# HG changeset patch
# User John Mulligan <phlogistonjohn at asynchrono.us>
# Date 1223151170 14400
# Node ID bd4439b5ea590341e6662e15ec17880dab701116
# Parent  72f027ac6eb2e2e0ac4ebb089d1d40272ec41788
branch closing: Hide closed branches from "heads" and "branches"

Remove the closed branches from the output of the heads and branches
commands by removing the unwanted csets from the output of
the localrepo functions that generate them.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -386,9 +386,13 @@
 
         # the branch cache is stored on disk as UTF-8, but in the local
         # charset internally
+        if self._ubranchcache is None:
+            self._ubranchcache = {}
         for k, v in partial.items():
-            self.branchcache[util.tolocal(k)] = v
-        self._ubranchcache = partial
+            extras = self.changelog.read(v)[5]
+            if not extras.get('close'):
+                self.branchcache[util.tolocal(k)] = v
+                self._ubranchcache[k] = v
         return self.branchcache
 
     def _readbranchcache(self):
@@ -1130,8 +1134,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