Mercurial > hgsubversion
annotate tests/test_unaffected_core.py @ 1572:51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sun, 27 May 2018 00:29:38 -0400 |
parents | d55c9d0ba350 |
children | af9a3156f8ae |
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 |
1570
d55c9d0ba350
tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents:
1545
diff
changeset
|
13 revsymbol = test_util.revsymbol |
d55c9d0ba350
tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents:
1545
diff
changeset
|
14 |
813
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
15 def _dispatch(ui, cmd): |
1344
38be7a6b6def
tests: have our dispatch wrappers assert --quiet is always passed
Augie Fackler <raf@durin42.com>
parents:
1343
diff
changeset
|
16 assert '--quiet' in cmd |
813
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
17 try: |
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
18 req = dispatch.request(cmd, ui=ui) |
1545
306187268f59
test_unaffected_core: be compatible with upstream change
Jun Wu <quark@fb.com>
parents:
1344
diff
changeset
|
19 req.earlyoptions = {'config': [], 'cwd': '', 'debugger': None, |
306187268f59
test_unaffected_core: be compatible with upstream change
Jun Wu <quark@fb.com>
parents:
1344
diff
changeset
|
20 'profile': False, 'repository': ''} |
813
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
21 dispatch._dispatch(req) |
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
22 except AttributeError: |
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
23 dispatch._dispatch(ui, cmd) |
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
713
diff
changeset
|
24 |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
25 class TestMercurialCore(test_util.TestBase): |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
26 ''' |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
27 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
|
28 ''' |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
29 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
30 @test_util.requiresoption('updaterev') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
31 def test_update(self): |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
32 ''' Test 'clone --updaterev' ''' |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
33 ui = self.ui() |
1343
e597714cb420
tests: pass --quiet anyplace we call dispatch to run a command
Augie Fackler <raf@durin42.com>
parents:
1048
diff
changeset
|
34 _dispatch(ui, ['init', '--quiet', self.wc_path]) |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
35 repo = self.repo |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
36 repo.ui.setconfig('ui', 'username', 'anonymous') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
37 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
38 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
|
39 f = file(fpath, 'w') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
40 f.write('C1') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
41 f.flush() |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
42 commands.add(ui, repo) |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
43 commands.commit(ui, repo, message="C1") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
44 f.write('C2') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
45 f.flush() |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
46 commands.commit(ui, repo, message="C2") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
47 f.write('C3') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
48 f.flush() |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
49 commands.commit(ui, repo, message="C3") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
50 |
1048
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1044
diff
changeset
|
51 self.assertEqual(test_util.repolen(repo), 3) |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
52 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
53 updaterev = 1 |
1343
e597714cb420
tests: pass --quiet anyplace we call dispatch to run a command
Augie Fackler <raf@durin42.com>
parents:
1048
diff
changeset
|
54 _dispatch(ui, ['clone', '--quiet', |
e597714cb420
tests: pass --quiet anyplace we call dispatch to run a command
Augie Fackler <raf@durin42.com>
parents:
1048
diff
changeset
|
55 self.wc_path, self.wc_path + '2', |
e597714cb420
tests: pass --quiet anyplace we call dispatch to run a command
Augie Fackler <raf@durin42.com>
parents:
1048
diff
changeset
|
56 '--updaterev=%s' % updaterev]) |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
57 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
58 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
|
59 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
60 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
|
61 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
62 @test_util.requiresoption('branch') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
63 def test_branch(self): |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
64 ''' Test 'clone --branch' ''' |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
65 ui = self.ui() |
1343
e597714cb420
tests: pass --quiet anyplace we call dispatch to run a command
Augie Fackler <raf@durin42.com>
parents:
1048
diff
changeset
|
66 _dispatch(ui, ['init', '--quiet', self.wc_path]) |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
67 repo = self.repo |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
68 repo.ui.setconfig('ui', 'username', 'anonymous') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
69 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
70 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
|
71 f = file(fpath, 'w') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
72 f.write('C1') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
73 f.flush() |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
74 commands.add(ui, repo) |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
75 commands.branch(ui, repo, label="B1") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
76 commands.commit(ui, repo, message="C1") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
77 f.write('C2') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
78 f.flush() |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
79 commands.branch(ui, repo, label="default") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
80 commands.commit(ui, repo, message="C2") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
81 f.write('C3') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
82 f.flush() |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
83 commands.branch(ui, repo, label="B2") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
84 commands.commit(ui, repo, message="C3") |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
85 |
1048
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1044
diff
changeset
|
86 self.assertEqual(test_util.repolen(repo), 3) |
713
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 branch = 'B1' |
1343
e597714cb420
tests: pass --quiet anyplace we call dispatch to run a command
Augie Fackler <raf@durin42.com>
parents:
1048
diff
changeset
|
89 _dispatch(ui, [ |
e597714cb420
tests: pass --quiet anyplace we call dispatch to run a command
Augie Fackler <raf@durin42.com>
parents:
1048
diff
changeset
|
90 'clone', '--quiet', |
e597714cb420
tests: pass --quiet anyplace we call dispatch to run a command
Augie Fackler <raf@durin42.com>
parents:
1048
diff
changeset
|
91 self.wc_path, self.wc_path + '2', |
e597714cb420
tests: pass --quiet anyplace we call dispatch to run a command
Augie Fackler <raf@durin42.com>
parents:
1048
diff
changeset
|
92 '--branch', branch]) |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
93 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff
changeset
|
94 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
|
95 |
1570
d55c9d0ba350
tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents:
1545
diff
changeset
|
96 self.assertEqual(revsymbol(repo, branch).hex(), revsymbol(repo2, '.').hex()) |