Show More
@@ -210,6 +210,8 b' def readgitpatch(lr):' | |||||
210 | gp.path = line[8:].rstrip() |
|
210 | gp.path = line[8:].rstrip() | |
211 | elif line.startswith('deleted file'): |
|
211 | elif line.startswith('deleted file'): | |
212 | gp.op = 'DELETE' |
|
212 | gp.op = 'DELETE' | |
|
213 | # is the deleted file a symlink? | |||
|
214 | gp.setmode(int(line.rstrip()[-6:], 8)) | |||
213 | elif line.startswith('new file mode '): |
|
215 | elif line.startswith('new file mode '): | |
214 | gp.op = 'ADD' |
|
216 | gp.op = 'ADD' | |
215 | gp.setmode(int(line.rstrip()[-6:], 8)) |
|
217 | gp.setmode(int(line.rstrip()[-6:], 8)) | |
@@ -364,7 +366,7 b' class patchfile:' | |||||
364 | self.rej.append(h) |
|
366 | self.rej.append(h) | |
365 | return -1 |
|
367 | return -1 | |
366 |
|
368 | |||
367 |
if isinstance(h, |
|
369 | if isinstance(h, githunk): | |
368 | if h.rmfile(): |
|
370 | if h.rmfile(): | |
369 | self.unlink(self.fname) |
|
371 | self.unlink(self.fname) | |
370 | else: |
|
372 | else: | |
@@ -654,12 +656,12 b' class hunk:' | |||||
654 | def new(self, fuzz=0, toponly=False): |
|
656 | def new(self, fuzz=0, toponly=False): | |
655 | return self.fuzzit(self.b, fuzz, toponly) |
|
657 | return self.fuzzit(self.b, fuzz, toponly) | |
656 |
|
658 | |||
657 |
class |
|
659 | class githunk(object): | |
658 | 'A binary patch file. Only understands literals so far.' |
|
660 | """A git hunk""" | |
659 | def __init__(self, gitpatch): |
|
661 | def __init__(self, gitpatch): | |
660 | self.gitpatch = gitpatch |
|
662 | self.gitpatch = gitpatch | |
661 | self.text = None |
|
663 | self.text = None | |
662 |
self.hunk = [ |
|
664 | self.hunk = [] | |
663 |
|
665 | |||
664 | def createfile(self): |
|
666 | def createfile(self): | |
665 | return self.gitpatch.op in ('ADD', 'RENAME', 'COPY') |
|
667 | return self.gitpatch.op in ('ADD', 'RENAME', 'COPY') | |
@@ -673,6 +675,12 b' class binhunk:' | |||||
673 | def new(self): |
|
675 | def new(self): | |
674 | return [self.text] |
|
676 | return [self.text] | |
675 |
|
677 | |||
|
678 | class binhunk(githunk): | |||
|
679 | 'A binary patch file. Only understands literals so far.' | |||
|
680 | def __init__(self, gitpatch): | |||
|
681 | super(binhunk, self).__init__(gitpatch) | |||
|
682 | self.hunk = ['GIT binary patch\n'] | |||
|
683 | ||||
676 | def extract(self, lr): |
|
684 | def extract(self, lr): | |
677 | line = lr.readline() |
|
685 | line = lr.readline() | |
678 | self.hunk.append(line) |
|
686 | self.hunk.append(line) | |
@@ -700,6 +708,18 b' class binhunk:' | |||||
700 | len(text), size) |
|
708 | len(text), size) | |
701 | self.text = text |
|
709 | self.text = text | |
702 |
|
710 | |||
|
711 | class symlinkhunk(githunk): | |||
|
712 | """A git symlink hunk""" | |||
|
713 | def __init__(self, gitpatch, hunk): | |||
|
714 | super(symlinkhunk, self).__init__(gitpatch) | |||
|
715 | self.hunk = hunk | |||
|
716 | ||||
|
717 | def complete(self): | |||
|
718 | return True | |||
|
719 | ||||
|
720 | def fix_newline(self): | |||
|
721 | return | |||
|
722 | ||||
703 | def parsefilename(str): |
|
723 | def parsefilename(str): | |
704 | # --- filename \t|space stuff |
|
724 | # --- filename \t|space stuff | |
705 | s = str[4:].rstrip('\r\n') |
|
725 | s = str[4:].rstrip('\r\n') | |
@@ -857,6 +877,10 b' def iterhunks(ui, fp, sourcefile=None):' | |||||
857 | create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD' |
|
877 | create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD' | |
858 | remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE' |
|
878 | remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE' | |
859 | current_hunk = hunk(x, hunknum + 1, lr, context, create, remove) |
|
879 | current_hunk = hunk(x, hunknum + 1, lr, context, create, remove) | |
|
880 | if remove: | |||
|
881 | gpatch = changed.get(afile[2:]) | |||
|
882 | if gpatch and gpatch.mode[0]: | |||
|
883 | current_hunk = symlinkhunk(gpatch, current_hunk) | |||
860 | except PatchError, err: |
|
884 | except PatchError, err: | |
861 | ui.debug(err) |
|
885 | ui.debug(err) | |
862 | current_hunk = None |
|
886 | current_hunk = None | |
@@ -1038,7 +1062,7 b' def updatedir(ui, repo, patches, similar' | |||||
1038 | if gp.op == 'ADD' and not os.path.exists(dst): |
|
1062 | if gp.op == 'ADD' and not os.path.exists(dst): | |
1039 | flags = (isexec and 'x' or '') + (islink and 'l' or '') |
|
1063 | flags = (isexec and 'x' or '') + (islink and 'l' or '') | |
1040 | repo.wwrite(gp.path, '', flags) |
|
1064 | repo.wwrite(gp.path, '', flags) | |
1041 | else: |
|
1065 | elif gp.op != 'DELETE': | |
1042 | util.set_flags(dst, islink, isexec) |
|
1066 | util.set_flags(dst, islink, isexec) | |
1043 | cmdutil.addremove(repo, cfiles, similarity=similarity) |
|
1067 | cmdutil.addremove(repo, cfiles, similarity=similarity) | |
1044 | files = patches.keys() |
|
1068 | files = patches.keys() |
General Comments 0
You need to be logged in to leave comments.
Login now