Mercurial > hgsubversion
annotate tests/test_push_renames.py @ 1002:117b3b421294
buildmeta: verify uuid when passed explicit url
2c87bdc43d3c changed buildmeta to read the uuid from local disk, if
it's available. As a side effect, it disabled the validation of the
uuid we've recorded locall in the commits against the uuid of the repo
we are building against. This is probably reasonable when someone
runs a bare updatemeta or rebuildmeta. I think it's a worthwhile
sanity check when someone passes an explicit repository url to
rebuild/updatemeta. This restores the validation in that case, and
fixes a failing test in the process.
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Fri, 12 Apr 2013 10:51:42 -0700 |
parents | a279b5838aaf |
children | d741f536f23a |
rev | line source |
---|---|
643
d2ef7220a079
tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
512
diff
changeset
|
1 import test_util |
d2ef7220a079
tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
512
diff
changeset
|
2 |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
3 import sys |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
4 import unittest |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
5 |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
6 class TestPushRenames(test_util.TestBase): |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
7 def setUp(self): |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
8 test_util.TestBase.setUp(self) |
872
a279b5838aaf
test_util: remove self.repo_path, generate new paths each time
Patrick Mezard <patrick@mezard.eu>
parents:
869
diff
changeset
|
9 self.repo_path = self.load_and_fetch('pushrenames.svndump', |
a279b5838aaf
test_util: remove self.repo_path, generate new paths each time
Patrick Mezard <patrick@mezard.eu>
parents:
869
diff
changeset
|
10 stupid=True)[1] |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
11 |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
12 def _debug_print_copies(self, ctx): |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
13 w = sys.stderr.write |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
14 for f in ctx.files(): |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
15 if f not in ctx: |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
16 w('R %s\n' % f) |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
17 else: |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
18 w('U %s %r\n' % (f, ctx[f].data())) |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
19 if ctx[f].renamed(): |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
20 w('%s copied from %s\n' % (f, ctx[f].renamed()[0])) |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
21 |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
22 def test_push_renames(self): |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
23 repo = self.repo |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
24 |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
25 changes = [ |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
26 # Regular copy of a single file |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
27 ('a', 'a2', None), |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
28 # Copy and update of target |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
29 ('a', 'a3', 'aa\n'), |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
30 # Regular move of a single file |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
31 ('b', 'b2', None), |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
32 ('b', None, None), |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
33 # Regular move and update of target |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
34 ('c', 'c2', 'c\nc\n'), |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
35 ('c', None, None), |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
36 # Copy and update of source and targets |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
37 ('d', 'd2', 'd\nd2\n'), |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
38 ('d', 'd', 'd\nd\n'), |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
39 # Double copy and removal (aka copy and move) |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
40 ('e', 'e2', 'e\ne2\n'), |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
41 ('e', 'e3', 'e\ne3\n'), |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
42 ('e', None, None), |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
43 ] |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
44 self.commitchanges(changes) |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
45 self.pushrevisions() |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
46 tip = self.repo['tip'] |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
47 # self._debug_print_copies(tip) |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
48 self.assertchanges(changes, tip) |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
49 |
512
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
50 def test_push_rename_with_space(self): |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
51 changes = [ |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
52 ('random/dir with space/file with space', |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
53 'random/dir with space/file with space', |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
54 'file contents'), |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
55 ] |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
56 self.commitchanges(changes) |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
57 |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
58 changes = [ |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
59 ('random/dir with space/file with space', |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
60 'random2/dir with space/file with space', |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
61 None), |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
62 ('random/dir with space/file with space', |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
63 None, None), |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
64 ] |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
65 self.commitchanges(changes) |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
66 self.pushrevisions() |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
67 self.assertEqual(self.repo['tip'].manifest().keys(), |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
68 ['a', 'c', 'b', 'e', 'd', |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
69 'random2/dir with space/file with space']) |
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
323
diff
changeset
|
70 |
323
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
71 def test_push_rename_tree(self): |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
72 repo = self.repo |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
73 |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
74 changes = [ |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
75 ('geek/alpha', 'geek/alpha', 'content',), |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
76 ('geek/beta', 'geek/beta', 'content',), |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
77 ('geek/delta', 'geek/delta', 'content',), |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
78 ('geek/gamma', 'geek/gamma', 'content',), |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
79 ('geek/later/pi', 'geek/later/pi', 'content geek/later/pi',), |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
80 ('geek/later/rho', 'geek/later/rho', 'content geek/later/rho',), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
81 ('geek/other/blah', 'geek/other/blah', 'content geek/other/blah',), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
82 ('geek/other/another/layer', 'geek/other/another/layer', 'content deep file',), |
323
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
83 ] |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
84 |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
85 self.commitchanges(changes) |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
86 self.pushrevisions() |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
87 self.assertchanges(changes, self.repo['tip']) |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
88 |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
89 changes = [ |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
90 # rename (copy + remove) all of geek to greek |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
91 ('geek/alpha', 'greek/alpha', None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
92 ('geek/beta', 'greek/beta', None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
93 ('geek/delta', 'greek/delta', None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
94 ('geek/gamma', 'greek/gamma', None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
95 ('geek/later/pi', 'greek/later/pi', None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
96 ('geek/later/rho', 'greek/later/rho', None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
97 ('geek/other/blah', 'greek/other/blah', None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
98 ('geek/other/another/layer', 'greek/other/another/layer', None,), |
323
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
99 |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
100 ('geek/alpha', None, None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
101 ('geek/beta', None, None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
102 ('geek/delta', None, None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
103 ('geek/gamma', None, None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
104 ('geek/later/pi', None, None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
105 ('geek/later/rho', None, None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
106 ('geek/other/blah', None, None,), |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
643
diff
changeset
|
107 ('geek/other/another/layer', None, None,), |
323
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
108 ] |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
109 self.commitchanges(changes) |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
110 self.pushrevisions() |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
111 assert reduce(lambda x, y: x and y, |
869
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
865
diff
changeset
|
112 ('geek' not in f for f in test_util.svnls(self.repo_path, 'trunk'))), ( |
323
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
113 'This failure means rename of an entire tree is broken.' |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
114 ' There is a print on the preceding line commented out ' |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
115 'that should help you.') |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
116 |
067914ecb4eb
push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents:
96
diff
changeset
|
117 |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
118 def suite(): |
833
312b37bc5e20
tests: avoid shadowing Python builtin all()
Yonggang Luo <luoyonggang@gmail.com>
parents:
832
diff
changeset
|
119 all_tests = [unittest.TestLoader().loadTestsFromTestCase(TestPushRenames), |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
120 ] |
833
312b37bc5e20
tests: avoid shadowing Python builtin all()
Yonggang Luo <luoyonggang@gmail.com>
parents:
832
diff
changeset
|
121 return unittest.TestSuite(all_tests) |