Mercurial > hgsubversion
annotate tests/comprehensive/test_verify.py @ 777:60948939555d
clone: pass on the repository instance rather than the string given
Previously, cloning a Mercurial repository that required
authentication would prompt for authentication twice. This is because
hgclonewrapper() first created a repository instance, but didn't pass
it on. hg.close() would then create another instance, and since
Mercurial doesn't cache authentication credentials across instances,
this would cause a second credential prompt.
This change could have unfortunate side effects in case of other
extensions wanting to modify the source passed to clone. This seems
like a somewhat unlikely scenario. I'll think about a possible way to
avoid all this hackery...
| author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
|---|---|
| date | Tue, 14 Dec 2010 12:09:27 +0100 |
| parents | 124cd25de4ef |
| children | 312b37bc5e20 |
| rev | line source |
|---|---|
|
395
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1 import os |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
2 import pickle |
|
766
124cd25de4ef
tests: fix running the comprehensive tests using nose.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
499
diff
changeset
|
3 import sys |
|
395
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
4 import unittest |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
5 |
|
426
72e63999722f
tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents:
395
diff
changeset
|
6 # wrapped in a try/except because of weirdness in how |
|
72e63999722f
tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents:
395
diff
changeset
|
7 # run.py works as compared to nose. |
|
72e63999722f
tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents:
395
diff
changeset
|
8 try: |
|
72e63999722f
tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents:
395
diff
changeset
|
9 import test_util |
|
72e63999722f
tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents:
395
diff
changeset
|
10 except ImportError: |
|
766
124cd25de4ef
tests: fix running the comprehensive tests using nose.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
499
diff
changeset
|
11 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) |
|
124cd25de4ef
tests: fix running the comprehensive tests using nose.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
499
diff
changeset
|
12 import test_util |
|
395
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
13 |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
14 from mercurial import hg |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
15 from mercurial import ui |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
16 |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
17 from hgsubversion import svncommands |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
18 |
|
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
19 def _do_case(self, name, stupid, layout): |
|
395
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
20 subdir = test_util.subdir.get(name, '') |
|
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
21 repo = self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid, layout=layout) |
|
395
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
22 assert len(self.repo) > 0 |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
23 for i in repo: |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
24 ctx = repo[i] |
|
441
de085126dbd4
svncommands: use rev instead of verifynode -- should not have to be a node
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
427
diff
changeset
|
25 self.assertEqual(svncommands.verify(repo.ui, repo, rev=ctx.node()), 0) |
|
395
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
26 |
|
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
27 def buildmethod(case, name, stupid, layout): |
|
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
28 m = lambda self: self._do_case(case, stupid, layout) |
|
395
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
29 m.__name__ = name |
|
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
30 bits = case, stupid and 'stupid' or 'real', layout |
|
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
31 m.__doc__ = 'Test verify on %s with %s replay. (%s)' % bits |
|
395
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
32 return m |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
33 |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
34 attrs = {'_do_case': _do_case} |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
35 fixtures = [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')] |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
36 for case in fixtures: |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
37 # this fixture results in an empty repository, don't use it |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
38 if case == 'project_root_not_repo_root.svndump': |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
39 continue |
|
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
40 bname = 'test_' + case[:-len('.svndump')] |
|
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
41 attrs[bname] = buildmethod(case, bname, False, 'standard') |
|
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
42 name = bname + '_stupid' |
|
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
43 attrs[name] = buildmethod(case, name, True, 'standard') |
|
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
44 name = bname + '_single' |
|
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
45 attrs[name] = buildmethod(case, name, False, 'single') |
|
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
46 # Disabled because the "stupid and real are the same" tests |
|
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
47 # verify this plus even more. |
|
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
48 # name = bname + '_single_stupid' |
|
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
441
diff
changeset
|
49 # attrs[name] = buildmethod(case, name, True, 'single') |
|
395
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
50 |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
51 VerifyTests = type('VerifyTests', (test_util.TestBase,), attrs) |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
52 |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
53 def suite(): |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
54 all = [unittest.TestLoader().loadTestsFromTestCase(VerifyTests)] |
|
636e9bf5d49c
svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
55 return unittest.TestSuite(all) |
