Mercurial > hg
comparison hgext/convert/cvsps.py @ 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 | 4e5b7d130e76 |
children | 525fdb738975 |
comparison
equal
deleted
inserted
replaced
15789:2c10ea43c801 | 15790:52f816b40674 |
---|---|
554 # Hence the check for 1 entry here. | 554 # Hence the check for 1 entry here. |
555 c.synthetic = len(c.entries) == 1 and c.entries[0].synthetic | 555 c.synthetic = len(c.entries) == 1 and c.entries[0].synthetic |
556 | 556 |
557 # Sort files in each changeset | 557 # Sort files in each changeset |
558 | 558 |
559 def entitycompare(l, r): | |
560 'Mimic cvsps sorting order' | |
561 l = l.file.split('/') | |
562 r = r.file.split('/') | |
563 nl = len(l) | |
564 nr = len(r) | |
565 n = min(nl, nr) | |
566 for i in range(n): | |
567 if i + 1 == nl and nl < nr: | |
568 return -1 | |
569 elif i + 1 == nr and nl > nr: | |
570 return +1 | |
571 elif l[i] < r[i]: | |
572 return -1 | |
573 elif l[i] > r[i]: | |
574 return +1 | |
575 return 0 | |
576 | |
559 for c in changesets: | 577 for c in changesets: |
560 def pathcompare(l, r): | |
561 'Mimic cvsps sorting order' | |
562 l = l.split('/') | |
563 r = r.split('/') | |
564 nl = len(l) | |
565 nr = len(r) | |
566 n = min(nl, nr) | |
567 for i in range(n): | |
568 if i + 1 == nl and nl < nr: | |
569 return -1 | |
570 elif i + 1 == nr and nl > nr: | |
571 return +1 | |
572 elif l[i] < r[i]: | |
573 return -1 | |
574 elif l[i] > r[i]: | |
575 return +1 | |
576 return 0 | |
577 def entitycompare(l, r): | |
578 return pathcompare(l.file, r.file) | |
579 | |
580 c.entries.sort(entitycompare) | 578 c.entries.sort(entitycompare) |
581 | 579 |
582 # Sort changesets by date | 580 # Sort changesets by date |
583 | 581 |
584 def cscmp(l, r): | 582 def cscmp(l, r): |