annotate tests/test_fetch_renames.py @ 1229:46523cdfd3b0 stable 1.6.3

pushmod: prepend "link " to base text for links http://svn.apache.org/viewvc?view=revision&revision=1223036 exposes what is arguably a bug in hgsubversion push code. Specifically, when we are receiving text from the server in an editor, we prepend a "link " to the text of symlinks when opening a file and strip it when closing a file. We don't, however, prepend "link " to the base we use when sending text changes to the server. This was working before because prior to that revision, the first thing subversion did was to check whether the entirety of the before text or the entirety of the after text was less than 64 bytes. In that case, it just sent the entirety of the after text as a single insert operation. I'd expect most, but not all symlinks to fit under the 64 byte limit, including the leading "link " text on the subversion end. After the change, the first thing subversion does is check for a leading match that is more than 4 bytes long, or that is the full length of the after text. In this case, it sends a copy operation for the leading match, and then goes into the if < 64 bytes remaining send the whole thing behavior. It also looks for trailing matches of more than 4 bytes even in the <64 byte case, but that's not what breaks the tests. Incidentally, changing the destination of long symlinks was broken even before this subversion change. This diff includes test additions that cover that breakage.
author David Schleimer <dschleimer@gmail.com>
date Thu, 07 Aug 2014 19:30:26 -0700
parents dc516f85b6c3
children 0d0132cba155
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 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):
1064
dc516f85b6c3 test_fetch_renames: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
7 stupid_mode_tests = True
dc516f85b6c3 test_fetch_renames: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
8
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
9 def _debug_print_copies(self, repo):
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
10 w = sys.stderr.write
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
11 for rev in repo:
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
12 ctx = repo[rev]
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
13 w('%d - %s\n' % (ctx.rev(), ctx.branch()))
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
14 for f in ctx:
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
15 fctx = ctx[f]
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
16 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
17
1064
dc516f85b6c3 test_fetch_renames: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
18 def test_rename(self):
944
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 833
diff changeset
19 config = {
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 833
diff changeset
20 'hgsubversion.filestoresize': '0',
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 833
diff changeset
21 }
1064
dc516f85b6c3 test_fetch_renames: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
22 repo = self._load_fixture_and_fetch('renames.svndump', config=config)
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
23
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
24 # 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
25 copies = {
68
e0c86ebe05e3 test_fetch_renames: test copy of deleted stuff from the past
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
26 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
27 'a1': ('a', 'a\n'),
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
28 'a2': ('a', 'a\n'),
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
29 'b1': ('b', 'b\nc\n'),
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
30 'da1/daf': ('da/daf', 'c\n'),
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
31 'da1/db/dbf': ('da/db/dbf', 'd\n'),
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
32 'da2/daf': ('da/daf', 'c\n'),
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
33 'da2/db/dbf': ('da/db/dbf', 'd\n'),
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
34 },
68
e0c86ebe05e3 test_fetch_renames: test copy of deleted stuff from the past
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
35 5: {
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
36 '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
37 },
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 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
39 '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
40 '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
41 },
5e0dfe59d4c3 copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents: 132
diff changeset
42 10: {
5e0dfe59d4c3 copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents: 132
diff changeset
43 'groupdir2/b': ('groupdir/b', 'b\n')
5e0dfe59d4c3 copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents: 132
diff changeset
44 },
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
45 }
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
46 for rev in repo:
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
47 ctx = repo[rev]
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
48 copymap = copies.get(rev, {})
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
49 for f in ctx.manifest():
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
50 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
51 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
52 '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
53 if not cp:
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
54 continue
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
55 self.assertEqual(cp[0], copymap[f][0])
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
56 self.assertEqual(ctx[f].data(), copymap[f][1])
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
57
130
c2a84d436202 test_fetch_rename: test content of files coming from the past
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
58 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
59
1064
dc516f85b6c3 test_fetch_renames: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
60 def test_case(self):
dc516f85b6c3 test_fetch_renames: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
61 repo = self._load_fixture_and_fetch('filecase.svndump')
132
3a9d6cd18332 test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents: 130
diff changeset
62 files = {
3a9d6cd18332 test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents: 130
diff changeset
63 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
64 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
65 }
3a9d6cd18332 test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents: 130
diff changeset
66 for rev in repo:
3a9d6cd18332 test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents: 130
diff changeset
67 self.assertEqual(sorted(files[rev]), sorted(repo[rev].manifest()))