Show More
@@ -301,7 +301,14 b' class patchfile(object):' | |||
|
301 | 301 | fp.close() |
|
302 | 302 | |
|
303 | 303 | def writelines(self, fname, lines): |
|
304 | fp = self.opener(fname, 'w') | |
|
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: | |
|
311 | fp = self.opener(fname, 'w') | |
|
305 | 312 | try: |
|
306 | 313 | if self.eol and self.eol != '\n': |
|
307 | 314 | for l in lines: |
@@ -310,6 +317,8 b' class patchfile(object):' | |||
|
310 | 317 | fp.write(l) |
|
311 | 318 | else: |
|
312 | 319 | fp.writelines(lines) |
|
320 | if islink: | |
|
321 | self.opener.symlink(fp.getvalue(), fname) | |
|
313 | 322 | finally: |
|
314 | 323 | fp.close() |
|
315 | 324 |
@@ -10,7 +10,8 b' hg qinit' | |||
|
10 | 10 | hg qnew base.patch |
|
11 | 11 | echo aaa > a |
|
12 | 12 | echo bbb > b |
|
13 | hg add a b | |
|
13 | echo ccc > c | |
|
14 | hg add a b c | |
|
14 | 15 | hg qrefresh |
|
15 | 16 | $TESTDIR/readlink.py a |
|
16 | 17 | |
@@ -25,6 +26,28 b' hg qpop' | |||
|
25 | 26 | hg qpush |
|
26 | 27 | $TESTDIR/readlink.py a |
|
27 | 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 | ||
|
28 | 51 | echo '% test symlink removal' |
|
29 | 52 | hg qnew removesl.patch |
|
30 | 53 | hg rm a |
@@ -5,8 +5,23 b' now at: base.patch' | |||
|
5 | 5 | applying symlink.patch |
|
6 | 6 | now at: symlink.patch |
|
7 | 7 | a -> b |
|
8 | % test updating a symlink | |
|
9 | a -> c | |
|
10 | now at: symlink.patch | |
|
11 | applying updatelink | |
|
12 | patching file a | |
|
13 | a | |
|
14 | now at: updatelink | |
|
15 | a -> c | |
|
16 | % test replacing a symlink with a file | |
|
17 | now at: addlink | |
|
18 | applying replacelinkwithfile | |
|
19 | now at: replacelinkwithfile | |
|
20 | sss | |
|
8 | 21 | % test symlink removal |
|
9 | now at: symlink.patch | |
|
22 | now at: replacelinkwithfile | |
|
10 | 23 | applying removesl.patch |
|
11 | 24 | now at: removesl.patch |
|
12 | 25 | C b |
|
26 | C c | |
|
27 | C s |
General Comments 0
You need to be logged in to leave comments.
Login now