Mercurial > hgsubversion
annotate tests/test_fetch_mappings.py @ 371:b45671850969
Add some comments for rebuildmeta, simplify a little.
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Fri, 29 May 2009 12:36:30 +0200 |
parents | 27e9fea5d114 |
children | 2851b81c65ce |
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 |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 from mercurial import ui |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
8 from mercurial import node |
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 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 class MapTests(test_util.TestBase): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 @property |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 def authors(self): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 return os.path.join(self.tmpdir, 'authormap') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 @property |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 def filemap(self): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 return os.path.join(self.tmpdir, 'filemap') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 def test_author_map(self, stupid=False): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 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
|
23 authormap = open(self.authors, 'w') |
360
27e9fea5d114
Author maps: strip comments.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
358
diff
changeset
|
24 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
|
25 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
|
26 authormap.close() |
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
|
27 _ui = ui.ui() |
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
|
28 _ui.setconfig('hgsubversion', 'stupid', str(stupid)) |
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
|
29 _ui.setconfig('hgsubversion', 'authormap', self.authors) |
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
|
30 commands.clone(_ui, test_util.fileurl(self.repo_path), |
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
|
31 self.wc_path, authors=self.authors) |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 self.assertEqual(self.repo[0].user(), |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 'Augie Fackler <durin42@gmail.com>') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 self.assertEqual(self.repo['tip'].user(), |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 'evil@5b65bade-98f3-4993-a01f-b7a6710da339') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 def test_author_map_stupid(self): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 self.test_author_map(True) |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 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
|
41 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
|
42 authormap = open(self.authors, 'w') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 authormap.write("evil=Testy <test@test>") |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 authormap.close() |
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
|
45 _ui = ui.ui() |
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
|
46 _ui.setconfig('hgsubversion', 'stupid', str(stupid)) |
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
|
47 _ui.setconfig('hgsubversion', 'authormap', self.authors) |
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
|
48 commands.clone(_ui, test_util.fileurl(self.repo_path), |
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
|
49 self.wc_path, authors=self.authors) |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 self.assertEqual(self.repo[0].user(), |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 'Augie@5b65bade-98f3-4993-a01f-b7a6710da339') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 self.assertEqual(self.repo['tip'].user(), |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 'Testy <test@test>') |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 def test_author_map_closing_author_stupid(self): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 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
|
57 |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
58 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
|
59 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
|
60 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
|
61 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
|
62 filemap.close() |
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
|
63 _ui = ui.ui() |
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
|
64 _ui.setconfig('hgsubversion', 'stupid', str(stupid)) |
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
|
65 _ui.setconfig('hgsubversion', 'filemap', self.filemap) |
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
|
66 commands.clone(_ui, test_util.fileurl(self.repo_path), |
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
|
67 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
|
68 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
|
69 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
|
70 |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
71 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
|
72 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
|
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_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
|
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("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
|
78 filemap.close() |
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
|
79 _ui = ui.ui() |
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
|
80 _ui.setconfig('hgsubversion', 'stupid', str(stupid)) |
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
|
81 _ui.setconfig('hgsubversion', 'filemap', self.filemap) |
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 commands.clone(_ui, test_util.fileurl(self.repo_path), |
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
|
83 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
|
84 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
|
85 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
|
86 |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
168
diff
changeset
|
87 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
|
88 self.test_file_map_exclude(True) |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
89 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
90 |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
91 def suite(): |
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
92 return unittest.TestLoader().loadTestsFromTestCase(MapTests) |