##// END OF EJS Templates
patch: handle symlinks without symlinkhunk...
Patrick Mezard -
r9585:ea1935e2 default
parent child Browse files
Show More
@@ -292,13 +292,15 b' class patchfile(object):'
292 292 self.hunks = 0
293 293
294 294 def readlines(self, fname):
295 if os.path.islink(fname):
296 return [os.readlink(fname)]
295 297 fp = self.opener(fname, 'r')
296 298 try:
297 299 return list(linereader(fp, self.eol is not None))
298 300 finally:
299 301 fp.close()
300 302
301 def writelines(self, fname, lines):
303 def writelines(self, fname, lines):
302 304 fp = self.opener(fname, 'w')
303 305 try:
304 306 if self.eol and self.eol != '\n':
@@ -405,7 +407,7 b' class patchfile(object):'
405 407 self.rej.append(h)
406 408 return -1
407 409
408 if isinstance(h, githunk):
410 if isinstance(h, binhunk):
409 411 if h.rmfile():
410 412 self.unlink(self.fname)
411 413 else:
@@ -696,12 +698,12 b' class hunk(object):'
696 698 def new(self, fuzz=0, toponly=False):
697 699 return self.fuzzit(self.b, fuzz, toponly)
698 700
699 class githunk(object):
700 """A git hunk"""
701 class binhunk:
702 'A binary patch file. Only understands literals so far.'
701 703 def __init__(self, gitpatch):
702 704 self.gitpatch = gitpatch
703 705 self.text = None
704 self.hunk = []
706 self.hunk = ['GIT binary patch\n']
705 707
706 708 def createfile(self):
707 709 return self.gitpatch.op in ('ADD', 'RENAME', 'COPY')
@@ -715,12 +717,6 b' class githunk(object):'
715 717 def new(self):
716 718 return [self.text]
717 719
718 class binhunk(githunk):
719 'A binary patch file. Only understands literals so far.'
720 def __init__(self, gitpatch):
721 super(binhunk, self).__init__(gitpatch)
722 self.hunk = ['GIT binary patch\n']
723
724 720 def extract(self, lr):
725 721 line = lr.readline()
726 722 self.hunk.append(line)
@@ -748,18 +744,6 b' class binhunk(githunk):'
748 744 len(text), size)
749 745 self.text = text
750 746
751 class symlinkhunk(githunk):
752 """A git symlink hunk"""
753 def __init__(self, gitpatch, hunk):
754 super(symlinkhunk, self).__init__(gitpatch)
755 self.hunk = hunk
756
757 def complete(self):
758 return True
759
760 def fix_newline(self):
761 return
762
763 747 def parsefilename(str):
764 748 # --- filename \t|space stuff
765 749 s = str[4:].rstrip('\r\n')
@@ -897,10 +881,6 b' def iterhunks(ui, fp, sourcefile=None, t'
897 881 create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD'
898 882 remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE'
899 883 current_hunk = hunk(x, hunknum + 1, lr, context, create, remove)
900 if remove:
901 gpatch = changed.get(afile[2:])
902 if gpatch and gpatch.mode[0]:
903 current_hunk = symlinkhunk(gpatch, current_hunk)
904 884 except PatchError, err:
905 885 ui.debug(err)
906 886 current_hunk = None
@@ -1,9 +1,11 b''
1 1 a -> a not a symlink
2 % test replacing a file with a symlink
2 3 a -> b
3 4 now at: base.patch
4 5 applying symlink.patch
5 6 now at: symlink.patch
6 7 a -> b
8 % test symlink removal
7 9 now at: symlink.patch
8 10 applying removesl.patch
9 11 now at: removesl.patch
General Comments 0
You need to be logged in to leave comments. Login now