def test_fetch_missing_text_other_location_fails(self): source_tree = self.make_branch_and_tree('source') source = source_tree.branch.repository target = self.make_to_repository('target') # start by adding a file so the data knit for the file exists in # repositories that have specific files for each fileid. self.build_tree(['source/id']) source_tree.add(['id'], ['id']) source_tree.commit('a', rev_id='a') # now we manually insert a revision with an inventory referencing # file 'id' at revision 'b', but we do not insert revision b. # this should ensure that the new versions of files are being checked # for during pull operations inv = source.get_inventory('a') source.lock_write() self.addCleanup(source.unlock) source.start_write_group() inv['id'].revision = 'b' inv.revision_id = 'b' sha1 = source.add_inventory('b', inv, ['a']) rev = Revision(timestamp=0, timezone=None, committer="Foo Bar <*****@*****.**>", message="Message", inventory_sha1=sha1, revision_id='b') rev.parent_ids = ['a'] source.add_revision('b', rev) self.disable_commit_write_group_paranoia(source) source.commit_write_group() self.assertRaises(errors.RevisionNotPresent, target.fetch, source) self.assertFalse(target.has_revision('b'))
def test_fetch_missing_text_other_location_fails(self): source_tree = self.make_branch_and_tree('source') source = source_tree.branch.repository target = self.make_to_repository('target') # start by adding a file so the data knit for the file exists in # repositories that have specific files for each fileid. self.build_tree(['source/id']) source_tree.add(['id'], ['id']) source_tree.commit('a', rev_id='a') # now we manually insert a revision with an inventory referencing # 'id' at revision 'b', but we do not insert revision b. # this should ensure that the new versions of files are being checked # for during pull operations inv = source.get_inventory('a') source.lock_write() self.addCleanup(source.unlock) source.start_write_group() inv['id'].revision = 'b' inv.revision_id = 'b' sha1 = source.add_inventory('b', inv, ['a']) rev = Revision(timestamp=0, timezone=None, committer="Foo Bar <*****@*****.**>", message="Message", inventory_sha1=sha1, revision_id='b') rev.parent_ids = ['a'] source.add_revision('b', rev) source.commit_write_group() self.assertRaises(errors.RevisionNotPresent, target.fetch, source) self.assertFalse(target.has_revision('b'))
def annotate_file_tree(tree, file_id, to_file, verbose=False, full=False, show_ids=False, branch=None): """Annotate file_id in a tree. The tree should already be read_locked() when annotate_file_tree is called. :param tree: The tree to look for revision numbers and history from. :param file_id: The file_id to annotate. :param to_file: The file to output the annotation to. :param verbose: Show all details rather than truncating to ensure reasonable text width. :param full: XXXX Not sure what this does. :param show_ids: Show revision ids in the annotation output. :param branch: Branch to use for revision revno lookups """ if branch is None: branch = tree.branch if to_file is None: to_file = sys.stdout # Handle the show_ids case annotations = list(tree.annotate_iter(file_id)) if show_ids: return _show_id_annotations(annotations, to_file, full) if not getattr(tree, "get_revision_id", False): # Create a virtual revision to represent the current tree state. # Should get some more pending commit attributes, like pending tags, # bugfixes etc. current_rev = Revision(CURRENT_REVISION) current_rev.parent_ids = tree.get_parent_ids() try: current_rev.committer = branch.get_config_stack().get('email') except errors.NoWhoami: current_rev.committer = 'local user' current_rev.message = "?" current_rev.timestamp = round(time.time(), 3) current_rev.timezone = osutils.local_time_offset() else: current_rev = None annotation = list(_expand_annotations(annotations, branch, current_rev)) _print_annotations(annotation, verbose, to_file, full)
def setUp(self): self.reduceLockdirTimeout() super(TestReconcileWithIncorrectRevisionCache, self).setUp() t = get_transport(self.get_url()) # we need a revision with two parents in the wrong order # which should trigger reinsertion. # and another with the first one correct but the other two not # which should not trigger reinsertion. # these need to be in different repositories so that we don't # trigger a reconcile based on the other case. # there is no api to construct a broken knit repository at # this point. if we ever encounter a bad graph in a knit repo # we should add a lower level api to allow constructing such cases. # first off the common logic: tree = self.make_branch_and_tree('wrong-first-parent') second_tree = self.make_branch_and_tree('reversed-secondary-parents') for t in [tree, second_tree]: t.commit('1', rev_id='1') uncommit(t.branch, tree=t) t.commit('2', rev_id='2') uncommit(t.branch, tree=t) t.commit('3', rev_id='3') uncommit(t.branch, tree=t) #second_tree = self.make_branch_and_tree('reversed-secondary-parents') #second_tree.pull(tree) # XXX won't copy the repo? repo_secondary = second_tree.branch.repository # now setup the wrong-first parent case repo = tree.branch.repository repo.lock_write() repo.start_write_group() inv = Inventory(revision_id='wrong-first-parent') inv.root.revision = 'wrong-first-parent' sha1 = repo.add_inventory('wrong-first-parent', inv, ['2', '1']) rev = Revision(timestamp=0, timezone=None, committer="Foo Bar <*****@*****.**>", message="Message", inventory_sha1=sha1, revision_id='wrong-first-parent') rev.parent_ids = ['1', '2'] repo.add_revision('wrong-first-parent', rev) repo.commit_write_group() repo.unlock() # now setup the wrong-secondary parent case repo = repo_secondary repo.lock_write() repo.start_write_group() inv = Inventory(revision_id='wrong-secondary-parent') inv.root.revision = 'wrong-secondary-parent' if repo.supports_rich_root(): root_id = inv.root.file_id repo.texts.add_lines((root_id, 'wrong-secondary-parent'), [], []) sha1 = repo.add_inventory('wrong-secondary-parent', inv, ['1', '3', '2']) rev = Revision(timestamp=0, timezone=None, committer="Foo Bar <*****@*****.**>", message="Message", inventory_sha1=sha1, revision_id='wrong-secondary-parent') rev.parent_ids = ['1', '2', '3'] repo.add_revision('wrong-secondary-parent', rev) repo.commit_write_group() repo.unlock()