cvsps: pull function definition out of loop
authorMartin Geisler <mg@aragost.com>
Sun, 08 Jan 2012 17:57:25 +0100
changeset 15790 52f816b40674
parent 15789 2c10ea43c801
child 15791 a814f8fcc65a
cvsps: pull function definition out of loop
hgext/convert/cvsps.py
--- a/hgext/convert/cvsps.py	Sun Jan 08 11:23:21 2012 +0100
+++ b/hgext/convert/cvsps.py	Sun Jan 08 17:57:25 2012 +0100
@@ -556,27 +556,25 @@
 
     # Sort files in each changeset
 
+    def entitycompare(l, r):
+        'Mimic cvsps sorting order'
+        l = l.file.split('/')
+        r = r.file.split('/')
+        nl = len(l)
+        nr = len(r)
+        n = min(nl, nr)
+        for i in range(n):
+            if i + 1 == nl and nl < nr:
+                return -1
+            elif i + 1 == nr and nl > nr:
+                return +1
+            elif l[i] < r[i]:
+                return -1
+            elif l[i] > r[i]:
+                return +1
+        return 0
+
     for c in changesets:
-        def pathcompare(l, r):
-            'Mimic cvsps sorting order'
-            l = l.split('/')
-            r = r.split('/')
-            nl = len(l)
-            nr = len(r)
-            n = min(nl, nr)
-            for i in range(n):
-                if i + 1 == nl and nl < nr:
-                    return -1
-                elif i + 1 == nr and nl > nr:
-                    return +1
-                elif l[i] < r[i]:
-                    return -1
-                elif l[i] > r[i]:
-                    return +1
-            return 0
-        def entitycompare(l, r):
-            return pathcompare(l.file, r.file)
-
         c.entries.sort(entitycompare)
 
     # Sort changesets by date