Patchwork [3,of,4] changelog: add a `branch` method for direct access to the branch value

mail settings
Submitter Pierre-Yves David
Date Jan. 11, 2013, 6:17 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/544/
State Accepted
Headers show


Pierre-Yves David - Jan. 11, 2013, 6:17 p.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1357774900 -3600
# Node ID dc2e69dcdb6e477b1cbc15b08a51990de8737b0b
# Parent  0ea0b0c68cbee6d9a257a942eba773f00f696d3a
changelog: add a `branch` method for direct access to the branch value

The only way to access the branch of a changeset is currently to create a
changectx object and access it's `branch()` method. Creating a new python object
is costly and have a huge impact on code doing massive access to `branch()`
(like branchmap).

This changesets introduce a new method on changelog that allows direct access to
the branch of a revision. See the next changeset for impact.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -335,5 +335,12 @@  class changelog(revlog.revlog):
             extra = encodeextra(extra)
             parseddate = "%s %s" % (parseddate, extra)
         l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc]
         text = "\n".join(l)
         return self.addrevision(text, transaction, len(self), p1, p2)
+    def branch(self, rev):
+        """return the branch of a revision
+        This function exist because creating a changectx object just to access
+        this is costly."""
+        return encoding.tolocal([5].get("branch"))