Mercurial > hgsubversion
annotate tests/test_pull_fallback.py @ 1600:6f5b296c01dd
verify: use ui.write() instead of ui.warn()
Looks like ui.warn() is being written to output directly and it's not pushed to
buffer which ui objects maintain. Let's use ui.write() instead which is used in
the other instance of same error messages too.
This fixes test_utility_commands.py which was failing for me on tip of default
branch.
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Wed, 26 Dec 2018 18:40:12 +0300 |
parents | 4f1461428334 |
children |
rev | line source |
---|---|
932
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
1 import test_util |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
2 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
3 import re |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
4 import mercurial |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
5 from mercurial import commands |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
6 from hgsubversion import stupid |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
7 from hgsubversion import svnwrap |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
8 from hgsubversion import wrappers |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
9 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
10 class TestPullFallback(test_util.TestBase): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
11 def setUp(self): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
12 super(TestPullFallback, self).setUp() |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
13 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
14 def _loadupdate(self, fixture_name, *args, **kwargs): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
15 kwargs = kwargs.copy() |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
16 kwargs.update(noupdate=False) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
17 repo, repo_path = self.load_and_fetch(fixture_name, *args, **kwargs) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
18 return repo, repo_path |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
19 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
20 def test_stupid_fallback_to_stupid_fullrevs(self): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
21 return |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
22 to_patch = { |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
23 'mercurial.patch.patchbackend': _patchbackend_raise, |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
24 'stupid.diff_branchrev': stupid.diff_branchrev, |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
25 'stupid.fetch_branchrev': stupid.fetch_branchrev, |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
26 } |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
27 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
28 expected_calls = { |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
29 'mercurial.patch.patchbackend': 1, |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
30 'stupid.diff_branchrev': 1, |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
31 'stupid.fetch_branchrev': 1, |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
32 } |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
33 |
1069
f6c9394032cb
test_pull_fallback: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1044
diff
changeset
|
34 self.stupid = True |
f6c9394032cb
test_pull_fallback: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1044
diff
changeset
|
35 repo, repo_path = self._loadupdate('single_rev.svndump') |
f6c9394032cb
test_pull_fallback: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1044
diff
changeset
|
36 self.stupid = False |
932
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
37 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
38 # Passing stupid=True doesn't seem to be working - force it |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
39 repo.ui.setconfig('hgsubversion', 'stupid', "true") |
1417
4f1461428334
test_hooks: cope with localrepo.parents() going away
Augie Fackler <raf@durin42.com>
parents:
1069
diff
changeset
|
40 state = repo[None].parents() |
932
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
41 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
42 calls, replaced = _monkey_patch(to_patch) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
43 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
44 try: |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
45 self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed'}) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
46 commands.pull(self.repo.ui, repo, update=True) |
1417
4f1461428334
test_hooks: cope with localrepo.parents() going away
Augie Fackler <raf@durin42.com>
parents:
1069
diff
changeset
|
47 self.failIfEqual(state, repo[None].parents()) |
932
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
48 self.assertTrue('tip' in repo[None].tags()) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
49 self.assertEqual(expected_calls, calls) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
50 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
51 finally: |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
52 _monkey_unpatch(replaced) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
53 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
54 def _monkey_patch(to_patch, start=None): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
55 if start is None: |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
56 import sys |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
57 start = sys.modules[__name__] |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
58 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
59 calls = {} |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
60 replaced = {} |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
61 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
62 for path, replacement in to_patch.iteritems(): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
63 obj = start |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
64 owner, attr = path.rsplit('.', 1) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
65 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
66 for a in owner.split('.', -1): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
67 obj = getattr(obj, a) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
68 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
69 replaced[path] = getattr(obj, attr) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
70 calls[path] = 0 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
71 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
72 def outer(path=path, calls=calls, replacement=replacement): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
73 def wrapper(*p, **kw): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
74 calls[path] += 1 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
75 return replacement(*p, **kw) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
76 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
77 return wrapper |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
78 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
79 setattr(obj, attr, outer()) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
80 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
81 return calls, replaced |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
82 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
83 def _monkey_unpatch(to_patch, start=None): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
84 if start is None: |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
85 import sys |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
86 start = sys.modules[__name__] |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
87 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
88 replaced = {} |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
89 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
90 for path, replacement in to_patch.iteritems(): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
91 obj = start |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
92 owner, attr = path.rsplit('.', 1) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
93 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
94 for a in owner.split('.', -1): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
95 obj = getattr(obj, a) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
96 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
97 replaced[path] = getattr(obj, attr) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
98 setattr(obj, attr, replacement) |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
99 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
100 return replaced |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
101 |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
102 def _patchbackend_raise(*p, **kw): |
dfb3afa6c619
stupid: Fail over to full revision when a PatchError is thrown (issue294)
Tim Delaney <timothy.c.delaney@gmail.com>
parents:
diff
changeset
|
103 raise mercurial.patch.PatchError("patch failed") |