changeset 24262:7f24b2a0581a

record: move countChanges in the hunk class Part of a series of patches to move record from hgext to core
author Laurent Charignon <lcharignon@fb.com>
date Mon, 09 Mar 2015 13:08:19 -0700
parents 20aac24e2114
children a45d1c51109e
files hgext/record.py
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/record.py	Mon Mar 09 13:04:50 2015 -0700
+++ b/hgext/record.py	Mon Mar 09 13:08:19 2015 -0700
@@ -69,12 +69,6 @@
             else:
                 yield 'other', line
 
-def countchanges(hunk):
-    """hunk -> (n+,n-)"""
-    add = len([h for h in hunk if h[0] == '+'])
-    rem = len([h for h in hunk if h[0] == '-'])
-    return add, rem
-
 class hunk(object):
     """patch hunk
 
@@ -94,7 +88,13 @@
         self.toline, self.after = trimcontext(toline, after)
         self.proc = proc
         self.hunk = hunk
-        self.added, self.removed = countchanges(self.hunk)
+        self.added, self.removed = self.countchanges(self.hunk)
+
+    def countchanges(self, hunk):
+        """hunk -> (n+,n-)"""
+        add = len([h for h in hunk if h[0] == '+'])
+        rem = len([h for h in hunk if h[0] == '-'])
+        return add, rem
 
     def write(self, fp):
         delta = len(self.before) + len(self.after)