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, |
|
|
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 |
|
|
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 |
@@ -8,12 +8,13 b' echo "mq=" >> $HGRCPATH' | |||
|
8 | 8 | hg init |
|
9 | 9 | hg qinit |
|
10 | 10 | hg qnew base.patch |
|
11 | echo a > a | |
|
12 | echo b > b | |
|
11 | echo aaa > a | |
|
12 | echo bbb > b | |
|
13 | 13 | hg add a b |
|
14 | 14 | hg qrefresh |
|
15 | 15 | $TESTDIR/readlink.py a |
|
16 | 16 | |
|
17 | echo '% test replacing a file with a symlink' | |
|
17 | 18 | hg qnew symlink.patch |
|
18 | 19 | rm a |
|
19 | 20 | ln -s b a |
@@ -24,6 +25,7 b' hg qpop' | |||
|
24 | 25 | hg qpush |
|
25 | 26 | $TESTDIR/readlink.py a |
|
26 | 27 | |
|
28 | echo '% test symlink removal' | |
|
27 | 29 | hg qnew removesl.patch |
|
28 | 30 | hg rm a |
|
29 | 31 | hg qrefresh --git |
General Comments 0
You need to be logged in to leave comments.
Login now