Comment 3 for bug 115343

Revision history for this message
John A Meinel (jameinel) wrote :

In tracking through the code it seems to occurring in:

 BzrDir.sprout()
  Branch.sprout()
    Branch.copy_content_into()
      Branch6._synchronize_history()

The reason is that Branch5._sync... does:
  try:
    new_history = revision_history[:revision_history.index(revision_id)]
  except IndexError:
    new_history = self.generate_history(revision_id)

Which means that if necessary it will regenerate a revision history for that id.

However, Branch6 uses:

        if revision_id is None:
            revno, revision_id = self.last_revision_info()
        else:
            revno = self.revision_id_to_revno(revision_id)
        destination.set_last_revision_info(revno, revision_id)

With no fallback in the case that revision_id doesn't exist in the revision_history.

The difficulty is that 'set_last_revision_info()' needs to know the revno for the given revision. Which in general means creating the full history for it, and finding it's left-hand distance to null (revno).

A simple fix is:

  rev = self.repository.get_revision(revision_id)
  new_history = rev.get_history(self.repository)[1:]
  revno = len(new_history)

Another possibility is:

  revno = len(list(self.repository.iter_reverse_revision_history(revision_id)))

It would be nice if we could figure this stuff out without traversing the whole graph, but
a) Revisions don't record their revno at commit time (though they could)
b) revno is distance to null, so you have to walk back to null to find the distance.