[MERGE] [BUG #172970] bzrlib.revision.is_ancestor should use graph functions.

John Arbash Meinel john at arbash-meinel.com
Fri Nov 30 16:02:21 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Pool wrote:
> Martin Pool has voted resubmit.
> Status is now: Resubmit
> Comment:
> This passes in its own branch, but fails for me when merged into bzr.1.0
> with

Attached.

It seems that packs repositories need to be explicitly locked for
graph.is_ancestor() to work.

It was just a small change to add a "branch.lock_read()" trap around the
is_ancestor check.

The merge code itself already does the tree locking much earlier. So all the
code that uses this is already locking the tree.

Having done some other work recently, I'm starting to think the "if is_null()"
check should be moved into Graph.is_ancestor(). Because there are other places
that would benefit from it.

  bzr init x; cd x; bzr pull ../other-branch

Has to walk the entire graph to find that yes, the null revision *is* an
ancestor of any tip.

So I went ahead and deprecated the is_ancestor() function, and moved the
"is_null()" check into the Graph code. This might be a bit more controversial
than just adding the lock_read()/unlock calls. So I can submit the earlier
patch if you prefer.

It also turns out that our "Branch.pull()" code does a symmetry check for
(is_ancestor(target, current)) so that it doesn't do anything if you try to
pull to an older revision. So I went ahead and special cased both:
  is_ancestor('null:', X) and is_ancestor(X, 'null:')

With just this patch, doing:
  bzr init test
  cd test
  bzr remove-tree
  bzr pull ../bzr.dev

Drops from 52.370s to 32.633s.

To get the rest of the time down, you need my "set_last_revision_info" patch.
(With both patches the total time becomes 2.283s!!!!)

I also addressed Martin's concern about the "assert repo.is_locked()".
Following the route that Dirstate went, and I raise "ObjectNotLocked" rather
than a plain assert.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHUDQNJdeBCYSNAAMRAoO8AKDS4JSXy2tuHlfUkhaqFf5bwXr9vQCgwhTI
m34RRl87/utlliuBJClHqgs=
=gOod
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: is_ancestor_fix.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20071130/abbb9021/attachment-0001.diff 


More information about the bazaar mailing list