annotate tests/comprehensive/test_rebuildmeta.py @ 1324:dde1ade36a49 stable 1.8.1

fixes indent for hgsubversionbranch section in extension help
author Andrei Dziahel <develop7@develop7.info>
date Thu, 07 May 2015 08:46:09 +0000
parents 11c8de73b48a
children c6b01fd34694
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 unittest
1042
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 953
diff changeset
3 import sys
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 953
diff changeset
4
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 953
diff changeset
5 # wrapped in a try/except because of weirdness in how
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 953
diff changeset
6 # run.py works as compared to nose.
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 953
diff changeset
7 try:
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 953
diff changeset
8 import test_util
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 953
diff changeset
9 except ImportError:
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 953
diff changeset
10 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
af84ef787d93 tests: move updatemeta & rebuildmeta tests into comprehensive
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 953
diff changeset
11 import test_util
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12
638
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
13 from mercurial import context
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
14 from mercurial import extensions
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 from mercurial import hg
1249
11c8de73b48a test_rebuildmeta: call exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents: 1159
diff changeset
16 from mercurial import localrepo
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 from mercurial import ui
1249
11c8de73b48a test_rebuildmeta: call exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents: 1159
diff changeset
18 from mercurial import util as hgutil
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19
1103
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents: 1092
diff changeset
20 from hgsubversion import compathacks
337
46e69be8e2c8 Reorganize to have a more conventional module structure.
Augie Fackler <durin42@gmail.com>
parents: 331
diff changeset
21 from hgsubversion import svncommands
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 414
diff changeset
22 from hgsubversion import svnmeta
1133
ff4e102932ed tests: use util.load instead of bare pickle
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
23 from hgsubversion import util
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24
821
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
25 # These test repositories have harmless skew in rebuildmeta for the
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
26 # last-pulled-rev because the last rev in svn causes absolutely no
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
27 # changes in hg.
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
28 expect_youngest_skew = [('file_mixed_with_branches.svndump', False, False),
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
29 ('file_mixed_with_branches.svndump', True, False),
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
30 ('unrelatedbranch.svndump', False, False),
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
31 ('unrelatedbranch.svndump', True, False),
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
32 ]
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
33
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
34
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
35
1092
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
36 def _do_case(self, name, layout):
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
37 subdir = test_util.subdir.get(name, '')
1092
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
38 single = layout == 'single'
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
39 u = ui.ui()
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
40 config = {}
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
41 if layout == 'custom':
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
42 for branch, path in test_util.custom.get(name, {}).iteritems():
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
43 config['hgsubversionbranch.%s' % branch] = path
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
44 u.setconfig('hgsubversionbranch', branch, path)
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
45 repo, repo_path = self.load_and_fetch(name, subdir=subdir, layout=layout)
1048
903c9c9dfe6a tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
46 assert test_util.repolen(self.repo) > 0
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47 wc2_path = self.wc_path + '_clone'
816
86d124a8768e Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents: 748
diff changeset
48 src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False)
930
5bacb9c63e3e Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents: 916
diff changeset
49 src = test_util.getlocalpeer(src)
5bacb9c63e3e Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents: 916
diff changeset
50 dest = test_util.getlocalpeer(dest)
638
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
51
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
52 # insert a wrapper that prevents calling changectx.children()
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
53 def failfn(orig, ctx):
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
54 self.fail('calling %s is forbidden; it can cause massive slowdowns '
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
55 'when rebuilding large repositories' % orig)
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
56
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
57 origchildren = getattr(context.changectx, 'children')
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
58 extensions.wrapfunction(context.changectx, 'children', failfn)
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
59
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
60 try:
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
61 svncommands.rebuildmeta(u, dest,
867
50c13e01c7e3 test_util: add a load_and_fetch() returning the repo_path
Patrick Mezard <patrick@mezard.eu>
parents: 833
diff changeset
62 args=[test_util.fileurl(repo_path +
638
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
63 subdir), ])
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
64 finally:
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
65 # remove the wrapper
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
66 context.changectx.children = origchildren
ea0f42e0004d tests: disallow calling changectx.children() during rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 622
diff changeset
67
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
68 self._run_assertions(name, single, src, dest, u)
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
69
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
70 wc3_path = self.wc_path + '_partial'
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
71 src, dest = test_util.hgclone(u,
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
72 self.wc_path,
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
73 wc3_path,
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
74 update=False,
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
75 rev=[0])
930
5bacb9c63e3e Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents: 916
diff changeset
76 srcrepo = test_util.getlocalpeer(src)
5bacb9c63e3e Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents: 916
diff changeset
77 dest = test_util.getlocalpeer(dest)
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
78
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
79 # insert a wrapper that prevents calling changectx.children()
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
80 extensions.wrapfunction(context.changectx, 'children', failfn)
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
81
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
82 try:
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
83 svncommands.rebuildmeta(u, dest,
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
84 args=[test_util.fileurl(repo_path +
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
85 subdir), ])
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
86 finally:
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
87 # remove the wrapper
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
88 context.changectx.children = origchildren
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
89
1249
11c8de73b48a test_rebuildmeta: call exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents: 1159
diff changeset
90 if hgutil.safehasattr(localrepo.localrepository, 'pull'):
11c8de73b48a test_rebuildmeta: call exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents: 1159
diff changeset
91 dest.pull(src)
11c8de73b48a test_rebuildmeta: call exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents: 1159
diff changeset
92 else:
11c8de73b48a test_rebuildmeta: call exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents: 1159
diff changeset
93 # Mercurial >= 3.2
11c8de73b48a test_rebuildmeta: call exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents: 1159
diff changeset
94 from mercurial import exchange
11c8de73b48a test_rebuildmeta: call exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents: 1159
diff changeset
95 exchange.pull(dest, src)
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
96
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
97 # insert a wrapper that prevents calling changectx.children()
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
98 extensions.wrapfunction(context.changectx, 'children', failfn)
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
99 try:
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
100 svncommands.updatemeta(u, dest,
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
101 args=[test_util.fileurl(repo_path +
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
102 subdir), ])
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
103 finally:
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
104 # remove the wrapper
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
105 context.changectx.children = origchildren
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
106
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
107 self._run_assertions(name, single, srcrepo, dest, u)
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
108
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
109
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
110 def _run_assertions(self, name, single, src, dest, u):
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
111
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 246
diff changeset
112 self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 246
diff changeset
113 'no .hg/svn directory in the source!')
953
3b43b1c45e2e test_rebuildmeta: fix src/dest typo
Patrick Mezard <patrick@mezard.eu>
parents: 930
diff changeset
114 self.assertTrue(os.path.isdir(os.path.join(dest.path, 'svn')),
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 246
diff changeset
115 'no .hg/svn directory in the destination!')
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
116 dest = hg.repository(u, os.path.dirname(dest.path))
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 821
diff changeset
117 for tf in ('lastpulled', 'rev_map', 'uuid', 'tagmap', 'layout', 'subdir',):
821
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
118
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 246
diff changeset
119 stf = os.path.join(src.path, 'svn', tf)
1159
d62c53c7a37d tests: relax testing for tagmap existence
Sean Farley <sean.michael.farley@gmail.com>
parents: 1149
diff changeset
120 # the generation of tagmap is lazy so it doesn't strictly need to exist
d62c53c7a37d tests: relax testing for tagmap existence
Sean Farley <sean.michael.farley@gmail.com>
parents: 1149
diff changeset
121 # if it's not being used
d62c53c7a37d tests: relax testing for tagmap existence
Sean Farley <sean.michael.farley@gmail.com>
parents: 1149
diff changeset
122 if not stf.endswith('tagmap'):
d62c53c7a37d tests: relax testing for tagmap existence
Sean Farley <sean.michael.farley@gmail.com>
parents: 1149
diff changeset
123 self.assertTrue(os.path.isfile(stf), '%r is missing!' % stf)
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 246
diff changeset
124 dtf = os.path.join(dest.path, 'svn', tf)
1159
d62c53c7a37d tests: relax testing for tagmap existence
Sean Farley <sean.michael.farley@gmail.com>
parents: 1149
diff changeset
125 old, new = None, None
d62c53c7a37d tests: relax testing for tagmap existence
Sean Farley <sean.michael.farley@gmail.com>
parents: 1149
diff changeset
126 if not dtf.endswith('tagmap'):
d62c53c7a37d tests: relax testing for tagmap existence
Sean Farley <sean.michael.farley@gmail.com>
parents: 1149
diff changeset
127 self.assertTrue(os.path.isfile(dtf), '%r is missing!' % tf)
d62c53c7a37d tests: relax testing for tagmap existence
Sean Farley <sean.michael.farley@gmail.com>
parents: 1149
diff changeset
128 if os.path.isfile(stf) and os.path.isfile(dtf):
d62c53c7a37d tests: relax testing for tagmap existence
Sean Farley <sean.michael.farley@gmail.com>
parents: 1149
diff changeset
129 old, new = util.load(stf, resave=False), util.load(dtf, resave=False)
821
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
130 if tf == 'lastpulled' and (name,
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
131 self.stupid, single) in expect_youngest_skew:
821
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
132 self.assertNotEqual(old, new,
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
133 'rebuildmeta unexpected match on youngest rev!')
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 816
diff changeset
134 continue
1149
34173bbd3b8e tests: use util.load instead of reading file directly
Sean Farley <sean.michael.farley@gmail.com>
parents: 1133
diff changeset
135 self.assertEqual(old, new, tf + ' differs')
1103
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents: 1092
diff changeset
136 try:
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents: 1092
diff changeset
137 self.assertEqual(src.branchmap(), dest.branchmap())
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents: 1092
diff changeset
138 except AttributeError:
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents: 1092
diff changeset
139 # hg 2.8 and earlier
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents: 1092
diff changeset
140 self.assertEqual(src.branchtags(), dest.branchtags())
1133
ff4e102932ed tests: use util.load instead of bare pickle
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
141 srcbi = util.load(os.path.join(src.path, 'svn', 'branch_info'))
ff4e102932ed tests: use util.load instead of bare pickle
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
142 destbi = util.load(os.path.join(dest.path, 'svn', 'branch_info'))
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
143 self.assertEqual(sorted(srcbi.keys()), sorted(destbi.keys()))
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 414
diff changeset
144 revkeys = svnmeta.SVNMeta(dest).revmap.keys()
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
145 for branch in destbi:
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
146 srcinfo = srcbi[branch]
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
147 destinfo = destbi[branch]
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 416
diff changeset
148 if srcinfo[:2] == (None, 0) or destinfo[:2] == (None, 0):
655
dcac6dc1abe6 test_rebuildmeta: make an assertion more helpful.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 643
diff changeset
149 self.assertTrue(srcinfo[2] <= destinfo[2],
dcac6dc1abe6 test_rebuildmeta: make an assertion more helpful.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 643
diff changeset
150 'Latest revision for %s decreased from %d to %d!'
dcac6dc1abe6 test_rebuildmeta: make an assertion more helpful.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 643
diff changeset
151 % (branch or 'default', srcinfo[2], destinfo[2]))
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
152 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
153 else:
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
154 pr = sorted(filter(lambda x: x[1] == srcinfo[0] and x[0] <= srcinfo[1],
405
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 383
diff changeset
155 revkeys), reverse=True)[0][0]
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
156 self.assertEqual(pr, destinfo[1])
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
157 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
158
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
159
1092
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
160 def buildmethod(case, name, layout):
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
161 m = lambda self: self._do_case(case, layout)
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
162 m.__name__ = name
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
163 m.__doc__ = ('Test rebuildmeta on %s (%s)' %
1092
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
164 (case, layout))
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
165 return m
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
166
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
167
892
3bfb7e985c47 svn verify: add a test for corrupt repositories.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 867
diff changeset
168 skip = set([
3bfb7e985c47 svn verify: add a test for corrupt repositories.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 867
diff changeset
169 'project_root_not_repo_root.svndump',
3bfb7e985c47 svn verify: add a test for corrupt repositories.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 867
diff changeset
170 'corrupt.svndump',
3bfb7e985c47 svn verify: add a test for corrupt repositories.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 867
diff changeset
171 ])
3bfb7e985c47 svn verify: add a test for corrupt repositories.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 867
diff changeset
172
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
173 attrs = {'_do_case': _do_case,
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 867
diff changeset
174 '_run_assertions': _run_assertions,
1057
cd256960b622 comprehensive tests: consolidate stupidity into test_util
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1048
diff changeset
175 'stupid_mode_tests': True,
155
ba801f44d240 utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
176 }
182
47d25d61abfa remove generators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 155
diff changeset
177 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]:
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
178 # this fixture results in an empty repository, don't use it
892
3bfb7e985c47 svn verify: add a test for corrupt repositories.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 867
diff changeset
179 if case in skip:
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
180 continue
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 474
diff changeset
181 bname = 'test_' + case[:-len('.svndump')]
1092
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
182 attrs[bname] = buildmethod(case, bname, 'auto')
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
183 attrs[bname + '_single'] = buildmethod(case, bname + '_single', 'single')
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
184 if case in test_util.custom:
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
185 attrs[bname + '_custom'] = buildmethod(case,
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
186 bname + '_custom',
cd0d14e25757 layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents: 1057
diff changeset
187 'single')
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 474
diff changeset
188
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 821
diff changeset
189 RebuildMetaTests = type('RebuildMetaTests', (test_util.TestBase,), attrs)