Mercurial > hgsubversion
comparison tests/test_push_command.py @ 1570:d55c9d0ba350
tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
author | Paul Morelle <paul.morelle@octobus.net> |
---|---|
date | Fri, 25 May 2018 11:52:03 +0200 |
parents | cff81f35b31e |
children | 2b342625a92a |
comparison
equal
deleted
inserted
replaced
1569:4afe8d7e4602 | 1570:d55c9d0ba350 |
---|---|
21 from hgsubversion import util | 21 from hgsubversion import util |
22 from hgsubversion import compathacks | 22 from hgsubversion import compathacks |
23 | 23 |
24 import time | 24 import time |
25 | 25 |
26 revsymbol = test_util.revsymbol | |
27 | |
26 | 28 |
27 class PushTests(test_util.TestBase): | 29 class PushTests(test_util.TestBase): |
28 obsolete_mode_tests = True | 30 obsolete_mode_tests = True |
29 | 31 |
30 def setUp(self): | 32 def setUp(self): |
42 islink=False, | 44 islink=False, |
43 isexec=False, | 45 isexec=False, |
44 copied=False) | 46 copied=False) |
45 raise IOError() | 47 raise IOError() |
46 ctx = context.memctx(repo, | 48 ctx = context.memctx(repo, |
47 (repo['default'].node(), node.nullid), | 49 (revsymbol(repo, 'default').node(), node.nullid), |
48 'automated test', | 50 'automated test', |
49 [], | 51 [], |
50 file_callback, | 52 file_callback, |
51 'an_author', | 53 'an_author', |
52 '2008-10-07 20:59:48 -0500', | 54 '2008-10-07 20:59:48 -0500', |
53 {'branch': 'default', }) | 55 {'branch': 'default', }) |
54 new_hash = repo.commitctx(ctx) | 56 new_hash = repo.commitctx(ctx) |
55 hg.update(repo, repo['tip'].node()) | 57 hg.update(repo, revsymbol(repo, 'tip').node()) |
56 old_tip = repo['tip'].node() | 58 old_tip = revsymbol(repo, 'tip').node() |
57 self.pushrevisions() | 59 self.pushrevisions() |
58 tip = self.repo['tip'] | 60 tip = revsymbol(self.repo, 'tip') |
59 self.assertEqual(tip.node(), old_tip) | 61 self.assertEqual(tip.node(), old_tip) |
60 | 62 |
61 def test_push_add_of_added_upstream_gives_sane_error(self): | 63 def test_push_add_of_added_upstream_gives_sane_error(self): |
62 repo = self.repo | 64 repo = self.repo |
63 def file_callback(repo, memctx, path): | 65 def file_callback(repo, memctx, path): |
68 data='foo', | 70 data='foo', |
69 islink=False, | 71 islink=False, |
70 isexec=False, | 72 isexec=False, |
71 copied=False) | 73 copied=False) |
72 raise IOError() | 74 raise IOError() |
73 p1 = repo['default'].node() | 75 p1 = revsymbol(repo, 'default').node() |
74 ctx = context.memctx(repo, | 76 ctx = context.memctx(repo, |
75 (p1, node.nullid), | 77 (p1, node.nullid), |
76 'automated test', | 78 'automated test', |
77 ['adding_file'], | 79 ['adding_file'], |
78 file_callback, | 80 file_callback, |
79 'an_author', | 81 'an_author', |
80 '2008-10-07 20:59:48 -0500', | 82 '2008-10-07 20:59:48 -0500', |
81 {'branch': 'default', }) | 83 {'branch': 'default', }) |
82 new_hash = repo.commitctx(ctx) | 84 new_hash = repo.commitctx(ctx) |
83 hg.update(repo, repo['tip'].node()) | 85 hg.update(repo, revsymbol(repo, 'tip').node()) |
84 old_tip = repo['tip'].node() | 86 old_tip = revsymbol(repo, 'tip').node() |
85 self.pushrevisions() | 87 self.pushrevisions() |
86 tip = self.repo['tip'] | 88 tip = revsymbol(self.repo, 'tip') |
87 self.assertNotEqual(tip.node(), old_tip) | 89 self.assertNotEqual(tip.node(), old_tip) |
88 | 90 |
89 # This node adds the same file as the first one we added, and | 91 # This node adds the same file as the first one we added, and |
90 # will be refused by the server for adding a file that already | 92 # will be refused by the server for adding a file that already |
91 # exists. We should respond with an error suggesting the user | 93 # exists. We should respond with an error suggesting the user |
97 file_callback, | 99 file_callback, |
98 'an_author', | 100 'an_author', |
99 '2008-10-07 20:59:48 -0500', | 101 '2008-10-07 20:59:48 -0500', |
100 {'branch': 'default', }) | 102 {'branch': 'default', }) |
101 new_hash = repo.commitctx(ctx) | 103 new_hash = repo.commitctx(ctx) |
102 hg.update(repo, repo['tip'].node()) | 104 hg.update(repo, revsymbol(repo, 'tip').node()) |
103 old_tip = repo['tip'].node() | 105 old_tip = revsymbol(repo, 'tip').node() |
104 try: | 106 try: |
105 self.pushrevisions() | 107 self.pushrevisions() |
106 except hgerror.Abort, e: | 108 except hgerror.Abort, e: |
107 assert "pull again and rebase" in str(e) | 109 assert "pull again and rebase" in str(e) |
108 tip = self.repo['tip'] | 110 tip = revsymbol(self.repo, 'tip') |
109 self.assertEqual(tip.node(), old_tip) | 111 self.assertEqual(tip.node(), old_tip) |
110 | 112 |
111 def test_cant_push_with_changes(self): | 113 def test_cant_push_with_changes(self): |
112 repo = self.repo | 114 repo = self.repo |
113 def file_callback(repo, memctx, path): | 115 def file_callback(repo, memctx, path): |
117 data='foo', | 119 data='foo', |
118 islink=False, | 120 islink=False, |
119 isexec=False, | 121 isexec=False, |
120 copied=False) | 122 copied=False) |
121 ctx = context.memctx(repo, | 123 ctx = context.memctx(repo, |
122 (repo['default'].node(), node.nullid), | 124 (revsymbol(repo, 'default').node(), node.nullid), |
123 'automated test', | 125 'automated test', |
124 ['adding_file'], | 126 ['adding_file'], |
125 file_callback, | 127 file_callback, |
126 'an_author', | 128 'an_author', |
127 '2008-10-07 20:59:48 -0500', | 129 '2008-10-07 20:59:48 -0500', |
128 {'branch': 'default', }) | 130 {'branch': 'default', }) |
129 new_hash = repo.commitctx(ctx) | 131 new_hash = repo.commitctx(ctx) |
130 hg.update(repo, repo['tip'].node()) | 132 hg.update(repo, revsymbol(repo, 'tip').node()) |
131 # Touch an existing file | 133 # Touch an existing file |
132 repo.wwrite('beta', 'something else', '') | 134 repo.wwrite('beta', 'something else', '') |
133 try: | 135 try: |
134 self.pushrevisions() | 136 self.pushrevisions() |
135 except hgerror.Abort: | 137 except hgerror.Abort: |
136 pass | 138 pass |
137 tip = self.repo['tip'] | 139 tip = revsymbol(self.repo, 'tip') |
138 self.assertEqual(new_hash, tip.node()) | 140 self.assertEqual(new_hash, tip.node()) |
139 | 141 |
140 def internal_push_over_svnserve(self, subdir='', commit=True): | 142 def internal_push_over_svnserve(self, subdir='', commit=True): |
141 repo_path = self.load_svndump('simple_branch.svndump') | 143 repo_path = self.load_svndump('simple_branch.svndump') |
142 open(os.path.join(repo_path, 'conf', 'svnserve.conf'), | 144 open(os.path.join(repo_path, 'conf', 'svnserve.conf'), |
191 commands.clone(self.ui(), | 193 commands.clone(self.ui(), |
192 urlfmt % (self.host, self.port, subdir), | 194 urlfmt % (self.host, self.port, subdir), |
193 self.wc_path, noupdate=True) | 195 self.wc_path, noupdate=True) |
194 | 196 |
195 repo = self.repo | 197 repo = self.repo |
196 old_tip = repo['tip'].node() | 198 old_tip = revsymbol(repo, 'tip').node() |
197 expected_parent = repo['default'].node() | 199 expected_parent = revsymbol(repo, 'default').node() |
198 def file_callback(repo, memctx, path): | 200 def file_callback(repo, memctx, path): |
199 if path == 'adding_file': | 201 if path == 'adding_file': |
200 return compathacks.makememfilectx(repo, | 202 return compathacks.makememfilectx(repo, |
201 memctx=memctx, | 203 memctx=memctx, |
202 path=path, | 204 path=path, |
204 islink=False, | 206 islink=False, |
205 isexec=False, | 207 isexec=False, |
206 copied=False) | 208 copied=False) |
207 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 209 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
208 ctx = context.memctx(repo, | 210 ctx = context.memctx(repo, |
209 parents=(repo['default'].node(), node.nullid), | 211 parents=(revsymbol(repo, 'default').node(), node.nullid), |
210 text='automated test', | 212 text='automated test', |
211 files=['adding_file'], | 213 files=['adding_file'], |
212 filectxfn=file_callback, | 214 filectxfn=file_callback, |
213 user='an_author', | 215 user='an_author', |
214 date='2008-10-07 20:59:48 -0500', | 216 date='2008-10-07 20:59:48 -0500', |
215 extra={'branch': 'default', }) | 217 extra={'branch': 'default', }) |
216 new_hash = repo.commitctx(ctx) | 218 new_hash = repo.commitctx(ctx) |
217 if not commit: | 219 if not commit: |
218 return # some tests use this test as an extended setup. | 220 return # some tests use this test as an extended setup. |
219 hg.update(repo, repo['tip'].node()) | 221 hg.update(repo, revsymbol(repo, 'tip').node()) |
220 oldauthor = repo['tip'].user() | 222 oldauthor = revsymbol(repo, 'tip').user() |
221 commands.push(repo.ui, repo) | 223 commands.push(repo.ui, repo) |
222 tip = self.repo['tip'] | 224 tip = revsymbol(self.repo, 'tip') |
223 self.assertNotEqual(oldauthor, tip.user()) | 225 self.assertNotEqual(oldauthor, tip.user()) |
224 self.assertNotEqual(tip.node(), old_tip) | 226 self.assertNotEqual(tip.node(), old_tip) |
225 self.assertEqual(tip.parents()[0].node(), expected_parent) | 227 self.assertEqual(tip.parents()[0].node(), expected_parent) |
226 self.assertEqual(tip['adding_file'].data(), 'foo') | 228 self.assertEqual(tip['adding_file'].data(), 'foo') |
227 self.assertEqual(tip.branch(), 'default') | 229 self.assertEqual(tip.branch(), 'default') |
240 def test_push_over_svnserve_with_subdir(self): | 242 def test_push_over_svnserve_with_subdir(self): |
241 self.internal_push_over_svnserve(subdir='///branches////the_branch/////') | 243 self.internal_push_over_svnserve(subdir='///branches////the_branch/////') |
242 | 244 |
243 def test_push_to_default(self, commit=True): | 245 def test_push_to_default(self, commit=True): |
244 repo = self.repo | 246 repo = self.repo |
245 old_tip = repo['tip'].node() | 247 old_tip = revsymbol(repo, 'tip').node() |
246 expected_parent = repo['default'].node() | 248 expected_parent = revsymbol(repo, 'default').node() |
247 def file_callback(repo, memctx, path): | 249 def file_callback(repo, memctx, path): |
248 if path == 'adding_file': | 250 if path == 'adding_file': |
249 return compathacks.makememfilectx(repo, | 251 return compathacks.makememfilectx(repo, |
250 memctx=memctx, | 252 memctx=memctx, |
251 path=path, | 253 path=path, |
253 islink=False, | 255 islink=False, |
254 isexec=False, | 256 isexec=False, |
255 copied=False) | 257 copied=False) |
256 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 258 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
257 ctx = context.memctx(repo, | 259 ctx = context.memctx(repo, |
258 (repo['default'].node(), node.nullid), | 260 (revsymbol(repo, 'default').node(), node.nullid), |
259 'automated test', | 261 'automated test', |
260 ['adding_file'], | 262 ['adding_file'], |
261 file_callback, | 263 file_callback, |
262 'an_author', | 264 'an_author', |
263 '2008-10-07 20:59:48 -0500', | 265 '2008-10-07 20:59:48 -0500', |
264 {'branch': 'default', }) | 266 {'branch': 'default', }) |
265 new_hash = repo.commitctx(ctx) | 267 new_hash = repo.commitctx(ctx) |
266 if not commit: | 268 if not commit: |
267 return # some tests use this test as an extended setup. | 269 return # some tests use this test as an extended setup. |
268 hg.update(repo, repo['tip'].node()) | 270 hg.update(repo, revsymbol(repo, 'tip').node()) |
269 self.pushrevisions() | 271 self.pushrevisions() |
270 tip = self.repo['tip'] | 272 tip = revsymbol(self.repo, 'tip') |
271 self.assertNotEqual(tip.node(), old_tip) | 273 self.assertNotEqual(tip.node(), old_tip) |
272 self.assertEqual(node.hex(tip.parents()[0].node()), | 274 self.assertEqual(node.hex(tip.parents()[0].node()), |
273 node.hex(expected_parent)) | 275 node.hex(expected_parent)) |
274 self.assertEqual(tip['adding_file'].data(), 'foo') | 276 self.assertEqual(tip['adding_file'].data(), 'foo') |
275 self.assertEqual(tip.branch(), 'default') | 277 self.assertEqual(tip.branch(), 'default') |
281 path=path, | 283 path=path, |
282 data=path, | 284 data=path, |
283 islink=False, | 285 islink=False, |
284 isexec=False, | 286 isexec=False, |
285 copied=False) | 287 copied=False) |
286 oldtiphash = self.repo['default'].node() | 288 oldtiphash = revsymbol(self.repo, 'default').node() |
287 lr = self.repo | 289 lr = self.repo |
288 ctx = context.memctx(lr, | 290 ctx = context.memctx(lr, |
289 (lr[0].node(), revlog.nullid,), | 291 (lr[0].node(), revlog.nullid,), |
290 'automated test', | 292 'automated test', |
291 ['gamma', ], | 293 ['gamma', ], |
304 {'branch': 'localbranch', }) | 306 {'branch': 'localbranch', }) |
305 newhash = lr.commitctx(ctx) | 307 newhash = lr.commitctx(ctx) |
306 repo = self.repo | 308 repo = self.repo |
307 hg.update(repo, newhash) | 309 hg.update(repo, newhash) |
308 commands.push(repo.ui, repo) | 310 commands.push(repo.ui, repo) |
309 self.assertEqual(self.repo['tip'].parents()[0].parents()[0].node(), oldtiphash) | 311 self.assertEqual(revsymbol(self.repo, 'tip').parents()[0].parents()[0].node(), oldtiphash) |
310 self.assertEqual(self.repo['tip'].files(), ['delta', ]) | 312 self.assertEqual(revsymbol(self.repo, 'tip').files(), ['delta', ]) |
311 self.assertEqual(sorted(self.repo['tip'].manifest().keys()), | 313 self.assertEqual(sorted(revsymbol(self.repo, 'tip').manifest().keys()), |
312 ['alpha', 'beta', 'delta', 'gamma']) | 314 ['alpha', 'beta', 'delta', 'gamma']) |
313 | 315 |
314 def test_push_two_revs(self): | 316 def test_push_two_revs(self): |
315 # set up some work for us | 317 # set up some work for us |
316 self.test_push_to_default(commit=False) | 318 self.test_push_to_default(commit=False) |
317 repo = self.repo | 319 repo = self.repo |
318 old_tip = repo['tip'].node() | 320 old_tip = revsymbol(repo, 'tip').node() |
319 expected_parent = repo['tip'].parents()[0].node() | 321 expected_parent = revsymbol(repo, 'tip').parents()[0].node() |
320 def file_callback(repo, memctx, path): | 322 def file_callback(repo, memctx, path): |
321 if path == 'adding_file2': | 323 if path == 'adding_file2': |
322 return compathacks.makememfilectx(repo, | 324 return compathacks.makememfilectx(repo, |
323 memctx=memctx, | 325 memctx=memctx, |
324 path=path, | 326 path=path, |
326 islink=False, | 328 islink=False, |
327 isexec=False, | 329 isexec=False, |
328 copied=False) | 330 copied=False) |
329 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 331 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
330 ctx = context.memctx(repo, | 332 ctx = context.memctx(repo, |
331 (repo['default'].node(), node.nullid), | 333 (revsymbol(repo, 'default').node(), node.nullid), |
332 'automated test', | 334 'automated test', |
333 ['adding_file2'], | 335 ['adding_file2'], |
334 file_callback, | 336 file_callback, |
335 'an_author', | 337 'an_author', |
336 '2008-10-07 20:59:48 -0500', | 338 '2008-10-07 20:59:48 -0500', |
337 {'branch': 'default', }) | 339 {'branch': 'default', }) |
338 new_hash = repo.commitctx(ctx) | 340 new_hash = repo.commitctx(ctx) |
339 hg.update(repo, repo['tip'].node()) | 341 hg.update(repo, revsymbol(repo, 'tip').node()) |
340 self.pushrevisions() | 342 self.pushrevisions() |
341 tip = self.repo['tip'] | 343 tip = revsymbol(self.repo, 'tip') |
342 self.assertNotEqual(tip.node(), old_tip) | 344 self.assertNotEqual(tip.node(), old_tip) |
343 self.assertNotEqual(tip.parents()[0].node(), old_tip) | 345 self.assertNotEqual(tip.parents()[0].node(), old_tip) |
344 self.assertEqual(tip.parents()[0].parents()[0].node(), expected_parent) | 346 self.assertEqual(tip.parents()[0].parents()[0].node(), expected_parent) |
345 self.assertEqual(tip['adding_file2'].data(), 'foo2') | 347 self.assertEqual(tip['adding_file2'].data(), 'foo2') |
346 self.assertEqual(tip['adding_file'].data(), 'foo') | 348 self.assertEqual(tip['adding_file'].data(), 'foo') |
363 islink=False, | 365 islink=False, |
364 isexec=False, | 366 isexec=False, |
365 copied=False) | 367 copied=False) |
366 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 368 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
367 ctx = context.memctx(repo, | 369 ctx = context.memctx(repo, |
368 (repo['the_branch'].node(), node.nullid), | 370 (revsymbol(repo, 'the_branch').node(), node.nullid), |
369 'automated test', | 371 'automated test', |
370 ['adding_file'], | 372 ['adding_file'], |
371 file_callback, | 373 file_callback, |
372 'an_author', | 374 'an_author', |
373 '2008-10-07 20:59:48 -0500', | 375 '2008-10-07 20:59:48 -0500', |
374 {'branch': 'the_branch', }) | 376 {'branch': 'the_branch', }) |
375 new_hash = repo.commitctx(ctx) | 377 new_hash = repo.commitctx(ctx) |
376 hg.update(repo, repo['tip'].node()) | 378 hg.update(repo, revsymbol(repo, 'tip').node()) |
377 if push: | 379 if push: |
378 self.pushrevisions() | 380 self.pushrevisions() |
379 tip = self.repo['tip'] | 381 tip = revsymbol(self.repo, 'tip') |
380 self.assertNotEqual(tip.node(), new_hash) | 382 self.assertNotEqual(tip.node(), new_hash) |
381 self.assertEqual(tip['adding_file'].data(), 'foo') | 383 self.assertEqual(tip['adding_file'].data(), 'foo') |
382 self.assertEqual(tip.branch(), 'the_branch') | 384 self.assertEqual(tip.branch(), 'the_branch') |
383 | 385 |
384 def test_push_to_non_tip(self): | 386 def test_push_to_non_tip(self): |
406 svncommands.rebuildmeta(u, | 408 svncommands.rebuildmeta(u, |
407 self.repo, | 409 self.repo, |
408 args=[test_util.fileurl(self.repo_path)]) | 410 args=[test_util.fileurl(self.repo_path)]) |
409 | 411 |
410 | 412 |
411 hg.update(self.repo, self.repo['tip'].node()) | 413 hg.update(self.repo, revsymbol(self.repo, 'tip').node()) |
412 oldnode = self.repo['tip'].hex() | 414 oldnode = revsymbol(self.repo, 'tip').hex() |
413 self.pushrevisions(expected_extra_back=1) | 415 self.pushrevisions(expected_extra_back=1) |
414 self.assertNotEqual(oldnode, self.repo['tip'].hex(), 'Revision was not pushed.') | 416 self.assertNotEqual(oldnode, revsymbol(self.repo, 'tip').hex(), 'Revision was not pushed.') |
415 | 417 |
416 def test_delete_file(self): | 418 def test_delete_file(self): |
417 repo = self.repo | 419 repo = self.repo |
418 def file_callback(repo, memctx, path): | 420 def file_callback(repo, memctx, path): |
419 return compathacks.filectxfn_deleted(memctx, path) | 421 return compathacks.filectxfn_deleted(memctx, path) |
420 old_files = set(repo['default'].manifest().keys()) | 422 old_files = set(revsymbol(repo, 'default').manifest().keys()) |
421 ctx = context.memctx(repo, | 423 ctx = context.memctx(repo, |
422 (repo['default'].node(), node.nullid), | 424 (revsymbol(repo, 'default').node(), node.nullid), |
423 'automated test', | 425 'automated test', |
424 ['alpha'], | 426 ['alpha'], |
425 file_callback, | 427 file_callback, |
426 'an author', | 428 'an author', |
427 '2008-10-29 21:26:00 -0500', | 429 '2008-10-29 21:26:00 -0500', |
428 {'branch': 'default', }) | 430 {'branch': 'default', }) |
429 new_hash = repo.commitctx(ctx) | 431 new_hash = repo.commitctx(ctx) |
430 hg.update(repo, repo['tip'].node()) | 432 hg.update(repo, revsymbol(repo, 'tip').node()) |
431 self.pushrevisions() | 433 self.pushrevisions() |
432 tip = self.repo['tip'] | 434 tip = revsymbol(self.repo, 'tip') |
433 self.assertEqual(old_files, | 435 self.assertEqual(old_files, |
434 set(tip.manifest().keys() + ['alpha'])) | 436 set(tip.manifest().keys() + ['alpha'])) |
435 self.assert_('alpha' not in tip.manifest()) | 437 self.assert_('alpha' not in tip.manifest()) |
436 | 438 |
437 def test_push_executable_file(self): | 439 def test_push_executable_file(self): |
446 islink=False, | 448 islink=False, |
447 isexec=True, | 449 isexec=True, |
448 copied=False) | 450 copied=False) |
449 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 451 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
450 ctx = context.memctx(repo, | 452 ctx = context.memctx(repo, |
451 (repo['tip'].node(), node.nullid), | 453 (revsymbol(repo, 'tip').node(), node.nullid), |
452 'message', | 454 'message', |
453 ['gamma', ], | 455 ['gamma', ], |
454 file_callback, | 456 file_callback, |
455 'author', | 457 'author', |
456 '2008-10-29 21:26:00 -0500', | 458 '2008-10-29 21:26:00 -0500', |
457 {'branch': 'default', }) | 459 {'branch': 'default', }) |
458 new_hash = repo.commitctx(ctx) | 460 new_hash = repo.commitctx(ctx) |
459 hg.clean(repo, repo['tip'].node()) | 461 hg.clean(repo, revsymbol(repo, 'tip').node()) |
460 self.pushrevisions() | 462 self.pushrevisions() |
461 tip = self.repo['tip'] | 463 tip = revsymbol(self.repo, 'tip') |
462 self.assertNotEqual(tip.node(), new_hash) | 464 self.assertNotEqual(tip.node(), new_hash) |
463 self.assert_('@' in self.repo['tip'].user()) | 465 self.assert_('@' in revsymbol(self.repo, 'tip').user()) |
464 self.assertEqual(tip['gamma'].flags(), 'x') | 466 self.assertEqual(tip['gamma'].flags(), 'x') |
465 self.assertEqual(tip['gamma'].data(), 'foo') | 467 self.assertEqual(tip['gamma'].data(), 'foo') |
466 self.assertEqual(sorted([x for x in tip.manifest().keys() if 'x' not in | 468 self.assertEqual(sorted([x for x in tip.manifest().keys() if 'x' not in |
467 tip[x].flags()]), | 469 tip[x].flags()]), |
468 ['adding_file', 'alpha', 'beta', ]) | 470 ['adding_file', 'alpha', 'beta', ]) |
479 islink=True, | 481 islink=True, |
480 isexec=False, | 482 isexec=False, |
481 copied=False) | 483 copied=False) |
482 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 484 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
483 ctx = context.memctx(repo, | 485 ctx = context.memctx(repo, |
484 (repo['tip'].node(), node.nullid), | 486 (revsymbol(repo, 'tip').node(), node.nullid), |
485 'message', | 487 'message', |
486 ['gamma', ], | 488 ['gamma', ], |
487 file_callback, | 489 file_callback, |
488 'author', | 490 'author', |
489 '2008-10-29 21:26:00 -0500', | 491 '2008-10-29 21:26:00 -0500', |
490 {'branch': 'default', }) | 492 {'branch': 'default', }) |
491 new_hash = repo.commitctx(ctx) | 493 new_hash = repo.commitctx(ctx) |
492 hg.update(repo, repo['tip'].node()) | 494 hg.update(repo, revsymbol(repo, 'tip').node()) |
493 self.pushrevisions() | 495 self.pushrevisions() |
494 # grab a new repo instance (self.repo is an @property functions) | 496 # grab a new repo instance (self.repo is an @property functions) |
495 repo = self.repo | 497 repo = self.repo |
496 tip = repo['tip'] | 498 tip = revsymbol(repo, 'tip') |
497 self.assertNotEqual(tip.node(), new_hash) | 499 self.assertNotEqual(tip.node(), new_hash) |
498 self.assertEqual(tip['gamma'].flags(), 'l') | 500 self.assertEqual(tip['gamma'].flags(), 'l') |
499 self.assertEqual(tip['gamma'].data(), 'foo') | 501 self.assertEqual(tip['gamma'].data(), 'foo') |
500 self.assertEqual(sorted([x for x in tip.manifest().keys() if 'l' not in | 502 self.assertEqual(sorted([x for x in tip.manifest().keys() if 'l' not in |
501 tip[x].flags()]), | 503 tip[x].flags()]), |
511 isexec=False, | 513 isexec=False, |
512 copied=False) | 514 copied=False) |
513 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 515 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
514 | 516 |
515 ctx = context.memctx(repo, | 517 ctx = context.memctx(repo, |
516 (repo['tip'].node(), node.nullid), | 518 (revsymbol(repo, 'tip').node(), node.nullid), |
517 'message', | 519 'message', |
518 ['gamma', ], | 520 ['gamma', ], |
519 file_callback2, | 521 file_callback2, |
520 'author', | 522 'author', |
521 '2014-08-08 20:11:41 -0700', | 523 '2014-08-08 20:11:41 -0700', |
522 {'branch': 'default', }) | 524 {'branch': 'default', }) |
523 repo.commitctx(ctx) | 525 repo.commitctx(ctx) |
524 hg.update(repo, repo['tip'].node()) | 526 hg.update(repo, revsymbol(repo, 'tip').node()) |
525 self.pushrevisions() | 527 self.pushrevisions() |
526 # grab a new repo instance (self.repo is an @property functions) | 528 # grab a new repo instance (self.repo is an @property functions) |
527 repo = self.repo | 529 repo = self.repo |
528 tip = repo['tip'] | 530 tip = revsymbol(repo, 'tip') |
529 self.assertEqual(tip['gamma'].flags(), 'l') | 531 self.assertEqual(tip['gamma'].flags(), 'l') |
530 self.assertEqual(tip['gamma'].data(), 'a'*129) | 532 self.assertEqual(tip['gamma'].data(), 'a'*129) |
531 | 533 |
532 def file_callback3(repo, memctx, path): | 534 def file_callback3(repo, memctx, path): |
533 if path == 'gamma': | 535 if path == 'gamma': |
539 isexec=False, | 541 isexec=False, |
540 copied=False) | 542 copied=False) |
541 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 543 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
542 | 544 |
543 ctx = context.memctx(repo, | 545 ctx = context.memctx(repo, |
544 (repo['tip'].node(), node.nullid), | 546 (revsymbol(repo, 'tip').node(), node.nullid), |
545 'message', | 547 'message', |
546 ['gamma', ], | 548 ['gamma', ], |
547 file_callback3, | 549 file_callback3, |
548 'author', | 550 'author', |
549 '2014-08-08 20:16:25 -0700', | 551 '2014-08-08 20:16:25 -0700', |
550 {'branch': 'default', }) | 552 {'branch': 'default', }) |
551 repo.commitctx(ctx) | 553 repo.commitctx(ctx) |
552 hg.update(repo, repo['tip'].node()) | 554 hg.update(repo, revsymbol(repo, 'tip').node()) |
553 self.pushrevisions() | 555 self.pushrevisions() |
554 repo = self.repo | 556 repo = self.repo |
555 tip = repo['tip'] | 557 tip = revsymbol(repo, 'tip') |
556 self.assertEqual(tip['gamma'].flags(), 'l') | 558 self.assertEqual(tip['gamma'].flags(), 'l') |
557 self.assertEqual(tip['gamma'].data(), 'a' * 64 + 'b' * 65) | 559 self.assertEqual(tip['gamma'].data(), 'a' * 64 + 'b' * 65) |
558 | 560 |
559 | 561 |
560 def test_push_existing_file_newly_symlink(self): | 562 def test_push_existing_file_newly_symlink(self): |
573 data='foo', | 575 data='foo', |
574 islink=link, | 576 islink=link, |
575 isexec=execute, | 577 isexec=execute, |
576 copied=False) | 578 copied=False) |
577 ctx = context.memctx(repo, | 579 ctx = context.memctx(repo, |
578 (repo['default'].node(), node.nullid), | 580 (revsymbol(repo, 'default').node(), node.nullid), |
579 'message', | 581 'message', |
580 ['alpha', ], | 582 ['alpha', ], |
581 file_callback, | 583 file_callback, |
582 'author', | 584 'author', |
583 '2008-1-1 00:00:00 -0500', | 585 '2008-1-1 00:00:00 -0500', |
584 {'branch': 'default', }) | 586 {'branch': 'default', }) |
585 new_hash = repo.commitctx(ctx) | 587 new_hash = repo.commitctx(ctx) |
586 hg.update(repo, repo['tip'].node()) | 588 hg.update(repo, revsymbol(repo, 'tip').node()) |
587 self.pushrevisions() | 589 self.pushrevisions() |
588 tip = self.repo['tip'] | 590 tip = revsymbol(self.repo, 'tip') |
589 self.assertNotEqual(tip.node(), new_hash) | 591 self.assertNotEqual(tip.node(), new_hash) |
590 self.assertEqual(tip['alpha'].data(), 'foo') | 592 self.assertEqual(tip['alpha'].data(), 'foo') |
591 self.assertEqual(tip.parents()[0]['alpha'].flags(), '') | 593 self.assertEqual(tip.parents()[0]['alpha'].flags(), '') |
592 self.assertEqual(tip['alpha'].flags(), expected_flags) | 594 self.assertEqual(tip['alpha'].flags(), expected_flags) |
593 # while we're here, double check pushing an already-executable file | 595 # while we're here, double check pushing an already-executable file |
600 data='bar', | 602 data='bar', |
601 islink=link, | 603 islink=link, |
602 isexec=execute, | 604 isexec=execute, |
603 copied=False) | 605 copied=False) |
604 ctx = context.memctx(repo, | 606 ctx = context.memctx(repo, |
605 (repo['default'].node(), node.nullid), | 607 (revsymbol(repo, 'default').node(), node.nullid), |
606 'mutate already-special file alpha', | 608 'mutate already-special file alpha', |
607 ['alpha', ], | 609 ['alpha', ], |
608 file_callback2, | 610 file_callback2, |
609 'author', | 611 'author', |
610 '2008-1-1 00:00:00 -0500', | 612 '2008-1-1 00:00:00 -0500', |
611 {'branch': 'default', }) | 613 {'branch': 'default', }) |
612 new_hash = repo.commitctx(ctx) | 614 new_hash = repo.commitctx(ctx) |
613 hg.update(repo, repo['tip'].node()) | 615 hg.update(repo, revsymbol(repo, 'tip').node()) |
614 self.pushrevisions() | 616 self.pushrevisions() |
615 tip = self.repo['tip'] | 617 tip = revsymbol(self.repo, 'tip') |
616 self.assertNotEqual(tip.node(), new_hash) | 618 self.assertNotEqual(tip.node(), new_hash) |
617 self.assertEqual(tip['alpha'].data(), 'bar') | 619 self.assertEqual(tip['alpha'].data(), 'bar') |
618 self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags) | 620 self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags) |
619 self.assertEqual(tip['alpha'].flags(), expected_flags) | 621 self.assertEqual(tip['alpha'].flags(), expected_flags) |
620 # now test removing the property entirely | 622 # now test removing the property entirely |
626 data='bar', | 628 data='bar', |
627 islink=False, | 629 islink=False, |
628 isexec=False, | 630 isexec=False, |
629 copied=False) | 631 copied=False) |
630 ctx = context.memctx(repo, | 632 ctx = context.memctx(repo, |
631 (repo['default'].node(), node.nullid), | 633 (revsymbol(repo, 'default').node(), node.nullid), |
632 'convert alpha back to regular file', | 634 'convert alpha back to regular file', |
633 ['alpha', ], | 635 ['alpha', ], |
634 file_callback3, | 636 file_callback3, |
635 'author', | 637 'author', |
636 '2008-01-01 00:00:00 -0500', | 638 '2008-01-01 00:00:00 -0500', |
637 {'branch': 'default', }) | 639 {'branch': 'default', }) |
638 new_hash = repo.commitctx(ctx) | 640 new_hash = repo.commitctx(ctx) |
639 hg.update(repo, repo['tip'].node()) | 641 hg.update(repo, revsymbol(repo, 'tip').node()) |
640 self.pushrevisions() | 642 self.pushrevisions() |
641 tip = self.repo['tip'] | 643 tip = revsymbol(self.repo, 'tip') |
642 self.assertNotEqual(tip.node(), new_hash) | 644 self.assertNotEqual(tip.node(), new_hash) |
643 self.assertEqual(tip['alpha'].data(), 'bar') | 645 self.assertEqual(tip['alpha'].data(), 'bar') |
644 self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags) | 646 self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags) |
645 self.assertEqual(tip['alpha'].flags(), '') | 647 self.assertEqual(tip['alpha'].flags(), '') |
646 | 648 |
647 def test_push_outdated_base_text(self): | 649 def test_push_outdated_base_text(self): |
648 self.test_push_two_revs() | 650 self.test_push_two_revs() |
649 changes = [('adding_file', 'adding_file', 'different_content',), | 651 changes = [('adding_file', 'adding_file', 'different_content',), |
650 ] | 652 ] |
651 par = self.repo['tip'].rev() | 653 par = revsymbol(self.repo, 'tip').rev() |
652 self.commitchanges(changes, parent=par) | 654 self.commitchanges(changes, parent=par) |
653 self.pushrevisions() | 655 self.pushrevisions() |
654 changes = [('adding_file', 'adding_file', | 656 changes = [('adding_file', 'adding_file', |
655 'even_more different_content',), | 657 'even_more different_content',), |
656 ] | 658 ] |
673 # used to fail because hg internal encoding was being changed during | 675 # used to fail because hg internal encoding was being changed during |
674 # the interactions with subversion, *and during the rebase*, which | 676 # the interactions with subversion, *and during the rebase*, which |
675 # confused the dirstate and made it believe the file was deleted. | 677 # confused the dirstate and made it believe the file was deleted. |
676 fn = 'pi\xc3\xa8ce/test' | 678 fn = 'pi\xc3\xa8ce/test' |
677 changes = [(fn, fn, 'a')] | 679 changes = [(fn, fn, 'a')] |
678 par = self.repo['tip'].rev() | 680 par = revsymbol(self.repo, 'tip').rev() |
679 self.commitchanges(changes, parent=par) | 681 self.commitchanges(changes, parent=par) |
680 self.pushrevisions() | 682 self.pushrevisions() |
681 | 683 |
682 def test_push_emptying_changeset(self): | 684 def test_push_emptying_changeset(self): |
683 r = self.repo['tip'] | 685 r = revsymbol(self.repo, 'tip') |
684 changes = [ | 686 changes = [ |
685 ('alpha', None, None), | 687 ('alpha', None, None), |
686 ('beta', None, None), | 688 ('beta', None, None), |
687 ] | 689 ] |
688 parent = self.repo['tip'].rev() | 690 parent = revsymbol(self.repo, 'tip').rev() |
689 self.commitchanges(changes, parent=parent) | 691 self.commitchanges(changes, parent=parent) |
690 self.pushrevisions() | 692 self.pushrevisions() |
691 self.assertEqual(len(self.repo['tip'].manifest()), 0) | 693 self.assertEqual(len(revsymbol(self.repo, 'tip').manifest()), 0) |
692 | 694 |
693 # Try to re-add a file after emptying the branch | 695 # Try to re-add a file after emptying the branch |
694 changes = [ | 696 changes = [ |
695 ('alpha', 'alpha', 'alpha'), | 697 ('alpha', 'alpha', 'alpha'), |
696 ] | 698 ] |
697 self.commitchanges(changes, parent=self.repo['tip'].rev()) | 699 self.commitchanges(changes, parent=revsymbol(self.repo, 'tip').rev()) |
698 self.pushrevisions() | 700 self.pushrevisions() |
699 self.assertEqual(['alpha'], list(self.repo['tip'].manifest())) | 701 self.assertEqual(['alpha'], list(revsymbol(self.repo, 'tip').manifest())) |
700 | 702 |
701 def test_push_without_pushing_children(self): | 703 def test_push_without_pushing_children(self): |
702 ''' | 704 ''' |
703 Verify that a push of a nontip node, keeps the tip child | 705 Verify that a push of a nontip node, keeps the tip child |
704 on top of the pushed commit. | 706 on top of the pushed commit. |
705 ''' | 707 ''' |
706 | 708 |
707 oldlen = test_util.repolen(self.repo) | 709 oldlen = test_util.repolen(self.repo) |
708 oldtiphash = self.repo['default'].node() | 710 oldtiphash = revsymbol(self.repo, 'default').node() |
709 | 711 |
710 changes = [('gamma', 'gamma', 'sometext')] | 712 changes = [('gamma', 'gamma', 'sometext')] |
711 newhash1 = self.commitchanges(changes) | 713 newhash1 = self.commitchanges(changes) |
712 | 714 |
713 changes = [('delta', 'delta', 'sometext')] | 715 changes = [('delta', 'delta', 'sometext')] |
718 hg.update(repo, newhash1) | 720 hg.update(repo, newhash1) |
719 commands.push(repo.ui, repo) | 721 commands.push(repo.ui, repo) |
720 self.assertEqual(test_util.repolen(self.repo), oldlen + 2) | 722 self.assertEqual(test_util.repolen(self.repo), oldlen + 2) |
721 | 723 |
722 # verify that the first commit is pushed, and the second is not | 724 # verify that the first commit is pushed, and the second is not |
723 commit2 = self.repo['tip'] | 725 commit2 = revsymbol(self.repo, 'tip') |
724 self.assertEqual(commit2.files(), ['delta', ]) | 726 self.assertEqual(commit2.files(), ['delta', ]) |
725 self.assertEqual(util.getsvnrev(commit2), None) | 727 self.assertEqual(util.getsvnrev(commit2), None) |
726 commit1 = commit2.parents()[0] | 728 commit1 = commit2.parents()[0] |
727 self.assertEqual(commit1.files(), ['gamma', ]) | 729 self.assertEqual(commit1.files(), ['gamma', ]) |
728 prefix = 'svn:' + self.repo.svnmeta().uuid | 730 prefix = 'svn:' + self.repo.svnmeta().uuid |
734 Push performs a rebase if two commits touch the same file. | 736 Push performs a rebase if two commits touch the same file. |
735 This test verifies that code path works. | 737 This test verifies that code path works. |
736 ''' | 738 ''' |
737 | 739 |
738 oldlen = test_util.repolen(self.repo) | 740 oldlen = test_util.repolen(self.repo) |
739 oldtiphash = self.repo['default'].node() | 741 oldtiphash = revsymbol(self.repo, 'default').node() |
740 | 742 |
741 changes = [('gamma', 'gamma', 'sometext')] | 743 changes = [('gamma', 'gamma', 'sometext')] |
742 newhash = self.commitchanges(changes) | 744 newhash = self.commitchanges(changes) |
743 changes = [('gamma', 'gamma', 'sometext\n moretext'), | 745 changes = [('gamma', 'gamma', 'sometext\n moretext'), |
744 ('delta', 'delta', 'sometext\n moretext'), | 746 ('delta', 'delta', 'sometext\n moretext'), |
749 hg.update(repo, newhash) | 751 hg.update(repo, newhash) |
750 commands.push(repo.ui, repo) | 752 commands.push(repo.ui, repo) |
751 self.assertEqual(test_util.repolen(self.repo), oldlen + 2) | 753 self.assertEqual(test_util.repolen(self.repo), oldlen + 2) |
752 | 754 |
753 # verify that both commits are pushed | 755 # verify that both commits are pushed |
754 commit1 = self.repo['tip'] | 756 commit1 = revsymbol(self.repo, 'tip') |
755 self.assertEqual(commit1.files(), ['delta', 'gamma']) | 757 self.assertEqual(commit1.files(), ['delta', 'gamma']) |
756 | 758 |
757 prefix = 'svn:' + self.repo.svnmeta().uuid | 759 prefix = 'svn:' + self.repo.svnmeta().uuid |
758 self.assertEqual(util.getsvnrev(commit1), | 760 self.assertEqual(util.getsvnrev(commit1), |
759 prefix + '/branches/the_branch@6') | 761 prefix + '/branches/the_branch@6') |
762 self.assertEqual(util.getsvnrev(commit2), | 764 self.assertEqual(util.getsvnrev(commit2), |
763 prefix + '/branches/the_branch@5') | 765 prefix + '/branches/the_branch@5') |
764 | 766 |
765 def test_push_in_subdir(self, commit=True): | 767 def test_push_in_subdir(self, commit=True): |
766 repo = self.repo | 768 repo = self.repo |
767 old_tip = repo['tip'].node() | 769 old_tip = revsymbol(repo, 'tip').node() |
768 def file_callback(repo, memctx, path): | 770 def file_callback(repo, memctx, path): |
769 if path == 'adding_file' or path == 'newdir/new_file': | 771 if path == 'adding_file' or path == 'newdir/new_file': |
770 testData = 'fooFirstFile' | 772 testData = 'fooFirstFile' |
771 if path == 'newdir/new_file': | 773 if path == 'newdir/new_file': |
772 testData = 'fooNewFile' | 774 testData = 'fooNewFile' |
777 islink=False, | 779 islink=False, |
778 isexec=False, | 780 isexec=False, |
779 copied=False) | 781 copied=False) |
780 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 782 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
781 ctx = context.memctx(repo, | 783 ctx = context.memctx(repo, |
782 (repo['default'].node(), node.nullid), | 784 (revsymbol(repo, 'default').node(), node.nullid), |
783 'automated test', | 785 'automated test', |
784 ['adding_file'], | 786 ['adding_file'], |
785 file_callback, | 787 file_callback, |
786 'an_author', | 788 'an_author', |
787 '2012-12-13 20:59:48 -0500', | 789 '2012-12-13 20:59:48 -0500', |
788 {'branch': 'default', }) | 790 {'branch': 'default', }) |
789 new_hash = repo.commitctx(ctx) | 791 new_hash = repo.commitctx(ctx) |
790 p = os.path.join(repo.root, "newdir") | 792 p = os.path.join(repo.root, "newdir") |
791 os.mkdir(p) | 793 os.mkdir(p) |
792 ctx = context.memctx(repo, | 794 ctx = context.memctx(repo, |
793 (repo['default'].node(), node.nullid), | 795 (revsymbol(repo, 'default').node(), node.nullid), |
794 'automated test', | 796 'automated test', |
795 ['newdir/new_file'], | 797 ['newdir/new_file'], |
796 file_callback, | 798 file_callback, |
797 'an_author', | 799 'an_author', |
798 '2012-12-13 20:59:48 -0500', | 800 '2012-12-13 20:59:48 -0500', |
799 {'branch': 'default', }) | 801 {'branch': 'default', }) |
800 os.chdir(p) | 802 os.chdir(p) |
801 new_hash = repo.commitctx(ctx) | 803 new_hash = repo.commitctx(ctx) |
802 hg.update(repo, repo['tip'].node()) | 804 hg.update(repo, revsymbol(repo, 'tip').node()) |
803 self.pushrevisions() | 805 self.pushrevisions() |
804 tip = self.repo['tip'] | 806 tip = revsymbol(self.repo, 'tip') |
805 self.assertNotEqual(tip.node(), old_tip) | 807 self.assertNotEqual(tip.node(), old_tip) |
806 self.assertEqual(p, os.getcwd()) | 808 self.assertEqual(p, os.getcwd()) |
807 self.assertEqual(tip['adding_file'].data(), 'fooFirstFile') | 809 self.assertEqual(tip['adding_file'].data(), 'fooFirstFile') |
808 self.assertEqual(tip['newdir/new_file'].data(), 'fooNewFile') | 810 self.assertEqual(tip['newdir/new_file'].data(), 'fooNewFile') |
809 self.assertEqual(tip.branch(), 'default') | 811 self.assertEqual(tip.branch(), 'default') |
818 self.repo_path, | 820 self.repo_path, |
819 {'trunk/racey_file': 'race conditions suck'})) | 821 {'trunk/racey_file': 'race conditions suck'})) |
820 | 822 |
821 self.test_push_to_branch(push=False) | 823 self.test_push_to_branch(push=False) |
822 commands.push(ui, repo) | 824 commands.push(ui, repo) |
823 newctx = self.repo['.'] | 825 newctx = revsymbol(self.repo, '.') |
824 self.assertNotEqual(newctx.node(), self.repo['tip'].node()) | 826 self.assertNotEqual(newctx.node(), revsymbol(self.repo, 'tip').node()) |
825 self.assertEqual(newctx['adding_file'].data(), 'foo') | 827 self.assertEqual(newctx['adding_file'].data(), 'foo') |
826 self.assertEqual(newctx.branch(), 'the_branch') | 828 self.assertEqual(newctx.branch(), 'the_branch') |