'bzr ignore' in subdirectory should prepend relative path

Bug #3780 reported by Martin Pool
8
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Medium
Unassigned
Breezy
Triaged
Low
Unassigned

Bug Description

Matthieu Moy to bazaar-ng 27 Oct (5 days ago)
Hi,

The behavior of bzr ignored when called from a subdirectory of the
project is a bit confusing:

$ bzr root
/tmp/proj
$ pwd
/tmp/proj/dir
$ ls
file foo
$ bzr ignore ./foo
$ cat ../.bzrignore
./foo
$ bzr unknowns
dir/foo

I think it would make more sense to prepend the path from root, and add dir/foo instead of ./foo to the list of ignored files.

Tags: ignore ui
Revision history for this message
Robert Collins (lifeless) wrote :

I think martin has already fixed this. Martin?

Changed in bzr:
assignee: nobody → mbp
status: Unconfirmed → Confirmed
Revision history for this message
John A Meinel (jameinel) wrote :

This still seems to be a bug. Here is a test case:

$ bzr init proj
$ cd proj
$ bzr mkdir a
$ cd a
$ bzr ignore foo
$ bzr ignore ./foo
$ cat ../.bzrignore
foo
./foo

Arguably, the first one is a wildcard that should match 'foo' everywhere, but the latter one is definitely incorrect, since it should prepend the relative path and make it a/foo

John

Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

Martin agreed on IRC to allow me to take this bug.

Changed in bzr:
assignee: mbp → richard-wilbur
Changed in bzr:
status: Confirmed → In Progress
Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

John, Martin, et al:

I'd like to propose some changes in the user interface for ignore:
Use cases:
1. Mary wants to know the current list of ignores (patterns), so, even though she is developing in ~/bzr/bug_3780/bzrlib/tests/blackbox she types ``bzr ignore`` and it prints the path of the active ignore file and each pattern.
2. Jules does a find of certain files he wants to ignore and notices that in a particular subdirectory of his branch a certain filetype appears. He types
``bzr ignore /absolute/path/from/find/*.filetype`` and, since it is in his branch, a branch-root-relative pattern is added to the ignore file. (Advantage: Jules can select/copy and paste the path from the find output directly into his command line without having to trim to his branch base directory.)
3. Later, Jules notices another filetype he wishes to ignore and types ``bzr ignore /different/absolute/path/*.filetype`` and, since it is not in his branch, ignore fails with an error notifying him that the path is outside his branch.

These changes fell naturally out of fixing bug 3780. The test cases are already written and no new regressions noted.

Cheers,

Richard

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 3780] Re: 'bzr ignore' in subdirectory should prepend relative path

On 18 Oct 2006, Richard Wilbur <email address hidden> wrote:
> John, Martin, et al:
>
> I'd like to propose some changes in the user interface for ignore:
>
> These changes fell naturally out of fixing bug 3780. The test cases are
> already written and no new regressions noted.

So just to be clear, the *changes* from the current behaviour would be:

 * 'bzr ignore' shows the path of the relevant ignore file.
   (OK)

 * 'bzr ignore' with no arguments shows the list of ignore patterns?
   (I'm not so sure about this, though it could be OK under an
   option.)

 * bzr ignore with absolute paths turns them into branch-root-relative
   relative paths before adding them (also reasonable, matches what we
   do with other commands.)

I'll watch out for the test cases.

--
Martin

Revision history for this message
Aaron Bentley (abentley) wrote :

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

Richard Wilbur wrote:
> John, Martin, et al:
>
> 2. Jules does a find of certain files he wants to ignore and notices that in a particular subdirectory of his branch a certain filetype appears. He types
> ``bzr ignore /absolute/path/from/find/*.filetype`` and, since it is in his branch, a branch-root-relative pattern is added to the ignore file. (Advantage: Jules can select/copy and paste the path from the find output directly into his command line without having to trim to his branch base directory.)

I'd like to propose that we not do this. I would like it to be a
branch-root-relative filename.

I think the earlier problem of ignoring multiple files is that we were
trying to make the ignore command handle both filenames and patterns.

An ignore command that just does filenames works better with unix
commandline tools than an ignore command that supports patterns. (This
is particularly true when a filename includes square brackets).

When people want to edit their patterns, it's probably easier to edit
.bzrignore than to run "bzr ignore". Or they can run "bzr ignore
- --pattern", if you prefer.

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

iD8DBQFFNu8x0F+nu1YWqI0RAvYsAJ9MpU3LogCbFLLyZigss2LDYwjOfwCggzLV
X60NLS5ovJffCx5Nn5NjZ7A=
=Ci1n
-----END PGP SIGNATURE-----

Revision history for this message
Martin Pool (mbp) wrote :

On 19 Oct 2006, Aaron Bentley <email address hidden> wrote:
> Richard Wilbur wrote:
> > John, Martin, et al:
> >
> > 2. Jules does a find of certain files he wants to ignore and notices that in a particular subdirectory of his branch a certain filetype appears. He types
> > ``bzr ignore /absolute/path/from/find/*.filetype`` and, since it is in his branch, a branch-root-relative pattern is added to the ignore file. (Advantage: Jules can select/copy and paste the path from the find output directly into his command line without having to trim to his branch base directory.)
>
> I'd like to propose that we not do this. I would like it to be a
> branch-root-relative filename.
>
> I think the earlier problem of ignoring multiple files is that we were
> trying to make the ignore command handle both filenames and patterns.
>
> An ignore command that just does filenames works better with unix
> commandline tools than an ignore command that supports patterns. (This
> is particularly true when a filename includes square brackets).
>
> When people want to edit their patterns, it's probably easier to edit
> .bzrignore than to run "bzr ignore". Or they can run "bzr ignore
> --pattern", if you prefer.

I'm not sure I understand. (In retrospect I'm not sure if Jules in
Richard's example is meant to be giving a filename or a quoted pattern
or an unquoted pattern, but since he talks of copy/pasting the output of
find I assume it is a file.)

--
Martin

Revision history for this message
Richard Wilbur (richard-wilbur) wrote : Re: [Bug 3780] Re: 'bzr ignore' in subdirectory should prepend relative path

On Wed, 2006-10-18 at 05:20 +0000, Martin Pool wrote:
> On 18 Oct 2006, Richard Wilbur <email address hidden> wrote:
> > John, Martin, et al:
> >
> > I'd like to propose some changes in the user interface for ignore:
> >
> > These changes fell naturally out of fixing bug 3780. The test cases are
> > already written and no new regressions noted.
>
> So just to be clear, the *changes* from the current behaviour would be:
>
> * 'bzr ignore' shows the path of the relevant ignore file.
> (OK)
>
> * 'bzr ignore' with no arguments shows the list of ignore patterns?
> (I'm not so sure about this, though it could be OK under an
> option.)
These first two *changes* amount to a correct interpretation of the
first use case where Mary types only 'bzr ignore'.

If the list of ignore patterns requires an option, what would you
suggest? '-l, --list'?

> * bzr ignore with absolute paths turns them into branch-root-relative
> relative paths before adding them (also reasonable, matches what we
> do with other commands.)
This is also correct for Jules' test cases (the second and third). He
can paste a filename or a path and add wildcards. Some software
projects have very long paths, and in this case select and paste saves a
lot of typing--and misspelling. The idea is that, as long as the path
is in the branch, the absolute path in the pattern will be processed
into a branch-root-relative path as if you had taken the care to
properly trim it.

This works hand-in-hand with the changes required by bug 3780 (to add
branch-root-relative paths to a pattern), but more like the
contrapositive.

>
> I'll watch out for the test cases.
The initial patch (containing test cases) is attached to the bug. I
wanted to nail down the specification before sending it on to the
mailing list.
> --
> Martin
>

Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

On Thu, 2006-10-19 at 03:21 +0000, Aaron Bentley wrote:
> Richard Wilbur wrote:
> > John, Martin, et al:
> >
> > 2. Jules does a find of certain files he wants to ignore and notices that in a particular subdirectory of his branch a certain filetype appears. He types
> > ``bzr ignore /absolute/path/from/find/*.filetype`` and, since it is in his branch, a branch-root-relative pattern is added to the ignore file. (Advantage: Jules can select/copy and paste the path from the find output directly into his command line without having to trim to his branch base directory.)
>
> I'd like to propose that we not do this. I would like it to be a
> branch-root-relative filename.
>
> I think the earlier problem of ignoring multiple files is that we were
> trying to make the ignore command handle both filenames and patterns.
In my understanding, a filename is a pattern. It just matches only one
file--unless you add a ? or * to the filename without escaping it. Then
when ignore tries to interpret it as a pattern it will naturally see
those characters as wildcards.

>
> An ignore command that just does filenames works better with unix
> commandline tools than an ignore command that supports patterns. (This
> is particularly true when a filename includes square brackets).
>
> When people want to edit their patterns, it's probably easier to edit
> .bzrignore than to run "bzr ignore". Or they can run "bzr ignore
> - --pattern", if you prefer.
In my reading, the current documentation for ignore speaks of a list of
patterns to which bzr ignore is designed to append unique additions.
>
> Aaron

Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

On Thu, 2006-10-19 at 06:00 +0000, Martin Pool wrote:
> On 19 Oct 2006, Aaron Bentley <email address hidden> wrote:
> > Richard Wilbur wrote:
> > > John, Martin, et al:
> > >
> > > 2. Jules does a find of certain files he wants to ignore and notices that in a particular subdirectory of his branch a certain filetype appears. He types
> > > ``bzr ignore /absolute/path/from/find/*.filetype`` and, since it is in his branch, a branch-root-relative pattern is added to the ignore file. (Advantage: Jules can select/copy and paste the path from the find output directly into his command line without having to trim to his branch base directory.)
> >
[...]
> I'm not sure I understand. (In retrospect I'm not sure if Jules in
> Richard's example is meant to be giving a filename or a quoted pattern
> or an unquoted pattern, but since he talks of copy/pasting the output of
> find I assume it is a file.)
>
> --
> Martin
I forgot to quote the pattern. Oops! Sorry for the confusion.
``bzr ignore
'/really/miserably/obtusely/historically/extensively/long/absolute/path/from/find/pointing/into/package/*.filetype'``

I have unfortunately worked on projects with paths that wrapped on an
eighty-column terminal. So Jules sees a path that is producing, or
inhabited with, a certain filename pattern he wishes to ignore. Rather
than trim the path to 'extensively', which might be his branch root, and
add a '.' to make it relative, and then fix the other end of the
pattern, he can simply paste the whole mess in and deal with the pattern
(at the leaf end) which was the whole point after all.

This doesn't break any current functionality, and it extends it in the
same fashion as the relative path changes associated with the
specification of this bug. My suspicion is that this change offers
simpler and more expedient user interaction.

Richard

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

It seems reasonable to me, going by what Martin has said.

I would just like to mention that we have global (per user) ignores in ~/.bazaar/ignore, as well as per-branch ignores in .bzrignore.

So a file may be ignored from either (or both) files. So we would want to make that clear.

I also know we discussed getting rid of an explicit file-on-disk. Which would mean we have no path to print. I'm not sure that we really decided to go there, though. And in the short term, it is a good thing to display the path.

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

6 years is a very long time for a bug fix to be in progress :)

tags: added: ignore
Changed in bzr:
assignee: Richard Wilbur (richard-wilbur) → nobody
status: In Progress → Confirmed
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
Jelmer Vernooij (jelmer)
tags: added: ui
removed: check-for-breezy
Changed in brz:
status: New → Triaged
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.