Show More
@@ -292,13 +292,15 b' class patchfile(object):' | |||||
292 | self.hunks = 0 |
|
292 | self.hunks = 0 | |
293 |
|
293 | |||
294 | def readlines(self, fname): |
|
294 | def readlines(self, fname): | |
|
295 | if os.path.islink(fname): | |||
|
296 | return [os.readlink(fname)] | |||
295 | fp = self.opener(fname, 'r') |
|
297 | fp = self.opener(fname, 'r') | |
296 | try: |
|
298 | try: | |
297 | return list(linereader(fp, self.eol is not None)) |
|
299 | return list(linereader(fp, self.eol is not None)) | |
298 | finally: |
|
300 | finally: | |
299 | fp.close() |
|
301 | fp.close() | |
300 |
|
302 | |||
301 | def writelines(self, fname, lines): |
|
303 | def writelines(self, fname, lines): | |
302 | fp = self.opener(fname, 'w') |
|
304 | fp = self.opener(fname, 'w') | |
303 | try: |
|
305 | try: | |
304 | if self.eol and self.eol != '\n': |
|
306 | if self.eol and self.eol != '\n': | |
@@ -405,7 +407,7 b' class patchfile(object):' | |||||
405 | self.rej.append(h) |
|
407 | self.rej.append(h) | |
406 | return -1 |
|
408 | return -1 | |
407 |
|
409 | |||
408 |
if isinstance(h, |
|
410 | if isinstance(h, binhunk): | |
409 | if h.rmfile(): |
|
411 | if h.rmfile(): | |
410 | self.unlink(self.fname) |
|
412 | self.unlink(self.fname) | |
411 | else: |
|
413 | else: | |
@@ -696,12 +698,12 b' class hunk(object):' | |||||
696 | def new(self, fuzz=0, toponly=False): |
|
698 | def new(self, fuzz=0, toponly=False): | |
697 | return self.fuzzit(self.b, fuzz, toponly) |
|
699 | return self.fuzzit(self.b, fuzz, toponly) | |
698 |
|
700 | |||
699 |
class |
|
701 | class binhunk: | |
700 | """A git hunk""" |
|
702 | 'A binary patch file. Only understands literals so far.' | |
701 | def __init__(self, gitpatch): |
|
703 | def __init__(self, gitpatch): | |
702 | self.gitpatch = gitpatch |
|
704 | self.gitpatch = gitpatch | |
703 | self.text = None |
|
705 | self.text = None | |
704 | self.hunk = [] |
|
706 | self.hunk = ['GIT binary patch\n'] | |
705 |
|
707 | |||
706 | def createfile(self): |
|
708 | def createfile(self): | |
707 | return self.gitpatch.op in ('ADD', 'RENAME', 'COPY') |
|
709 | return self.gitpatch.op in ('ADD', 'RENAME', 'COPY') | |
@@ -715,12 +717,6 b' class githunk(object):' | |||||
715 | def new(self): |
|
717 | def new(self): | |
716 | return [self.text] |
|
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 | def extract(self, lr): |
|
720 | def extract(self, lr): | |
725 | line = lr.readline() |
|
721 | line = lr.readline() | |
726 | self.hunk.append(line) |
|
722 | self.hunk.append(line) | |
@@ -748,18 +744,6 b' class binhunk(githunk):' | |||||
748 | len(text), size) |
|
744 | len(text), size) | |
749 | self.text = text |
|
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 | def parsefilename(str): |
|
747 | def parsefilename(str): | |
764 | # --- filename \t|space stuff |
|
748 | # --- filename \t|space stuff | |
765 | s = str[4:].rstrip('\r\n') |
|
749 | s = str[4:].rstrip('\r\n') | |
@@ -897,10 +881,6 b' def iterhunks(ui, fp, sourcefile=None, t' | |||||
897 | create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD' |
|
881 | create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD' | |
898 | remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE' |
|
882 | remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE' | |
899 | current_hunk = hunk(x, hunknum + 1, lr, context, create, remove) |
|
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 | except PatchError, err: |
|
884 | except PatchError, err: | |
905 | ui.debug(err) |
|
885 | ui.debug(err) | |
906 | current_hunk = None |
|
886 | current_hunk = None |
@@ -8,12 +8,13 b' echo "mq=" >> $HGRCPATH' | |||||
8 | hg init |
|
8 | hg init | |
9 | hg qinit |
|
9 | hg qinit | |
10 | hg qnew base.patch |
|
10 | hg qnew base.patch | |
11 | echo a > a |
|
11 | echo aaa > a | |
12 | echo b > b |
|
12 | echo bbb > b | |
13 | hg add a b |
|
13 | hg add a b | |
14 | hg qrefresh |
|
14 | hg qrefresh | |
15 | $TESTDIR/readlink.py a |
|
15 | $TESTDIR/readlink.py a | |
16 |
|
16 | |||
|
17 | echo '% test replacing a file with a symlink' | |||
17 | hg qnew symlink.patch |
|
18 | hg qnew symlink.patch | |
18 | rm a |
|
19 | rm a | |
19 | ln -s b a |
|
20 | ln -s b a | |
@@ -24,6 +25,7 b' hg qpop' | |||||
24 | hg qpush |
|
25 | hg qpush | |
25 | $TESTDIR/readlink.py a |
|
26 | $TESTDIR/readlink.py a | |
26 |
|
27 | |||
|
28 | echo '% test symlink removal' | |||
27 | hg qnew removesl.patch |
|
29 | hg qnew removesl.patch | |
28 | hg rm a |
|
30 | hg rm a | |
29 | hg qrefresh --git |
|
31 | hg qrefresh --git |
@@ -1,9 +1,11 b'' | |||||
1 | a -> a not a symlink |
|
1 | a -> a not a symlink | |
|
2 | % test replacing a file with a symlink | |||
2 | a -> b |
|
3 | a -> b | |
3 | now at: base.patch |
|
4 | now at: base.patch | |
4 | applying symlink.patch |
|
5 | applying symlink.patch | |
5 | now at: symlink.patch |
|
6 | now at: symlink.patch | |
6 | a -> b |
|
7 | a -> b | |
|
8 | % test symlink removal | |||
7 | now at: symlink.patch |
|
9 | now at: symlink.patch | |
8 | applying removesl.patch |
|
10 | applying removesl.patch | |
9 | now at: removesl.patch |
|
11 | now at: removesl.patch |
General Comments 0
You need to be logged in to leave comments.
Login now