Mercurial > hgsubversion
annotate tests/test_rebuildmeta.py @ 186:6266ba36ee15
Create patch to make normal output much less verboseā¦
author | Dan Villiom Podlaski Christiansen <danchr@cs.au.dk> |
---|---|
date | Sat, 17 Jan 2009 15:30:38 -0600 |
parents | 47d25d61abfa |
children | 13ae1bded5e7 |
rev | line source |
---|---|
155
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 import os |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 import pickle |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import unittest |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 from mercurial import hg |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 from mercurial import ui |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
8 import test_util |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 import rebuildmeta |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 import hg_delta_editor |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 subdir = {'truncatedhistory.svndump': '/project2', |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 'fetch_missing_files_subdir.svndump': '/foo', |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 } |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 # List of expected "missing" branches - these are really files that happen |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 # to be in the branches dir. This will be fixed at a later date. |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 expected_branch_deltas = {'unrelatedbranch.svndump': ['c', ], |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 'file_mixed_with_branches.svndump': ['README', ], |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 } |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 def _do_case(self, name, stupid): |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 self._load_fixture_and_fetch(name, subdir=subdir.get(name, ''), stupid=stupid) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
23 assert len(self.repo) > 0 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 wc2_path = self.wc_path + '_clone' |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 u = ui.ui() |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 src, dest = hg.clone(u, self.wc_path, wc2_path, update=False) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 rebuildmeta.rebuildmeta(u, |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 dest, |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 os.path.dirname(dest.path), |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 args=[test_util.fileurl(self.repo_path + |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 subdir.get(name, '')), ]) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 dest = hg.repository(u, os.path.dirname(dest.path)) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 self.assert_(open(os.path.join(src.path, 'svn', 'last_rev')).read() >= |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 open(os.path.join(dest.path, 'svn', 'last_rev')).read()) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 for tf in ('rev_map', 'uuid', 'url'): |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 self.assertEqual(open(os.path.join(src.path, 'svn', tf)).read(), |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 open(os.path.join(dest.path, 'svn', tf)).read()) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 self.assertEqual(pickle.load(open(os.path.join(src.path, 'svn', |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 'tag_info'))), |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 pickle.load(open(os.path.join(dest.path, 'svn', |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 'tag_info')))) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 self.assertEqual(src.branchtags(), dest.branchtags()) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 srcbi = pickle.load(open(os.path.join(src.path, 'svn', 'branch_info'))) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 for mustpop in expected_branch_deltas.get(name, []): |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 del srcbi[mustpop] |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 destbi = pickle.load(open(os.path.join(dest.path, 'svn', 'branch_info'))) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 self.assertEqual(sorted(srcbi.keys()), sorted(destbi.keys())) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 for branch in destbi: |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 srcinfo = srcbi[branch] |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 destinfo = destbi[branch] |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 hge = hg_delta_editor.HgChangeReceiver(path=os.path.dirname(dest.path), |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 repo=dest, |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 ui_=u) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 if destinfo[:2] == (None, 0): |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 self.assert_(srcinfo[2] <= destinfo[2]) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 self.assertEqual(srcinfo[0], destinfo[0]) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 else: |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 pr = sorted(filter(lambda x: x[1] == srcinfo[0] and x[0] <= srcinfo[1], |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 hge.revmap.keys()), reverse=True)[0][0] |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 self.assertEqual(pr, destinfo[1]) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
61 self.assertEqual(srcinfo[2], destinfo[2]) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
62 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
63 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
64 def buildmethod(case, name, stupid): |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
65 m = lambda self: self._do_case(case, stupid) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
66 m.__name__ = name |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
67 m.__doc__ = ('Test rebuildmeta on %s with %s replay.' % |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
68 (case, (stupid and 'stupid') or 'real')) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
69 return m |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
70 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
71 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
72 attrs = {'_do_case': _do_case, |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
73 } |
182
47d25d61abfa
remove generators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
155
diff
changeset
|
74 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]: |
155
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
75 name = 'test_' + case[:-len('.svndump')] |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
76 attrs[name] = buildmethod(case, name, False) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
77 name += '_stupid' |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
78 attrs[name] = buildmethod(case, name, True) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
79 RebuildMetaTests = type('RebuildMetaTests', (test_util.TestBase, ), attrs) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
80 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
81 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
82 def suite(): |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
83 all = [unittest.TestLoader().loadTestsFromTestCase(RebuildMetaTests), |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
84 ] |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
85 return unittest.TestSuite(all) |