Mercurial > hgsubversion
annotate tests/test_template_keywords.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 | f089ca13cc4c |
children | d741f536f23a |
rev | line source |
---|---|
684
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
1 import test_util |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
2 |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
3 import unittest |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
4 |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
5 from mercurial import commands |
722
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
6 from mercurial import error |
684
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
7 from mercurial import ui |
687
d424bd1ac647
templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents:
684
diff
changeset
|
8 try: |
d424bd1ac647
templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents:
684
diff
changeset
|
9 from mercurial import templatekw |
d424bd1ac647
templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents:
684
diff
changeset
|
10 templatekw.keywords |
d424bd1ac647
templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents:
684
diff
changeset
|
11 except ImportError: |
d424bd1ac647
templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents:
684
diff
changeset
|
12 templatekw = None |
684
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
13 |
722
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
14 try: |
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
15 from mercurial import revset |
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
16 revset.methods |
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
17 except ImportError: |
835
f089ca13cc4c
test_template_keywords.py: fix indentation of revset except block
Yonggang Luo <luoyonggang@gmail.com>
parents:
833
diff
changeset
|
18 revset = None |
684
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
19 |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
20 class CapturingUI(ui.ui): |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
21 |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
22 def __init__(self, *args, **kwds): |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
23 super(CapturingUI, self).__init__(*args, **kwds) |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
24 self._output = "" |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
25 |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
26 def write(self, msg, *args, **kwds): |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
27 self._output += msg |
8687c5aa4f35
Add svnrev, svnpath and svnuuid keyword.
Andi Albrecht <albrecht.andi@gmail.com>
parents:
diff
changeset
|
28 |
721
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
29 |
707
cb32d90f915e
templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
687
diff
changeset
|
30 class TestLogKeywords(test_util.TestBase): |
721
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
31 @test_util.requiresmodule(templatekw) |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
32 def test_svn_keywords(self): |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
33 defaults = {'date': None, 'rev': None, 'user': None} |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
34 repo = self._load_fixture_and_fetch('two_revs.svndump') |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
35 |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
36 # we want one commit that isn't from Subversion |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
37 self.commitchanges([('foo', 'foo', 'frobnicate\n')]) |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
38 |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
39 ui = CapturingUI() |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
40 commands.log(ui, repo, template='{rev}:{svnrev} ', **defaults) |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
41 self.assertEqual(ui._output, '0:2 1:3 2: ') |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
42 ui = CapturingUI() |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
43 commands.log(ui, repo, template='{rev}:{svnpath} ', **defaults) |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
44 self.assertEqual(ui._output, '0:/trunk 1:/trunk 2: ') |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
45 ui = CapturingUI() |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
46 commands.log(ui, repo, template='{rev}:{svnuuid} ', **defaults) |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
47 self.assertEqual(ui._output, |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
48 ('0:df2126f7-00ab-4d49-b42c-7e981dde0bcf ' |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
49 '1:df2126f7-00ab-4d49-b42c-7e981dde0bcf ' |
af817963897e
test_template_keywords: use new requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
707
diff
changeset
|
50 '2: ')) |
687
d424bd1ac647
templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents:
684
diff
changeset
|
51 |
723
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
52 @test_util.requiresmodule(revset) |
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
53 @test_util.requiresmodule(templatekw) |
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
54 def test_svn_revsets(self): |
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
55 repo = self._load_fixture_and_fetch('two_revs.svndump') |
722
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
56 |
723
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
57 # we want one commit that isn't from Subversion |
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
58 self.commitchanges([('foo', 'foo', 'frobnicate\n')]) |
722
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
59 |
723
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
60 defaults = {'date': None, 'rev': ['fromsvn()'], 'user': None} |
722
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
61 |
723
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
62 ui = CapturingUI() |
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
63 commands.log(ui, repo, template='{rev}:{svnrev} ', **defaults) |
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
64 self.assertEqual(ui._output, '0:2 1:3 ') |
722
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
65 |
723
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
66 defaults = {'date': None, 'rev': ['svnrev(2)'], 'user': None} |
722
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
67 |
723
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
68 ui = CapturingUI() |
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
69 commands.log(ui, repo, template='{rev}:{svnrev} ', **defaults) |
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
70 self.assertEqual(ui._output, '0:2 ') |
722
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
71 |
723
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
72 defaults = {'date': None, 'rev': ['fromsvn(1)'], 'user': None} |
722
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
73 |
723
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
74 self.assertRaises(error.ParseError, |
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
75 commands.log, self.ui(), repo, |
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
76 template='{rev}:{svnrev} ', **defaults) |
722
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
77 |
723
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
78 defaults = {'date': None, 'rev': ['svnrev(1, 2)'], 'user': None} |
722
aa24148a7454
uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
721
diff
changeset
|
79 |
723
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
80 self.assertRaises(error.ParseError, |
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
81 commands.log, self.ui(), repo, |
4baa41e0f8ad
revset tests: use requiresmodule decorator
Augie Fackler <durin42@gmail.com>
parents:
722
diff
changeset
|
82 template='{rev}:{svnrev} ', **defaults) |
687
d424bd1ac647
templatekw: restore compatibility with hg < 1.5
Augie Fackler <durin42@gmail.com>
parents:
684
diff
changeset
|
83 |
707
cb32d90f915e
templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
687
diff
changeset
|
84 def suite(): |
833
312b37bc5e20
tests: avoid shadowing Python builtin all()
Yonggang Luo <luoyonggang@gmail.com>
parents:
832
diff
changeset
|
85 all_tests = [unittest.TestLoader().loadTestsFromTestCase(TestLogKeywords), ] |
312b37bc5e20
tests: avoid shadowing Python builtin all()
Yonggang Luo <luoyonggang@gmail.com>
parents:
832
diff
changeset
|
86 return unittest.TestSuite(all_tests) |