Mercurial > hgsubversion
comparison tests/test_push_command.py @ 992:110794582448
push: avoid failure when push is being called from a newly created subdirectory
The failure was occuring during push when a new file is added inside a new subdirectory and push is being called from this subdirectory.
This subdirectory disappears when the commit is being rebased[during push] causing the push to fail with 'no such file/directory' error.
author | Kapil Bajaj <kapilbajaj@fb.com> |
---|---|
date | Thu, 17 Jan 2013 17:01:45 -0800 |
parents | 26e9fd21f3bf |
children | e775ffbcb359 |
comparison
equal
deleted
inserted
replaced
991:26e9fd21f3bf | 992:110794582448 |
---|---|
578 self.assertFalse(commit1.mutable()) | 578 self.assertFalse(commit1.mutable()) |
579 commit2 = commit1.parents()[0] | 579 commit2 = commit1.parents()[0] |
580 self.assertEqual(commit2.files(), ['gamma']) | 580 self.assertEqual(commit2.files(), ['gamma']) |
581 self.assertFalse(commit2.mutable()) | 581 self.assertFalse(commit2.mutable()) |
582 | 582 |
583 def test_push_in_subdir(self, commit=True): | |
584 repo = self.repo | |
585 old_tip = repo['tip'].node() | |
586 def file_callback(repo, memctx, path): | |
587 if path == 'adding_file' or path == 'newdir/new_file': | |
588 testData = 'fooFirstFile' | |
589 if path == 'newdir/new_file': | |
590 testData = 'fooNewFile' | |
591 return context.memfilectx(path=path, | |
592 data=testData, | |
593 islink=False, | |
594 isexec=False, | |
595 copied=False) | |
596 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) | |
597 ctx = context.memctx(repo, | |
598 (repo['default'].node(), node.nullid), | |
599 'automated test', | |
600 ['adding_file'], | |
601 file_callback, | |
602 'an_author', | |
603 '2012-12-13 20:59:48 -0500', | |
604 {'branch': 'default', }) | |
605 new_hash = repo.commitctx(ctx) | |
606 p = os.path.join(repo.root, "newdir") | |
607 os.mkdir(p) | |
608 ctx = context.memctx(repo, | |
609 (repo['default'].node(), node.nullid), | |
610 'automated test', | |
611 ['newdir/new_file'], | |
612 file_callback, | |
613 'an_author', | |
614 '2012-12-13 20:59:48 -0500', | |
615 {'branch': 'default', }) | |
616 os.chdir(p) | |
617 new_hash = repo.commitctx(ctx) | |
618 hg.update(repo, repo['tip'].node()) | |
619 self.pushrevisions() | |
620 tip = self.repo['tip'] | |
621 self.assertNotEqual(tip.node(), old_tip) | |
622 self.assertEqual(p, os.getcwd()) | |
623 self.assertEqual(tip['adding_file'].data(), 'fooFirstFile') | |
624 self.assertEqual(tip['newdir/new_file'].data(), 'fooNewFile') | |
625 self.assertEqual(tip.branch(), 'default') | |
626 | |
583 | 627 |
584 def suite(): | 628 def suite(): |
585 test_classes = [PushTests, ] | 629 test_classes = [PushTests, ] |
586 all_tests = [] | 630 all_tests = [] |
587 # This is the quickest hack I could come up with to load all the tests from | 631 # This is the quickest hack I could come up with to load all the tests from |