182
182
parents = new.get_parent_ids()
183
183
if len(parents) < 2:
185
186
pending = parents[1:]
186
187
branch = new.branch
187
188
last_revision = parents[0]
188
189
to_file.write('<pending_merges>')
189
if last_revision is not None:
191
ignore = set(branch.repository.get_ancestry(last_revision))
192
except errors.NoSuchRevision:
193
# the last revision is a ghost : assume everything is new
195
ignore = set([None, last_revision])
198
190
# TODO: this could be improved using merge_sorted - we'd get the same
199
191
# output rather than one level of indent.
192
graph = branch.repository.get_graph()
193
other_revisions = [last_revision]
200
194
for merge in pending:
203
width = terminal_width()
204
m_revision = branch.repository.get_revision(merge)
205
to_file.write(logxml.line_log(m_revision))
206
inner_merges = branch.repository.get_ancestry(merge)
207
assert inner_merges[0] is None
209
inner_merges.reverse()
210
for mmerge in inner_merges:
213
mm_revision = branch.repository.get_revision(mmerge)
214
to_file.write(logxml.line_log(mm_revision))
216
except errors.NoSuchRevision:
217
to_file.write('<pending_merge>%s</pending_merge>' % merge)
196
rev = branch.repository.get_revisions([merge])[0]
197
except errors.NoSuchRevision:
198
# If we are missing a revision, just print out the revision id
199
show_ghost(to_file, merge)
200
other_revisions.append(merge)
203
# Log the merge, as it gets a slightly different formatting
204
to_file.write(logxml.line_log(rev))
205
# Find all of the revisions in the merge source, which are not in the
206
# last committed revision.
207
merge_extra = graph.find_unique_ancestors(merge, other_revisions)
208
other_revisions.append(merge)
209
merge_extra.discard(_mod_revision.NULL_REVISION)
211
# Get a handle to all of the revisions we will need
213
revisions = dict((rev.revision_id, rev) for rev in
214
branch.repository.get_revisions(merge_extra))
215
except errors.NoSuchRevision:
216
# One of the sub nodes is a ghost, check each one
218
for revision_id in merge_extra:
220
rev = branch.repository.get_revisions([revision_id])[0]
221
except errors.NoSuchRevision:
222
revisions[revision_id] = None
224
revisions[revision_id] = rev
226
# Display the revisions brought in by this merge.
227
rev_id_iterator = _get_sorted_revisions(merge, merge_extra,
228
branch.repository.get_parent_map(merge_extra))
229
# Skip the first node
230
num, first, depth, eom = rev_id_iterator.next()
232
raise AssertionError('Somehow we misunderstood how'
233
' iter_topo_order works %s != %s' % (first, merge))
234
for num, sub_merge, depth, eom in rev_id_iterator:
235
rev = revisions[sub_merge]
237
show_ghost(to_file, sub_merge)
239
to_file.write(logxml.line_log(revisions[sub_merge]))
218
240
to_file.write('</pending_merges>')
243
def show_ghost(to_file, merge):
244
to_file.write('<pending_merge kind="ghost"><log><revisionid>'
245
'%s</revisionid></log></pending_merge>' \
220
249
def show_tree_xml(delta, to_file, show_ids=False, show_unchanged=False,
221
250
short_status=False, show_unversioned=False):
222
251
"""output this delta in a (xml) status-like form to to_file."""