##// END OF EJS Templates
absorb: use pycompat to get xrange...
Augie Fackler -
r38956:a5c8c547 default
parent child Browse files
Show More
@@ -43,6 +43,7 b' from mercurial import ('
43 obsolete,
43 obsolete,
44 patch,
44 patch,
45 phases,
45 phases,
46 pycompat,
46 registrar,
47 registrar,
47 repair,
48 repair,
48 scmutil,
49 scmutil,
@@ -390,7 +391,7 b' class filefixupstate(object):'
390 newfixups.append((fixuprev, a1, a2, b1, b2))
391 newfixups.append((fixuprev, a1, a2, b1, b2))
391 elif a2 - a1 == b2 - b1 or b1 == b2:
392 elif a2 - a1 == b2 - b1 or b1 == b2:
392 # 1:1 line mapping, or chunk was deleted
393 # 1:1 line mapping, or chunk was deleted
393 for i in xrange(a1, a2):
394 for i in pycompat.xrange(a1, a2):
394 rev, linenum = annotated[i]
395 rev, linenum = annotated[i]
395 if rev > 1:
396 if rev > 1:
396 if b1 == b2: # deletion, simply remove that single line
397 if b1 == b2: # deletion, simply remove that single line
@@ -417,7 +418,7 b' class filefixupstate(object):'
417 """
418 """
418 llog = linelog.linelog()
419 llog = linelog.linelog()
419 a, alines = '', []
420 a, alines = '', []
420 for i in xrange(len(self.contents)):
421 for i in pycompat.xrange(len(self.contents)):
421 b, blines = self.contents[i], self.contentlines[i]
422 b, blines = self.contents[i], self.contentlines[i]
422 llrev = i * 2 + 1
423 llrev = i * 2 + 1
423 chunks = self._alldiffchunks(a, b, alines, blines)
424 chunks = self._alldiffchunks(a, b, alines, blines)
@@ -429,7 +430,7 b' class filefixupstate(object):'
429 def _checkoutlinelog(self):
430 def _checkoutlinelog(self):
430 """() -> [str]. check out file contents from linelog"""
431 """() -> [str]. check out file contents from linelog"""
431 contents = []
432 contents = []
432 for i in xrange(len(self.contents)):
433 for i in pycompat.xrange(len(self.contents)):
433 rev = (i + 1) * 2
434 rev = (i + 1) * 2
434 self.linelog.annotate(rev)
435 self.linelog.annotate(rev)
435 content = ''.join(map(self._getline, self.linelog.annotateresult))
436 content = ''.join(map(self._getline, self.linelog.annotateresult))
@@ -554,18 +555,18 b' class filefixupstate(object):'
554 a1, a2, b1, b2 = chunk
555 a1, a2, b1, b2 = chunk
555 aidxs, bidxs = [0] * (a2 - a1), [0] * (b2 - b1)
556 aidxs, bidxs = [0] * (a2 - a1), [0] * (b2 - b1)
556 for idx, fa1, fa2, fb1, fb2 in fixups:
557 for idx, fa1, fa2, fb1, fb2 in fixups:
557 for i in xrange(fa1, fa2):
558 for i in pycompat.xrange(fa1, fa2):
558 aidxs[i - a1] = (max(idx, 1) - 1) // 2
559 aidxs[i - a1] = (max(idx, 1) - 1) // 2
559 for i in xrange(fb1, fb2):
560 for i in pycompat.xrange(fb1, fb2):
560 bidxs[i - b1] = (max(idx, 1) - 1) // 2
561 bidxs[i - b1] = (max(idx, 1) - 1) // 2
561
562
562 buf = [] # [(idx, content)]
563 buf = [] # [(idx, content)]
563 buf.append((0, label('@@ -%d,%d +%d,%d @@'
564 buf.append((0, label('@@ -%d,%d +%d,%d @@'
564 % (a1, a2 - a1, b1, b2 - b1), 'diff.hunk')))
565 % (a1, a2 - a1, b1, b2 - b1), 'diff.hunk')))
565 buf += [(aidxs[i - a1], label('-' + alines[i], 'diff.deleted'))
566 buf += [(aidxs[i - a1], label('-' + alines[i], 'diff.deleted'))
566 for i in xrange(a1, a2)]
567 for i in pycompat.xrange(a1, a2)]
567 buf += [(bidxs[i - b1], label('+' + blines[i], 'diff.inserted'))
568 buf += [(bidxs[i - b1], label('+' + blines[i], 'diff.inserted'))
568 for i in xrange(b1, b2)]
569 for i in pycompat.xrange(b1, b2)]
569 for idx, line in buf:
570 for idx, line in buf:
570 shortnode = idx and node.short(self.fctxs[idx].node()) or ''
571 shortnode = idx and node.short(self.fctxs[idx].node()) or ''
571 ui.write(ui.label(shortnode[0:7].ljust(8), 'absorb.node') +
572 ui.write(ui.label(shortnode[0:7].ljust(8), 'absorb.node') +
General Comments 0
You need to be logged in to leave comments. Login now