Mercurial > hgsubversion
annotate tests/test_revmap_migrate.py @ 1489:9a6bb3657861
Merge with stable.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sun, 26 Jun 2016 21:10:36 -0400 |
parents | 623af04c6e06 |
children | 8937f19586fe |
rev | line source |
---|---|
1473
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
1 import test_util |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
2 |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
3 from mercurial import util as hgutil |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
4 from hgsubversion import svnmeta, maps |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
5 from mercurial.node import hex |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
6 |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
7 class TestRevMapMigrate(test_util.TestBase): |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
8 |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
9 def _test_revmap_migrate(self, fromclass, toclass): |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
10 # revmap interfaces to test |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
11 getters = [ |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
12 lambda x: x.branchedits('the_branch', 3), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
13 lambda x: x.branchedits('the_branch', 4), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
14 lambda x: x.branchedits('the_branch', 5), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
15 lambda x: x.branchedits('the_branch', 6), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
16 lambda x: x.branchedits(None, 5), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
17 lambda x: x.branchedits('non_existed', 10), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
18 lambda x: x.branchmaxrevnum('the_branch', 3), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
19 lambda x: x.branchmaxrevnum('the_branch', 4), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
20 lambda x: x.branchmaxrevnum('the_branch', 5), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
21 lambda x: x.branchmaxrevnum('the_branch', 6), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
22 lambda x: x.branchmaxrevnum(None, 5), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
23 lambda x: x.branchmaxrevnum('non_existed', 10), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
24 lambda x: list(x.revhashes(3)), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
25 lambda x: list(x.revhashes(4)), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
26 lambda x: list(x.revhashes(42)), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
27 lambda x: list(x.revhashes(105)), |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
28 lambda x: x.firstpulled, |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
29 lambda x: x.lastpulled, |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
30 lambda x: x.lasthash, |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
31 ] |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
32 |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
33 svnmeta.SVNMeta._defaultrevmapclass = fromclass |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
34 repo = self._load_fixture_and_fetch('two_heads.svndump') |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
35 meta = svnmeta.SVNMeta(repo) |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
36 self.assertEqual(meta.revmap.__class__, fromclass) |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
37 origrevmap = meta.revmap |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
38 |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
39 # insert fake special (duplicated, with '\0') data |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
40 origrevmap[103, None] = b'\0' * 20 |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
41 origrevmap[104, None] = b'\0' * 18 + b'cd' |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
42 origrevmap[105, None] = b'ab\0cdefghijklmnopqrs' |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
43 origrevmap[104, None] = b'\0' * 18 + b'\xff\0' |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
44 origrevmap[105, 'ab'] = origrevmap[105, None] |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
45 |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
46 origvalues = [f(meta.revmap) for f in getters] |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
47 |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
48 # migrate to another format (transparently) |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
49 svnmeta.SVNMeta._defaultrevmapclass = toclass |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
50 meta = svnmeta.SVNMeta(repo) |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
51 self.assertEqual(meta.revmap.__class__, toclass) |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
52 |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
53 # enable iteration otherwise we cannot use iteritems |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
54 origrevmap._allowiter = True |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
55 for k, v in origrevmap.iteritems(): |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
56 newv = meta.revmap[k] |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
57 self.assertEqual(newv, v) |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
58 self.assertEqual(len(newv), 20) |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
59 self.assertEqual(meta.revmap[meta.revmap.hashes()[v]], v) |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
60 |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
61 newvalues = [f(meta.revmap) for f in getters] |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
62 self.assertEqual(origvalues, newvalues) |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
63 |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
64 def test_revmap_migrate_up(self): |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
65 self._test_revmap_migrate(maps.RevMap, maps.SqliteRevMap) |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
66 |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
67 def test_revmap_migrate_down(self): |
623af04c6e06
tests: new test about revmap two-way migrations
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
68 self._test_revmap_migrate(maps.SqliteRevMap, maps.RevMap) |