Mercurial > hgsubversion
annotate tests/test_fetch_renames.py @ 97:0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
- SubversionRepo.get_file() strips the symlink prefix
- Enforce that hg_delta_editor symlink data always contains the prefix. The
alternative was seducing and more consistent with hg content but it makes the
code more complicated since svn:special can be set before or after the content
is set, and we need it in apply_textdelta()
This issue fixes jQuery repository conversion at r3674.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Thu, 20 Nov 2008 22:41:15 -0600 |
parents | 7d10165cf3d9 |
children | a3b717e4abf5 |
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 |
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
|
15 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
|
16 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
|
17 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
|
18 self.wc_path, stupid=stupid) |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
19 |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
20 def _debug_print_copies(self, repo): |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
21 w = sys.stderr.write |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
22 for rev in repo: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
23 ctx = repo[rev] |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
24 w('%d - %s\n' % (ctx.rev(), ctx.branch())) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
25 for f in ctx: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
26 fctx = ctx[f] |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
27 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
|
28 |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
29 def _test_rename(self, stupid): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
30 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
|
31 # self._debug_print_copies(repo) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
32 |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
33 # 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
|
34 copies = { |
68
e0c86ebe05e3
test_fetch_renames: test copy of deleted stuff from the past
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
35 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
|
36 'a1': ('a', 'a\n'), |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
37 'a2': ('a', 'a\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
38 'b1': ('b', 'b\nc\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
39 'da1/daf': ('da/daf', 'c\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
40 'da1/db/dbf': ('da/db/dbf', 'd\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
41 'da2/daf': ('da/daf', 'c\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
42 'da2/db/dbf': ('da/db/dbf', 'd\n'), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
43 }, |
68
e0c86ebe05e3
test_fetch_renames: test copy of deleted stuff from the past
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
44 5: { |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
45 '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
|
46 }, |
63ece4ea25c9
hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents:
68
diff
changeset
|
47 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
|
48 '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
|
49 'unchangeddir2/f': ('unchangeddir/f', 'unchanged2\n'), |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
50 } |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
51 } |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
52 for rev in repo: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
53 ctx = repo[rev] |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
54 copymap = copies.get(rev, {}) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
55 for f in ctx.manifest(): |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
56 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
|
57 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
|
58 '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
|
59 if not cp: |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
60 continue |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
61 self.assertEqual(cp[0], copymap[f][0]) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
62 self.assertEqual(ctx[f].data(), copymap[f][1]) |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
63 |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
64 def test_rename(self): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
65 self._test_rename(False) |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
66 |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
67 def test_rename_stupid(self): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
68 self._test_rename(True) |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
69
diff
changeset
|
69 |
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
70 def suite(): |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
71 all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchRenames), |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
72 ] |
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
73 return unittest.TestSuite(all) |