Mercurial > hgsubversion
annotate svnwrap/tests/test_svnwrap.py @ 323:067914ecb4eb
push: Fix a bug in deletion of an entire tree.
This bug meant that if an entire subtree of the repo was
deleted and there were files at varying levels of the
hierarchy, then some of the files at higher levels
might escape deletion when the revision was pushed to svn.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Fri, 08 May 2009 16:26:33 -0500 |
parents | 9ad5cf45e30c |
children | 4f4db3d2fdbb |
rev | line source |
---|---|
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 import os |
309
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
2 import subprocess |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import shutil |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 import tempfile |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 import unittest |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 from nose import tools |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
8 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 import svnwrap |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 class TestBasicRepoLayout(unittest.TestCase): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 def setUp(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 self.tmpdir = tempfile.mkdtemp('svnwrap_test') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 self.repo_path = '%s/testrepo' % self.tmpdir |
26
bfbce70a9a57
Reworked the svnwrap tests to use the same fixture system as I created for the hgsubversion tests since it is much much faster.
Augie Fackler <durin42@gmail.com>
parents:
7
diff
changeset
|
15 os.spawnvp(os.P_WAIT, 'svnadmin', ['svnadmin', 'create', |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 self.repo_path,]) |
26
bfbce70a9a57
Reworked the svnwrap tests to use the same fixture system as I created for the hgsubversion tests since it is much much faster.
Augie Fackler <durin42@gmail.com>
parents:
7
diff
changeset
|
17 inp = open(os.path.join(os.path.dirname(__file__), 'fixtures', |
bfbce70a9a57
Reworked the svnwrap tests to use the same fixture system as I created for the hgsubversion tests since it is much much faster.
Augie Fackler <durin42@gmail.com>
parents:
7
diff
changeset
|
18 'project_root_at_repo_root.svndump')) |
309
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
19 proc = subprocess.check_call(['svnadmin', 'load', self.repo_path,], |
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
20 stdin=inp, close_fds=True, |
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
21 stdout=subprocess.PIPE, |
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
22 stderr=subprocess.STDOUT) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
23 self.repo = svnwrap.SubversionRepo('file://%s' % self.repo_path) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 def tearDown(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 shutil.rmtree(self.tmpdir) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 def test_num_revs(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 revs = list(self.repo.revisions()) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 tools.eq_(len(revs), 7) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 r = revs[1] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 tools.eq_(r.revnum, 2) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 tools.eq_(sorted(r.paths.keys()), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 ['trunk/alpha', 'trunk/beta', 'trunk/delta']) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 for r in revs: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 for p in r.paths: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 # make sure these paths are always non-absolute for sanity |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 if p: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 assert p[0] != '/' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 revs = list(self.repo.revisions(start=3)) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 tools.eq_(len(revs), 4) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 def test_branches(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 tools.eq_(self.repo.branches.keys(), ['crazy', 'more_crazy']) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 tools.eq_(self.repo.branches['crazy'], ('trunk', 2, 4)) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 tools.eq_(self.repo.branches['more_crazy'], ('trunk', 5, 7)) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 def test_tags(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 tags = self.repo.tags |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 tools.eq_(tags.keys(), ['rev1']) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 tools.eq_(tags['rev1'], ('trunk', 2)) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 class TestRootAsSubdirOfRepo(TestBasicRepoLayout): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 def setUp(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 self.tmpdir = tempfile.mkdtemp('svnwrap_test') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 self.repo_path = '%s/testrepo' % self.tmpdir |
26
bfbce70a9a57
Reworked the svnwrap tests to use the same fixture system as I created for the hgsubversion tests since it is much much faster.
Augie Fackler <durin42@gmail.com>
parents:
7
diff
changeset
|
60 os.spawnvp(os.P_WAIT, 'svnadmin', ['svnadmin', 'create', |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
61 self.repo_path,]) |
26
bfbce70a9a57
Reworked the svnwrap tests to use the same fixture system as I created for the hgsubversion tests since it is much much faster.
Augie Fackler <durin42@gmail.com>
parents:
7
diff
changeset
|
62 inp = open(os.path.join(os.path.dirname(__file__), 'fixtures', |
bfbce70a9a57
Reworked the svnwrap tests to use the same fixture system as I created for the hgsubversion tests since it is much much faster.
Augie Fackler <durin42@gmail.com>
parents:
7
diff
changeset
|
63 'project_root_not_repo_root.svndump')) |
309
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
64 subprocess.check_call(['svnadmin', 'load', self.repo_path,], |
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
65 stdin=inp, close_fds=True, |
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
66 stdout=subprocess.PIPE, |
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
67 stderr=subprocess.STDOUT) |
26
bfbce70a9a57
Reworked the svnwrap tests to use the same fixture system as I created for the hgsubversion tests since it is much much faster.
Augie Fackler <durin42@gmail.com>
parents:
7
diff
changeset
|
68 self.repo = svnwrap.SubversionRepo('file://%s/dummyproj' % |
bfbce70a9a57
Reworked the svnwrap tests to use the same fixture system as I created for the hgsubversion tests since it is much much faster.
Augie Fackler <durin42@gmail.com>
parents:
7
diff
changeset
|
69 self.repo_path) |