Show More
@@ -115,7 +115,11 b' class logstream(object):' | |||||
115 |
|
115 | |||
116 | def __iter__(self): |
|
116 | def __iter__(self): | |
117 | while True: |
|
117 | while True: | |
|
118 | try: | |||
118 | entry = pickle.load(self._stdout) |
|
119 | entry = pickle.load(self._stdout) | |
|
120 | except EOFError: | |||
|
121 | raise util.Abort(_('Mercurial failed to run itself, check' | |||
|
122 | ' hg executable is in PATH')) | |||
119 | try: |
|
123 | try: | |
120 | orig_paths, revnum, author, date, message = entry |
|
124 | orig_paths, revnum, author, date, message = entry | |
121 | except: |
|
125 | except: |
@@ -292,6 +292,8 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)) | |
@@ -299,6 +301,13 b' class patchfile(object):' | |||||
299 | fp.close() |
|
301 | fp.close() | |
300 |
|
302 | |||
301 | def writelines(self, fname, lines): |
|
303 | def writelines(self, fname, lines): | |
|
304 | # Ensure supplied data ends in fname, being a regular file or | |||
|
305 | # a symlink. updatedir() will -too magically- take care of | |||
|
306 | # setting it to the proper type afterwards. | |||
|
307 | islink = os.path.islink(fname) | |||
|
308 | if islink: | |||
|
309 | fp = cStringIO.StringIO() | |||
|
310 | else: | |||
302 | fp = self.opener(fname, 'w') |
|
311 | fp = self.opener(fname, 'w') | |
303 | try: |
|
312 | try: | |
304 | if self.eol and self.eol != '\n': |
|
313 | if self.eol and self.eol != '\n': | |
@@ -308,6 +317,8 b' class patchfile(object):' | |||||
308 | fp.write(l) |
|
317 | fp.write(l) | |
309 | else: |
|
318 | else: | |
310 | fp.writelines(lines) |
|
319 | fp.writelines(lines) | |
|
320 | if islink: | |||
|
321 | self.opener.symlink(fp.getvalue(), fname) | |||
311 | finally: |
|
322 | finally: | |
312 | fp.close() |
|
323 | fp.close() | |
313 |
|
324 | |||
@@ -399,7 +410,7 b' class patchfile(object):' | |||||
399 | self.rej.append(h) |
|
410 | self.rej.append(h) | |
400 | return -1 |
|
411 | return -1 | |
401 |
|
412 | |||
402 |
if isinstance(h, |
|
413 | if isinstance(h, binhunk): | |
403 | if h.rmfile(): |
|
414 | if h.rmfile(): | |
404 | self.unlink(self.fname) |
|
415 | self.unlink(self.fname) | |
405 | else: |
|
416 | else: | |
@@ -665,12 +676,12 b' class hunk(object):' | |||||
665 | def new(self, fuzz=0, toponly=False): |
|
676 | def new(self, fuzz=0, toponly=False): | |
666 | return self.fuzzit(self.b, fuzz, toponly) |
|
677 | return self.fuzzit(self.b, fuzz, toponly) | |
667 |
|
678 | |||
668 |
class |
|
679 | class binhunk: | |
669 | """A git hunk""" |
|
680 | 'A binary patch file. Only understands literals so far.' | |
670 | def __init__(self, gitpatch): |
|
681 | def __init__(self, gitpatch): | |
671 | self.gitpatch = gitpatch |
|
682 | self.gitpatch = gitpatch | |
672 | self.text = None |
|
683 | self.text = None | |
673 | self.hunk = [] |
|
684 | self.hunk = ['GIT binary patch\n'] | |
674 |
|
685 | |||
675 | def createfile(self): |
|
686 | def createfile(self): | |
676 | return self.gitpatch.op in ('ADD', 'RENAME', 'COPY') |
|
687 | return self.gitpatch.op in ('ADD', 'RENAME', 'COPY') | |
@@ -684,12 +695,6 b' class githunk(object):' | |||||
684 | def new(self): |
|
695 | def new(self): | |
685 | return [self.text] |
|
696 | return [self.text] | |
686 |
|
697 | |||
687 | class binhunk(githunk): |
|
|||
688 | 'A binary patch file. Only understands literals so far.' |
|
|||
689 | def __init__(self, gitpatch): |
|
|||
690 | super(binhunk, self).__init__(gitpatch) |
|
|||
691 | self.hunk = ['GIT binary patch\n'] |
|
|||
692 |
|
||||
693 | def extract(self, lr): |
|
698 | def extract(self, lr): | |
694 | line = lr.readline() |
|
699 | line = lr.readline() | |
695 | self.hunk.append(line) |
|
700 | self.hunk.append(line) | |
@@ -717,18 +722,6 b' class binhunk(githunk):' | |||||
717 | len(text), size) |
|
722 | len(text), size) | |
718 | self.text = text |
|
723 | self.text = text | |
719 |
|
724 | |||
720 | class symlinkhunk(githunk): |
|
|||
721 | """A git symlink hunk""" |
|
|||
722 | def __init__(self, gitpatch, hunk): |
|
|||
723 | super(symlinkhunk, self).__init__(gitpatch) |
|
|||
724 | self.hunk = hunk |
|
|||
725 |
|
||||
726 | def complete(self): |
|
|||
727 | return True |
|
|||
728 |
|
||||
729 | def fix_newline(self): |
|
|||
730 | return |
|
|||
731 |
|
||||
732 | def parsefilename(str): |
|
725 | def parsefilename(str): | |
733 | # --- filename \t|space stuff |
|
726 | # --- filename \t|space stuff | |
734 | s = str[4:].rstrip('\r\n') |
|
727 | s = str[4:].rstrip('\r\n') | |
@@ -875,10 +868,6 b' def iterhunks(ui, fp, sourcefile=None, t' | |||||
875 | create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD' |
|
868 | create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD' | |
876 | remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE' |
|
869 | remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE' | |
877 | current_hunk = hunk(x, hunknum + 1, lr, context, create, remove) |
|
870 | current_hunk = hunk(x, hunknum + 1, lr, context, create, remove) | |
878 | if remove: |
|
|||
879 | gpatch = changed.get(afile[2:]) |
|
|||
880 | if gpatch and gpatch.mode[0]: |
|
|||
881 | current_hunk = symlinkhunk(gpatch, current_hunk) |
|
|||
882 | except PatchError, err: |
|
871 | except PatchError, err: | |
883 | ui.debug(err) |
|
872 | ui.debug(err) | |
884 | current_hunk = None |
|
873 | current_hunk = None |
@@ -28,3 +28,7 b" hg glog --template 'branch={branches} {r" | |||||
28 | hg branches | sed 's/:.*/:/' |
|
28 | hg branches | sed 's/:.*/:/' | |
29 | hg tags -q |
|
29 | hg tags -q | |
30 | cd .. |
|
30 | cd .. | |
|
31 | ||||
|
32 | echo '% test hg failing to call itself' | |||
|
33 | HG=foobar hg convert svn-repo B-hg 2>&1 | grep -v foobar | |||
|
34 |
@@ -48,3 +48,6 b' default 10:' | |||||
48 | old 9: |
|
48 | old 9: | |
49 | old2 8: |
|
49 | old2 8: | |
50 | tip |
|
50 | tip | |
|
51 | % test hg failing to call itself | |||
|
52 | initializing destination B-hg repository | |||
|
53 | abort: Mercurial failed to run itself, check hg executable is in PATH |
@@ -8,12 +8,14 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 | echo ccc > c | |
|
14 | hg add a b c | |||
14 | hg qrefresh |
|
15 | hg qrefresh | |
15 | $TESTDIR/readlink.py a |
|
16 | $TESTDIR/readlink.py a | |
16 |
|
17 | |||
|
18 | echo '% test replacing a file with a symlink' | |||
17 | hg qnew symlink.patch |
|
19 | hg qnew symlink.patch | |
18 | rm a |
|
20 | rm a | |
19 | ln -s b a |
|
21 | ln -s b a | |
@@ -24,6 +26,29 b' hg qpop' | |||||
24 | hg qpush |
|
26 | hg qpush | |
25 | $TESTDIR/readlink.py a |
|
27 | $TESTDIR/readlink.py a | |
26 |
|
28 | |||
|
29 | echo '% test updating a symlink' | |||
|
30 | rm a | |||
|
31 | ln -s c a | |||
|
32 | hg qnew --git -f updatelink | |||
|
33 | $TESTDIR/readlink.py a | |||
|
34 | hg qpop | |||
|
35 | hg qpush --debug | |||
|
36 | $TESTDIR/readlink.py a | |||
|
37 | hg st | |||
|
38 | ||||
|
39 | echo '% test replacing a symlink with a file' | |||
|
40 | ln -s c s | |||
|
41 | hg add s | |||
|
42 | hg qnew --git -f addlink | |||
|
43 | rm s | |||
|
44 | echo sss > s | |||
|
45 | hg qnew --git -f replacelinkwithfile | |||
|
46 | hg qpop | |||
|
47 | hg qpush | |||
|
48 | cat s | |||
|
49 | hg st | |||
|
50 | ||||
|
51 | echo '% test symlink removal' | |||
27 | hg qnew removesl.patch |
|
52 | hg qnew removesl.patch | |
28 | hg rm a |
|
53 | hg rm a | |
29 | hg qrefresh --git |
|
54 | hg qrefresh --git |
@@ -1,12 +1,31 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 | popping symlink.patch |
|
4 | popping symlink.patch | |
4 | now at: base.patch |
|
5 | now at: base.patch | |
5 | applying symlink.patch |
|
6 | applying symlink.patch | |
6 | now at: symlink.patch |
|
7 | now at: symlink.patch | |
7 | a -> b |
|
8 | a -> b | |
|
9 | % test updating a symlink | |||
|
10 | a -> c | |||
|
11 | popping updatelink | |||
|
12 | now at: symlink.patch | |||
|
13 | applying updatelink | |||
|
14 | patching file a | |||
|
15 | a | |||
|
16 | now at: updatelink | |||
|
17 | a -> c | |||
|
18 | % test replacing a symlink with a file | |||
|
19 | popping replacelinkwithfile | |||
|
20 | now at: addlink | |||
|
21 | applying replacelinkwithfile | |||
|
22 | now at: replacelinkwithfile | |||
|
23 | sss | |||
|
24 | % test symlink removal | |||
8 | popping removesl.patch |
|
25 | popping removesl.patch | |
9 | now at: symlink.patch |
|
26 | now at: replacelinkwithfile | |
10 | applying removesl.patch |
|
27 | applying removesl.patch | |
11 | now at: removesl.patch |
|
28 | now at: removesl.patch | |
12 | C b |
|
29 | C b | |
|
30 | C c | |||
|
31 | C s |
General Comments 0
You need to be logged in to leave comments.
Login now