]> xenbits.xensource.com Git - people/larsk/xenproject-org-gitdm.git/commitdiff
Move out global houskeeping from grabpatch()
authorMartin Nordholts <martinn@src.gnome.org>
Sun, 20 Dec 2009 08:41:07 +0000 (09:41 +0100)
committerJonathan Corbet <corbet@lwn.net>
Sat, 6 Feb 2010 23:32:35 +0000 (16:32 -0700)
As a step to make grabpatch() more unit-test friendly, move out global
houskeeping from grabpatch(). This also gets rid of a TODO in the
code. The regression tests still passes after this refactoring, of
course.

Signed-off-by: Martin Nordholts <martinn@src.gnome.org>
gitdm

diff --git a/gitdm b/gitdm
index 0d5f8b1f667d1c8c69e21aea4ef2dbc1906419f9..dcbb3a9f3c8ddba85b709d3324f65e8377e06c60 100755 (executable)
--- a/gitdm
+++ b/gitdm
@@ -145,7 +145,7 @@ class patch:
 # The core hack for grabbing the information about a changeset.
 #
 def grabpatch():
-    global NextLine, TotalAdded, TotalRemoved, TotalChanged
+    global NextLine
     
     while (1):
         m = Pcommit.match (NextLine)
@@ -250,23 +250,6 @@ def grabpatch():
     if '@' in p.author.name:
         print '%s is an author name, probably not what you want' % p.author.name
 
-    #
-    # Record some global information - but only if this patch had
-    # stuff which wasn't ignored.  This work should be done
-    # elsewhere,
-    #
-    if ((p.added + p.removed) > 0 or not FileFilter) and not p.merge:
-        TotalAdded += p.added
-        TotalRemoved += p.removed
-        TotalChanged += max (p.added, p.removed)
-        AddDateLines (p.date, max (p.added, p.removed))
-        empl = p.author.emailemployer (p.email, p.date)
-        empl.AddCSet (p)
-        if AkpmOverLt:
-            TrimLTSOBs (p)
-        for sobemail, sobber in p.sobs:
-            empl = sobber.emailemployer (sobemail, p.date)
-            empl.AddSOB()
     return p
 
 
@@ -340,6 +323,24 @@ while (1):
 #        continue
     if FileFilter and p.added == 0 and p.removed == 0:
         continue
+
+    #
+    # Record some global information - but only if this patch had
+    # stuff which wasn't ignored.
+    #
+    if ((p.added + p.removed) > 0 or not FileFilter) and not p.merge:
+        TotalAdded += p.added
+        TotalRemoved += p.removed
+        TotalChanged += max (p.added, p.removed)
+        AddDateLines (p.date, max (p.added, p.removed))
+        empl = p.author.emailemployer (p.email, p.date)
+        empl.AddCSet (p)
+        if AkpmOverLt:
+            TrimLTSOBs (p)
+        for sobemail, sobber in p.sobs:
+            empl = sobber.emailemployer (sobemail, p.date)
+            empl.AddSOB()
+
     if not p.merge:
         p.author.addpatch (p)
         for sobemail, sob in p.sobs: