Mercurial > hgsubversion
annotate tests/test_fetch_renames.py @ 104:f046564b2916
fetch_command: remove useless delete_all_files case
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Tue, 25 Nov 2008 09:18:27 -0600 |
parents | a3b717e4abf5 |
children | c2a84d436202 |
rev | line source |
---|---|
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
1 import sys |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
2 import unittest |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
3 |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
4 import test_util |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
5 |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
6 |
91
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
78
diff
changeset
|
7 class TestFetchRenames(test_util.TestBase): |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
8 def _load_fixture_and_fetch(self, fixture_name, stupid): |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
9 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path, |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
10 self.wc_path, stupid=stupid) |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
11 |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
12 def _debug_print_copies(self, repo): |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
13 w = sys.stderr.write |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
14 for rev in repo: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
15 ctx = repo[rev] |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
16 w('%d - %s\n' % (ctx.rev(), ctx.branch())) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
17 for f in ctx: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
18 fctx = ctx[f] |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
19 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
|
20 |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
21 def _test_rename(self, stupid): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
22 repo = self._load_fixture_and_fetch('renames.svndump', stupid) |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
23 # self._debug_print_copies(repo) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
24 |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
25 # 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
|
26 copies = { |
68
e0c86ebe05e3
test_fetch_renames: test copy of deleted stuff from the past
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
27 4: { |
91
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
78
diff
changeset
|
28 'a1': ('a', 'a\n'), |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
29 'a2': ('a', 'a\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
30 'b1': ('b', 'b\nc\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
31 'da1/daf': ('da/daf', 'c\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
32 'da1/db/dbf': ('da/db/dbf', 'd\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
33 'da2/daf': ('da/daf', 'c\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
34 'da2/db/dbf': ('da/db/dbf', 'd\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
35 }, |
68
e0c86ebe05e3
test_fetch_renames: test copy of deleted stuff from the past
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
36 5: { |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
37 'c1': ('c', 'c\nc\n'), |
69
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
68
diff
changeset
|
38 }, |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
68
diff
changeset
|
39 9: { |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
68
diff
changeset
|
40 'unchanged2': ('unchanged', 'unchanged\n'), |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
68
diff
changeset
|
41 'unchangeddir2/f': ('unchangeddir/f', 'unchanged2\n'), |
67
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 } |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
44 for rev in repo: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
45 ctx = repo[rev] |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
46 copymap = copies.get(rev, {}) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
47 for f in ctx.manifest(): |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
48 cp = ctx[f].renamed() |
69
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
68
diff
changeset
|
49 self.assertEqual(bool(cp), bool(copymap.get(f)), |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
68
diff
changeset
|
50 'copy records differ for %s in %d' % (f, rev)) |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
51 if not cp: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
52 continue |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
53 self.assertEqual(cp[0], copymap[f][0]) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
54 self.assertEqual(ctx[f].data(), copymap[f][1]) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
55 |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
56 def test_rename(self): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
57 self._test_rename(False) |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
58 |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
59 def test_rename_stupid(self): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
60 self._test_rename(True) |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
61 |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
62 def suite(): |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
63 all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchRenames), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
64 ] |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
65 return unittest.TestSuite(all) |