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
=== modified file 'bzrlib/status.py'
--- bzrlib/status.py 2011-06-01 12:53:56 +0000
+++ bzrlib/status.py 2011-11-30 00:53:25 +0000
@@ -157,7 +157,7 @@
157 try:157 try:
158 for hook in hooks['pre_status']:158 for hook in hooks['pre_status']:
159 hook(StatusHookParams(old, new, to_file, versioned,159 hook(StatusHookParams(old, new, to_file, versioned,
160 show_ids, short, verbose))160 show_ids, short, verbose, specific_files=specific_files))
161161
162 specific_files, nonexistents \162 specific_files, nonexistents \
163 = _filter_nonexistent(specific_files, old, new)163 = _filter_nonexistent(specific_files, old, new)
@@ -222,7 +222,7 @@
222 raise errors.PathsDoNotExist(nonexistents)222 raise errors.PathsDoNotExist(nonexistents)
223 for hook in hooks['post_status']:223 for hook in hooks['post_status']:
224 hook(StatusHookParams(old, new, to_file, versioned,224 hook(StatusHookParams(old, new, to_file, versioned,
225 show_ids, short, verbose))225 show_ids, short, verbose, specific_files=specific_files))
226 finally:226 finally:
227 old.unlock()227 old.unlock()
228 new.unlock()228 new.unlock()
@@ -416,7 +416,7 @@
416 """416 """
417417
418 def __init__(self, old_tree, new_tree, to_file, versioned, show_ids,418 def __init__(self, old_tree, new_tree, to_file, versioned, show_ids,
419 short, verbose):419 short, verbose, specific_files=None):
420 """Create a group of post_status hook parameters.420 """Create a group of post_status hook parameters.
421421
422 :param old_tree: Start tree (basis tree) for comparison.422 :param old_tree: Start tree (basis tree) for comparison.
@@ -426,6 +426,9 @@
426 :param show_ids: Show internal object ids.426 :param show_ids: Show internal object ids.
427 :param short: Use short status indicators.427 :param short: Use short status indicators.
428 :param verbose: Verbose flag.428 :param verbose: Verbose flag.
429 :param specific_files: If set, a list of filenames whose status should be
430 shown. It is an error to give a filename that is not in the working
431 tree, or in the working inventory or in the basis inventory.
429 """432 """
430 self.old_tree = old_tree433 self.old_tree = old_tree
431 self.new_tree = new_tree434 self.new_tree = new_tree
@@ -434,14 +437,15 @@
434 self.show_ids = show_ids437 self.show_ids = show_ids
435 self.short = short438 self.short = short
436 self.verbose = verbose439 self.verbose = verbose
440 self.specific_files = specific_files
437441
438 def __eq__(self, other):442 def __eq__(self, other):
439 return self.__dict__ == other.__dict__443 return self.__dict__ == other.__dict__
440444
441 def __repr__(self):445 def __repr__(self):
442 return "<%s(%s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,446 return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
443 self.old_tree, self.new_tree, self.to_file, self.versioned,447 self.old_tree, self.new_tree, self.to_file, self.versioned,
444 self.show_ids, self.short, self.verbose)448 self.show_ids, self.short, self.verbose, self.specific_files)
445449
446450
447def _show_shelve_summary(params):451def _show_shelve_summary(params):
@@ -449,6 +453,10 @@
449453
450 :param params: StatusHookParams.454 :param params: StatusHookParams.
451 """455 """
456 # Don't show shelves if status of specific files is being shown, only if
457 # no file arguments have been passed
458 if params.specific_files:
459 return
452 get_shelf_manager = getattr(params.new_tree, 'get_shelf_manager', None)460 get_shelf_manager = getattr(params.new_tree, 'get_shelf_manager', None)
453 if get_shelf_manager is None:461 if get_shelf_manager is None:
454 return462 return
455463
=== modified file 'bzrlib/tests/blackbox/test_status.py'
--- bzrlib/tests/blackbox/test_status.py 2011-06-03 08:45:36 +0000
+++ bzrlib/tests/blackbox/test_status.py 2011-11-30 00:53:25 +0000
@@ -53,24 +53,25 @@
53 status._show_shelve_summary,53 status._show_shelve_summary,
54 'bzr status')54 'bzr status')
5555
56 def assertStatus(self, expected_lines, working_tree,56 def assertStatus(self, expected_lines, working_tree, specific_files=None,
57 revision=None, short=False, pending=True, verbose=False):57 revision=None, short=False, pending=True, verbose=False):
58 """Run status in working_tree and look for output.58 """Run status in working_tree and look for output.
5959
60 :param expected_lines: The lines to look for.60 :param expected_lines: The lines to look for.
61 :param working_tree: The tree to run status in.61 :param working_tree: The tree to run status in.
62 """62 """
63 output_string = self.status_string(working_tree, revision, short,63 output_string = self.status_string(working_tree, specific_files, revision, short,
64 pending, verbose)64 pending, verbose)
65 self.assertEqual(expected_lines, output_string.splitlines(True))65 self.assertEqual(expected_lines, output_string.splitlines(True))
6666
67 def status_string(self, wt, revision=None, short=False, pending=True,67 def status_string(self, wt, specific_files=None, revision=None,
68 verbose=False):68 short=False, pending=True, verbose=False):
69 # use a real file rather than StringIO because it doesn't handle69 # use a real file rather than StringIO because it doesn't handle
70 # Unicode very well.70 # Unicode very well.
71 tof = codecs.getwriter('utf-8')(TemporaryFile())71 tof = codecs.getwriter('utf-8')(TemporaryFile())
72 show_tree_status(wt, to_file=tof, revision=revision, short=short,72 show_tree_status(wt, specific_files=specific_files, to_file=tof,
73 show_pending=pending, verbose=verbose)73 revision=revision, short=short, show_pending=pending,
74 verbose=verbose)
74 tof.seek(0)75 tof.seek(0)
75 return tof.read().decode('utf-8')76 return tof.read().decode('utf-8')
7677
@@ -569,14 +570,22 @@
569 ],570 ],
570 wt)571 wt)
571 self.run_bzr(['shelve', '--all', '-m', 'bar'])572 self.run_bzr(['shelve', '--all', '-m', 'bar'])
572 self.build_tree(['spam.c'])573 self.build_tree(['eggs.c', 'spam.c'])
574 wt.add('eggs.c')
573 wt.add('spam.c')575 wt.add('spam.c')
574 self.assertStatus([576 self.assertStatus([
575 'added:\n',577 'added:\n',
578 ' eggs.c\n',
576 ' spam.c\n',579 ' spam.c\n',
577 '2 shelves exist. See "bzr shelve --list" for details.\n',580 '2 shelves exist. See "bzr shelve --list" for details.\n',
578 ],581 ],
579 wt)582 wt)
583 self.assertStatus([
584 'added:\n',
585 ' spam.c\n',
586 ],
587 wt,
588 specific_files=['spam.c'])
580589
581590
582class CheckoutStatus(BranchStatus):591class CheckoutStatus(BranchStatus):
583592
=== modified file 'bzrlib/tests/test_status.py'
--- bzrlib/tests/test_status.py 2011-03-30 11:45:54 +0000
+++ bzrlib/tests/test_status.py 2011-11-30 00:53:25 +0000
@@ -169,7 +169,7 @@
169 params = calls[0]169 params = calls[0]
170 self.assertIsInstance(params, _mod_status.StatusHookParams)170 self.assertIsInstance(params, _mod_status.StatusHookParams)
171 attrs = ['old_tree', 'new_tree', 'to_file', 'versioned',171 attrs = ['old_tree', 'new_tree', 'to_file', 'versioned',
172 'show_ids', 'short', 'verbose']172 'show_ids', 'short', 'verbose', 'specific_files']
173 for a in attrs:173 for a in attrs:
174 self.assertTrue(hasattr(params, a),174 self.assertTrue(hasattr(params, a),
175 'Attribute "%s" not found in StatusHookParam' % a)175 'Attribute "%s" not found in StatusHookParam' % a)
@@ -192,7 +192,7 @@
192 params = calls[0]192 params = calls[0]
193 self.assertIsInstance(params, _mod_status.StatusHookParams)193 self.assertIsInstance(params, _mod_status.StatusHookParams)
194 attrs = ['old_tree', 'new_tree', 'to_file', 'versioned',194 attrs = ['old_tree', 'new_tree', 'to_file', 'versioned',
195 'show_ids', 'short', 'verbose']195 'show_ids', 'short', 'verbose', 'specific_files']
196 for a in attrs:196 for a in attrs:
197 self.assertTrue(hasattr(params, a),197 self.assertTrue(hasattr(params, a),
198 'Attribute "%s" not found in StatusHookParam' % a)198 'Attribute "%s" not found in StatusHookParam' % a)
199199
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- doc/en/release-notes/bzr-2.5.txt 2011-11-29 12:57:56 +0000
+++ doc/en/release-notes/bzr-2.5.txt 2011-11-30 00:53:25 +0000
@@ -46,6 +46,9 @@
46* Plugins can now register additional "location aliases".46* Plugins can now register additional "location aliases".
47 (Jelmer Vernooij)47 (Jelmer Vernooij)
4848
49* ``bzr status`` no longer shows shelves if files are specified.
50 (Francis Devereux)
51
49Bug Fixes52Bug Fixes
50*********53*********
5154