changeset 3042:2d35d7c6f251

[churn] Trivial cleanup suggested by Thomas
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Tue, 15 Aug 2006 05:48:49 -0400
parents 45942bb49194
children fe0e3508ec6e
files hgext/churn.py
diffstat 1 files changed, 7 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/churn.py	Tue Aug 08 15:29:33 2006 -0400
+++ b/hgext/churn.py	Tue Aug 15 05:48:49 2006 -0400
@@ -19,23 +19,19 @@
     def dirtywork(f, mmap1, mmap2):
         lines = 0
 
-        to = None
-        if mmap1:
-            to = repo.file(f).read(mmap1[f])
-        tn = None
-        if mmap2:
-            tn = repo.file(f).read(mmap2[f])
+        to = mmap1 and repo.file(f).read(mmap1[f]) or None
+        tn = mmap2 and repo.file(f).read(mmap2[f]) or None
 
         diff = mdiff.unidiff(to, "", tn, "", f).split("\n")
 
         for line in diff:
-            if len(line) <= 0:
+            if not len(line):
                 continue # skip EOF
-            if line[0] == " ":
+            if line.startswith(" "):
                 continue # context line
-            if line[0:4] == "--- " or line[0:4] == "+++ ":
+            if line.startswith("--- ") or line.startswith("+++ "):
                 continue # begining of diff
-            if line[0:3] == "@@ ":
+            if line.startswith("@@ "):
                 continue # info line
 
             # changed lines
@@ -135,7 +131,7 @@
 
     # make a list of tuples (name, lines) and sort it in descending order
     ordered = stats.items()
-    ordered.sort(cmp=lambda x,y:cmp(y[1], x[1]))
+    ordered.sort(cmp=lambda x, y: cmp(y[1], x[1]))
 
     maximum = ordered[0][1]