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