Mercurial > hg
comparison tests/test-walkrepo.py @ 6341:63bdfcc3eaaf
test: Add tests for webdir symlinks and walkrepos.
author | Eric Hopper <hopper@omnifarious.org> |
---|---|
date | Fri, 21 Mar 2008 08:46:15 -0700 |
parents | |
children | b1aea76f7001 |
comparison
equal
deleted
inserted
replaced
6340:949e607ac544 | 6341:63bdfcc3eaaf |
---|---|
1 import os | |
2 import os.path | |
3 from mercurial import hg, ui | |
4 from mercurial.util import walkrepos, set, frozenset | |
5 from os import mkdir, chdir | |
6 from os.path import join as pjoin | |
7 | |
8 u = ui.ui() | |
9 sym = hasattr(os, 'symlink') and hasattr(os.path, 'samestat') | |
10 | |
11 hg.repository(u, 'top1', create=1) | |
12 mkdir('subdir') | |
13 chdir('subdir') | |
14 hg.repository(u, 'sub1', create=1) | |
15 mkdir('subsubdir') | |
16 chdir('subsubdir') | |
17 hg.repository(u, 'subsub1', create=1) | |
18 chdir(os.path.pardir) | |
19 if sym: | |
20 os.symlink(os.path.pardir, 'circle') | |
21 os.symlink(pjoin('subsubdir', 'subsub1'), 'subsub1') | |
22 | |
23 def runtest(): | |
24 reposet = frozenset(walkrepos('.', followsym=True)) | |
25 if sym and (len(reposet) != 3): | |
26 print "reposet = %r" % (reposet,) | |
27 raise SystemExit(1, "Found %d repositories when I should have found 3" % (len(reposet),)) | |
28 if (not sym) and (len(reposet) != 2): | |
29 print "reposet = %r" % (reposet,) | |
30 raise SystemExit(1, "Found %d repositories when I should have found 2" % (len(reposet),)) | |
31 sub1set = frozenset((pjoin('.', 'sub1'), | |
32 pjoin('.', 'circle', 'subdir', 'sub1'))) | |
33 if len(sub1set & reposet) != 1: | |
34 print "sub1set = %r" % (sub1set,) | |
35 print "reposet = %r" % (reposet,) | |
36 raise SystemExit(1, "sub1set and reposet should have exactly one path in common.") | |
37 sub2set = frozenset((pjoin('.', 'subsub1'), | |
38 pjoin('.', 'subsubdir', 'subsub1'))) | |
39 if len(sub2set & reposet) != 1: | |
40 print "sub2set = %r" % (sub2set,) | |
41 print "reposet = %r" % (reposet,) | |
42 raise SystemExit(1, "sub1set and reposet should have exactly one path in common.") | |
43 sub3 = pjoin('.', 'circle', 'top1') | |
44 if sym and not (sub3 in reposet): | |
45 print "reposet = %r" % (reposet,) | |
46 raise SystemExit(1, "Symbolic links are supported and %s is not in reposet" % (sub3,)) | |
47 | |
48 runtest() | |
49 if sym: | |
50 # Simulate not having symlinks. | |
51 del os.path.samestat | |
52 sym = False | |
53 runtest() |