Mercurial > hgsubversion
comparison tests/test_push_command.py @ 1222:afd047a7df45 stable
test_push_command: call makememfilectx
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Mon, 02 Jun 2014 19:41:37 -0500 |
parents | 2d7398fffd0d |
children | aa8b72bd1320 46523cdfd3b0 |
comparison
equal
deleted
inserted
replaced
1221:f87502fd4d65 | 1222:afd047a7df45 |
---|---|
16 from mercurial import node | 16 from mercurial import node |
17 from mercurial import revlog | 17 from mercurial import revlog |
18 from mercurial import util as hgutil | 18 from mercurial import util as hgutil |
19 | 19 |
20 from hgsubversion import util | 20 from hgsubversion import util |
21 from hgsubversion import compathacks | |
21 | 22 |
22 import time | 23 import time |
23 | 24 |
24 | 25 |
25 class PushTests(test_util.TestBase): | 26 class PushTests(test_util.TestBase): |
31 | 32 |
32 def test_cant_push_empty_ctx(self): | 33 def test_cant_push_empty_ctx(self): |
33 repo = self.repo | 34 repo = self.repo |
34 def file_callback(repo, memctx, path): | 35 def file_callback(repo, memctx, path): |
35 if path == 'adding_file': | 36 if path == 'adding_file': |
36 return context.memfilectx(path=path, | 37 return compathacks.makememfilectx(repo, |
37 data='foo', | 38 path=path, |
38 islink=False, | 39 data='foo', |
39 isexec=False, | 40 islink=False, |
40 copied=False) | 41 isexec=False, |
42 copied=False) | |
41 raise IOError() | 43 raise IOError() |
42 ctx = context.memctx(repo, | 44 ctx = context.memctx(repo, |
43 (repo['default'].node(), node.nullid), | 45 (repo['default'].node(), node.nullid), |
44 'automated test', | 46 'automated test', |
45 [], | 47 [], |
56 | 58 |
57 def test_push_add_of_added_upstream_gives_sane_error(self): | 59 def test_push_add_of_added_upstream_gives_sane_error(self): |
58 repo = self.repo | 60 repo = self.repo |
59 def file_callback(repo, memctx, path): | 61 def file_callback(repo, memctx, path): |
60 if path == 'adding_file': | 62 if path == 'adding_file': |
61 return context.memfilectx(path=path, | 63 return compathacks.makememfilectx(repo, |
62 data='foo', | 64 path=path, |
63 islink=False, | 65 data='foo', |
64 isexec=False, | 66 islink=False, |
65 copied=False) | 67 isexec=False, |
68 copied=False) | |
66 raise IOError() | 69 raise IOError() |
67 p1 = repo['default'].node() | 70 p1 = repo['default'].node() |
68 ctx = context.memctx(repo, | 71 ctx = context.memctx(repo, |
69 (p1, node.nullid), | 72 (p1, node.nullid), |
70 'automated test', | 73 'automated test', |
103 self.assertEqual(tip.node(), old_tip) | 106 self.assertEqual(tip.node(), old_tip) |
104 | 107 |
105 def test_cant_push_with_changes(self): | 108 def test_cant_push_with_changes(self): |
106 repo = self.repo | 109 repo = self.repo |
107 def file_callback(repo, memctx, path): | 110 def file_callback(repo, memctx, path): |
108 return context.memfilectx( | 111 return compathacks.makememfilectx(repo, |
109 path=path, data='foo', islink=False, | 112 path=path, |
110 isexec=False, copied=False) | 113 data='foo', |
114 islink=False, | |
115 isexec=False, | |
116 copied=False) | |
111 ctx = context.memctx(repo, | 117 ctx = context.memctx(repo, |
112 (repo['default'].node(), node.nullid), | 118 (repo['default'].node(), node.nullid), |
113 'automated test', | 119 'automated test', |
114 ['adding_file'], | 120 ['adding_file'], |
115 file_callback, | 121 file_callback, |
152 repo = self.repo | 158 repo = self.repo |
153 old_tip = repo['tip'].node() | 159 old_tip = repo['tip'].node() |
154 expected_parent = repo['default'].node() | 160 expected_parent = repo['default'].node() |
155 def file_callback(repo, memctx, path): | 161 def file_callback(repo, memctx, path): |
156 if path == 'adding_file': | 162 if path == 'adding_file': |
157 return context.memfilectx(path=path, | 163 return compathacks.makememfilectx(repo, |
158 data='foo', | 164 path=path, |
159 islink=False, | 165 data='foo', |
160 isexec=False, | 166 islink=False, |
161 copied=False) | 167 isexec=False, |
168 copied=False) | |
162 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 169 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
163 ctx = context.memctx(repo, | 170 ctx = context.memctx(repo, |
164 parents=(repo['default'].node(), node.nullid), | 171 parents=(repo['default'].node(), node.nullid), |
165 text='automated test', | 172 text='automated test', |
166 files=['adding_file'], | 173 files=['adding_file'], |
199 repo = self.repo | 206 repo = self.repo |
200 old_tip = repo['tip'].node() | 207 old_tip = repo['tip'].node() |
201 expected_parent = repo['default'].node() | 208 expected_parent = repo['default'].node() |
202 def file_callback(repo, memctx, path): | 209 def file_callback(repo, memctx, path): |
203 if path == 'adding_file': | 210 if path == 'adding_file': |
204 return context.memfilectx(path=path, | 211 return compathacks.makememfilectx(repo, |
205 data='foo', | 212 path=path, |
206 islink=False, | 213 data='foo', |
207 isexec=False, | 214 islink=False, |
208 copied=False) | 215 isexec=False, |
216 copied=False) | |
209 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 217 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
210 ctx = context.memctx(repo, | 218 ctx = context.memctx(repo, |
211 (repo['default'].node(), node.nullid), | 219 (repo['default'].node(), node.nullid), |
212 'automated test', | 220 'automated test', |
213 ['adding_file'], | 221 ['adding_file'], |
227 self.assertEqual(tip['adding_file'].data(), 'foo') | 235 self.assertEqual(tip['adding_file'].data(), 'foo') |
228 self.assertEqual(tip.branch(), 'default') | 236 self.assertEqual(tip.branch(), 'default') |
229 | 237 |
230 def test_push_two_revs_different_local_branch(self): | 238 def test_push_two_revs_different_local_branch(self): |
231 def filectxfn(repo, memctx, path): | 239 def filectxfn(repo, memctx, path): |
232 return context.memfilectx(path=path, | 240 return compathacks.makememfilectx(repo, |
233 data=path, | 241 path=path, |
234 islink=False, | 242 data=path, |
235 isexec=False, | 243 islink=False, |
236 copied=False) | 244 isexec=False, |
245 copied=False) | |
237 oldtiphash = self.repo['default'].node() | 246 oldtiphash = self.repo['default'].node() |
238 ctx = context.memctx(self.repo, | 247 ctx = context.memctx(self.repo, |
239 (self.repo[0].node(), revlog.nullid,), | 248 (self.repo[0].node(), revlog.nullid,), |
240 'automated test', | 249 'automated test', |
241 ['gamma', ], | 250 ['gamma', ], |
267 repo = self.repo | 276 repo = self.repo |
268 old_tip = repo['tip'].node() | 277 old_tip = repo['tip'].node() |
269 expected_parent = repo['tip'].parents()[0].node() | 278 expected_parent = repo['tip'].parents()[0].node() |
270 def file_callback(repo, memctx, path): | 279 def file_callback(repo, memctx, path): |
271 if path == 'adding_file2': | 280 if path == 'adding_file2': |
272 return context.memfilectx(path=path, | 281 return compathacks.makememfilectx(repo, |
273 data='foo2', | 282 path=path, |
274 islink=False, | 283 data='foo2', |
275 isexec=False, | 284 islink=False, |
276 copied=False) | 285 isexec=False, |
286 copied=False) | |
277 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 287 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
278 ctx = context.memctx(repo, | 288 ctx = context.memctx(repo, |
279 (repo['default'].node(), node.nullid), | 289 (repo['default'].node(), node.nullid), |
280 'automated test', | 290 'automated test', |
281 ['adding_file2'], | 291 ['adding_file2'], |
302 | 312 |
303 def test_push_to_branch(self, push=True): | 313 def test_push_to_branch(self, push=True): |
304 repo = self.repo | 314 repo = self.repo |
305 def file_callback(repo, memctx, path): | 315 def file_callback(repo, memctx, path): |
306 if path == 'adding_file': | 316 if path == 'adding_file': |
307 return context.memfilectx(path=path, | 317 return compathacks.makememfilectx(repo, |
308 data='foo', | 318 path=path, |
309 islink=False, | 319 data='foo', |
310 isexec=False, | 320 islink=False, |
311 copied=False) | 321 isexec=False, |
322 copied=False) | |
312 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 323 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
313 ctx = context.memctx(repo, | 324 ctx = context.memctx(repo, |
314 (repo['the_branch'].node(), node.nullid), | 325 (repo['the_branch'].node(), node.nullid), |
315 'automated test', | 326 'automated test', |
316 ['adding_file'], | 327 ['adding_file'], |
383 def test_push_executable_file(self): | 394 def test_push_executable_file(self): |
384 self.test_push_to_default(commit=True) | 395 self.test_push_to_default(commit=True) |
385 repo = self.repo | 396 repo = self.repo |
386 def file_callback(repo, memctx, path): | 397 def file_callback(repo, memctx, path): |
387 if path == 'gamma': | 398 if path == 'gamma': |
388 return context.memfilectx(path=path, | 399 return compathacks.makememfilectx(repo, |
389 data='foo', | 400 path=path, |
390 islink=False, | 401 data='foo', |
391 isexec=True, | 402 islink=False, |
392 copied=False) | 403 isexec=True, |
404 copied=False) | |
393 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 405 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
394 ctx = context.memctx(repo, | 406 ctx = context.memctx(repo, |
395 (repo['tip'].node(), node.nullid), | 407 (repo['tip'].node(), node.nullid), |
396 'message', | 408 'message', |
397 ['gamma', ], | 409 ['gamma', ], |
413 def test_push_symlink_file(self): | 425 def test_push_symlink_file(self): |
414 self.test_push_to_default(commit=True) | 426 self.test_push_to_default(commit=True) |
415 repo = self.repo | 427 repo = self.repo |
416 def file_callback(repo, memctx, path): | 428 def file_callback(repo, memctx, path): |
417 if path == 'gamma': | 429 if path == 'gamma': |
418 return context.memfilectx(path=path, | 430 return compathacks.makememfilectx(repo, |
419 data='foo', | 431 path=path, |
420 islink=True, | 432 data='foo', |
421 isexec=False, | 433 islink=True, |
422 copied=False) | 434 isexec=False, |
435 copied=False) | |
423 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 436 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
424 ctx = context.memctx(repo, | 437 ctx = context.memctx(repo, |
425 (repo['tip'].node(), node.nullid), | 438 (repo['tip'].node(), node.nullid), |
426 'message', | 439 'message', |
427 ['gamma', ], | 440 ['gamma', ], |
447 def test_push_existing_file_newly_execute(self, execute=True, | 460 def test_push_existing_file_newly_execute(self, execute=True, |
448 link=False, expected_flags='x'): | 461 link=False, expected_flags='x'): |
449 self.test_push_to_default() | 462 self.test_push_to_default() |
450 repo = self.repo | 463 repo = self.repo |
451 def file_callback(repo, memctx, path): | 464 def file_callback(repo, memctx, path): |
452 return context.memfilectx(path=path, | 465 return compathacks.makememfilectx(repo, |
453 data='foo', | 466 path=path, |
454 islink=link, | 467 data='foo', |
455 isexec=execute, | 468 islink=link, |
456 copied=False) | 469 isexec=execute, |
470 copied=False) | |
457 ctx = context.memctx(repo, | 471 ctx = context.memctx(repo, |
458 (repo['default'].node(), node.nullid), | 472 (repo['default'].node(), node.nullid), |
459 'message', | 473 'message', |
460 ['alpha', ], | 474 ['alpha', ], |
461 file_callback, | 475 file_callback, |
472 self.assertEqual(tip['alpha'].flags(), expected_flags) | 486 self.assertEqual(tip['alpha'].flags(), expected_flags) |
473 # while we're here, double check pushing an already-executable file | 487 # while we're here, double check pushing an already-executable file |
474 # works | 488 # works |
475 repo = self.repo | 489 repo = self.repo |
476 def file_callback2(repo, memctx, path): | 490 def file_callback2(repo, memctx, path): |
477 return context.memfilectx(path=path, | 491 return compathacks.makememfilectx(repo, |
478 data='bar', | 492 path=path, |
479 islink=link, | 493 data='bar', |
480 isexec=execute, | 494 islink=link, |
481 copied=False) | 495 isexec=execute, |
496 copied=False) | |
482 ctx = context.memctx(repo, | 497 ctx = context.memctx(repo, |
483 (repo['default'].node(), node.nullid), | 498 (repo['default'].node(), node.nullid), |
484 'message', | 499 'message', |
485 ['alpha', ], | 500 ['alpha', ], |
486 file_callback2, | 501 file_callback2, |
496 self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags) | 511 self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags) |
497 self.assertEqual(tip['alpha'].flags(), expected_flags) | 512 self.assertEqual(tip['alpha'].flags(), expected_flags) |
498 # now test removing the property entirely | 513 # now test removing the property entirely |
499 repo = self.repo | 514 repo = self.repo |
500 def file_callback3(repo, memctx, path): | 515 def file_callback3(repo, memctx, path): |
501 return context.memfilectx(path=path, | 516 return compathacks.makememfilectx(repo, |
502 data='bar', | 517 path=path, |
503 islink=False, | 518 data='bar', |
504 isexec=False, | 519 islink=False, |
505 copied=False) | 520 isexec=False, |
521 copied=False) | |
506 ctx = context.memctx(repo, | 522 ctx = context.memctx(repo, |
507 (repo['default'].node(), node.nullid), | 523 (repo['default'].node(), node.nullid), |
508 'message', | 524 'message', |
509 ['alpha', ], | 525 ['alpha', ], |
510 file_callback3, | 526 file_callback3, |
644 def file_callback(repo, memctx, path): | 660 def file_callback(repo, memctx, path): |
645 if path == 'adding_file' or path == 'newdir/new_file': | 661 if path == 'adding_file' or path == 'newdir/new_file': |
646 testData = 'fooFirstFile' | 662 testData = 'fooFirstFile' |
647 if path == 'newdir/new_file': | 663 if path == 'newdir/new_file': |
648 testData = 'fooNewFile' | 664 testData = 'fooNewFile' |
649 return context.memfilectx(path=path, | 665 return compathacks.makememfilectx(repo, |
650 data=testData, | 666 path=path, |
651 islink=False, | 667 data=testData, |
652 isexec=False, | 668 islink=False, |
653 copied=False) | 669 isexec=False, |
670 copied=False) | |
654 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | 671 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
655 ctx = context.memctx(repo, | 672 ctx = context.memctx(repo, |
656 (repo['default'].node(), node.nullid), | 673 (repo['default'].node(), node.nullid), |
657 'automated test', | 674 'automated test', |
658 ['adding_file'], | 675 ['adding_file'], |