Show More
@@ -1,52 +1,53 b'' | |||||
1 | import os |
|
1 | import os | |
2 | from mercurial import hg, ui |
|
2 | from mercurial import hg, ui | |
3 | from mercurial.scmutil import walkrepos |
|
3 | from mercurial.scmutil import walkrepos | |
|
4 | from mercurial.util import checklink | |||
4 | from os import mkdir, chdir |
|
5 | from os import mkdir, chdir | |
5 | from os.path import join as pjoin |
|
6 | from os.path import join as pjoin | |
6 |
|
7 | |||
7 | u = ui.ui() |
|
8 | u = ui.ui() | |
8 | sym = getattr(os, 'symlink', False) and getattr(os.path, 'samestat', False) |
|
9 | sym = checklink('.') | |
9 |
|
10 | |||
10 | hg.repository(u, 'top1', create=1) |
|
11 | hg.repository(u, 'top1', create=1) | |
11 | mkdir('subdir') |
|
12 | mkdir('subdir') | |
12 | chdir('subdir') |
|
13 | chdir('subdir') | |
13 | hg.repository(u, 'sub1', create=1) |
|
14 | hg.repository(u, 'sub1', create=1) | |
14 | mkdir('subsubdir') |
|
15 | mkdir('subsubdir') | |
15 | chdir('subsubdir') |
|
16 | chdir('subsubdir') | |
16 | hg.repository(u, 'subsub1', create=1) |
|
17 | hg.repository(u, 'subsub1', create=1) | |
17 | chdir(os.path.pardir) |
|
18 | chdir(os.path.pardir) | |
18 | if sym: |
|
19 | if sym: | |
19 | os.symlink(os.path.pardir, 'circle') |
|
20 | os.symlink(os.path.pardir, 'circle') | |
20 | os.symlink(pjoin('subsubdir', 'subsub1'), 'subsub1') |
|
21 | os.symlink(pjoin('subsubdir', 'subsub1'), 'subsub1') | |
21 |
|
22 | |||
22 | def runtest(): |
|
23 | def runtest(): | |
23 | reposet = frozenset(walkrepos('.', followsym=True)) |
|
24 | reposet = frozenset(walkrepos('.', followsym=True)) | |
24 | if sym and (len(reposet) != 3): |
|
25 | if sym and (len(reposet) != 3): | |
25 | print "reposet = %r" % (reposet,) |
|
26 | print "reposet = %r" % (reposet,) | |
26 | print "Found %d repositories when I should have found 3" % (len(reposet),) |
|
27 | print "Found %d repositories when I should have found 3" % (len(reposet),) | |
27 | if (not sym) and (len(reposet) != 2): |
|
28 | if (not sym) and (len(reposet) != 2): | |
28 | print "reposet = %r" % (reposet,) |
|
29 | print "reposet = %r" % (reposet,) | |
29 | print "Found %d repositories when I should have found 2" % (len(reposet),) |
|
30 | print "Found %d repositories when I should have found 2" % (len(reposet),) | |
30 | sub1set = frozenset((pjoin('.', 'sub1'), |
|
31 | sub1set = frozenset((pjoin('.', 'sub1'), | |
31 | pjoin('.', 'circle', 'subdir', 'sub1'))) |
|
32 | pjoin('.', 'circle', 'subdir', 'sub1'))) | |
32 | if len(sub1set & reposet) != 1: |
|
33 | if len(sub1set & reposet) != 1: | |
33 | print "sub1set = %r" % (sub1set,) |
|
34 | print "sub1set = %r" % (sub1set,) | |
34 | print "reposet = %r" % (reposet,) |
|
35 | print "reposet = %r" % (reposet,) | |
35 | print "sub1set and reposet should have exactly one path in common." |
|
36 | print "sub1set and reposet should have exactly one path in common." | |
36 | sub2set = frozenset((pjoin('.', 'subsub1'), |
|
37 | sub2set = frozenset((pjoin('.', 'subsub1'), | |
37 | pjoin('.', 'subsubdir', 'subsub1'))) |
|
38 | pjoin('.', 'subsubdir', 'subsub1'))) | |
38 | if len(sub2set & reposet) != 1: |
|
39 | if len(sub2set & reposet) != 1: | |
39 | print "sub2set = %r" % (sub2set,) |
|
40 | print "sub2set = %r" % (sub2set,) | |
40 | print "reposet = %r" % (reposet,) |
|
41 | print "reposet = %r" % (reposet,) | |
41 | print "sub1set and reposet should have exactly one path in common." |
|
42 | print "sub1set and reposet should have exactly one path in common." | |
42 | sub3 = pjoin('.', 'circle', 'top1') |
|
43 | sub3 = pjoin('.', 'circle', 'top1') | |
43 | if sym and not (sub3 in reposet): |
|
44 | if sym and not (sub3 in reposet): | |
44 | print "reposet = %r" % (reposet,) |
|
45 | print "reposet = %r" % (reposet,) | |
45 | print "Symbolic links are supported and %s is not in reposet" % (sub3,) |
|
46 | print "Symbolic links are supported and %s is not in reposet" % (sub3,) | |
46 |
|
47 | |||
47 | runtest() |
|
48 | runtest() | |
48 | if sym: |
|
49 | if sym: | |
49 | # Simulate not having symlinks. |
|
50 | # Simulate not having symlinks. | |
50 | del os.path.samestat |
|
51 | del os.path.samestat | |
51 | sym = False |
|
52 | sym = False | |
52 | runtest() |
|
53 | runtest() |
General Comments 0
You need to be logged in to leave comments.
Login now