Mercurial > hgsubversion
comparison tests/test_tags.py @ 521:839734dfb5c7
Handle tag subdirectory as tag in replay mode (issue119)
Original version by Dirkjan Ochtman <dirkjan@ochtman.nl>
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Fri, 22 Jan 2010 18:01:19 -0600 |
parents | 63cb630d667d |
children | 76e9504db03b |
comparison
equal
deleted
inserted
replaced
520:5a5b90a6d522 | 521:839734dfb5c7 |
---|---|
1 import os | 1 import os, sys, cStringIO, difflib |
2 import unittest | 2 import unittest |
3 | 3 |
4 from mercurial import commands | 4 from mercurial import commands |
5 from mercurial import hg | 5 from mercurial import hg |
6 from mercurial import node | 6 from mercurial import node |
186 tm = os.path.join(repo.path, 'svn', 'tagmap') | 186 tm = os.path.join(repo.path, 'svn', 'tagmap') |
187 open(tm, 'w').write('1\n') | 187 open(tm, 'w').write('1\n') |
188 commands.pull(repo.ui, repo) | 188 commands.pull(repo.ui, repo) |
189 self.assertEqual(open(tm).read().splitlines()[0], '2') | 189 self.assertEqual(open(tm).read().splitlines()[0], '2') |
190 | 190 |
191 def _debug_print_tags(self, repo, ctx, fp): | |
192 def formatnode(ctx): | |
193 crev = ctx.extra().get('convert_revision', 'unk/unk@unk') | |
194 path, rev = crev.rsplit('@', 1) | |
195 path = path.split('/', 1)[-1] | |
196 branch = ctx.branch() or 'default' | |
197 return 'hg=%s@%d:svn=%s@%s' % (branch, ctx.rev(), path, rev) | |
198 | |
199 w = fp.write | |
200 if '.hgtags' not in ctx or not ctx['.hgtags'].data().strip(): | |
201 return | |
202 desc = ctx.description().splitlines()[0].strip() | |
203 w('node: %s\n' % formatnode(ctx)) | |
204 w('%s\n' % desc) | |
205 for line in ctx['.hgtags'].data().splitlines(False): | |
206 node, name = line.split(None, 1) | |
207 w(' %s: %s\n' % (name, formatnode(repo[node]))) | |
208 w('\n') | |
209 | |
210 def _test_tags(self, testpath, expected, stupid=False): | |
211 repo = self._load_fixture_and_fetch(testpath, stupid=stupid) | |
212 fp = cStringIO.StringIO() | |
213 for r in repo: | |
214 self._debug_print_tags(repo, repo[r], fp=fp) | |
215 output = fp.getvalue().strip() | |
216 expected = expected.strip() | |
217 if expected == output: | |
218 return | |
219 expected = expected.splitlines() | |
220 output = output.splitlines() | |
221 diff = difflib.unified_diff(expected, output, 'expected', 'output') | |
222 self.assert_(False, '\n' + '\n'.join(diff)) | |
223 | |
224 def test_tagging_into_tag(self, expected=None, stupid=False): | |
225 expected = """\ | |
226 node: hg=test@2:svn=branches/test@4 | |
227 First tag. | |
228 test-0.1: hg=test@1:svn=branches/test@3 | |
229 | |
230 node: hg=test@3:svn=branches/test@5 | |
231 Weird tag. | |
232 test-0.1: hg=test@1:svn=branches/test@3 | |
233 test-0.1/test: hg=test@1:svn=branches/test@3 | |
234 """ | |
235 self._test_tags('renametagdir.svndump', expected) | |
236 | |
237 def test_tagging_into_tag_stupid(self): | |
238 # This test exposed existing flaws with tag handling in stupid mode. | |
239 # They will be resolved in the future. | |
240 expected = """\ | |
241 node: hg=test@2:svn=branches/test@4 | |
242 First tag. | |
243 test-0.1: hg=test@1:svn=branches/test@3 | |
244 | |
245 node: hg=test@4:svn=branches/test@4 | |
246 Weird tag. | |
247 test-0.1: hg=test@1:svn=branches/test@3 | |
248 test-0.1: hg=test@3:svn=tags/test-0.1@5 | |
249 | |
250 node: hg=test@5:svn=branches/test@5 | |
251 Weird tag. | |
252 test-0.1: hg=test@1:svn=branches/test@3 | |
253 test-0.1: hg=test@3:svn=tags/test-0.1@5 | |
254 test-0.1/test: hg=test@1:svn=branches/test@3 | |
255 """ | |
256 self._test_tags('renametagdir.svndump', expected, True) | |
257 | |
191 | 258 |
192 def suite(): | 259 def suite(): |
193 return unittest.TestLoader().loadTestsFromTestCase(TestTags) | 260 return unittest.TestLoader().loadTestsFromTestCase(TestTags) |