##// END OF EJS Templates
tests: alias ui as uimod in test-walkrepo
Yuya Nishihara -
r28777:778d947f default
parent child Browse files
Show More
@@ -1,66 +1,66 b''
1 from __future__ import absolute_import, print_function
1 from __future__ import absolute_import, print_function
2
2
3 import os
3 import os
4
4
5 from mercurial import (
5 from mercurial import (
6 hg,
6 hg,
7 scmutil,
7 scmutil,
8 ui,
8 ui as uimod,
9 util,
9 util,
10 )
10 )
11
11
12 chdir = os.chdir
12 chdir = os.chdir
13 mkdir = os.mkdir
13 mkdir = os.mkdir
14 pjoin = os.path.join
14 pjoin = os.path.join
15
15
16 walkrepos = scmutil.walkrepos
16 walkrepos = scmutil.walkrepos
17 checklink = util.checklink
17 checklink = util.checklink
18
18
19 u = ui.ui()
19 u = uimod.ui()
20 sym = checklink('.')
20 sym = checklink('.')
21
21
22 hg.repository(u, 'top1', create=1)
22 hg.repository(u, 'top1', create=1)
23 mkdir('subdir')
23 mkdir('subdir')
24 chdir('subdir')
24 chdir('subdir')
25 hg.repository(u, 'sub1', create=1)
25 hg.repository(u, 'sub1', create=1)
26 mkdir('subsubdir')
26 mkdir('subsubdir')
27 chdir('subsubdir')
27 chdir('subsubdir')
28 hg.repository(u, 'subsub1', create=1)
28 hg.repository(u, 'subsub1', create=1)
29 chdir(os.path.pardir)
29 chdir(os.path.pardir)
30 if sym:
30 if sym:
31 os.symlink(os.path.pardir, 'circle')
31 os.symlink(os.path.pardir, 'circle')
32 os.symlink(pjoin('subsubdir', 'subsub1'), 'subsub1')
32 os.symlink(pjoin('subsubdir', 'subsub1'), 'subsub1')
33
33
34 def runtest():
34 def runtest():
35 reposet = frozenset(walkrepos('.', followsym=True))
35 reposet = frozenset(walkrepos('.', followsym=True))
36 if sym and (len(reposet) != 3):
36 if sym and (len(reposet) != 3):
37 print("reposet = %r" % (reposet,))
37 print("reposet = %r" % (reposet,))
38 print(("Found %d repositories when I should have found 3"
38 print(("Found %d repositories when I should have found 3"
39 % (len(reposet),)))
39 % (len(reposet),)))
40 if (not sym) and (len(reposet) != 2):
40 if (not sym) and (len(reposet) != 2):
41 print("reposet = %r" % (reposet,))
41 print("reposet = %r" % (reposet,))
42 print(("Found %d repositories when I should have found 2"
42 print(("Found %d repositories when I should have found 2"
43 % (len(reposet),)))
43 % (len(reposet),)))
44 sub1set = frozenset((pjoin('.', 'sub1'),
44 sub1set = frozenset((pjoin('.', 'sub1'),
45 pjoin('.', 'circle', 'subdir', 'sub1')))
45 pjoin('.', 'circle', 'subdir', 'sub1')))
46 if len(sub1set & reposet) != 1:
46 if len(sub1set & reposet) != 1:
47 print("sub1set = %r" % (sub1set,))
47 print("sub1set = %r" % (sub1set,))
48 print("reposet = %r" % (reposet,))
48 print("reposet = %r" % (reposet,))
49 print("sub1set and reposet should have exactly one path in common.")
49 print("sub1set and reposet should have exactly one path in common.")
50 sub2set = frozenset((pjoin('.', 'subsub1'),
50 sub2set = frozenset((pjoin('.', 'subsub1'),
51 pjoin('.', 'subsubdir', 'subsub1')))
51 pjoin('.', 'subsubdir', 'subsub1')))
52 if len(sub2set & reposet) != 1:
52 if len(sub2set & reposet) != 1:
53 print("sub2set = %r" % (sub2set,))
53 print("sub2set = %r" % (sub2set,))
54 print("reposet = %r" % (reposet,))
54 print("reposet = %r" % (reposet,))
55 print("sub2set and reposet should have exactly one path in common.")
55 print("sub2set and reposet should have exactly one path in common.")
56 sub3 = pjoin('.', 'circle', 'top1')
56 sub3 = pjoin('.', 'circle', 'top1')
57 if sym and sub3 not in reposet:
57 if sym and sub3 not in reposet:
58 print("reposet = %r" % (reposet,))
58 print("reposet = %r" % (reposet,))
59 print("Symbolic links are supported and %s is not in reposet" % (sub3,))
59 print("Symbolic links are supported and %s is not in reposet" % (sub3,))
60
60
61 runtest()
61 runtest()
62 if sym:
62 if sym:
63 # Simulate not having symlinks.
63 # Simulate not having symlinks.
64 del os.path.samestat
64 del os.path.samestat
65 sym = False
65 sym = False
66 runtest()
66 runtest()
General Comments 0
You need to be logged in to leave comments. Login now