Mercurial > hg
comparison tests/test-walkrepo.py @ 37878:fa2423acb02f
tests: port test-walkrepo.py to Python 3
# skip-blame just b prefixes, nothing interesting
Differential Revision: https://phab.mercurial-scm.org/D3473
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 27 Apr 2018 00:17:17 -0400 |
parents | d83ca854fa21 |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
37877:2cdae2582d8a | 37878:fa2423acb02f |
---|---|
15 | 15 |
16 walkrepos = scmutil.walkrepos | 16 walkrepos = scmutil.walkrepos |
17 checklink = util.checklink | 17 checklink = util.checklink |
18 | 18 |
19 u = uimod.ui.load() | 19 u = uimod.ui.load() |
20 sym = checklink('.') | 20 sym = checklink(b'.') |
21 | 21 |
22 hg.repository(u, 'top1', create=1) | 22 hg.repository(u, b'top1', create=1) |
23 mkdir('subdir') | 23 mkdir(b'subdir') |
24 chdir('subdir') | 24 chdir(b'subdir') |
25 hg.repository(u, 'sub1', create=1) | 25 hg.repository(u, b'sub1', create=1) |
26 mkdir('subsubdir') | 26 mkdir(b'subsubdir') |
27 chdir('subsubdir') | 27 chdir(b'subsubdir') |
28 hg.repository(u, 'subsub1', create=1) | 28 hg.repository(u, b'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, b'circle') |
32 os.symlink(pjoin('subsubdir', 'subsub1'), 'subsub1') | 32 os.symlink(pjoin(b'subsubdir', b'subsub1'), b'subsub1') |
33 | 33 |
34 def runtest(): | 34 def runtest(): |
35 reposet = frozenset(walkrepos('.', followsym=True)) | 35 reposet = frozenset(walkrepos(b'.', 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(b'.', b'sub1'), |
45 pjoin('.', 'circle', 'subdir', 'sub1'))) | 45 pjoin(b'.', b'circle', b'subdir', b'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(b'.', b'subsub1'), |
51 pjoin('.', 'subsubdir', 'subsub1'))) | 51 pjoin(b'.', b'subsubdir', b'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(b'.', b'circle', b'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() |