Merge lp://qastaging/~garyvdm/bzr/bug492116-ls-file into lp://qastaging/bzr

Proposed by Gary van der Merwe
Status: Superseded
Proposed branch: lp://qastaging/~garyvdm/bzr/bug492116-ls-file
Merge into: lp://qastaging/bzr
Diff against target: 615 lines (+235/-141) (has conflicts)
8 files modified
bzrlib/builtins.py (+21/-16)
bzrlib/revisiontree.py (+30/-13)
bzrlib/tests/blackbox/test_ls.py (+4/-0)
bzrlib/tests/per_tree/test_list_files.py (+56/-82)
bzrlib/transform.py (+44/-7)
bzrlib/workingtree.py (+34/-10)
bzrlib/workingtree_4.py (+31/-13)
doc/en/release-notes/bzr-2.3.txt (+15/-0)
Text conflict in bzrlib/transform.py
Text conflict in doc/en/release-notes/bzr-2.3.txt
To merge this branch: bzr merge lp://qastaging/~garyvdm/bzr/bug492116-ls-file
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+45679@code.qastaging.launchpad.net

Description of the change

This makes ``bzr ls FILE`` list the file passed, similar to how GNU coreutils ``ls`` behaves.

To achieve this, I changed the behavior of the ``Tree.list_files`` methods so that if passed a file, they will yield just the file.

I originally hoped that this would not be necessary, and that I could just make the necessary changes in ``builtins.cmd_ls``, but this was difficult because that would require logic to get a inventory entry, which for a wt is non-trivial. Hence, I decided to change the behavior ``Tree.list_files``.

A possible alternative to this is:
The inventory entry is only used in builtins.cmd_ls to get a entry.kind_character(), so maybe it would be easier if i were to add a tree.kind_character() method, and then I could get every thing I needed in builtins.cmd_ls with out calling Tree.list_files.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

This looks good !

I've fixed a couple of minor issues while I was reviewing it (lp:~vila/bzr/bug492116-ls-file), you may want to integrate them:
- yes, root is always a dir,
- don't use os.path when we have an osutils function for it,
- a couple of typos ;)
- some test code duplication.

On the overall, I'm a bit worried of the code duplication there, but you're not responsible for it for the most part so it's probably out of scope to fix them here. BUT, your proposed alternative may avoid to add more of it so may be it would be better to try to add the tree.kind_character method.

Revision history for this message
Andrew King (eurokang) wrote :

This also fixes a traceback I was going to report, which is bzr ls -rREV someFile.

Revision history for this message
John A Meinel (jameinel) wrote :

Putting this back to Needs Review because Gary pulled in Vincent's work, and I don't know where it stands at this point.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

This patch probably needs a bit of extra work as there are now conflicts. Gary, are you still planning to work on this?

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Unmerged revisions

5590. By Vincent Ladeuil

Fix typo.

5589. By Vincent Ladeuil

Yes, root is always a dir, use osutils instead of os.path, fix typo, remove commented out debugger call.

5588. By Vincent Ladeuil

Remove debugger call.

5587. By Vincent Ladeuil

Remove duplicated code in tests.

5586. By Vincent Ladeuil

Replace try/finally by addCleanup.

5585. By Gary van der Merwe

Make ``bzr ls FILE`` list the file passed, simillar to how GNU coreutils ``ls`` behaves.

5584. By Gary van der Merwe

Test ``Tree.list_files(from_dir=...) does deprecated warning.

5583. By Gary van der Merwe

Change all ``Tree.list_files`` methods so that if passed a file, rather than a directory, they will yield just the file.

In order to represent this, the ``from_dir`` argument has been renamed to ``from_path``, and the ``from_dir`` argument is deprecated.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.