Merge lp:~frankoid/bzr/status-shelve-message into lp:bzr

Proposed by Francis Devereux
Status: Superseded
Proposed branch: lp:~frankoid/bzr/status-shelve-message
Merge into: lp:bzr
Diff against target: 164 lines (+34/-14)
4 files modified
bzrlib/status.py (+13/-5)
bzrlib/tests/blackbox/test_status.py (+16/-7)
bzrlib/tests/test_status.py (+2/-2)
doc/en/release-notes/bzr-2.5.txt (+3/-0)
To merge this branch: bzr merge lp:~frankoid/bzr/status-shelve-message
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+82728@code.launchpad.net

This proposal has been superseded by a proposal from 2011-11-30.

Description of the change

Make "bzr status" only output the "x shelves exist" message when no files are specified.

If you run a plain "bzr status" then you are asking bzr about the status of the whole tree, so it is reasonable for it to report shelves, but if you run "bzr status myfile" then you are just asking it about the status of myfile, so it shouldn't tell you about shelves. Also, this change will prevent the annoying Emacs warnings that happen when you visit a file inside a branch with shelves.

If a file is specified and that file is in a shelve then the shelves message is still not output. This behaviour is to keep "bzr status" fast and to keep the logic simple (there has been some discussion about this on the <email address hidden>).

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Hi Francis,

There seem to be two parts to this change:

1) passing the specified_files to all the post_status hooks
2) changing the behaviour of one of the post_status hooks, which reports shelve status

(1) seems like a good idea in any case.

Perhaps it would make sense to split this branch up into two. The hook changes should be able to land pretty quickly, the second (in whatever form) can land once we decide on the correct behaviour for status when a file is specified.

(personally, I would prefer to keep the existing behaviour of "bzr status FILE" reporting shelves, but let's keep that discussion on the mailing list - I'll follow up there)

Revision history for this message
Francis Devereux (frankoid) wrote :

Hi Jelmer,

I've separated (1) into lp:~frankoid/bzr/status-hook-params-specific-files

So far nobody on the mailing list has objected to "bzr status FILE" not reporting shelves as long as FILE isn't in a shelf, and most people seemed to want it to not report shelves in that case too, so it would be good to hear your thoughts on the mailing list.

Thanks,

Francis

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

I think this is an improvement as it is. I won't send it right away, so Jelmer can have his say if he wants to. Thanks, frankoid.

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

Francis, could you please do the Canonical contributor agreement at http://canonical.com/contributors

Revision history for this message
Francis Devereux (frankoid) wrote :

I think I signed the Canonical contributor agreement last week (on the 24th of November). Let me know if I need to try again.

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

Thanks, Francis.

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

Could you please merge up trunk and fix the conflicts? Also it may be worth mentioning in the news that there is new information available to the hooks.

Revision history for this message
Francis Devereux (frankoid) wrote :

I've merged from trunk and fixed the conflicts.

I separated out the new attribute of StatusHookParams into its own branch and merge proposal at https://code.launchpad.net/~frankoid/bzr/status-hook-params-specific-files/+merge/82930, and that branch has release notes and more tests. I thought it might be good to mark this MP as depending on 82930, but I couldn't find a way to do so (it looked like I could only indicate dependencies when creating a merge proposal, not afterwards). I can merge the other branch into this one if you like.

On 30 Nov 2011, at 00:50, Martin Pool wrote:

> Could you please merge up trunk and fix the conflicts? Also it may be worth mentioning in the news that there is new information available to the hooks.
> --
> https://code.launchpad.net/~frankoid/bzr/status-shelve-message/+merge/82728
> You are the owner of lp:~frankoid/bzr/status-shelve-message.
>

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

You can change the prerequisite branch by clicking 'resubmit' -
there's no need to do that now though,I'll just send both.

Revision history for this message
Francis Devereux (frankoid) wrote :

Thanks :-)

Martin Pool <email address hidden> wrote:

You can change the prerequisite branch by clicking 'resubmit' -
there's no need to do that now though,I'll just send both.

--
https://code.launchpad.net/~frankoid/bzr/status-shelve-message/+merge/82728
You are the owner of lp:~frankoid/bzr/status-shelve-message.

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 2011-06-01 12:53:56 +0000
3+++ bzrlib/status.py 2011-11-30 00:53:25 +0000
4@@ -157,7 +157,7 @@
5 try:
6 for hook in hooks['pre_status']:
7 hook(StatusHookParams(old, new, to_file, versioned,
8- show_ids, short, verbose))
9+ show_ids, short, verbose, specific_files=specific_files))
10
11 specific_files, nonexistents \
12 = _filter_nonexistent(specific_files, old, new)
13@@ -222,7 +222,7 @@
14 raise errors.PathsDoNotExist(nonexistents)
15 for hook in hooks['post_status']:
16 hook(StatusHookParams(old, new, to_file, versioned,
17- show_ids, short, verbose))
18+ show_ids, short, verbose, specific_files=specific_files))
19 finally:
20 old.unlock()
21 new.unlock()
22@@ -416,7 +416,7 @@
23 """
24
25 def __init__(self, old_tree, new_tree, to_file, versioned, show_ids,
26- short, verbose):
27+ short, verbose, specific_files=None):
28 """Create a group of post_status hook parameters.
29
30 :param old_tree: Start tree (basis tree) for comparison.
31@@ -426,6 +426,9 @@
32 :param show_ids: Show internal object ids.
33 :param short: Use short status indicators.
34 :param verbose: Verbose flag.
35+ :param specific_files: If set, a list of filenames whose status should be
36+ shown. It is an error to give a filename that is not in the working
37+ tree, or in the working inventory or in the basis inventory.
38 """
39 self.old_tree = old_tree
40 self.new_tree = new_tree
41@@ -434,14 +437,15 @@
42 self.show_ids = show_ids
43 self.short = short
44 self.verbose = verbose
45+ self.specific_files = specific_files
46
47 def __eq__(self, other):
48 return self.__dict__ == other.__dict__
49
50 def __repr__(self):
51- return "<%s(%s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
52+ return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
53 self.old_tree, self.new_tree, self.to_file, self.versioned,
54- self.show_ids, self.short, self.verbose)
55+ self.show_ids, self.short, self.verbose, self.specific_files)
56
57
58 def _show_shelve_summary(params):
59@@ -449,6 +453,10 @@
60
61 :param params: StatusHookParams.
62 """
63+ # Don't show shelves if status of specific files is being shown, only if
64+ # no file arguments have been passed
65+ if params.specific_files:
66+ return
67 get_shelf_manager = getattr(params.new_tree, 'get_shelf_manager', None)
68 if get_shelf_manager is None:
69 return
70
71=== modified file 'bzrlib/tests/blackbox/test_status.py'
72--- bzrlib/tests/blackbox/test_status.py 2011-06-03 08:45:36 +0000
73+++ bzrlib/tests/blackbox/test_status.py 2011-11-30 00:53:25 +0000
74@@ -53,24 +53,25 @@
75 status._show_shelve_summary,
76 'bzr status')
77
78- def assertStatus(self, expected_lines, working_tree,
79+ def assertStatus(self, expected_lines, working_tree, specific_files=None,
80 revision=None, short=False, pending=True, verbose=False):
81 """Run status in working_tree and look for output.
82
83 :param expected_lines: The lines to look for.
84 :param working_tree: The tree to run status in.
85 """
86- output_string = self.status_string(working_tree, revision, short,
87+ output_string = self.status_string(working_tree, specific_files, revision, short,
88 pending, verbose)
89 self.assertEqual(expected_lines, output_string.splitlines(True))
90
91- def status_string(self, wt, revision=None, short=False, pending=True,
92- verbose=False):
93+ def status_string(self, wt, specific_files=None, revision=None,
94+ short=False, pending=True, verbose=False):
95 # use a real file rather than StringIO because it doesn't handle
96 # Unicode very well.
97 tof = codecs.getwriter('utf-8')(TemporaryFile())
98- show_tree_status(wt, to_file=tof, revision=revision, short=short,
99- show_pending=pending, verbose=verbose)
100+ show_tree_status(wt, specific_files=specific_files, to_file=tof,
101+ revision=revision, short=short, show_pending=pending,
102+ verbose=verbose)
103 tof.seek(0)
104 return tof.read().decode('utf-8')
105
106@@ -569,14 +570,22 @@
107 ],
108 wt)
109 self.run_bzr(['shelve', '--all', '-m', 'bar'])
110- self.build_tree(['spam.c'])
111+ self.build_tree(['eggs.c', 'spam.c'])
112+ wt.add('eggs.c')
113 wt.add('spam.c')
114 self.assertStatus([
115 'added:\n',
116+ ' eggs.c\n',
117 ' spam.c\n',
118 '2 shelves exist. See "bzr shelve --list" for details.\n',
119 ],
120 wt)
121+ self.assertStatus([
122+ 'added:\n',
123+ ' spam.c\n',
124+ ],
125+ wt,
126+ specific_files=['spam.c'])
127
128
129 class CheckoutStatus(BranchStatus):
130
131=== modified file 'bzrlib/tests/test_status.py'
132--- bzrlib/tests/test_status.py 2011-03-30 11:45:54 +0000
133+++ bzrlib/tests/test_status.py 2011-11-30 00:53:25 +0000
134@@ -169,7 +169,7 @@
135 params = calls[0]
136 self.assertIsInstance(params, _mod_status.StatusHookParams)
137 attrs = ['old_tree', 'new_tree', 'to_file', 'versioned',
138- 'show_ids', 'short', 'verbose']
139+ 'show_ids', 'short', 'verbose', 'specific_files']
140 for a in attrs:
141 self.assertTrue(hasattr(params, a),
142 'Attribute "%s" not found in StatusHookParam' % a)
143@@ -192,7 +192,7 @@
144 params = calls[0]
145 self.assertIsInstance(params, _mod_status.StatusHookParams)
146 attrs = ['old_tree', 'new_tree', 'to_file', 'versioned',
147- 'show_ids', 'short', 'verbose']
148+ 'show_ids', 'short', 'verbose', 'specific_files']
149 for a in attrs:
150 self.assertTrue(hasattr(params, a),
151 'Attribute "%s" not found in StatusHookParam' % a)
152
153=== modified file 'doc/en/release-notes/bzr-2.5.txt'
154--- doc/en/release-notes/bzr-2.5.txt 2011-11-29 12:57:56 +0000
155+++ doc/en/release-notes/bzr-2.5.txt 2011-11-30 00:53:25 +0000
156@@ -46,6 +46,9 @@
157 * Plugins can now register additional "location aliases".
158 (Jelmer Vernooij)
159
160+* ``bzr status`` no longer shows shelves if files are specified.
161+ (Francis Devereux)
162+
163 Bug Fixes
164 *********
165