annotate tests/test_fetch_mappings.py @ 331:75f082b5897e

Switch to using url scheme wrappers instead of duplicating each command we wrap. The 'hg svn url' command has been killed; the replacement is '.hg/hgrc'. More stuff related to its disappearance has been stripped, including two tests. HgChangeReceiver now takes a UUID argument, which it uses to ensure that remote repositories remain unchanged. This is a temporary solution, and I'm not entirely satisfied with how it's done either. Access to the UUID file has been isolated in a HgChangeReceiver property. Some more tests have been updated to use ui.pushbuffer()/popbuffer(), and to pass through the Mercurial API. Moved the arguments to wrappers.pull() to the UI configuration. Also, remove HgChangeReceiver.opts in favour of a 'usebranchnames' instance & configuration variable. The name is taken from the ConvertExtension.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 15 May 2009 19:18:43 +0200
parents ffccf0080e54
children 2c0649064455
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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')
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 authormap.write("Augie=Augie Fackler <durin42@gmail.com>\n")
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 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
26 _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
27 _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
28 _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
29 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
30 self.wc_path, authors=self.authors)
168
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 self.assertEqual(self.repo[0].user(),
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 'Augie Fackler <durin42@gmail.com>')
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 self.assertEqual(self.repo['tip'].user(),
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 'evil@5b65bade-98f3-4993-a01f-b7a6710da339')
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 def test_author_map_stupid(self):
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 self.test_author_map(True)
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 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
40 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
41 authormap = open(self.authors, 'w')
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 authormap.write("evil=Testy <test@test>")
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43 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
44 _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
45 _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
46 _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
47 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
48 self.wc_path, authors=self.authors)
168
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
49 self.assertEqual(self.repo[0].user(),
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
50 'Augie@5b65bade-98f3-4993-a01f-b7a6710da339')
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
51 self.assertEqual(self.repo['tip'].user(),
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
52 'Testy <test@test>')
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
53
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54 def test_author_map_closing_author_stupid(self):
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
55 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
56
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 168
diff changeset
57 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
58 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
59 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
60 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
61 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
62 _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
63 _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
64 _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
65 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
66 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
67 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
68 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
69
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 168
diff changeset
70 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
71 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
72
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 168
diff changeset
73 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
74 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
75 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
76 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
77 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
78 _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
79 _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
80 _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
81 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
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()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841')
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 179
diff changeset
84 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
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_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
87 self.test_file_map_exclude(True)
168
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
88
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 def suite():
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
91 return unittest.TestLoader().loadTestsFromTestCase(MapTests)