Show More
@@ -505,7 +505,7 b' class patchfile:' | |||
|
505 | 505 | return -1 |
|
506 | 506 | |
|
507 | 507 | class hunk: |
|
508 |
def __init__(self, desc, num, lr, context, |
|
|
508 | def __init__(self, desc, num, lr, context, create=False, remove=False): | |
|
509 | 509 | self.number = num |
|
510 | 510 | self.desc = desc |
|
511 | 511 | self.hunk = [ desc ] |
@@ -515,7 +515,8 b' class hunk:' | |||
|
515 | 515 | self.read_context_hunk(lr) |
|
516 | 516 | else: |
|
517 | 517 | self.read_unified_hunk(lr) |
|
518 |
self. |
|
|
518 | self.create = create | |
|
519 | self.remove = remove and not create | |
|
519 | 520 | |
|
520 | 521 | def read_unified_hunk(self, lr): |
|
521 | 522 | m = unidesc.match(self.desc) |
@@ -640,6 +641,7 b' class hunk:' | |||
|
640 | 641 | self.hunk[0] = self.desc |
|
641 | 642 | |
|
642 | 643 | def reverse(self): |
|
644 | self.create, self.remove = self.remove, self.create | |
|
643 | 645 | origlena = self.lena |
|
644 | 646 | origstarta = self.starta |
|
645 | 647 | self.lena = self.lenb |
@@ -670,12 +672,10 b' class hunk:' | |||
|
670 | 672 | return len(self.a) == self.lena and len(self.b) == self.lenb |
|
671 | 673 | |
|
672 | 674 | def createfile(self): |
|
673 | create = self.gitpatch is None or self.gitpatch.op == 'ADD' | |
|
674 | return self.starta == 0 and self.lena == 0 and create | |
|
675 | return self.starta == 0 and self.lena == 0 and self.create | |
|
675 | 676 | |
|
676 | 677 | def rmfile(self): |
|
677 | remove = self.gitpatch is None or self.gitpatch.op == 'DELETE' | |
|
678 | return self.startb == 0 and self.lenb == 0 and remove | |
|
678 | return self.startb == 0 and self.lenb == 0 and self.remove | |
|
679 | 679 | |
|
680 | 680 | def fuzzit(self, l, fuzz, toponly): |
|
681 | 681 | # this removes context lines from the top and bottom of list 'l'. It |
@@ -912,7 +912,9 b' def iterhunks(ui, fp, sourcefile=None):' | |||
|
912 | 912 | if context == None and x.startswith('***************'): |
|
913 | 913 | context = True |
|
914 | 914 | gpatch = changed.get(bfile[2:], (None, None))[1] |
|
915 | current_hunk = hunk(x, hunknum + 1, lr, context, gpatch) | |
|
915 | create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD' | |
|
916 | remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE' | |
|
917 | current_hunk = hunk(x, hunknum + 1, lr, context, create, remove) | |
|
916 | 918 | except PatchError, err: |
|
917 | 919 | ui.debug(err) |
|
918 | 920 | current_hunk = None |
General Comments 0
You need to be logged in to leave comments.
Login now