# HG changeset patch # User Martin Geisler # Date 1326041845 -3600 # Node ID 52f816b4067471dbf665793aac4a0b4b209465cf # Parent 2c10ea43c8016cd313f4495fafa516f30c74d314 cvsps: pull function definition out of loop diff -r 2c10ea43c801 -r 52f816b40674 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