[MERGE] Let find_previous_heads take a repository.
Aaron Bentley
aaron.bentley at utoronto.ca
Mon Jun 19 03:57:52 BST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Johan Rydberg wrote:
> Robert Collins <robertc at robertcollins.net> writes:
> Robert and I discussed this a bit on IRC. Here's a new patch to shoot
> down. We both dislike the fact that find_previous_heads use either a
> repository, or a passed repository_file, but because of how the
> upgrade code works it is a must, I'm afraid.
It looks as though VersionedFile is meant to be a type of
RepositoryFile. Shouldn't it subclass it?
I'm not sure about RepositoryFile as part of our API. It seems to me
that VersionedFile is a reasonable level of abstraction, and that it can
describe all our past and present ways of referring to versions of files
reasonably well.
When RepositoryFile is fleshed out more, how will it differ from
VersionedFile?
> === modified file 'bzrlib/versionedfile.py'
> --- bzrlib/versionedfile.py
> +++ bzrlib/versionedfile.py
> @@ -449,6 +449,38 @@
> def weave_merge(self, plan, a_marker=TextMerge.A_MARKER,
> b_marker=TextMerge.B_MARKER):
> return PlanWeaveMerge(plan, a_marker, b_marker).merge_lines()[0]
> +
> + def find_heads(self, versions):
> + """See RepositoryFile.find_heads."""
> + # list of revisions, one for each head.
> + heads = []
> + # revision: ancestor list for each head
> + head_ancestors = {}
> + # eliminate ancestors amongst the available candidates:
> + # heads are those that are not an ancestor of any other candidate
> + # - this provides convergence at a per-file level.
> + for version_id in versions:
> + # may be an ancestor of a known head:
> + already_present = 0 != len(
> + [head for head in heads
> + if version_id in head_ancestors[head]])
This is not very clear. Perhaps:
already_present = bool(len([head for head in heads if version_id in
head_ancestors[head]]))
or
already_present = False
for head in heads:
if version_id in head_ancestors[head]:
already_present = True
break
or
if len([head for head in heads if version_id in
head_ancestors[head]]) > 0:
already_present = True
else:
already_present = False
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFElhKw0F+nu1YWqI0RAjxxAJ9a1En2J9bdHfo9d5J6GCiGlRG+eQCff3dk
13HP/bPyWMiUQoCCNMMKp6Y=
=dJrm
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list