Mercurial > hgsubversion
annotate tests/test_fetch_mappings.py @ 639:b2c8c2079822
tests: add test for combining two branches using the branchmap
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Tue, 13 Jul 2010 13:18:08 +0200 |
parents | d4f433ee709a |
children | 67513cca972f |
rev | line source |
---|---|
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 """Tests for author maps and file maps. |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 """ |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import os |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 import unittest |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
257
diff
changeset
|
6 from mercurial import commands |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
7 from mercurial import node |
636
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
8 from mercurial import util as hgutil |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 import test_util |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 |
430
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
12 from hgsubversion import maps |
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
13 |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 class MapTests(test_util.TestBase): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 @property |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 def authors(self): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 return os.path.join(self.tmpdir, 'authormap') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 @property |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 def filemap(self): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 return os.path.join(self.tmpdir, 'filemap') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 |
574
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
23 @property |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
24 def branchmap(self): |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
25 return os.path.join(self.tmpdir, 'branchmap') |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
26 |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 def test_author_map(self, stupid=False): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 authormap = open(self.authors, 'w') |
360
27e9fea5d114
Author maps: strip comments.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
358
diff
changeset
|
30 authormap.write('Augie=Augie Fackler <durin42@gmail.com> # stuffy\n') |
358
2c0649064455
Author maps: handle lines without = gracefully.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
331
diff
changeset
|
31 authormap.write("Augie Fackler <durin42@gmail.com>\n") |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 authormap.close() |
576
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
33 ui = self.ui(stupid) |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
34 ui.setconfig('hgsubversion', 'authormap', self.authors) |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
35 commands.clone(ui, test_util.fileurl(self.repo_path), |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
257
diff
changeset
|
36 self.wc_path, authors=self.authors) |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 self.assertEqual(self.repo[0].user(), |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 'Augie Fackler <durin42@gmail.com>') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 self.assertEqual(self.repo['tip'].user(), |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 'evil@5b65bade-98f3-4993-a01f-b7a6710da339') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 def test_author_map_stupid(self): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 self.test_author_map(True) |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 def test_author_map_closing_author(self, stupid=False): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 authormap = open(self.authors, 'w') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 authormap.write("evil=Testy <test@test>") |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 authormap.close() |
576
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
50 ui = self.ui(stupid) |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
51 ui.setconfig('hgsubversion', 'authormap', self.authors) |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
52 commands.clone(ui, test_util.fileurl(self.repo_path), |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
257
diff
changeset
|
53 self.wc_path, authors=self.authors) |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 self.assertEqual(self.repo[0].user(), |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 'Augie@5b65bade-98f3-4993-a01f-b7a6710da339') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 self.assertEqual(self.repo['tip'].user(), |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 'Testy <test@test>') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 def test_author_map_closing_author_stupid(self): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 self.test_author_map_closing_author(True) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
61 |
430
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
62 def test_author_map_no_overwrite(self): |
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
63 cwd = os.path.dirname(__file__) |
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
64 orig = os.path.join(cwd, 'fixtures', 'author-map-test.txt') |
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
65 new = open(self.authors, 'w') |
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
66 new.write(open(orig).read()) |
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
67 new.close() |
576
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
68 test = maps.AuthorMap(self.ui(), self.authors) |
430
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
69 fromself = set(test) |
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
70 test.load(orig) |
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
71 all = set(test) |
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
72 self.assertEqual(fromself.symmetric_difference(all), set()) |
2851b81c65ce
maps: make sure AuthorMaps don't overwrite themselves, fix overriding
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
360
diff
changeset
|
73 |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
74 def test_file_map(self, stupid=False): |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
75 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
76 filemap = open(self.filemap, 'w') |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
77 filemap.write("include alpha\n") |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
78 filemap.close() |
576
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
79 ui = self.ui(stupid) |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
80 ui.setconfig('hgsubversion', 'filemap', self.filemap) |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
81 commands.clone(ui, test_util.fileurl(self.repo_path), |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
257
diff
changeset
|
82 self.wc_path, filemap=self.filemap) |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
83 self.assertEqual(node.hex(self.repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d') |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
84 self.assertEqual(node.hex(self.repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155') |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
85 |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
86 def test_file_map_stupid(self): |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
87 self.test_file_map(True) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
88 |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
89 def test_file_map_exclude(self, stupid=False): |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
90 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
91 filemap = open(self.filemap, 'w') |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
92 filemap.write("exclude alpha\n") |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
93 filemap.close() |
576
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
94 ui = self.ui(stupid) |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
95 ui.setconfig('hgsubversion', 'filemap', self.filemap) |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
96 commands.clone(ui, test_util.fileurl(self.repo_path), |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
257
diff
changeset
|
97 self.wc_path, filemap=self.filemap) |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
98 self.assertEqual(node.hex(self.repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841') |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
99 self.assertEqual(node.hex(self.repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1') |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
100 |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
101 def test_file_map_exclude_stupid(self): |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
102 self.test_file_map_exclude(True) |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
103 |
574
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
104 def test_branchmap(self, stupid=False): |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
105 test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump') |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
106 branchmap = open(self.branchmap, 'w') |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
107 branchmap.write("badname = good-name # stuffy\n") |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
108 branchmap.write("feature = default\n") |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
109 branchmap.close() |
576
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
110 ui = self.ui(stupid) |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
111 ui.setconfig('hgsubversion', 'branchmap', self.branchmap) |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
112 commands.clone(ui, test_util.fileurl(self.repo_path), |
574
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
113 self.wc_path, branchmap=self.branchmap) |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
114 branches = set(self.repo[i].branch() for i in self.repo) |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
115 self.assert_('badname' not in branches) |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
116 self.assert_('good-name' in branches) |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
117 self.assertEquals(self.repo[2].branch(), 'default') |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
118 |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
119 def test_branchmap_stupid(self): |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
120 self.test_branchmap(True) |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
430
diff
changeset
|
121 |
634
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
122 def test_branchmap_tagging(self, stupid=False): |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
123 '''test tagging a renamed branch, which used to raise an exception''' |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
124 test_util.load_svndump_fixture(self.repo_path, 'commit-to-tag.svndump') |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
125 branchmap = open(self.branchmap, 'w') |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
126 branchmap.write("magic = art\n") |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
127 branchmap.close() |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
128 ui = self.ui(stupid) |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
129 ui.setconfig('hgsubversion', 'branchmap', self.branchmap) |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
130 commands.clone(ui, test_util.fileurl(self.repo_path), |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
131 self.wc_path, branchmap=self.branchmap) |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
132 branches = set(self.repo[i].branch() for i in self.repo) |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
133 self.assertEquals(sorted(branches), ['art', 'closeme']) |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
134 |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
135 def test_branchmap_tagging_stupid(self): |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
136 self.test_branchmap_tagging(True) |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
137 |
635
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
138 def test_branchmap_empty_commit(self, stupid=False): |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
139 '''test mapping an empty commit on a renamed branch''' |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
140 test_util.load_svndump_fixture(self.repo_path, 'propset-branch.svndump') |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
141 branchmap = open(self.branchmap, 'w') |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
142 branchmap.write("the-branch = bob\n") |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
143 branchmap.close() |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
144 ui = self.ui(stupid) |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
145 ui.setconfig('hgsubversion', 'branchmap', self.branchmap) |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
146 commands.clone(ui, test_util.fileurl(self.repo_path), |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
147 self.wc_path, branchmap=self.branchmap) |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
148 branches = set(self.repo[i].branch() for i in self.repo) |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
149 self.assertEquals(sorted(branches), ['bob', 'default']) |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
150 |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
151 def test_branchmap_empty_commit_stupid(self): |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
152 '''test mapping an empty commit on a renamed branch (stupid)''' |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
153 self.test_branchmap_empty_commit(True) |
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
154 |
639
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
155 def test_branchmap_combine(self, stupid=False): |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
156 '''test combining two branches, but retaining heads''' |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
157 test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump') |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
158 branchmap = open(self.branchmap, 'w') |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
159 branchmap.write("badname = default\n") |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
160 branchmap.write("feature = default\n") |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
161 branchmap.close() |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
162 ui = self.ui(stupid) |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
163 ui.setconfig('hgsubversion', 'branchmap', self.branchmap) |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
164 commands.clone(ui, test_util.fileurl(self.repo_path), |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
165 self.wc_path, branchmap=self.branchmap) |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
166 branches = set(self.repo[i].branch() for i in self.repo) |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
167 self.assertEquals(sorted(branches), ['default']) |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
168 self.assertEquals(len(self.repo.heads()), 2) |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
169 self.assertEquals(len(self.repo.branchheads('default')), 2) |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
170 |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
171 # test that the mapping does not affect branch info |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
172 branches = self.repo.svnmeta().branches |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
173 self.assertEquals(sorted(branches.keys()), |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
174 [None, 'badname', 'feature']) |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
175 |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
176 def test_branchmap_combine_stupid(self): |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
177 '''test combining two branches, but retaining heads (stupid)''' |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
178 self.test_branchmap_combine(True) |
b2c8c2079822
tests: add test for combining two branches using the branchmap
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
636
diff
changeset
|
179 |
636
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
180 def test_branchmap_no_replacement(self): |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
181 ''' |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
182 test that empty mappings are rejected |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
183 |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
184 Empty mappings are lines like 'this ='. The most sensible thing to do |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
185 is to not convert the 'this' branches. Until we can do that, we settle |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
186 with aborting. |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
187 ''' |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
188 test_util.load_svndump_fixture(self.repo_path, 'propset-branch.svndump') |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
189 branchmap = open(self.branchmap, 'w') |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
190 branchmap.write("closeme =\n") |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
191 branchmap.close() |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
192 self.assertRaises(hgutil.Abort, |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
193 maps.BranchMap, self.ui(), self.branchmap) |
d4f433ee709a
branchmap: reject empty mappings
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
194 |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
195 def suite(): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
196 return unittest.TestLoader().loadTestsFromTestCase(MapTests) |