# Bazaar revision bundle v0.7 # # message: # Let find_previous_heads take a Repository. # committer: Johan Rydberg # date: Tue 2006-06-13 01:23:29.792676926 +0200 === modified file bzrlib/bzrdir.py --- bzrlib/bzrdir.py +++ bzrlib/bzrdir.py @@ -1600,6 +1600,15 @@ The file needs to be added into the weave if it is a merge of >=2 parents or if it's changed from its parent. """ + class AncestryProvider(object): + """Implement Repositorys ancestry file queries.""" + + def __init__(self, w): + self._w = w + + def get_file_ancestry(self, file_id, revision_ids): + return self._w.get_ancestry(revision_ids) + if ie.kind == 'root_directory': return file_id = ie.file_id @@ -1610,9 +1619,7 @@ self.text_weaves[file_id] = w text_changed = False previous_entries = ie.find_previous_heads(parent_invs, - None, - None, - entry_vf=w) + AncestryProvider(w)) for old_revision in previous_entries: # if this fails, its a ghost ? assert old_revision in self.converted_revs === modified file bzrlib/inventory.py --- bzrlib/inventory.py +++ bzrlib/inventory.py @@ -157,9 +157,7 @@ """Perform a diff between two entries of the same kind.""" def find_previous_heads(self, previous_inventories, - versioned_file_store, - transaction, - entry_vf=None): + repository): """Return the revisions and entries that directly preceed this. Returned as a map from revision to inventory entry. @@ -168,14 +166,12 @@ for which the file exists, and its revision is not a parent of any other. If the file is new, the set will be empty. - :param versioned_file_store: A store where ancestry data on this - file id can be queried. - :param transaction: The transaction that queries to the versioned - file store should be completed under. - :param entry_vf: The entry versioned file, if its already available. + :param repository: A repository where ancestry data on this + file can be queried. """ - def get_ancestors(weave, entry): - return set(weave.get_ancestry(entry.revision)) + def get_ancestors(entry): + return set(repository.get_file_ancestry(entry.file_id, + entry.revision)) # revision:ie mapping for each ie found in previous_inventories. candidates = {} # revision:ie mapping with one revision for each head. @@ -226,10 +222,7 @@ continue # not an ancestor of a known head: # load the versioned file for this file id if needed - if entry_vf is None: - entry_vf = versioned_file_store.get_weave_or_empty( - self.file_id, transaction) - ancestors = get_ancestors(entry_vf, ie) + ancestors = get_ancestors(ie) # may knock something else out: check_heads = list(heads.keys()) for head in check_heads: === modified file bzrlib/repository.py --- bzrlib/repository.py +++ bzrlib/repository.py @@ -628,6 +628,18 @@ result.check() return result + def get_file_ancestry(self, file_id, revision_ids): + """Return a list of all ancestors of given version(s). This + will not include the null revision. + + Must raise RevisionNotPresent if any of the given versions are + not present in file history.""" + if isinstance(revision_ids, basestring): + revision_ids = [revision_ids] + vf = self.text_store.get_weave_or_empty(file_id, + self.get_transaction()) + return vf.get_ancestry(revision_ids) + class AllInOneRepository(Repository): """Legacy support - the repository behaviour for all-in-one branches.""" @@ -2024,10 +2036,7 @@ # which may be the sole parent if it is untouched. if ie.revision is not None: return - previous_entries = ie.find_previous_heads( - parent_invs, - self.repository.weave_store, - self.repository.get_transaction()) + previous_entries = ie.find_previous_heads(parent_invs, self.repository) # we are creating a new revision for ie in the history store # and inventory. ie.snapshot(self._new_revision_id, path, previous_entries, tree, self) === modified file bzrlib/tests/test_inv.py --- bzrlib/tests/test_inv.py +++ bzrlib/tests/test_inv.py @@ -426,9 +426,7 @@ def get_previous_heads(self, inventories): return self.file_active.find_previous_heads( - inventories, - self.branch.repository.weave_store, - self.branch.repository.get_transaction()) + inventories, self.branch.repository) def test_fileid_in_no_inventory(self): self.assertEqual({}, self.get_previous_heads([self.inv_A])) # revision id: jrydberg@gnu.org-20060612232329-31581648dee530d5 # sha1: 87a1c281182d1e57665f6c305d3b966b23fed900 # inventory sha1: 08a1fd45ddf3fa6ac728ffe4cabdb39f9642567c # parent ids: # pqm@pqm.ubuntu.com-20060611213609-113d9fc9c0f8edfc # base id: pqm@pqm.ubuntu.com-20060611213609-113d9fc9c0f8edfc # properties: # branch-nick: bzr.jrydberg.blob