def test_merge_kind_change(self): tree_a = self.make_branch_and_tree('tree_a') self.build_tree_contents([('tree_a/file', b'content_1')]) tree_a.add('file', b'file-id') tree_a.commit('added file') tree_b = tree_a.controldir.sprout('tree_b').open_workingtree() os.unlink('tree_a/file') self.build_tree(['tree_a/file/']) tree_a.commit('changed file to directory') self.run_bzr('merge ../tree_a', working_dir='tree_b') self.assertEqual('directory', osutils.file_kind('tree_b/file')) tree_b.revert() self.assertEqual('file', osutils.file_kind('tree_b/file')) self.build_tree_contents([('tree_b/file', b'content_2')]) tree_b.commit('content change') self.run_bzr('merge ../tree_a', retcode=1, working_dir='tree_b') self.assertEqual( tree_b.conflicts(), [conflicts.ContentsConflict('file', file_id='file-id')])
def load(self): kind = osutils.file_kind(self.filename) text = '' if kind == 'file': f = open(self.filename, 'rb') try: text = f.read() finally: f.close() elif kind == 'symlink': text = os.readlink(self.filename) self.text = text self._create_and_show_browser(self.filename, text, kind)
def add(self, files, ids=None, kinds=None): # hg does not use ids, toss them out with self.lock_tree_write(): if isinstance(files, basestring): files = [files] if kinds is None: kinds = [osutils.file_kind(self.abspath(f)) for f in files] hg_files = [] for file, kind in zip(files, kinds): if kind == "directory": continue hg_files.append(file.encode('utf-8')) # hg does not canonicalise paths : make them absolute self._dirstate.add(hg_files)
def change_kind(): if osutils.file_kind(path) == "directory": osutils.rmtree(path) else: osutils.delete_any(path) make_after(path)