Mercurial > hgsubversion
annotate svnwrap/tests/test_svnwrap.py @ 69:63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Handle copies of items from revision X into revision Y where X is not the
parent of Y. This cannot happen in Mercurial because copies always happen
between parents and children. A file copy is recorded if:
1- Source and destination revs are in the same branch.
2- The file is unchanged (content, type, removal) through all revisions between
destination and source, not including source and destination.
Directory copies are registered only if the previous rules apply on all copied
items.
[1] is there because file copies across branches are meaningless in Mercurial
world. We could have tried to remap the source rev to a similar one in the
correct branch, but anyway the intent is wrong.
[2] is more questionable but I think it's better this way for we live in a
non-perfect svn world. In theory, 99% of copies out there should come from the
direct parent. But the direct parent is a fuzzy notion when you can have a
working directory composed of different directory at different revisions. So we
assume that stuff copied from past revisions exactly matching the content of
the direct parent revision is really copied from the parent revision. The
alternative would be to discard the copy, which would always happen unless
people kept updating the working directory after every commit (see
tests).
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Wed, 05 Nov 2008 13:37:08 +0100 |
parents | bfbce70a9a57 |
children | 9ad5cf45e30c |
rev | line source |
---|---|
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 import os |
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
|
2 import popen2 |
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 proc = popen2.Popen4(['svnadmin', 'load', self.repo_path,]) |
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 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
|
19 'project_root_at_repo_root.svndump')) |
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
|
20 proc.tochild.write(inp.read()) |
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
|
21 proc.tochild.close() |
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
|
22 proc.wait() |
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 proc = popen2.Popen4(['svnadmin', 'load', self.repo_path,]) |
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 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
|
64 'project_root_not_repo_root.svndump')) |
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
|
65 proc.tochild.write(inp.read()) |
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
|
66 proc.tochild.close() |
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
|
67 proc.wait() |
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) |