##// END OF EJS Templates
patch: check filename is /dev/null for creation or deletion (issue 1033)...
Patrick Mezard -
r6280:9db24a36 default
parent child Browse files
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, gitpatch=None):
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.gitpatch = gitpatch
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
@@ -487,3 +487,13 b' cd qclonedest2'
487 487 qlog
488 488 cd ..
489 489
490 echo % 'test applying on an empty file (issue 1033)'
491 hg init empty
492 cd empty
493 touch a
494 hg ci -Am addempty
495 echo a > a
496 hg qnew -f -e changea
497 hg qpop
498 hg qpush
499 cd ..
@@ -472,3 +472,8 b' main repo:'
472 472 rev 0: add foo
473 473 patch repo:
474 474 rev 0: checkpoint
475 % test applying on an empty file (issue 1033)
476 adding a
477 Patch queue now empty
478 applying changea
479 Now at: changea
General Comments 0
You need to be logged in to leave comments. Login now