def setUp(self): super(AutomaticTagNameTests, self).setUp() if isinstance(self.branch_format, bzrbranch.BranchReferenceFormat): # This test could in principle apply to BranchReferenceFormat, but # make_branch_builder doesn't support it. raise tests.TestSkipped( "BranchBuilder can't make reference branches.") self.builder = self.make_branch_builder('.') self.builder.build_snapshot(None, [('add', ('', None, 'directory', None))], message='foo') self.branch = self.builder.get_branch() if not self.branch._format.supports_tags(): raise tests.TestSkipped("format %s doesn't support tags" % self.branch._format)
def get_instrumented_branch(self): """Get a Branch object which has been instrumented""" # TODO: jam 20060630 It may be that not all formats have a # 'control_files' member. So we should fail gracefully if # not there. But assuming it has them lets us test the exact # lock/unlock order. self.locks = [] b = lock_helpers.LockWrapper(self.locks, self.get_branch(), 'b') b.repository = lock_helpers.LockWrapper(self.locks, b.repository, 'r') bcf = getattr(b, "control_files", None) rcf = getattr(b.repository, 'control_files', None) if rcf is None: self.combined_branch = False else: # Look out for branch types that reuse their control files self.combined_control = bcf is rcf and bcf is not None try: b.control_files = lock_helpers.LockWrapper( self.locks, b.control_files, 'bc') except AttributeError: # RemoteBranch seems to trigger this. raise tests.TestSkipped( 'Could not instrument branch control files.') if self.combined_control: # instrument the repository control files too to ensure its worked # with correctly. When they are not shared, we trust the repository # API and only instrument the repository itself. b.repository.control_files = lock_helpers.LockWrapper( self.locks, b.repository.control_files, 'rc') return b
def test_utf8_file_ids_and_revision_ids(self): main_wt = self.make_branch_and_tree('main') main_branch = main_wt.branch self.build_tree(["main/a"]) file_id = u'a-f\xedle-id'.encode('utf8') main_wt.add(['a'], [file_id]) revision_id = u'r\xe9v-a'.encode('utf8') try: main_wt.commit('a', rev_id=revision_id) except errors.NonAsciiRevisionId: raise tests.TestSkipped( 'non-ascii revision ids not supported by %s' % self.repository_format) repo = main_wt.branch.repository repo.lock_read() self.addCleanup(repo.unlock) file_ids = repo.fileids_altered_by_revision_ids([revision_id]) root_id = main_wt.basis_tree().path2id('') if root_id in file_ids: self.assertEqual({ file_id: {revision_id}, root_id: {revision_id} }, file_ids) else: self.assertEqual({file_id: {revision_id}}, file_ids)
def setUp(self): super(TestBranchTags, self).setUp() # formats that don't support tags can skip the rest of these # tests... branch = self.make_branch('probe') if not branch._format.supports_tags(): raise tests.TestSkipped("format %s doesn't support tags" % branch._format)
def test_add_unicode(self): tree = self.make_branch_and_tree('.') try: self.build_tree([u'f\xf6']) except UnicodeError: raise tests.TestSkipped('Filesystem does not support filename.') tree.add([u'f\xf6']) self.assertTreeLayout(['', u'f\xf6'], tree)
def setUp(self): # NB: see http://pad.lv/626679 and # <https://code.launchpad.net/~mbp/bzr/626679-strace/+merge/34157>: # testing strace by connecting to ourselves has repeatedly caused # hangs in running the test suite; these are fixable given enough # determination but given that strace is not used by any other tests # at the moment and that it's only test-support code, we just leave it # untested -- mbp 20100901 raise tests.TestSkipped("strace selftests are broken and disabled")
def _check_can_encode_paths(self): fs_enc = sys.getfilesystemencoding() terminal_enc = osutils.get_terminal_encoding() fname = self.info['filename'] dir_name = self.info['directory'] for thing in [fname, dir_name]: try: thing.encode(fs_enc) except UnicodeEncodeError: raise tests.TestSkipped( 'Unable to represent path %r in filesystem encoding "%s"' % (thing, fs_enc)) try: thing.encode(terminal_enc) except UnicodeEncodeError: raise tests.TestSkipped( 'Unable to represent path %r in terminal encoding "%s"' ' (even though it is valid in filesystem encoding "%s")' % (thing, terminal_enc, fs_enc))
def strace_detailed_or_skip(self, *args, **kwargs): """Run strace, but cope if it's not allowed""" try: return strace_detailed(*args, **kwargs) except strace.StraceError as e: if e.err_messages.startswith( "attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted" ): raise tests.TestSkipped("ptrace not permitted") else: raise
def setUp(self): super(TestTagsMergeToInCheckouts, self).setUp() branch1 = self.make_branch('tags-probe') if not branch1._format.supports_tags(): raise tests.TestSkipped("format %s doesn't support tags" % branch1._format) branch2 = self.make_branch('bind-probe') try: branch2.bind(branch1) except errors.UpgradeRequired: raise tests.TestNotApplicable( "format %s doesn't support bound branches" % branch2._format)
def disable_commit_write_group_paranoia(self, repo): if isinstance(repo, remote.RemoteRepository): # We can't easily disable the checks in a remote repo. repo.abort_write_group() raise tests.TestSkipped( "repository format does not support storing revisions with " "missing texts.") pack_coll = getattr(repo, '_pack_collection', None) if pack_coll is not None: # Monkey-patch the pack collection instance to allow storing # incomplete revisions. pack_coll._check_new_inventories = lambda: []
def test_last_modified_dir_link(self): if not self.repository_format.supports_versioned_directories: # TODO(jelmer): Perhaps test this by creating a directory # with a file in it? raise tests.TestNotApplicable( 'format does not support versioned directories') try: self._check_kind_change(self.make_dir, self.make_link) except errors.UnsupportedKindChange: raise tests.TestSkipped( "tree does not support changing entry kind from " "directory to link")
def test_subsume_failure(self): base_tree, sub_tree = self.make_trees() if base_tree.path2id('') == sub_tree.path2id(''): raise tests.TestSkipped('This test requires unique roots') self.assertRaises(errors.BadSubsumeSource, base_tree.subsume, base_tree) self.assertRaises(errors.BadSubsumeSource, sub_tree.subsume, base_tree) self.build_tree(['subtree2/']) sub_tree2 = self.make_branch_and_tree('subtree2') self.assertRaises(errors.BadSubsumeSource, sub_tree.subsume, sub_tree2) self.build_tree(['tree/subtree/subtree3/']) sub_tree3 = self.make_branch_and_tree('tree/subtree/subtree3') self.assertRaises(errors.BadSubsumeSource, base_tree.subsume, sub_tree3)
def setUp(self): super(TestLocale, self).setUp() if sys.platform in ('win32',): raise tests.TestSkipped('Windows does not respond to the LANG' ' env variable') tree = self.make_branch_and_tree('tree') self.build_tree(['tree/a']) tree.add('a') tree.commit(u'Unicode \xb5 commit', rev_id=b'r1', committer=u'\u062c\u0648\u062c\u0648' u' Meinel <*****@*****.**>', timestamp=1156451297.96, timezone=0) self.tree = tree
def test_pull_orphans(self): if not self.workingtree_format.missing_parent_conflicts: raise tests.TestSkipped( '%r does not support missing parent conflicts' % self.workingtree_format) trunk = self.make_branch_deleting_dir('trunk') work = trunk.controldir.sprout('work', revision_id=b'2').open_workingtree() work.branch.get_config_stack().set('transform.orphan_policy', 'move') # Add some unversioned files in dir self.build_tree( ['work/dir/foo', 'work/dir/subdir/', 'work/dir/subdir/foo']) work.pull(trunk) self.assertLength(0, work.conflicts()) # The directory removal should succeed self.assertPathDoesNotExist('work/dir')
def test_sprout_preserves_tags(self): """Sprout preserves tags, even tags of absent revisions.""" try: builder = self.make_branch_builder('source') except errors.UninitializableFormat: raise tests.TestSkipped('Uninitializable branch format') builder.build_commit(message="Rev 1") source = builder.get_branch() try: source.tags.set_tag('tag-a', b'missing-rev') except (errors.TagsNotSupported, errors.GhostTagsNotSupported): raise tests.TestNotApplicable( 'Branch format does not support tags or tags to ghosts.') # Now source has a tag pointing to an absent revision. Sprout it. target_bzrdir = self.make_repository('target').controldir new_branch = source.sprout(target_bzrdir) # The tag is present in the target self.assertEqual(b'missing-rev', new_branch.tags.lookup_tag('tag-a'))
def test_strict_history(self): tree1 = self.make_branch_and_tree('tree1') try: tree1.branch.set_append_revisions_only(True) except errors.UpgradeRequired: raise tests.TestSkipped('Format does not support strict history') tree1.commit('empty commit') tree2 = tree1.controldir.sprout('tree2').open_workingtree() tree2.commit('empty commit 2') tree1.pull(tree2.branch) tree1.commit('empty commit 3') tree2.commit('empty commit 4') self.assertRaises(errors.DivergedBranches, tree1.pull, tree2.branch) tree2.merge_from_branch(tree1.branch) tree2.commit('empty commit 5') self.assertRaises(errors.AppendRevisionsOnlyViolation, tree1.pull, tree2.branch) tree3 = tree1.controldir.sprout('tree3').open_workingtree() tree3.merge_from_branch(tree2.branch) tree3.commit('empty commit 6') tree2.pull(tree3.branch)
def test_external_diff(self): """Test that we can spawn an external diff process""" self.disable_missing_extensions_warning() # We have to use run_bzr_subprocess, because we need to # test writing directly to stdout, (there was a bug in # subprocess.py that we had to workaround). # However, if 'diff' may not be available self.make_example_branch() out, err = self.run_bzr_subprocess( 'diff -Oprogress_bar=none -r 1 --diff-options -ub', universal_newlines=True, retcode=None) if b'Diff is not installed on this machine' in err: raise tests.TestSkipped("No external 'diff' is available") self.assertEqual(b'', err) # We have to skip the stuff in the middle, because it depends # on time.time() self.assertStartsWith( out, b"=== added file 'goodbye'\n" b"--- old/goodbye\t1970-01-01 00:00:00 +0000\n" b"+++ new/goodbye\t") self.assertEndsWith(out, b"\n@@ -0,0 +1 @@\n" b"+baz\n\n")
def setUp(self): super(TestFileIdInvolvedSuperset, self).setUp() self.branch = None main_wt = self.make_branch_and_tree('main') main_branch = main_wt.branch self.build_tree(["main/a", "main/b", "main/c"]) main_wt.add(['a', 'b', 'c'], [ b'a-file-id-2006-01-01-abcd', b'b-file-id-2006-01-01-defg', b'c-funky<file-id>quiji\'"%bo' ]) try: main_wt.commit("Commit one", rev_id=b"rev-A") except errors.IllegalPath: # TODO: jam 20060701 Consider raising a different exception # newer formats do support this, and nothin can done to # correct this test - its not a bug. if sys.platform == 'win32': raise tests.TestSkipped('Old repository formats do not' ' support file ids with <> on win32') # This is not a known error condition raise branch2_wt = self.make_branch_and_tree('branch2') branch2_wt.pull(main_branch) branch2_bzrdir = branch2_wt.controldir branch2_branch = branch2_bzrdir.open_branch() set_executability(branch2_wt, 'b', True) branch2_wt.commit("branch2, Commit one", rev_id=b"rev-J") main_wt.merge_from_branch(branch2_branch) set_executability(main_wt, 'b', False) main_wt.commit("merge branch1, rev-22", rev_id=b"rev-G") # end G self.branch = main_branch
def test_sprout_branch_nickname(self): # test the nick name is reset always raise tests.TestSkipped('XXX branch sprouting is not yet tested.')
def setUp(self): if not self.platform_supports_readonly_dirs(): raise tests.TestSkipped('platform does not support readonly' ' directories.') super(TestReadonly, self).setUp()
def setUp(self): super(TestFileIdInvolved, self).setUp() # create three branches, and merge it # # ,-->J------>K (branch2) # / \ # A --->B --->C---->D-->G (main) # \ / / # '--->E---+---->F (branch1) # A changes: # B changes: 'a-file-id-2006-01-01-abcd' # C changes: Nothing (perfect merge) # D changes: 'b-file-id-2006-01-01-defg' # E changes: 'file-d' # F changes: 'file-d' # G changes: 'b-file-id-2006-01-01-defg' # J changes: 'b-file-id-2006-01-01-defg' # K changes: 'c-funky<file-id>quiji%bo' main_wt = self.make_branch_and_tree('main') main_branch = main_wt.branch self.build_tree(["main/a", "main/b", "main/c"]) main_wt.add(['a', 'b', 'c'], [ b'a-file-id-2006-01-01-abcd', b'b-file-id-2006-01-01-defg', b'c-funky<file-id>quiji%bo' ]) try: main_wt.commit("Commit one", rev_id=b"rev-A") except errors.IllegalPath: # TODO: jam 20060701 Consider raising a different exception # newer formats do support this, and nothin can done to # correct this test - its not a bug. if sys.platform == 'win32': raise tests.TestSkipped('Old repository formats do not' ' support file ids with <> on win32') # This is not a known error condition raise # -------- end A ----------- bt1 = self.make_branch_and_tree('branch1') bt1.pull(main_branch) b1 = bt1.branch self.build_tree(["branch1/d"]) bt1.add(['d'], [b'file-d']) bt1.commit("branch1, Commit one", rev_id=b"rev-E") # -------- end E ----------- self.touch(main_wt, "a") main_wt.commit("Commit two", rev_id=b"rev-B") # -------- end B ----------- bt2 = self.make_branch_and_tree('branch2') bt2.pull(main_branch) branch2_branch = bt2.branch set_executability(bt2, 'b', True) bt2.commit("branch2, Commit one", rev_id=b"rev-J") # -------- end J ----------- main_wt.merge_from_branch(b1) main_wt.commit("merge branch1, rev-11", rev_id=b"rev-C") # -------- end C ----------- bt1.rename_one("d", "e") bt1.commit("branch1, commit two", rev_id=b"rev-F") # -------- end F ----------- self.touch(bt2, "c") bt2.commit("branch2, commit two", rev_id=b"rev-K") # -------- end K ----------- main_wt.merge_from_branch(b1) self.touch(main_wt, "b") # D gets some funky characters to make sure the unescaping works main_wt.commit("merge branch1, rev-12", rev_id=b"rev-<D>") # end D main_wt.merge_from_branch(branch2_branch) main_wt.commit("merge branch1, rev-22", rev_id=b"rev-G") # end G self.branch = main_branch
def setUp(self): super(TestUnsupportedTags, self).setUp() branch = self.make_branch('probe') if branch._format.supports_tags(): raise tests.TestSkipped( "Format %s declares that tags are supported" % branch._format)
def test_clone_branch_nickname(self): # test the nick name is preserved always raise tests.TestSkipped('XXX branch cloning is not yet tested.')