changeset 18306:06185554e7e3

changelog: add a `branch` method, bypassing changectx The only way to access the branch of a changeset is currently to create a changectx object and access its `branch()` method. Creating a new Python object is costly and has a huge impact on code doing heavy access to `branch()` (like branchmap). This change introduces a new method on changelog that allows direct access to the branch of a revision. See the next changeset for impact.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Thu, 10 Jan 2013 00:41:40 +0100
parents 2502a15e033d
children 0eed2546118a
files mercurial/changelog.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changelog.py	Tue Jan 08 01:28:39 2013 +0100
+++ b/mercurial/changelog.py	Thu Jan 10 00:41:40 2013 +0100
@@ -337,3 +337,10 @@
         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 exists because creating a changectx object
+	just to access this is costly."""
+        return encoding.tolocal(self.read(rev)[5].get("branch"))