Rev 5444: (parthm) 'bzr status' now displays shelve summary (#403687). (Parth in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Sep 24 17:37:41 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5444 [merge]
revision-id: pqm at pqm.ubuntu.com-20100924163738-had2t815v98b262p
parent: pqm at pqm.ubuntu.com-20100924081819-5b3m10xulgg6d3cv
parent: parth.malwankar at gmail.com-20100924151157-w3v5z7xfvcxg8dd5
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-09-24 17:37:38 +0100
message:
(parthm) 'bzr status' now displays shelve summary (#403687). (Parth
Malwankar)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/shelf.py prepare_shelf.py-20081005181341-n74qe6gu1e65ad4v-1
bzrlib/status.py status.py-20050505062338-431bfa63ec9b19e6
bzrlib/tests/blackbox/test_status.py teststatus.py-20050712014354-508855eb9f29f7dc
=== modified file 'NEWS'
--- a/NEWS 2010-09-24 02:19:28 +0000
+++ b/NEWS 2010-09-24 12:53:00 +0000
@@ -18,10 +18,15 @@
* Add ``mainline`` revision specifier, which selects the revision that
merged a specified revision into the mainline. (Aaron Bentley)
-
+
* Add ``annotate`` revision specifier, which selects the revision that
introduced a specified line of a file. (Aaron Bentley)
+* ``bzr status`` now displays a summary of existing shelves after
+ the other status information. This is done using a ``post_status``
+ hook.
+ (Parth Malwankar, #403687)
+
Bug Fixes
*********
=== modified file 'bzrlib/shelf.py'
--- a/bzrlib/shelf.py 2010-04-30 11:03:59 +0000
+++ b/bzrlib/shelf.py 2010-09-24 15:11:57 +0000
@@ -18,6 +18,8 @@
import errno
import re
+from bzrlib.lazy_import import lazy_import
+lazy_import(globals(), """
from bzrlib import (
bencode,
errors,
@@ -26,6 +28,7 @@
pack,
transform,
)
+""")
class ShelfCreator(object):
=== modified file 'bzrlib/status.py'
--- a/bzrlib/status.py 2010-08-31 13:49:48 +0000
+++ b/bzrlib/status.py 2010-09-17 15:15:34 +0000
@@ -398,9 +398,6 @@
(2, 3), None))
-hooks = StatusHooks()
-
-
class StatusHookParams(object):
"""Object holding parameters passed to post_status hooks.
@@ -441,3 +438,22 @@
self.old_tree, self.new_tree, self.to_file, self.versioned,
self.show_ids, self.short, self.verbose)
+
+def _show_shelve_summary(params):
+ """post_status hook to display a summary of shelves.
+
+ :param params: StatusHookParams.
+ """
+ manager = params.new_tree.get_shelf_manager()
+ shelves = manager.active_shelves()
+ if shelves:
+ params.to_file.write('%d shelves exist. '
+ 'See "bzr shelve --list" for details.\n' % len(shelves))
+
+
+hooks = StatusHooks()
+
+
+hooks.install_named_hook('post_status', _show_shelve_summary,
+ 'bzr status')
+
=== modified file 'bzrlib/tests/blackbox/test_status.py'
--- a/bzrlib/tests/blackbox/test_status.py 2010-06-24 06:57:31 +0000
+++ b/bzrlib/tests/blackbox/test_status.py 2010-09-12 05:09:24 +0000
@@ -33,6 +33,7 @@
conflicts,
errors,
osutils,
+ status,
)
import bzrlib.branch
from bzrlib.osutils import pathjoin
@@ -520,6 +521,27 @@
out, err = self.run_bzr('status branch1 -rbranch:branch2')
self.assertEqual('', out)
+ def test_status_with_shelves(self):
+ """Ensure that _show_shelve_summary handler works.
+ """
+ wt = self.make_branch_and_tree('.')
+ self.build_tree(['hello.c'])
+ wt.add('hello.c')
+ self.run_bzr(['shelve', '--all', '-m', 'foo'])
+ self.build_tree(['bye.c'])
+ wt.add('bye.c')
+ # As TestCase.setUp clears all hooks, we install this default
+ # post_status hook handler for the test.
+ status.hooks.install_named_hook('post_status',
+ status._show_shelve_summary,
+ 'bzr status')
+ self.assertStatus([
+ 'added:\n',
+ ' bye.c\n',
+ '1 shelves exist. See "bzr shelve --list" for details.\n',
+ ],
+ wt)
+
class CheckoutStatus(BranchStatus):
More information about the bazaar-commits
mailing list