Show More
@@ -0,0 +1,68 b'' | |||||
|
1 | Create extension that can disable symlink support: | |||
|
2 | ||||
|
3 | $ cat > nolink.py <<EOF | |||
|
4 | > from mercurial import extensions, util | |||
|
5 | > def setflags(orig, f, l, x): | |||
|
6 | > pass | |||
|
7 | > def checklink(orig, path): | |||
|
8 | > return False | |||
|
9 | > def extsetup(ui): | |||
|
10 | > extensions.wrapfunction(util, 'setflags', setflags) | |||
|
11 | > extensions.wrapfunction(util, 'checklink', checklink) | |||
|
12 | > EOF | |||
|
13 | ||||
|
14 | $ hg init unix-repo | |||
|
15 | $ cd unix-repo | |||
|
16 | $ echo foo > a | |||
|
17 | $ ln -s a b | |||
|
18 | $ hg ci -Am0 | |||
|
19 | adding a | |||
|
20 | adding b | |||
|
21 | $ cd .. | |||
|
22 | ||||
|
23 | Simulate a checkout shared on NFS/Samba: | |||
|
24 | ||||
|
25 | $ hg clone -q unix-repo shared | |||
|
26 | $ cd shared | |||
|
27 | $ rm b | |||
|
28 | $ echo foo > b | |||
|
29 | $ hg --config extensions.n=$TESTTMP/nolink.py status --debug | |||
|
30 | ignoring suspect symlink placeholder "b" | |||
|
31 | ||||
|
32 | Make a clone using placeholders: | |||
|
33 | ||||
|
34 | $ hg --config extensions.n=$TESTTMP/nolink.py clone . ../win-repo | |||
|
35 | updating to branch default | |||
|
36 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
37 | $ cd ../win-repo | |||
|
38 | $ cat b | |||
|
39 | a (no-eol) | |||
|
40 | $ hg --config extensions.n=$TESTTMP/nolink.py st --debug | |||
|
41 | ||||
|
42 | Write binary data to the placeholder: | |||
|
43 | ||||
|
44 | >>> open('b', 'w').write('this is a binary\0') | |||
|
45 | $ hg --config extensions.n=$TESTTMP/nolink.py st --debug | |||
|
46 | ignoring suspect symlink placeholder "b" | |||
|
47 | ||||
|
48 | Write a long string to the placeholder: | |||
|
49 | ||||
|
50 | >>> open('b', 'w').write('this' * 1000) | |||
|
51 | $ hg --config extensions.n=$TESTTMP/nolink.py st --debug | |||
|
52 | ignoring suspect symlink placeholder "b" | |||
|
53 | ||||
|
54 | Commit shouldn't succeed: | |||
|
55 | ||||
|
56 | $ hg --config extensions.n=$TESTTMP/nolink.py ci -m1 | |||
|
57 | nothing changed | |||
|
58 | [1] | |||
|
59 | ||||
|
60 | Write a valid string to the placeholder: | |||
|
61 | ||||
|
62 | >>> open('b', 'w').write('this') | |||
|
63 | $ hg --config extensions.n=$TESTTMP/nolink.py st --debug | |||
|
64 | M b | |||
|
65 | $ hg --config extensions.n=$TESTTMP/nolink.py ci -m1 | |||
|
66 | $ hg manifest tip --verbose | |||
|
67 | 644 a | |||
|
68 | 644 @ b |
@@ -1354,6 +1354,22 b' class localrepository(repo.repository):' | |||||
1354 | added.append(fn) |
|
1354 | added.append(fn) | |
1355 | removed = mf1.keys() |
|
1355 | removed = mf1.keys() | |
1356 |
|
1356 | |||
|
1357 | if working and modified and not self.dirstate._checklink: | |||
|
1358 | # Symlink placeholders may get non-symlink-like contents | |||
|
1359 | # via user error or dereferencing by NFS or Samba servers, | |||
|
1360 | # so we filter out any placeholders that don't look like a | |||
|
1361 | # symlink | |||
|
1362 | sane = [] | |||
|
1363 | for f in modified: | |||
|
1364 | if ctx2.flags(f) == 'l': | |||
|
1365 | d = ctx2[f].data() | |||
|
1366 | if len(d) >= 1024 or '\n' in d or util.binary(d): | |||
|
1367 | self.ui.debug('ignoring suspect symlink placeholder' | |||
|
1368 | ' "%s"\n' % f) | |||
|
1369 | continue | |||
|
1370 | sane.append(f) | |||
|
1371 | modified = sane | |||
|
1372 | ||||
1357 | r = modified, added, removed, deleted, unknown, ignored, clean |
|
1373 | r = modified, added, removed, deleted, unknown, ignored, clean | |
1358 |
|
1374 | |||
1359 | if listsubrepos: |
|
1375 | if listsubrepos: |
General Comments 0
You need to be logged in to leave comments.
Login now