299
299
This determines the set of revisions which are involved, and then
300
300
finds all file ids affected by those revisions.
302
# TODO: jam 20060119 This code assumes that w.inclusions will
303
# always be correct. But because of the presence of ghosts
304
# it is possible to be wrong.
305
# One specific example from Robert Collins:
306
# Two branches, with revisions ABC, and AD
307
# C is a ghost merge of D.
308
# Inclusions doesn't recognize D as an ancestor.
309
# If D is ever merged in the future, the weave
310
# won't be fixed, because AD never saw revision C
311
# to cause a conflict which would force a reweave.
312
302
w = self.get_inventory_weave()
313
303
from_set = set(w.get_ancestry(from_revid))
314
304
to_set = set(w.get_ancestry(to_revid))
360
350
w = self.get_inventory_weave()
363
for lineno, insert, deletes, line in w.walk(changes):
353
# this code needs to read every line in every inventory for the
354
# inventories [changes]. Seeing a line twice is ok. Seeing a line
355
# not pesent in one of those inventories is unnecessary and not
356
# harmful because we are filtering by the revision id marker in the
357
# inventory lines to only select file ids altered in one of those
358
# revisions. We dont need to see all lines in the inventory because
359
# only those added in an inventory in rev X can contain a revision=X
361
for line in w.iter_lines_added_or_present_in_versions(changes):
364
362
start = line.find('file_id="')+9
365
363
if start < 9: continue
366
364
end = line.find('"', start)
489
487
# FIXME format 4-6 cannot be shared, this is technically faulty.
490
488
return self.control_files._transport.has('shared-storage')
492
"""Reconcile this repository."""
493
from bzrlib.reconcile import RepoReconciler
494
reconciler = RepoReconciler(self)
495
reconciler.reconcile()
493
499
def revision_tree(self, revision_id):
494
500
"""Return Tree for a revision on this branch.
514
520
if not self.has_revision(revision_id):
515
521
raise errors.NoSuchRevision(self, revision_id)
516
522
w = self.get_inventory_weave()
517
return [None] + w.get_ancestry(revision_id)
523
candidates = w.get_ancestry(revision_id)
524
return [None] + candidates # self._eliminate_revisions_not_present(candidates)
520
527
def print_file(self, file, revision_id):
682
689
"""See Repository.all_revision_ids()."""
683
690
return self._revision_store.all_revision_ids(self.get_transaction())
693
def get_ancestry(self, revision_id):
694
"""Return a list of revision-ids integrated by a revision.
696
This is topologically sorted.
698
if revision_id is None:
700
vf = self._revision_store.get_revision_file(self.get_transaction())
702
return [None] + vf.get_ancestry(revision_id)
703
except errors.RevisionNotPresent:
704
raise errors.NoSuchRevision(self, revision_id)
707
def get_revision(self, revision_id):
708
"""Return the Revision object for a named revision"""
709
return self.get_revision_reconcile(revision_id)
712
def get_revision_graph_with_ghosts(self, revision_ids=None):
713
"""Return a graph of the revisions with ghosts marked as applicable.
715
:param revision_ids: an iterable of revisions to graph or None for all.
716
:return: a Graph object with the graph reachable from revision_ids.
719
vf = self._revision_store.get_revision_file(self.get_transaction())
720
versions = vf.versions()
722
pending = set(self.all_revision_ids())
725
pending = set(revision_ids)
726
required = set(revision_ids)
729
revision_id = pending.pop()
730
if not revision_id in versions:
731
if revision_id in required:
732
raise errors.NoSuchRevision(self, revision_id)
734
result.add_ghost(revision_id)
736
parent_ids = vf.get_parents_with_ghosts(revision_id)
737
for parent_id in parent_ids:
738
# is this queued or done ?
739
if (parent_id not in pending and
740
parent_id not in done):
742
pending.add(parent_id)
743
result.add_node(revision_id, parent_ids)
749
"""Reconcile this repository."""
750
from bzrlib.reconcile import KnitReconciler
751
reconciler = KnitReconciler(self)
752
reconciler.reconcile()
686
756
class RepositoryFormat(object):
687
757
"""A repository format.
1186
1256
repo_transport = a_bzrdir.get_repository_transport(None)
1187
1257
control_files = LockableFiles(repo_transport, 'lock', LockDir)
1188
1258
control_store = self._get_control_store(repo_transport, control_files)
1189
transaction = bzrlib.transactions.PassThroughTransaction()
1259
transaction = bzrlib.transactions.WriteTransaction()
1190
1260
# trigger a write of the inventory store.
1191
1261
control_store.get_weave_or_empty('inventory', transaction)
1192
1262
_revision_store = self._get_revision_store(repo_transport, control_files)