| 1 |
import os |
| 2 |
|
| 3 |
from mercurial import ( |
| 4 |
scmutil, |
| 5 |
ui as uimod, |
| 6 |
util, |
| 7 |
) |
| 8 |
from mercurial.repo import factory |
| 9 |
|
| 10 |
chdir = os.chdir |
| 11 |
mkdir = os.mkdir |
| 12 |
pjoin = os.path.join |
| 13 |
|
| 14 |
walkrepos = scmutil.walkrepos |
| 15 |
checklink = util.checklink |
| 16 |
|
| 17 |
u = uimod.ui.load() |
| 18 |
sym = checklink(b'.') |
| 19 |
|
| 20 |
factory.repository(u, b'top1', create=1) |
| 21 |
mkdir(b'subdir') |
| 22 |
chdir(b'subdir') |
| 23 |
factory.repository(u, b'sub1', create=1) |
| 24 |
mkdir(b'subsubdir') |
| 25 |
chdir(b'subsubdir') |
| 26 |
factory.repository(u, b'subsub1', create=1) |
| 27 |
chdir(os.path.pardir) |
| 28 |
if sym: |
| 29 |
os.symlink(os.path.pardir, b'circle') |
| 30 |
os.symlink(pjoin(b'subsubdir', b'subsub1'), b'subsub1') |
| 31 |
|
| 32 |
|
| 33 |
def runtest(): |
| 34 |
reposet = frozenset(walkrepos(b'.', followsym=True)) |
| 35 |
if sym and (len(reposet) != 3): |
| 36 |
print("reposet = %r" % (reposet,)) |
| 37 |
print( |
| 38 |
"Found %d repositories when I should have found 3" % (len(reposet),) |
| 39 |
) |
| 40 |
if (not sym) and (len(reposet) != 2): |
| 41 |
print("reposet = %r" % (reposet,)) |
| 42 |
print( |
| 43 |
"Found %d repositories when I should have found 2" % (len(reposet),) |
| 44 |
) |
| 45 |
sub1set = frozenset( |
| 46 |
(pjoin(b'.', b'sub1'), pjoin(b'.', b'circle', b'subdir', b'sub1')) |
| 47 |
) |
| 48 |
if len(sub1set & reposet) != 1: |
| 49 |
print("sub1set = %r" % (sub1set,)) |
| 50 |
print("reposet = %r" % (reposet,)) |
| 51 |
print("sub1set and reposet should have exactly one path in common.") |
| 52 |
sub2set = frozenset( |
| 53 |
(pjoin(b'.', b'subsub1'), pjoin(b'.', b'subsubdir', b'subsub1')) |
| 54 |
) |
| 55 |
if len(sub2set & reposet) != 1: |
| 56 |
print("sub2set = %r" % (sub2set,)) |
| 57 |
print("reposet = %r" % (reposet,)) |
| 58 |
print("sub2set and reposet should have exactly one path in common.") |
| 59 |
sub3 = pjoin(b'.', b'circle', b'top1') |
| 60 |
if sym and sub3 not in reposet: |
| 61 |
print("reposet = %r" % (reposet,)) |
| 62 |
print("Symbolic links are supported and %s is not in reposet" % (sub3,)) |
| 63 |
|
| 64 |
|
| 65 |
runtest() |
| 66 |
if sym: |
| 67 |
# Simulate not having symlinks. |
| 68 |
del os.path.samestat |
| 69 |
sym = False |
| 70 |
runtest() |