Mercurial > hgsubversion
annotate tests/test_unaffected_core.py @ 890:78db88de9622
Partial metadata rebuilding
For highly active subversion repositories, it can be excruciatingly
slow to pull updates one at a time from subversion. One way around
this is to setup another mercurial repo that pulls new commits from
svn periodicly (say every 5 minutes). When you want to update your
repository, you can pull commits from this mercurial repository via
native mercurial protocols, which will be much faster than pulling
directly from svn.
Unfortunately, your metadata will be out of date after doing so.
Highly active repositories also tend to be very large, which means
that it takes a long time to rebuild your metadata from scratch. To
address this, this adds support to do a partial rebuild on the
metadata by processing only revisions that have been added to the
repository after the last revision we processed.
With the rev map 1k revisions (~2 days) behind tip updatemeta is
dramatically faster than rebuild meta:
$ hg --time svn updatemeta
Time: real 0.570 secs (user 0.480+0.000 sys 0.060+0.000)
$ hg --time svn rebuildmeta
Time: real 129.160 secs (user 128.570+0.000 sys 0.320+0.000)
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Sat, 12 May 2012 07:28:23 -0700 |
parents | 312b37bc5e20 |
children | d741f536f23a |
rev | line source |
---|---|
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
1 import test_util |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
2 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
3 import os |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
4 import unittest |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
5 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
6 from mercurial import commands |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
7 from mercurial import dispatch |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
8 from mercurial import error |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
9 from mercurial import hg |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
10 from mercurial import node |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
11 from mercurial import ui |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
12 |
813
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
13 def _dispatch(ui, cmd): |
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
14 try: |
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
15 req = dispatch.request(cmd, ui=ui) |
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
16 dispatch._dispatch(req) |
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
17 except AttributeError: |
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
18 dispatch._dispatch(ui, cmd) |
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
19 |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
20 class TestMercurialCore(test_util.TestBase): |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
21 ''' |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
22 Test that the core Mercurial operations aren't broken by hgsubversion. |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
23 ''' |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
24 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
25 @test_util.requiresoption('updaterev') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
26 def test_update(self): |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
27 ''' Test 'clone --updaterev' ''' |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
28 ui = self.ui() |
813
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
29 _dispatch(ui, ['init', self.wc_path]) |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
30 repo = self.repo |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
31 repo.ui.setconfig('ui', 'username', 'anonymous') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
32 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
33 fpath = os.path.join(self.wc_path, 'it') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
34 f = file(fpath, 'w') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
35 f.write('C1') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
36 f.flush() |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
37 commands.add(ui, repo) |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
38 commands.commit(ui, repo, message="C1") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
39 f.write('C2') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
40 f.flush() |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
41 commands.commit(ui, repo, message="C2") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
42 f.write('C3') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
43 f.flush() |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
44 commands.commit(ui, repo, message="C3") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
45 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
46 self.assertEqual(len(repo), 3) |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
47 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
48 updaterev = 1 |
813
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
49 _dispatch(ui, ['clone', self.wc_path, self.wc_path + '2', |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
50 '--updaterev=%s' % updaterev]) |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
51 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
52 repo2 = hg.repository(ui, self.wc_path + '2') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
53 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
54 self.assertEqual(str(repo[updaterev]), str(repo2['.'])) |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
55 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
56 @test_util.requiresoption('branch') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
57 def test_branch(self): |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
58 ''' Test 'clone --branch' ''' |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
59 ui = self.ui() |
813
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
60 _dispatch(ui, ['init', self.wc_path]) |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
61 repo = self.repo |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
62 repo.ui.setconfig('ui', 'username', 'anonymous') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
63 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
64 fpath = os.path.join(self.wc_path, 'it') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
65 f = file(fpath, 'w') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
66 f.write('C1') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
67 f.flush() |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
68 commands.add(ui, repo) |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
69 commands.branch(ui, repo, label="B1") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
70 commands.commit(ui, repo, message="C1") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
71 f.write('C2') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
72 f.flush() |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
73 commands.branch(ui, repo, label="default") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
74 commands.commit(ui, repo, message="C2") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
75 f.write('C3') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
76 f.flush() |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
77 commands.branch(ui, repo, label="B2") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
78 commands.commit(ui, repo, message="C3") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
79 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
80 self.assertEqual(len(repo), 3) |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
81 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
82 branch = 'B1' |
813
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
83 _dispatch(ui, ['clone', self.wc_path, self.wc_path + '2', |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
84 '--branch', branch]) |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
85 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
86 repo2 = hg.repository(ui, self.wc_path + '2') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
87 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
88 self.assertEqual(repo[branch].hex(), repo2['.'].hex()) |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
89 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
90 def suite(): |
833
312b37bc5e20
tests: avoid shadowing Python builtin all()
Yonggang Luo <luoyonggang@gmail.com>
parents:
813
diff
changeset
|
91 all_tests = [unittest.TestLoader().loadTestsFromTestCase(TestMercurialCore)] |
312b37bc5e20
tests: avoid shadowing Python builtin all()
Yonggang Luo <luoyonggang@gmail.com>
parents:
813
diff
changeset
|
92 return unittest.TestSuite(all_tests) |