[merge][0.11] 'bzr inventory filename'

Aaron Bentley aaron.bentley at utoronto.ca
Fri Sep 22 15:39:41 BST 2006


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

John Arbash Meinel wrote:
> -        for path, entry in inv.entries():
> +        if file_list:
> +            entries = [(path, inv[inv.path2id(path)]) for path in file_list]

This looks wrong; the paths the user provides are relative to the CWD,
but you're treating them as though they're relative to the tree root.

I suggest using tree_files, like so:

tree, file_list = tree_files(file_list)

That will give you our standard behaviour, and allow you to invoke
inventory on a tree other than one containing the CWD.

Also, you're not accounting for the possibility that the user has
entered an unversioned file.  If that happens, path2id returns None, and
the lookup fails:

./bzr inventory moo
bzr: ERROR: can't look up file_id None

I suggest using find_ids_across_trees(file_list, [tree]).  This will
ensure the files are versioned, and will recurse over subdirectories,
like we normally do.

It probably wouldn't hurt to write a helper that combined the two:

def tree_file_ids(file_list, default_branch='.',

                  require_versioned=True):
    tree, file_list = tree_files(file_list, default_branch)
    return tree, find_ids_across_trees(file_list, [tree],
                                       require_versioned)

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFFE/Wt0F+nu1YWqI0RAi/mAJ9D14Vu3GE/Bl3WGZo1b4SKIGNL6wCffJpo
fpTJsrY7z995RMdxyU/HZ08=
=t563
-----END PGP SIGNATURE-----




More information about the bazaar mailing list