Merge lp:~ajeans/bzr/fix-40103-status-on-ignored into lp:bzr

Proposed by Arnaud Jeansen
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~ajeans/bzr/fix-40103-status-on-ignored
Merge into: lp:bzr
Diff against target: 68 lines (+47/-0)
2 files modified
bzrlib/status.py (+14/-0)
bzrlib/tests/blackbox/test_status.py (+33/-0)
To merge this branch: bzr merge lp:~ajeans/bzr/fix-40103-status-on-ignored
Reviewer Review Type Date Requested Status
Robert Collins (community) Needs Fixing
Martin Pool Needs Fixing
Review via email: mp+22486@code.launchpad.net

Commit message

Inform users that a file specified to commit is an ignored unversioned file.

Description of the change

This branch adds a warning when the user issues a status command on a given file, but the file is unversioned *and* should be ignored. A unit test is added to show the new behaviour

LP: #40103 has more details

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

Thanks for tackling this and thanks for giving a good cover letter including the bug link - it makes it much easier to review.

I think this is a bit overspecific to the case of giving just one ignored file; if I said

 bzr st foo~ bar~

and they were both ignored I would still find it strange if this just said nothing.

Now in the output format perhaps it is better not to give a warning but rather to show them under the heading 'ignored':

  % bzr st foo~ bar~
  ignored:
    foo~
    bar~

that might be more adaptable to other presentations of the status output too.

hth

review: Needs Fixing
Revision history for this message
Arnaud Jeansen (ajeans) wrote :

Thanks for the quick reply Martin,

I was looking for an easy fix to a very specific case. If we want to be complete, we need to answer the following questions (where 'we' translates to 'you' :))

1) "ignored:\n foo~\n bar~\n" looks similar to the "normal" output, so to be consistent we should also handle short output with something like "I foo~\nI bar~". Does it look correct to you ?

2) If we output a list of ignored files, in which conditions do we make it appear ?
   a) Display ignored files whatever the case (even for a general "bzr status")
   b) Display ignored files when specific files have been fed (only for "bzr status foo~ bar~")
   c) Display ignored files when specifc files have been fed, and no other status is present (for "bzr status foo*" and only if there is not a versioned 'foo' file)

I would be in favor of 1)handling short and 2)c), which is the less intrusive change.

Thoughts ?
Arnaud

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

On 1 April 2010 03:17, Arnaud Jeansen <email address hidden> wrote:
> Thanks for the quick reply Martin,
>
> I was looking for an easy fix to a very specific case. If we want to be complete, we need to answer the following questions (where 'we' translates to 'you' :))
>
> 1) "ignored:\n foo~\n bar~\n" looks similar to the "normal" output, so to be consistent we should also handle short output with something like "I  foo~\nI  bar~". Does it look correct to you ?
>
> 2) If we output a list of ignored files, in which conditions do we make it appear ?
>   a) Display ignored files whatever the case (even for a general "bzr status")
>   b) Display ignored files when specific files have been fed (only for "bzr status foo~ bar~")
>   c) Display ignored files when specifc files have been fed, and no other status is present (for "bzr status foo*" and only if there is not a versioned 'foo' file)
>
> I would be in favor of 1)handling short and 2)c), which is the less intrusive change.

I would have said 1 and 2b, if I'm understanding you correctly. All
the files you name on the command line should be included in the
output, even if some or all of them are ignored. That seems probably
simplest for the user.

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Arnaud Jeansen (ajeans) wrote :

Martin,

Understood, I will give this a try. However, I will wait for the status callback to land (https://code.launchpad.net/~ajeans/bzr/status-callback/+merge/20828). It will make the change easier for me, and it touches the same code (now that the change impacts normal and short output).

Thanks.

Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

Hi Arnaud,

The status-callback branch has now landed.

Could you mark this patch as Work In Progress if it's back in your court (rather than needing another review) please?

Revision history for this message
Arnaud Jeansen (ajeans) wrote :

Good evening,

The merge interface does not seem to like a push --overwrite on a rebased branch, sorry about this mess. Obviously only changes authored by me are relevant. At least, the diff below is clean.

Martin, I implemented what you suggested in your latest comment. I'm not entirely happy with the code (pushing this change outside of the new callback and the ChangeReporter), but I think this is the best 'short term' fix.

I will try to clean this up along with the rest, but that will be RFC material.

Thank you,
Arnaud

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

I'm not sure the XXX is appropriate; deltas can't really talk about ignored/not ignored, and I'm not sure they should. Could you take it out? I find speculative XXX's age very fast and usually just are noise.

review: Needs Fixing
Revision history for this message
Arnaud Jeansen (ajeans) wrote :

Good evening Robert,

I don't really mind removing the XXX, so here is the change.

However I am convinced that this whole part should be improved, and I will submit a proposal as time permits.

Thank you for the review.

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

Queued on 2010-04-15 23:30:35.997048+00:00 now submitted to PQM.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/status.py'
2--- bzrlib/status.py 2010-03-20 00:07:45 +0000
3+++ bzrlib/status.py 2010-04-15 20:25:58 +0000
4@@ -166,6 +166,20 @@
5 short=short, want_unchanged=show_unchanged,
6 want_unversioned=want_unversioned, show_ids=show_ids)
7
8+ # show the ignored files among specific files (i.e. show the files
9+ # identified from input that we choose to ignore).
10+ if specific_files is not None:
11+ # Ignored files is sorted because specific_files is already sorted
12+ ignored_files = [specific for specific in
13+ specific_files if new.is_ignored(specific)]
14+ if len(ignored_files) > 0 and not short:
15+ to_file.write("ignored:\n")
16+ prefix = ' '
17+ else:
18+ prefix = 'I '
19+ for ignored_file in ignored_files:
20+ to_file.write("%s %s\n" % (prefix, ignored_file))
21+
22 # show the new conflicts only for now. XXX: get them from the
23 # delta.
24 conflicts = new.conflicts()
25
26=== modified file 'bzrlib/tests/blackbox/test_status.py'
27--- bzrlib/tests/blackbox/test_status.py 2010-03-25 09:39:03 +0000
28+++ bzrlib/tests/blackbox/test_status.py 2010-04-15 20:25:58 +0000
29@@ -472,6 +472,39 @@
30 self.assertEqual("working tree is out of date, run 'bzr update'\n",
31 err)
32
33+ def test_status_on_ignored(self):
34+ """Tests branch status on an unversioned file which is considered ignored.
35+
36+ See https://bugs.launchpad.net/bzr/+bug/40103
37+ """
38+ tree = self.make_branch_and_tree('.')
39+
40+ self.build_tree(['test1.c', 'test1.c~', 'test2.c~'])
41+ result = self.run_bzr('status')[0]
42+ self.assertContainsRe(result, "unknown:\n test1.c\n")
43+ short_result = self.run_bzr('status --short')[0]
44+ self.assertContainsRe(short_result, "\? test1.c\n")
45+
46+ result = self.run_bzr('status test1.c')[0]
47+ self.assertContainsRe(result, "unknown:\n test1.c\n")
48+ short_result = self.run_bzr('status --short test1.c')[0]
49+ self.assertContainsRe(short_result, "\? test1.c\n")
50+
51+ result = self.run_bzr('status test1.c~')[0]
52+ self.assertContainsRe(result, "ignored:\n test1.c~\n")
53+ short_result = self.run_bzr('status --short test1.c~')[0]
54+ self.assertContainsRe(short_result, "I test1.c~\n")
55+
56+ result = self.run_bzr('status test1.c~ test2.c~')[0]
57+ self.assertContainsRe(result, "ignored:\n test1.c~\n test2.c~\n")
58+ short_result = self.run_bzr('status --short test1.c~ test2.c~')[0]
59+ self.assertContainsRe(short_result, "I test1.c~\nI test2.c~\n")
60+
61+ result = self.run_bzr('status test1.c test1.c~ test2.c~')[0]
62+ self.assertContainsRe(result, "unknown:\n test1.c\nignored:\n test1.c~\n test2.c~\n")
63+ short_result = self.run_bzr('status --short test1.c test1.c~ test2.c~')[0]
64+ self.assertContainsRe(short_result, "\? test1.c\nI test1.c~\nI test2.c~\n")
65+
66 def test_status_write_lock(self):
67 """Test that status works without fetching history and
68 having a write lock.