161
def old_common_ancestor(revision_a, revision_b, revision_source):
162
"""Find the ancestor common to both revisions that is closest to both.
164
from bzrlib.trace import mutter
165
a_ancestors = find_present_ancestors(revision_a, revision_source)
166
b_ancestors = find_present_ancestors(revision_b, revision_source)
169
# a_order is used as a tie-breaker when two equally-good bases are found
170
for revision, (a_order, a_distance) in a_ancestors.iteritems():
171
if b_ancestors.has_key(revision):
172
a_intersection.append((a_distance, a_order, revision))
173
b_intersection.append((b_ancestors[revision][1], a_order, revision))
174
mutter("a intersection: %r", a_intersection)
175
mutter("b intersection: %r", b_intersection)
177
a_closest = __get_closest(a_intersection)
178
if len(a_closest) == 0:
180
b_closest = __get_closest(b_intersection)
181
assert len(b_closest) != 0
182
mutter ("a_closest %r", a_closest)
183
mutter ("b_closest %r", b_closest)
184
if a_closest[0] in b_closest:
186
elif b_closest[0] in a_closest:
189
raise bzrlib.errors.AmbiguousBase((a_closest[0], b_closest[0]))
192
161
def revision_graph(revision, revision_source):
193
162
"""Produce a graph of the ancestry of the specified revision.
194
163
Return root, ancestors map, descendants map
199
168
RBC: 20051024: note that when we have two partial histories, this may not
200
169
be possible. But if we are willing to pretend :)... sure.
171
revision_source.lock_read()
173
return _revision_graph(revision, revision_source)
175
revision_source.unlock()
177
def _revision_graph(revision, revision_source):
178
"""See revision_graph."""
204
181
lines = [revision]
283
260
def common_ancestor(revision_a, revision_b, revision_source,
284
261
pb=DummyProgress()):
262
if None in (revision_a, revision_b):
287
266
pb.update('Picking ancestor', 1, 3)
299
for source in self._revision_sources:
303
for source in self._revision_sources:
319
306
def get_intervening_revisions(ancestor_id, rev_id, rev_source,
320
307
revision_history=None):
321
308
"""Find the longest line of descent from maybe_ancestor to revision.