update -r does a lookup in whole-branch history

Bug #517800 reported by John A Meinel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Low
Parth Malwankar

Bug Description

The current WorkingTree._update_tree code has this clause:

        if revision is None:
            revision = self.branch.last_revision()
        else:
            if revision not in self.branch.revision_history():
                raise errors.NoSuchRevision(self.branch, revision)

Which has a couple issues:

1) I don't really know why we refuse to allow the revision to not be in the mainline of the branch. I don't see a specific problem doing "bzr update -r 1.2.1" for example.
2) Perhaps we meant to check if it was in the ancestry at all? I'm not sure that doing "bzr update -r revid:XXX" (for XXX not in the ancestry) needs to be forbidden, though.
3) Regardless, using 'revision_history()' for this requires reading the entire lefthand ancestry, and for something like emacs, this can be 100k revisions. If we want to keep the left-hand check, we could just do:
  revno = self.branch.revision_id_to_revno(revision)

Which will raise NoSuchRevision for us if the revision is not in the lefthand ancestry. I don't think we have a quick shortcut for the non-mainline case, though revision_id_to_dotted_revno() will check if it is in the ancestry, otherwise raising a NoSuchRevision exception, and it will probably be the fastest method to use. (Alternative is to use graph.iter_ancestry() and iterate until the revision is found, but that may not be super efficient anyway, and doesn't use the fast-path for loading index ancestry.)

Tags: performance

Related branches

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 517800] [NEW] update -r does a lookup in whole-branch history

On 5 February 2010 21:40, John A Meinel <email address hidden> wrote:
> 1) I don't really know why we refuse to allow the revision to not be in the mainline of the branch. I don't see a specific problem doing "bzr update -r 1.2.1" for example.
> 2) Perhaps we meant to check if it was in the ancestry at all? I'm not sure that doing "bzr update -r revid:XXX" (for XXX not in the ancestry) needs to be forbidden, though.

I don't see any good reason to forbid it either.

--
Martin <http://launchpad.net/~mbp/>

Parth Malwankar (parthm)
Changed in bzr:
status: Confirmed → In Progress
assignee: nobody → Parth Malwankar (parthm)
Parth Malwankar (parthm)
Changed in bzr:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.