18
18
# perhaps show them in log -v and allow them as options to the commit command.
22
21
import bzrlib.errors as errors
23
22
from bzrlib.graph import node_distances, select_farthest, all_descendants, Graph
24
23
from bzrlib.osutils import contains_whitespace
25
24
from bzrlib.progress import DummyProgress
26
from bzrlib.symbol_versioning import *
25
from bzrlib.symbol_versioning import (deprecated_function,
28
29
NULL_REVISION="null:"
101
103
reversed_result.reverse()
102
104
return reversed_result
106
def get_summary(self):
107
"""Get the first line of the log message for this revision.
109
return self.message.split('\n', 1)[0]
105
112
def is_ancestor(revision_id, candidate_id, branch):
106
113
"""Return true if candidate_id is an ancestor of revision_id.
124
131
yield ancestor, distance
126
133
revision = revision_source.get_revision(ancestor)
127
except bzrlib.errors.NoSuchRevision, e:
134
except errors.NoSuchRevision, e:
128
135
if e.revision == revision_id:
214
221
root_b, ancestors_b, descendants_b = revision_graph(
215
222
revision_b, revision_source)
216
223
if root != root_b:
217
raise bzrlib.errors.NoCommonRoot(revision_a, revision_b)
224
raise errors.NoCommonRoot(revision_a, revision_b)
219
226
for node, node_anc in ancestors_b.iteritems():
220
227
if node in ancestors:
268
275
root = NULL_REVISION
269
276
common.add(NULL_REVISION)
270
except bzrlib.errors.NoCommonRoot:
271
raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
277
except errors.NoCommonRoot:
278
raise errors.NoCommonAncestor(revision_a, revision_b)
273
280
pb.update('Picking ancestor', 2, 3)
274
281
distances = node_distances (descendants, ancestors, root)
275
282
pb.update('Picking ancestor', 3, 2)
276
283
farthest = select_farthest(distances, common)
277
284
if farthest is None or farthest == NULL_REVISION:
278
raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
285
raise errors.NoCommonAncestor(revision_a, revision_b)
300
307
for source in self._revision_sources:
302
309
return source.get_revision(revision_id)
303
except bzrlib.errors.NoSuchRevision, e:
310
except errors.NoSuchRevision, e:
399
406
def unlock(self):
400
407
for source in self._revision_sources:
411
@deprecated_function(zero_eight)
412
def get_intervening_revisions(ancestor_id, rev_id, rev_source,
413
revision_history=None):
414
"""Find the longest line of descent from maybe_ancestor to revision.
415
Revision history is followed where possible.
417
If ancestor_id == rev_id, list will be empty.
418
Otherwise, rev_id will be the last entry. ancestor_id will never appear.
419
If ancestor_id is not an ancestor, NotAncestor will be thrown
421
root, ancestors, descendants = revision_graph(rev_id, rev_source)
422
if len(descendants) == 0:
423
raise errors.NoSuchRevision(rev_source, rev_id)
424
if ancestor_id not in descendants:
425
rev_source.get_revision(ancestor_id)
426
raise errors.NotAncestor(rev_id, ancestor_id)
427
root_descendants = all_descendants(descendants, ancestor_id)
428
root_descendants.add(ancestor_id)
429
if rev_id not in root_descendants:
430
raise errors.NotAncestor(rev_id, ancestor_id)
431
distances = node_distances(descendants, ancestors, ancestor_id,
432
root_descendants=root_descendants)
434
def best_ancestor(rev_id):
436
for anc_id in ancestors[rev_id]:
438
distance = distances[anc_id]
441
if revision_history is not None and anc_id in revision_history:
443
elif best is None or distance > best[1]:
444
best = (anc_id, distance)
449
while next != ancestor_id:
451
next = best_ancestor(next)