changeset 15790:52f816b40674

cvsps: pull function definition out of loop
author Martin Geisler <mg@aragost.com>
date Sun, 08 Jan 2012 17:57:25 +0100
parents 2c10ea43c801
children a814f8fcc65a
files hgext/convert/cvsps.py
diffstat 1 files changed, 18 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- 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