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