Mercurial > hgsubversion
annotate tests/test_fetch_renames.py @ 1017:c6e9889dba27
layouts: use layouts library for branch mappingduring push
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Mon, 29 Apr 2013 15:11:55 -0700 |
parents | d6db289f1548 |
children | d741f536f23a |
rev | line source |
---|---|
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
1 import test_util |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
2 |
643
d2ef7220a079
tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
513
diff
changeset
|
3 import sys |
d2ef7220a079
tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
513
diff
changeset
|
4 import unittest |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
5 |
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
|
6 class TestFetchRenames(test_util.TestBase): |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
7 def _debug_print_copies(self, repo): |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
8 w = sys.stderr.write |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
9 for rev in repo: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
10 ctx = repo[rev] |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
11 w('%d - %s\n' % (ctx.rev(), ctx.branch())) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
12 for f in ctx: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
13 fctx = ctx[f] |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
14 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
|
15 |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
16 def _test_rename(self, stupid): |
944
d6db289f1548
pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents:
833
diff
changeset
|
17 config = { |
d6db289f1548
pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents:
833
diff
changeset
|
18 'hgsubversion.filestoresize': '0', |
d6db289f1548
pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents:
833
diff
changeset
|
19 } |
d6db289f1548
pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents:
833
diff
changeset
|
20 repo = self._load_fixture_and_fetch('renames.svndump', stupid=stupid, |
d6db289f1548
pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents:
833
diff
changeset
|
21 config=config) |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
22 |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
23 # 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
|
24 copies = { |
68
e0c86ebe05e3
test_fetch_renames: test copy of deleted stuff from the past
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
25 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
|
26 'a1': ('a', 'a\n'), |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
27 'a2': ('a', 'a\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
28 'b1': ('b', 'b\nc\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
29 'da1/daf': ('da/daf', 'c\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
30 'da1/db/dbf': ('da/db/dbf', 'd\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
31 'da2/daf': ('da/daf', 'c\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
32 'da2/db/dbf': ('da/db/dbf', 'd\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
33 }, |
68
e0c86ebe05e3
test_fetch_renames: test copy of deleted stuff from the past
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
34 5: { |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
35 '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
|
36 }, |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
68
diff
changeset
|
37 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
|
38 '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
|
39 'unchangeddir2/f': ('unchangeddir/f', 'unchanged2\n'), |
496
5e0dfe59d4c3
copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents:
132
diff
changeset
|
40 }, |
5e0dfe59d4c3
copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents:
132
diff
changeset
|
41 10: { |
5e0dfe59d4c3
copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents:
132
diff
changeset
|
42 'groupdir2/b': ('groupdir/b', 'b\n') |
5e0dfe59d4c3
copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents:
132
diff
changeset
|
43 }, |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
44 } |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
45 for rev in repo: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
46 ctx = repo[rev] |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
47 copymap = copies.get(rev, {}) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
48 for f in ctx.manifest(): |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
49 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
|
50 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
|
51 '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
|
52 if not cp: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
53 continue |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
54 self.assertEqual(cp[0], copymap[f][0]) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
55 self.assertEqual(ctx[f].data(), copymap[f][1]) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
56 |
130
c2a84d436202
test_fetch_rename: test content of files coming from the past
Patrick Mezard <pmezard@gmail.com>
parents:
101
diff
changeset
|
57 self.assertEqual(repo['tip']['changed3'].data(), 'changed\nchanged3\n') |
c2a84d436202
test_fetch_rename: test content of files coming from the past
Patrick Mezard <pmezard@gmail.com>
parents:
101
diff
changeset
|
58 |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
59 def test_rename(self): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
60 self._test_rename(False) |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
61 |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
62 def test_rename_stupid(self): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
63 self._test_rename(True) |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
64 |
132
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
65 def _test_case(self, stupid): |
513
5c8a48828ae9
test renames: remove redundant code
Augie Fackler <durin42@gmail.com>
parents:
496
diff
changeset
|
66 repo = self._load_fixture_and_fetch('filecase.svndump', stupid=stupid) |
132
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
67 files = { |
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
68 0: ['A', 'a', 'e/a', 'b', 'd/a', 'D/a', 'f/a', 'F'], |
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
69 1: ['A', 'a', 'E/a', 'B', 'd/A', 'D/a', 'f/a', 'F'], |
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
70 } |
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
71 for rev in repo: |
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
72 self.assertEqual(sorted(files[rev]), sorted(repo[rev].manifest())) |
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
73 |
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
74 def test_case(self): |
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
75 self._test_case(False) |
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
76 |
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
77 def test_case_stupid(self): |
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
78 self._test_case(True) |
3a9d6cd18332
test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents:
130
diff
changeset
|
79 |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
80 def suite(): |
833
312b37bc5e20
tests: avoid shadowing Python builtin all()
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
81 all_tests = [unittest.TestLoader().loadTestsFromTestCase(TestFetchRenames), |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
82 ] |
833
312b37bc5e20
tests: avoid shadowing Python builtin all()
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
83 return unittest.TestSuite(all_tests) |