Mercurial > hgsubversion
annotate tests/test_rebuildmeta.py @ 225:2117cb0118fe
Get rid of .hg/svn/last_rev:
We now calculate the last known revision by iterating over all known
revisions and finding the highest number. Theoretically, we might be
able to simply read the latest entry, but in practice, that's a bug
waiting to happen. For instance, we might want to achieve
compatibility with '.hg/shamap' as generated by the
ConvertExtension, and it not only cannot offer a guarantee of
linearity, but it also allows more than one conversion to source exists.
I'd say we have other problems to care about until this turns up as a
hotspot in profiling. Such as why we leak circa 100MB of memory per
1000 revisions converted ;)
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 27 Mar 2009 01:09:36 +0100 |
parents | 496ff87e2532 |
children | 074f27c68818 |
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 def _do_case(self, name, stupid): |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
182
diff
changeset
|
13 subdir = test_util.subdir.get(name, '') |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
182
diff
changeset
|
14 self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid) |
155
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 assert len(self.repo) > 0 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 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
|
17 u = ui.ui() |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 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
|
19 rebuildmeta.rebuildmeta(u, |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 dest, |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 os.path.dirname(dest.path), |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 args=[test_util.fileurl(self.repo_path + |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
182
diff
changeset
|
23 subdir), ]) |
155
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 'tag_info'))), |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 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
|
31 'tag_info')))) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 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
|
33 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
|
34 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
|
35 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
|
36 for branch in destbi: |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 srcinfo = srcbi[branch] |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 destinfo = destbi[branch] |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 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
|
40 repo=dest, |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 ui_=u) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 if destinfo[:2] == (None, 0): |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 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
|
44 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
|
45 else: |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 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
|
47 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
|
48 self.assertEqual(pr, destinfo[1]) |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 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
|
50 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 def buildmethod(case, name, stupid): |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 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
|
54 m.__name__ = name |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 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
|
56 (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
|
57 return m |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 attrs = {'_do_case': _do_case, |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
61 } |
182
47d25d61abfa
remove generators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
155
diff
changeset
|
62 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
|
63 name = 'test_' + case[:-len('.svndump')] |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
64 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
|
65 name += '_stupid' |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
66 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
|
67 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
|
68 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
69 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
70 def suite(): |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
71 all = [unittest.TestLoader().loadTestsFromTestCase(RebuildMetaTests), |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
72 ] |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
73 return unittest.TestSuite(all) |