~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

Merged John Meinel's integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
        self.revision_id = revision_id
46
46
        self.properties = properties or {}
47
47
        self._check_properties()
48
 
        self.__dict__.update(args)
49
48
        self.parent_ids = []
50
49
        self.parent_sha1s = []
 
50
        self.__dict__.update(args)
51
51
 
52
52
    def __repr__(self):
53
53
        return "<Revision id %s>" % self.revision_id
88
88
    revisions_source is an object supporting a get_revision operation that
89
89
    behaves like Branch's.
90
90
    """
91
 
    return candidate_id in branch.get_ancestry(revision_id)
 
91
    return candidate_id in branch.repository.get_ancestry(revision_id)
92
92
 
93
93
 
94
94
def iter_ancestors(revision_id, revision_source, only_present=False):
151
151
        if b_ancestors.has_key(revision):
152
152
            a_intersection.append((a_distance, a_order, revision))
153
153
            b_intersection.append((b_ancestors[revision][1], a_order, revision))
154
 
    mutter("a intersection: %r" % a_intersection)
155
 
    mutter("b intersection: %r" % b_intersection)
 
154
    mutter("a intersection: %r", a_intersection)
 
155
    mutter("b intersection: %r", b_intersection)
156
156
 
157
157
    a_closest = __get_closest(a_intersection)
158
158
    if len(a_closest) == 0:
159
159
        return None
160
160
    b_closest = __get_closest(b_intersection)
161
161
    assert len(b_closest) != 0
162
 
    mutter ("a_closest %r" % a_closest)
163
 
    mutter ("b_closest %r" % b_closest)
 
162
    mutter ("a_closest %r", a_closest)
 
163
    mutter ("b_closest %r", b_closest)
164
164
    if a_closest[0] in b_closest:
165
165
        return a_closest[0]
166
166
    elif b_closest[0] in a_closest:
176
176
    TODO: Produce graphs with the NULL revision as root, so that we can find
177
177
    a common even when trees are not branches don't represent a single line
178
178
    of descent.
 
179
    RBC: 20051024: note that when we have two partial histories, this may not
 
180
         be possible. But if we are willing to pretend :)... sure.
179
181
    """
180
182
    ancestors = {}
181
183
    descendants = {}
208
210
            if parents is not None:
209
211
                ancestors[line] = set(parents)
210
212
        lines = new_lines
 
213
    if root is None:
 
214
        # The history for revision becomes inaccessible without
 
215
        # actually hitting a no-parents revision. This then
 
216
        # makes these asserts below trigger. So, if root is None
 
217
        # determine the actual root by walking the accessible tree
 
218
        # and then stash NULL_REVISION at the end.
 
219
        root = NULL_REVISION
 
220
        descendants[root] = {}
 
221
        # for every revision, check we can access at least
 
222
        # one parent, if we cant, add NULL_REVISION and
 
223
        # a link
 
224
        for rev in ancestors:
 
225
            if len(ancestors[rev]) == 0:
 
226
                raise RuntimeError('unreachable code ?!')
 
227
            ok = False
 
228
            for parent in ancestors[rev]:
 
229
                if parent in ancestors:
 
230
                    ok = True
 
231
            if ok:
 
232
                continue
 
233
            descendants[root][rev] = 1
 
234
            ancestors[rev].add(root)
 
235
        ancestors[root] = set()
211
236
    assert root not in descendants[root]
212
237
    assert root not in ancestors[root]
213
238
    return root, ancestors, descendants