[MERGE] WorkingTree.unversion

John Arbash Meinel john at arbash-meinel.com
Thu Sep 7 19:38:18 BST 2006


Robert Collins wrote:
> This adds an unversion API to working tree which unversions entries by
> id.
> 
> When given an id, all the children of the id are unversioned too.
> 
> -Rob
> 

...

> +class NoSuchId(BzrNewError):
> +    """The file id %(file_id)s is not present in the tree %(tree)s."""
> +    
> +    def __init__(self, tree, file_id):
> +        BzrNewError.__init__(self)
> +        self.file_id = file_id
> +        self.tree = tree

I tend to do this as:
def __init__(self, tree, file_id):
    BzrNewError.__init__(self, file_id=file_id, tree=tree)

Since it is a little bit shorter. I don't know that we have a
preference, but since I saw the difference we may as well discuss it.

...

v- I thought PEP8 said
while to_find_delete:

was preferable to:
while len(to_find_delete):

Also, I think Aaron made a good point that remove_recursive() might be a
better name.

> +    def remove(self, file_id):
> +        """Remove file_id, and children, from the inventory."""
> +        to_find_delete = [self._byid[file_id]]
> +        to_delete = []
> +        while len(to_find_delete):
> +            ie = to_find_delete.pop()
> +            to_delete.append(ie.file_id)
> +            if ie.kind == 'directory':
> +                to_find_delete.extend(ie.children.values())
> +        for file_id in reversed(to_delete):
> +            del self._byid[file_id]
> +

The rest seems okay.

John
=:->



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060907/421056e5/attachment.pgp 


More information about the bazaar mailing list