annotate tests/test_fetch_renames.py @ 1580:0d18108ec153

hgsubversion: fix something which looks like a cycle Motivated from av6 fixes in topic extension on cycles and our internal servers consuming a lot of memory, I found this.
author Pulkit Goyal <pulkit@yandex-team.ru>
date Fri, 03 Aug 2018 21:08:37 +0530
parents 6088597abd20
children
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',
1235
6b15eeb78c1a editor: fix replay handling for copied + modified symlinks
David Schleimer <dschleimer@fb.com>
parents: 1234
diff changeset
21 # we set this because we expect all of the copies to be
6b15eeb78c1a editor: fix replay handling for copied + modified symlinks
David Schleimer <dschleimer@fb.com>
parents: 1234
diff changeset
22 # handled via replay, and we want to notice if that
6b15eeb78c1a editor: fix replay handling for copied + modified symlinks
David Schleimer <dschleimer@fb.com>
parents: 1234
diff changeset
23 # changes.
6b15eeb78c1a editor: fix replay handling for copied + modified symlinks
David Schleimer <dschleimer@fb.com>
parents: 1234
diff changeset
24 'hgsubversion.failonmissing': 'yes',
944
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 833
diff changeset
25 }
1064
dc516f85b6c3 test_fetch_renames: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
26 repo = self._load_fixture_and_fetch('renames.svndump', config=config)
1234
d3c79072bc6a editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents: 1233
diff changeset
27 self._run_assertions(repo)
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
28
1234
d3c79072bc6a editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents: 1233
diff changeset
29 def test_rename_with_prefix(self):
d3c79072bc6a editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents: 1233
diff changeset
30 config = {
d3c79072bc6a editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents: 1233
diff changeset
31 'hgsubversion.filestoresize': '0',
1235
6b15eeb78c1a editor: fix replay handling for copied + modified symlinks
David Schleimer <dschleimer@fb.com>
parents: 1234
diff changeset
32 'hgsubversion.failonmissing': 'yes',
1234
d3c79072bc6a editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents: 1233
diff changeset
33 }
d3c79072bc6a editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents: 1233
diff changeset
34 repo = self._load_fixture_and_fetch('renames_with_prefix.svndump',
d3c79072bc6a editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents: 1233
diff changeset
35 subdir='prefix',
d3c79072bc6a editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents: 1233
diff changeset
36 config=config)
1485
6088597abd20 test_fetch_renames: avoid hash randomization bug in test
Augie Fackler <raf@durin42.com>
parents: 1484
diff changeset
37 self._run_assertions(repo, prefix=True)
1234
d3c79072bc6a editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents: 1233
diff changeset
38
1485
6088597abd20 test_fetch_renames: avoid hash randomization bug in test
Augie Fackler <raf@durin42.com>
parents: 1484
diff changeset
39 def _run_assertions(self, repo, prefix=False):
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
40 # Map revnum to mappings of dest name to (source name, dest content)
1485
6088597abd20 test_fetch_renames: avoid hash randomization bug in test
Augie Fackler <raf@durin42.com>
parents: 1484
diff changeset
41 if prefix:
6088597abd20 test_fetch_renames: avoid hash randomization bug in test
Augie Fackler <raf@durin42.com>
parents: 1484
diff changeset
42 prefixlen = len('svn:ae30a990-0fd3-493e-b5d7-883bdd606745/prefix')
6088597abd20 test_fetch_renames: avoid hash randomization bug in test
Augie Fackler <raf@durin42.com>
parents: 1484
diff changeset
43 else:
6088597abd20 test_fetch_renames: avoid hash randomization bug in test
Augie Fackler <raf@durin42.com>
parents: 1484
diff changeset
44 prefixlen = len('svn:ae30a990-0fd3-493e-b5d7-883bdd606745')
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
45 copies = {
1485
6088597abd20 test_fetch_renames: avoid hash randomization bug in test
Augie Fackler <raf@durin42.com>
parents: 1484
diff changeset
46 '/trunk@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
47 'a1': ('a', 'a\n'),
1233
0d0132cba155 editor: fix edge case with in memory file-store size limit
David Schleimer <dschleimer@fb.com>
parents: 1064
diff changeset
48 'linka1': ('linka', 'a'),
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
49 'a2': ('a', 'a\n'),
1233
0d0132cba155 editor: fix edge case with in memory file-store size limit
David Schleimer <dschleimer@fb.com>
parents: 1064
diff changeset
50 'linka2': ('linka', 'a'),
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
51 'b1': ('b', 'b\nc\n'),
1233
0d0132cba155 editor: fix edge case with in memory file-store size limit
David Schleimer <dschleimer@fb.com>
parents: 1064
diff changeset
52 'linkb1': ('linkb', 'bc'),
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
53 'da1/daf': ('da/daf', 'c\n'),
1233
0d0132cba155 editor: fix edge case with in memory file-store size limit
David Schleimer <dschleimer@fb.com>
parents: 1064
diff changeset
54 'da1/dalink': ('da/dalink', 'daf'),
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
55 'da1/db/dbf': ('da/db/dbf', 'd\n'),
1233
0d0132cba155 editor: fix edge case with in memory file-store size limit
David Schleimer <dschleimer@fb.com>
parents: 1064
diff changeset
56 'da1/db/dblink': ('da/db/dblink', '../daf'),
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
57 'da2/daf': ('da/daf', 'c\n'),
1233
0d0132cba155 editor: fix edge case with in memory file-store size limit
David Schleimer <dschleimer@fb.com>
parents: 1064
diff changeset
58 'da2/dalink': ('da/dalink', 'daf'),
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
59 'da2/db/dbf': ('da/db/dbf', 'd\n'),
1233
0d0132cba155 editor: fix edge case with in memory file-store size limit
David Schleimer <dschleimer@fb.com>
parents: 1064
diff changeset
60 'da2/db/dblink': ('da/db/dblink', '../daf'),
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
61 },
1485
6088597abd20 test_fetch_renames: avoid hash randomization bug in test
Augie Fackler <raf@durin42.com>
parents: 1484
diff changeset
62 '/branches/branch1@6': {
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
63 'c1': ('c', 'c\nc\n'),
1233
0d0132cba155 editor: fix edge case with in memory file-store size limit
David Schleimer <dschleimer@fb.com>
parents: 1064
diff changeset
64 'linkc1': ('linkc', 'cc'),
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
65 },
1485
6088597abd20 test_fetch_renames: avoid hash randomization bug in test
Augie Fackler <raf@durin42.com>
parents: 1484
diff changeset
66 '/trunk@10': {
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
67 'unchanged2': ('unchanged', 'unchanged\n'),
1233
0d0132cba155 editor: fix edge case with in memory file-store size limit
David Schleimer <dschleimer@fb.com>
parents: 1064
diff changeset
68 'unchangedlink2': ('unchangedlink', 'unchanged'),
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
69 'unchangeddir2/f': ('unchangeddir/f', 'unchanged2\n'),
1233
0d0132cba155 editor: fix edge case with in memory file-store size limit
David Schleimer <dschleimer@fb.com>
parents: 1064
diff changeset
70 'unchangeddir2/link': ('unchangeddir/link', 'f'),
496
5e0dfe59d4c3 copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents: 132
diff changeset
71 },
1485
6088597abd20 test_fetch_renames: avoid hash randomization bug in test
Augie Fackler <raf@durin42.com>
parents: 1484
diff changeset
72 '/trunk@11': {
1233
0d0132cba155 editor: fix edge case with in memory file-store size limit
David Schleimer <dschleimer@fb.com>
parents: 1064
diff changeset
73 'groupdir2/b': ('groupdir/b', 'b\n'),
0d0132cba155 editor: fix edge case with in memory file-store size limit
David Schleimer <dschleimer@fb.com>
parents: 1064
diff changeset
74 'groupdir2/linkb': ('groupdir/linkb', 'b'),
496
5e0dfe59d4c3 copies: fix under-reporting of copies in hg
Augie Fackler <durin42@gmail.com>
parents: 132
diff changeset
75 },
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
76 }
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
77 for rev in repo:
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
78 ctx = repo[rev]
1485
6088597abd20 test_fetch_renames: avoid hash randomization bug in test
Augie Fackler <raf@durin42.com>
parents: 1484
diff changeset
79 copymap = copies.get(ctx.extra()['convert_revision'][prefixlen:],
6088597abd20 test_fetch_renames: avoid hash randomization bug in test
Augie Fackler <raf@durin42.com>
parents: 1484
diff changeset
80 {})
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
81 for f in ctx.manifest():
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
82 cp = ctx[f].renamed()
1483
4379baf58f9e test_fetch_renames: refactoring to make debugging easier
Augie Fackler <raf@durin42.com>
parents: 1235
diff changeset
83 want = copymap.get(f)
4379baf58f9e test_fetch_renames: refactoring to make debugging easier
Augie Fackler <raf@durin42.com>
parents: 1235
diff changeset
84 self.assertEqual(
4379baf58f9e test_fetch_renames: refactoring to make debugging easier
Augie Fackler <raf@durin42.com>
parents: 1235
diff changeset
85 bool(cp), bool(want),
4379baf58f9e test_fetch_renames: refactoring to make debugging easier
Augie Fackler <raf@durin42.com>
parents: 1235
diff changeset
86 'copy records differ for %s in %d (want %r, got %r)' % (
4379baf58f9e test_fetch_renames: refactoring to make debugging easier
Augie Fackler <raf@durin42.com>
parents: 1235
diff changeset
87 f, rev, want, cp))
1484
9f1fa3cc6ba5 test_fetch_renames: change how this if statement works
Augie Fackler <raf@durin42.com>
parents: 1483
diff changeset
88 if cp:
9f1fa3cc6ba5 test_fetch_renames: change how this if statement works
Augie Fackler <raf@durin42.com>
parents: 1483
diff changeset
89 self.assertEqual(cp[0], want[0])
9f1fa3cc6ba5 test_fetch_renames: change how this if statement works
Augie Fackler <raf@durin42.com>
parents: 1483
diff changeset
90 self.assertEqual(ctx[f].data(), want[1])
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
91
130
c2a84d436202 test_fetch_rename: test content of files coming from the past
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
92 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
93
1064
dc516f85b6c3 test_fetch_renames: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
94 def test_case(self):
dc516f85b6c3 test_fetch_renames: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
95 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
96 files = {
3a9d6cd18332 test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents: 130
diff changeset
97 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
98 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
99 }
3a9d6cd18332 test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents: 130
diff changeset
100 for rev in repo:
3a9d6cd18332 test_fetch_renames: test file and directory case changes
Patrick Mezard <pmezard@gmail.com>
parents: 130
diff changeset
101 self.assertEqual(sorted(files[rev]), sorted(repo[rev].manifest()))