[MERGE] trees - add get_parent_ids

John Arbash Meinel john at arbash-meinel.com
Fri Jun 16 15:56:49 BST 2006


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

Robert Collins wrote:
> This patch adds a get_parent_ids() call to all our tree objects (at
> least, I think to all of them ;)).
> 
> This call returns:
> [] for a tree with unknown parents
> ['null:'] for a tree descending from null:
> [revid, ...] in general.
> 
> EmptyTree descends from ['null:'].
> RevisionTree mirrors the revision graph.
> WorkingTree provides the union of last_revision and pending merges.
> 
> -Rob

...

> === modified file 'bzrlib/tree.py'
> --- bzrlib/tree.py	2006-06-12 01:53:19 +0000
> +++ bzrlib/tree.py	2006-06-16 13:03:27 +0000
> @@ -21,10 +21,11 @@
>  from cStringIO import StringIO
>  
>  import bzrlib
> -from bzrlib.trace import mutter, note
>  from bzrlib.errors import BzrError, BzrCheckError
>  from bzrlib.inventory import Inventory
>  from bzrlib.osutils import fingerprint_file
> +import bzrlib.revision
> +from bzrlib.trace import mutter, note
>  
>  class Tree(object):
>      """Abstract file tree.
> @@ -48,6 +49,22 @@
>      trees or versioned trees.
>      """
>      
> +    def conflicts(self):
> +        """Get a list of the conflicts in the tree.
> +
> +        Each conflict is an instance of bzrlib.conflicts.Conflict.
> +        """
> +        return []
> +
> +    def get_parent_ids(self):
> +        """Get the parent ids for this tree. 
> +
> +        :return: a list of parent ids. [NULL_REVISION] is returned to indicate
> +        a tree with no parents. [] is used to indicate a tree with unknown 
> +        parentage.
> +        """
> +        raise NotImplementedError(self.get_parent_ids)
> +    
>      def has_filename(self, filename):
>          """True if the tree has given filename."""
>          raise NotImplementedError()
> @@ -134,18 +151,29 @@
>      """
>      
>      def __init__(self, branch, inv, revision_id):
> -        self._branch = branch
> +        self._repository = branch
>          self._weave_store = branch.weave_store
>          self._inventory = inv
>          self._revision_id = revision_id
>  

You are saying 'self._repository = branch' which is just plain ugly. If
you have to, put a comment, otherwise change the name of the parameter.

Otherwise, +1 from me. (After fixing the EmptyTree is 'null:' that Aaron
already mentioned.)

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

iD8DBQFEksaxJdeBCYSNAAMRAvCwAKCI9/REH7XqG9W7zYShZ4YewOnX6ACfU6LH
dMHTOEYsll1tsdtCGDG5zWw=
=sF05
-----END PGP SIGNATURE-----




More information about the bazaar mailing list