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