comparison tests/test_fetch_mappings.py @ 954:1f77bd6ec0e5

test_fetch_mappings: reduce copy/paste
author Patrick Mezard <patrick@mezard.eu>
date Sun, 07 Oct 2012 20:34:04 +0200
parents 5bacb9c63e3e
children 502613f6b583
comparison
equal deleted inserted replaced
953:3b43b1c45e2e 954:1f77bd6ec0e5
99 fromself = set(test) 99 fromself = set(test)
100 test.load(orig) 100 test.load(orig)
101 all_tests = set(test) 101 all_tests = set(test)
102 self.assertEqual(fromself.symmetric_difference(all_tests), set()) 102 self.assertEqual(fromself.symmetric_difference(all_tests), set())
103 103
104 def _loadwithfilemap(self, svndump, filemapcontent, stupid=False):
105 repo_path = self.load_svndump(svndump)
106 filemap = open(self.filemap, 'w')
107 filemap.write(filemapcontent)
108 filemap.close()
109 ui = self.ui(stupid)
110 ui.setconfig('hgsubversion', 'filemap', self.filemap)
111 commands.clone(ui, test_util.fileurl(repo_path),
112 self.wc_path, filemap=self.filemap)
113 return self.repo
114
104 def test_file_map(self, stupid=False): 115 def test_file_map(self, stupid=False):
105 repo_path = self.load_svndump('replace_trunk_with_branch.svndump') 116 repo = self._loadwithfilemap('replace_trunk_with_branch.svndump',
106 filemap = open(self.filemap, 'w') 117 "include alpha\n", stupid)
107 filemap.write("include alpha\n") 118 self.assertEqual(node.hex(repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d')
108 filemap.close() 119 self.assertEqual(node.hex(repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155')
109 ui = self.ui(stupid)
110 ui.setconfig('hgsubversion', 'filemap', self.filemap)
111 commands.clone(ui, test_util.fileurl(repo_path),
112 self.wc_path, filemap=self.filemap)
113 self.assertEqual(node.hex(self.repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d')
114 self.assertEqual(node.hex(self.repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155')
115 120
116 def test_file_map_stupid(self): 121 def test_file_map_stupid(self):
117 # TODO: re-enable test if we ever reinstate this feature 122 # TODO: re-enable test if we ever reinstate this feature
118 self.assertRaises(hgutil.Abort, self.test_file_map, True) 123 self.assertRaises(hgutil.Abort, self.test_file_map, True)
119 124
120 def test_file_map_exclude(self, stupid=False): 125 def test_file_map_exclude(self, stupid=False):
121 repo_path = self.load_svndump('replace_trunk_with_branch.svndump') 126 repo = self._loadwithfilemap('replace_trunk_with_branch.svndump',
122 filemap = open(self.filemap, 'w') 127 "exclude alpha\n", stupid)
123 filemap.write("exclude alpha\n") 128 self.assertEqual(node.hex(repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841')
124 filemap.close() 129 self.assertEqual(node.hex(repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1')
125 ui = self.ui(stupid)
126 ui.setconfig('hgsubversion', 'filemap', self.filemap)
127 commands.clone(ui, test_util.fileurl(repo_path),
128 self.wc_path, filemap=self.filemap)
129 self.assertEqual(node.hex(self.repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841')
130 self.assertEqual(node.hex(self.repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1')
131 130
132 def test_file_map_exclude_stupid(self): 131 def test_file_map_exclude_stupid(self):
133 # TODO: re-enable test if we ever reinstate this feature 132 # TODO: re-enable test if we ever reinstate this feature
134 self.assertRaises(hgutil.Abort, self.test_file_map_exclude, True) 133 self.assertRaises(hgutil.Abort, self.test_file_map_exclude, True)
135 134
136 def test_file_map_rule_order(self): 135 def test_file_map_rule_order(self):
137 repo_path = self.load_svndump('replace_trunk_with_branch.svndump') 136 repo = self._loadwithfilemap('replace_trunk_with_branch.svndump',
138 filemap = open(self.filemap, 'w') 137 "exclude alpha\ninclude .\nexclude gamma\n")
139 filemap.write("exclude alpha\n")
140 filemap.write("include .\n")
141 filemap.write("exclude gamma\n")
142 filemap.close()
143 ui = self.ui(False)
144 ui.setconfig('hgsubversion', 'filemap', self.filemap)
145 commands.clone(ui, test_util.fileurl(repo_path),
146 self.wc_path, filemap=self.filemap)
147 # The exclusion of alpha is overridden by the later rule to 138 # The exclusion of alpha is overridden by the later rule to
148 # include all of '.', whereas gamma should remain excluded 139 # include all of '.', whereas gamma should remain excluded
149 # because it's excluded after the root directory. 140 # because it's excluded after the root directory.
150 self.assertEqual(self.repo[0].manifest().keys(), 141 self.assertEqual(self.repo[0].manifest().keys(),
151 ['alpha', 'beta']) 142 ['alpha', 'beta'])