changeset 27439:ed003859f1d8

changelog: add a new method to get files modified by a changeset This patch adds a new method "readfiles" to get the files modified by a changeset. It extracts some logic from "read" to only return the files modified by a changeset as efficiently as possible. This is used in the next patch to speed up hg log <file|folder>
author Laurent Charignon <lcharignon@fb.com>
date Fri, 18 Dec 2015 13:45:55 -0800
parents f121cf57ca9a
children ff305ab2e0d7
files mercurial/changelog.py
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changelog.py	Wed Dec 16 17:22:37 2015 -0500
+++ b/mercurial/changelog.py	Fri Dec 18 13:45:55 2015 -0800
@@ -360,6 +360,17 @@
         files = l[3:]
         return (manifest, user, (time, timezone), files, desc, extra)
 
+    def readfiles(self, node):
+        """
+        short version of read that only returns the files modified by the cset
+        """
+        text = self.revision(node)
+        if not text:
+            return []
+        last = text.index("\n\n")
+        l = text[:last].split('\n')
+        return l[3:]
+
     def add(self, manifest, files, desc, transaction, p1, p2,
                   user, date=None, extra=None):
         # Convert to UTF-8 encoded bytestrings as the very first