~richard-wilbur/bzr/1540333-makefiles

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

merge merge tweaks from aaron, which includes latest .dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
import bzrlib.errors
19
 
from bzrlib.graph import farthest_nodes, node_distances, all_descendants
 
19
from bzrlib.graph import node_distances, select_farthest, all_descendants
 
20
 
 
21
NULL_REVISION="null:"
20
22
 
21
23
class RevisionReference(object):
22
24
    """
106
108
    revisions_source is an object supporting a get_revision operation that
107
109
    behaves like Branch's.
108
110
    """
109
 
 
 
111
    if candidate_id is None:
 
112
        return True
110
113
    for ancestor_id, distance in iter_ancestors(revision_id, revision_source):
111
114
        if ancestor_id == candidate_id:
112
115
            return True
206
209
    while len(lines) > 0:
207
210
        new_lines = set()
208
211
        for line in lines:
209
 
            try:
210
 
                rev = revision_source.get_revision(line)
211
 
                parents = [p.revision_id for p in rev.parents]
212
 
                if len(parents) == 0:
213
 
                    root = line
214
 
            except bzrlib.errors.NoSuchRevision:
215
 
                if line == revision:
216
 
                    raise
217
 
                parents = None
 
212
            if line == NULL_REVISION:
 
213
                parents = []
 
214
                root = NULL_REVISION
 
215
            else:
 
216
                try:
 
217
                    rev = revision_source.get_revision(line)
 
218
                    parents = [p.revision_id for p in rev.parents]
 
219
                    if len(parents) == 0:
 
220
                        parents = [NULL_REVISION]
 
221
                except bzrlib.errors.NoSuchRevision:
 
222
                    if line == revision:
 
223
                        raise
 
224
                    parents = None
218
225
            if parents is not None:
219
226
                for parent in parents:
220
227
                    if parent not in ancestors:
257
264
    except bzrlib.errors.NoCommonRoot:
258
265
        raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
259
266
        
260
 
    nodes = farthest_nodes(descendants, ancestors, root)
261
 
    for node in nodes:
262
 
        if node in common:
263
 
            return node
264
 
    raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
 
267
    distances = node_distances (descendants, ancestors, root)
 
268
    farthest = select_farthest(distances, common)
 
269
    if farthest is None or farthest == NULL_REVISION:
 
270
        raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
 
271
    return farthest
265
272
 
266
273
class MultipleRevisionSources(object):
267
274
    """Proxy that looks in multiple branches for revisions."""