comparison tests/test_fetch_renames.py @ 67:e319c9168910

hg_delta_editor: register svn file copies
author Patrick Mezard <pmezard@gmail.com>
date Wed, 05 Nov 2008 13:37:07 +0100
parents
children e0c86ebe05e3
comparison
equal deleted inserted replaced
66:a31968146f3c 67:e319c9168910
1 import os
2 import shutil
3 import sys
4 import tempfile
5 import unittest
6
7 from mercurial import hg
8 from mercurial import ui
9 from mercurial import node
10
11 import fetch_command
12 import test_util
13
14
15 class TestFetchRenames(unittest.TestCase):
16 def setUp(self):
17 self.oldwd = os.getcwd()
18 self.tmpdir = tempfile.mkdtemp('svnwrap_test')
19 self.repo_path = '%s/testrepo' % self.tmpdir
20 self.wc_path = '%s/testrepo_wc' % self.tmpdir
21
22 def tearDown(self):
23 shutil.rmtree(self.tmpdir)
24 os.chdir(self.oldwd)
25
26 def _load_fixture_and_fetch(self, fixture_name):
27 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path,
28 self.wc_path)
29
30 def _debug_print_copies(self, repo):
31 w = sys.stderr.write
32 for rev in repo:
33 ctx = repo[rev]
34 w('%d - %s\n' % (ctx.rev(), ctx.branch()))
35 for f in ctx:
36 fctx = ctx[f]
37 w('%s: %r %r\n' % (f, fctx.data(), fctx.renamed()))
38
39 def test_rename(self):
40 repo = self._load_fixture_and_fetch('renames.svndump')
41 # self._debug_print_copies(repo)
42
43 # Map revnum to mappings of dest name to (source name, dest content)
44 copies = {
45 3: {
46 'a1': ('a', 'a\n'),
47 'a2': ('a', 'a\n'),
48 'b1': ('b', 'b\nc\n'),
49 'da1/daf': ('da/daf', 'c\n'),
50 'da1/db/dbf': ('da/db/dbf', 'd\n'),
51 'da2/daf': ('da/daf', 'c\n'),
52 'da2/db/dbf': ('da/db/dbf', 'd\n'),
53 },
54 4: {
55 'c1': ('c', 'c\nc\n'),
56 }
57 }
58 for rev in repo:
59 ctx = repo[rev]
60 copymap = copies.get(rev, {})
61 for f in ctx.manifest():
62 cp = ctx[f].renamed()
63 self.assertEqual(bool(cp), bool(copymap.get(f)))
64 if not cp:
65 continue
66 self.assertEqual(cp[0], copymap[f][0])
67 self.assertEqual(ctx[f].data(), copymap[f][1])
68
69 def suite():
70 all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchRenames),
71 ]
72 return unittest.TestSuite(all)