~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/missing.py

  • Committer: Vincent Ladeuil
  • Date: 2008-09-10 14:49:15 UTC
  • mto: (3705.1.1 trunk2)
  • mto: This revision was merged to the branch mainline in revision 3708.
  • Revision ID: v.ladeuil+lp@free.fr-20080910144915-ul6dhgtzd80ut9kb
Fix incorrect revnos based on jam's feedback.

* missing.py:
(_enumerate_with_merges): We need full history to get correct
revnos, let's do that :-( A 'branch' parameter is now needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
    return mainline
112
112
 
113
113
 
114
 
def _enumerate_with_merges(ancestry, graph, tip_revno, tip, reverse=False):
 
114
def _enumerate_with_merges(branch, ancestry, graph, tip_revno, tip,
 
115
                           reverse=False):
115
116
    """Enumerate the revisions for the ancestry.
116
117
 
 
118
    :param branch: The branch we care about
117
119
    :param ancestry: A set of revisions that we care about
118
120
    :param graph: A Graph which lets us find the parents for a revision
119
121
    :param tip_revno: The revision number for the tip revision
126
128
    if not ancestry: #Empty ancestry, no need to do any work
127
129
        return []
128
130
 
129
 
    parent_map = graph.get_parent_map(ancestry)
 
131
    mainline_revs, rev_nos, start_rev_id, end_rev_id = log._get_mainline_revs(
 
132
        branch, None, tip_revno)
 
133
    if not mainline_revs:
 
134
        return []
 
135
 
 
136
    # This asks for all mainline revisions, which is size-of-history and
 
137
    # should be addressed (but currently the only way to get correct
 
138
    # revnos).
 
139
 
 
140
    # mainline_revisions always includes an extra revision at the
 
141
    # beginning, so don't request it.
 
142
    parent_map = dict(((key, value) for key, value
 
143
                       in graph.iter_ancestry(mainline_revs[1:])
 
144
                       if value is not None))
130
145
    # filter out ghosts; merge_sort errors on ghosts. 
131
 
    # XXX: is this needed here ? -- vila080903
 
146
    # XXX: is this needed here ? -- vila080910
132
147
    rev_graph = _mod_repository._strip_NULL_ghosts(parent_map)
133
 
    # XXX: what if rev_graph is empty now ?
 
148
    # XXX: what if rev_graph is empty now ? -- vila080910
134
149
    merge_sorted_revisions = tsort.merge_sort(rev_graph, tip,
135
 
                                              None, generate_revno=True)
136
 
    # merge_sort calculate revno for the given graph, we have to recalculate
137
 
    # the correct revno from the tip_revno.
138
 
    ms_tip_revno = merge_sorted_revisions[0][3]
139
 
    revno_delta = tip_revno - ms_tip_revno[0]
 
150
                                              mainline_revs,
 
151
                                              generate_revno=True)
 
152
    # Now that we got the correct revnos, keep only the relevant
 
153
    # revisions.
 
154
    merge_sorted_revisions = [
 
155
        (s, revid, n, d, e) for s, revid, n, d, e in merge_sorted_revisions
 
156
        if revid in ancestry]
140
157
    if reverse:
141
158
        merge_sorted_revisions = log.reverse_by_depth(merge_sorted_revisions)
142
159
    revline = []
143
160
    for seq, rev_id, merge_depth, revno, end_of_merge in merge_sorted_revisions:
144
 
        real_revno = (revno[0] + revno_delta,) + revno[1:]
145
 
        revline.append(('.'.join(map(str, real_revno)), rev_id))
 
161
        revline.append(('.'.join(map(str, revno)), rev_id))
146
162
    return revline
147
163
 
148
164
 
173
189
        local_extra, remote_extra = graph.find_difference(local_revision_id,
174
190
                                                          remote_revision_id)
175
191
    if include_merges:
176
 
        locals = _enumerate_with_merges(local_extra, graph, local_revno,
 
192
        locals = _enumerate_with_merges(local_branch, local_extra,
 
193
                                        graph, local_revno,
177
194
                                        local_revision_id, reverse)
178
 
        remotes = _enumerate_with_merges(remote_extra, graph, remote_revno,
179
 
                                      remote_revision_id, reverse)
 
195
        remotes = _enumerate_with_merges(remote_branch, remote_extra,
 
196
                                         graph, remote_revno,
 
197
                                         remote_revision_id, reverse)
180
198
    else:
181
199
        # Now that we have unique ancestors, compute just the mainline, and
182
200
        # generate revnos for them.