Rev 3893: Add --list option to shelve (abentley) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Dec 11 07:57:57 GMT 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3893
revision-id: pqm at pqm.ubuntu.com-20081211075753-m1ktaz1at8oxlp00
parent: pqm at pqm.ubuntu.com-20081210210638-e569azc2bomqq5qx
parent: aaron at aaronbentley.com-20081211060357-c03e8qj0oaiw3g6t
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2008-12-11 07:57:53 +0000
message:
Add --list option to shelve (abentley)
added:
bzrlib/tests/blackbox/test_shelve.py test_ls_shelf.py-20081202053526-thlo8yt0pi1cgor1-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/shelf.py prepare_shelf.py-20081005181341-n74qe6gu1e65ad4v-1
bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
bzrlib/tests/test_shelf.py test_prepare_shelf.p-20081005181341-n74qe6gu1e65ad4v-2
------------------------------------------------------------
revno: 0.16.119
revision-id: aaron at aaronbentley.com-20081211060357-c03e8qj0oaiw3g6t
parent: aaron at aaronbentley.com-20081211043815-txr61gyz174x41c1
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: ls-shelf
timestamp: Wed 2008-12-10 22:03:57 -0800
message:
Fix option help style.
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
------------------------------------------------------------
revno: 0.16.118
revision-id: aaron at aaronbentley.com-20081211043815-txr61gyz174x41c1
parent: aaron at aaronbentley.com-20081211042826-0zgon0hquuau0rse
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: ls-shelf
timestamp: Wed 2008-12-10 20:38:15 -0800
message:
Fix open_containing
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
------------------------------------------------------------
revno: 0.16.117
revision-id: aaron at aaronbentley.com-20081211042826-0zgon0hquuau0rse
parent: aaron at aaronbentley.com-20081211030727-1e95kx8mixx0spru
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: ls-shelf
timestamp: Wed 2008-12-10 20:28:26 -0800
message:
Remove references to ls-shelf
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
------------------------------------------------------------
revno: 0.16.116
revision-id: aaron at aaronbentley.com-20081211030727-1e95kx8mixx0spru
parent: aaron at aaronbentley.com-20081211030610-mw6v6v7dxwseyyhm
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: ls-shelf
timestamp: Wed 2008-12-10 19:07:27 -0800
message:
Update NEWS
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 0.16.115
revision-id: aaron at aaronbentley.com-20081211030610-mw6v6v7dxwseyyhm
parent: aaron at aaronbentley.com-20081211030500-sl63oogmfwy3tjd3
parent: pqm at pqm.ubuntu.com-20081210210638-e569azc2bomqq5qx
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: ls-shelf
timestamp: Wed 2008-12-10 19:06:10 -0800
message:
Merge bzr.dev into shelf2
added:
bzrlib/fifo_cache.py fifo_cache.py-20081209212307-31ffjwvteyvmydnf-1
bzrlib/tests/per_repository/test_add_inventory_by_delta.py test_add_inventory_d-20081013002626-rut81igtlqb4590z-1
bzrlib/tests/test_fifo_cache.py test_fifo_cache.py-20081209212307-31ffjwvteyvmydnf-2
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/__init__.py __init__.py-20050309040759-33e65acf91bbcd5d
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/commit.py commit.py-20050511101309-79ec1a0168e0e825
bzrlib/fetch.py fetch.py-20050818234941-26fea6105696365d
bzrlib/graph.py graph_walker.py-20070525030359-y852guab65d4wtn0-1
bzrlib/inventory.py inventory.py-20050309040759-6648b84ca2005b37
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/lru_cache.py lru_cache.py-20070119165515-tlw203kuwh0id5gv-1
bzrlib/registry.py lazy_factory.py-20060809213415-2gfvqadtvdn0phtg-1
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_ls.py test_ls.py-20060712232047-0jraqpecwngee12y-1
bzrlib/tests/blackbox/test_pull.py test_pull.py-20051201144907-64959364f629947f
bzrlib/tests/blackbox/test_revision_info.py test_revision_info.py-20050917162600-21dab3877aa348d7
bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
bzrlib/tests/interrepository_implementations/__init__.py __init__.py-20060220054744-baf49a1f88f17b1a
bzrlib/tests/per_repository/__init__.py __init__.py-20060131092037-9564957a7d4a841b
bzrlib/tests/per_repository/test_add_fallback_repository.py test_add_fallback_re-20080215040003-8w9n4ck9uqdxj18m-1
bzrlib/tests/per_repository/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
bzrlib/tests/test_fetch.py testfetch.py-20050825090644-f73e07e7dfb1765a
bzrlib/tests/test_graph.py test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
bzrlib/tests/test_lru_cache.py test_lru_cache.py-20070119165535-hph6rk4h9rzy4180-1
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
bzrlib/upgrade.py history2weaves.py-20050818063535-e7d319791c19a8b2
bzrlib/versionedfile.py versionedfile.py-20060222045106-5039c71ee3b65490
doc/developers/HACKING.txt HACKING-20050805200004-2a5dc975d870f78c
------------------------------------------------------------
revno: 0.16.114
revision-id: aaron at aaronbentley.com-20081211030500-sl63oogmfwy3tjd3
parent: aaron at aaronbentley.com-20081203053127-vozu5rmsixaadw0v
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: ls-shelf
timestamp: Wed 2008-12-10 19:05:00 -0800
message:
Use open_containing when listing shelves
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
------------------------------------------------------------
revno: 0.16.113
revision-id: aaron at aaronbentley.com-20081203053127-vozu5rmsixaadw0v
parent: aaron at aaronbentley.com-20081202055411-89w3mu0uu6wrstoh
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: ls-shelf
timestamp: Wed 2008-12-03 00:31:27 -0500
message:
Change ls-shelf to shelve --list
renamed:
bzrlib/tests/blackbox/test_ls_shelf.py => bzrlib/tests/blackbox/test_shelve.py test_ls_shelf.py-20081202053526-thlo8yt0pi1cgor1-1
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
bzrlib/tests/blackbox/test_shelve.py test_ls_shelf.py-20081202053526-thlo8yt0pi1cgor1-1
------------------------------------------------------------
revno: 0.16.112
revision-id: aaron at aaronbentley.com-20081202055411-89w3mu0uu6wrstoh
parent: aaron at aaronbentley.com-20081202054417-24d9o48m6l55ln8w
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: ls-shelf
timestamp: Tue 2008-12-02 00:54:11 -0500
message:
Add tests
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/shelf.py prepare_shelf.py-20081005181341-n74qe6gu1e65ad4v-1
bzrlib/tests/test_shelf.py test_prepare_shelf.p-20081005181341-n74qe6gu1e65ad4v-2
------------------------------------------------------------
revno: 0.16.111
revision-id: aaron at aaronbentley.com-20081202054417-24d9o48m6l55ln8w
parent: aaron at aaronbentley.com-20081202053551-1f8ifkqem116sudi
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: ls-shelf
timestamp: Tue 2008-12-02 00:44:17 -0500
message:
Return metadata as a dict.
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/shelf.py prepare_shelf.py-20081005181341-n74qe6gu1e65ad4v-1
------------------------------------------------------------
revno: 0.16.110
revision-id: aaron at aaronbentley.com-20081202053551-1f8ifkqem116sudi
parent: aaron at aaronbentley.com-20081202042459-y0y1n73u7jwqpgeq
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: ls-shelf
timestamp: Tue 2008-12-02 00:35:51 -0500
message:
Implement ls-shelf command
added:
bzrlib/tests/blackbox/test_ls_shelf.py test_ls_shelf.py-20081202053526-thlo8yt0pi1cgor1-1
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/shelf.py prepare_shelf.py-20081005181341-n74qe6gu1e65ad4v-1
bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
------------------------------------------------------------
revno: 0.16.109
revision-id: aaron at aaronbentley.com-20081202042459-y0y1n73u7jwqpgeq
parent: aaron at aaronbentley.com-20081115203736-6ikutv274y59s0jo
parent: pqm at pqm.ubuntu.com-20081202015700-3mc9dola31w7h5h4
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: ls-shelf
timestamp: Mon 2008-12-01 23:24:59 -0500
message:
Merge bzr.dev into ls-shelf
added:
bzrlib/foreign.py foreign.py-20081112170002-olsxmandkk8qyfuq-1
bzrlib/tests/test_foreign.py test_foreign.py-20081125004048-ywb901edgp9lluxo-1
contrib/convert_to_1.9.py convert_to_dev2.py-20081014130524-z1ydl3mq9b4ehlvv-1
tools/win32/build_release.py build_release.py-20081105204355-2ghh5cv01v1x4rzz-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzr bzr.py-20050313053754-5485f144c7006fa6
bzrlib/__init__.py __init__.py-20050309040759-33e65acf91bbcd5d
bzrlib/_patiencediff_c.c _patiencediff_c.c-20070721205602-q3imkipwlgagp3cy-1
bzrlib/_readdir_pyx.pyx readdir.pyx-20060609152855-rm6v321vuaqyh9tu-1
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/btree_index.py index.py-20080624222253-p0x5f92uyh5hw734-7
bzrlib/bugtracker.py bugtracker.py-20070410073305-vu1vu1qosjurg8kb-1
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/commit.py commit.py-20050511101309-79ec1a0168e0e825
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/fetch.py fetch.py-20050818234941-26fea6105696365d
bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
bzrlib/index.py index.py-20070712131115-lolkarso50vjr64s-1
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/lockable_files.py control_files.py-20051111201905-bb88546e799d669f
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/mutabletree.py mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
bzrlib/plugin.py plugin.py-20050622060424-829b654519533d69
bzrlib/python-compat.h pythoncompat.h-20080924041409-9kvi0fgtuuqp743j-1
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/revisionspec.py revisionspec.py-20050907152633-17567659fd5c0ddb
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_diff.py test_diff.py-20060110203741-aa99ac93e633d971
bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
bzrlib/tests/branch_implementations/__init__.py __init__.py-20060123013057-b12a52c3f361daf4
bzrlib/tests/branch_implementations/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
bzrlib/tests/branch_implementations/test_sprout.py test_sprout.py-20070521151739-b8t8p7axw1h966ws-1
bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
bzrlib/tests/commands/test_commit.py test_commit.py-20070913161801-ydrx2k5gmv7k7eiu-1
bzrlib/tests/interrepository_implementations/test_fetch.py test_fetch.py-20080425213627-j60cjh782ufm83ry-1
bzrlib/tests/per_repository/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
bzrlib/tests/per_repository/test_revision.py testrevprops.py-20051013073044-92bc3c68302ce1bf
bzrlib/tests/test_fetch.py testfetch.py-20050825090644-f73e07e7dfb1765a
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
bzrlib/tests/test_log.py testlog.py-20050728115707-1a514809d7d49309
bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
bzrlib/tests/test_permissions.py test_permissions.py-20051215004520-ccf475789c80e80c
bzrlib/tests/test_plugins.py plugins.py-20050622075746-32002b55e5e943e9
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
bzrlib/tests/test_revision.py testrevision.py-20050804210559-46f5e1eb67b01289
bzrlib/tests/test_sftp_transport.py testsftp.py-20051027032739-247570325fec7e7e
bzrlib/tests/test_transport.py testtransport.py-20050718175618-e5cdb99f4555ddce
bzrlib/tests/workingtree_implementations/test_parents.py test_set_parents.py-20060807231740-yicmnlci1mj8smu1-1
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
bzrlib/transport/remote.py ssh.py-20060608202016-c25gvf1ob7ypbus6-1
bzrlib/versionedfile.py versionedfile.py-20060222045106-5039c71ee3b65490
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
doc/developers/ppa.txt ppa.txt-20080722055539-606u7t2z32t3ae4w-1
=== modified file 'NEWS'
--- a/NEWS 2008-12-10 17:26:40 +0000
+++ b/NEWS 2008-12-11 03:07:27 +0000
@@ -17,6 +17,9 @@
NEW FEATURES:
+ * ``shelve --list`` can now be used to list shelved changes.
+ (Aaron Bentley)
+
IMPROVEMENTS:
* Add trailing slash to directories in all output of ``bzr ls``, except
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2008-12-10 02:05:30 +0000
+++ b/bzrlib/builtins.py 2008-12-11 06:03:57 +0000
@@ -4749,6 +4749,8 @@
ie. out of the way, until a later time when you can bring them back from
the shelf with the 'unshelve' command.
+ If shelve --list is specified, previously-shelved changes are listed.
+
Shelve is intended to help separate several sets of changes that have
been inappropriately mingled. If you just want to get rid of all changes
and you don't need to restore them later, use revert. If you want to
@@ -4771,12 +4773,16 @@
'message',
RegistryOption('writer', 'Method to use for writing diffs.',
bzrlib.option.diff_writer_registry,
- value_switches=True, enum_switch=False)
+ value_switches=True, enum_switch=False),
+
+ Option('list', help='List shelved changes.'),
]
_see_also = ['unshelve']
def run(self, revision=None, all=False, file_list=None, message=None,
- writer=None):
+ writer=None, list=False):
+ if list:
+ return self.run_for_list()
from bzrlib.shelf_ui import Shelver
if writer is None:
writer = bzrlib.option.diff_writer_registry.get()
@@ -4786,6 +4792,24 @@
except errors.UserAbort:
return 0
+ def run_for_list(self):
+ tree = WorkingTree.open_containing('.')[0]
+ tree.lock_read()
+ try:
+ manager = tree.get_shelf_manager()
+ shelves = manager.active_shelves()
+ if len(shelves) == 0:
+ note('No shelved changes.')
+ return 0
+ for shelf_id in reversed(shelves):
+ message = manager.get_metadata(shelf_id).get('message')
+ if message is None:
+ message = '<no message>'
+ self.outf.write('%3d: %s\n' % (shelf_id, message))
+ return 1
+ finally:
+ tree.unlock()
+
class cmd_unshelve(Command):
"""Restore shelved changes.
=== modified file 'bzrlib/shelf.py'
--- a/bzrlib/shelf.py 2008-11-03 21:35:03 +0000
+++ b/bzrlib/shelf.py 2008-12-02 05:54:11 +0000
@@ -228,6 +228,23 @@
self.transform = transform
self.message = message
+ @staticmethod
+ def iter_records(shelf_file):
+ parser = pack.ContainerPushParser()
+ parser.accept_bytes(shelf_file.read())
+ return iter(parser.read_pending_records())
+
+ @staticmethod
+ def parse_metadata(records):
+ names, metadata_bytes = records.next()
+ if names[0] != ('metadata',):
+ raise errors.ShelfCorrupt
+ metadata = bencode.bdecode(metadata_bytes)
+ message = metadata.get('message')
+ if message is not None:
+ metadata['message'] = message.decode('utf-8')
+ return metadata
+
@classmethod
def from_tree_and_shelf(klass, tree, shelf_file):
"""Create an Unshelver from a tree and a shelf file.
@@ -236,24 +253,17 @@
:param shelf_file: A file-like object containing shelved changes.
:return: The Unshelver.
"""
- parser = pack.ContainerPushParser()
- parser.accept_bytes(shelf_file.read())
- records = iter(parser.read_pending_records())
- names, metadata_bytes = records.next()
- if names[0] != ('metadata',):
- raise errors.ShelfCorrupt
- metadata = bencode.bdecode(metadata_bytes)
+ records = klass.iter_records(shelf_file)
+ metadata = klass.parse_metadata(records)
base_revision_id = metadata['revision_id']
- message = metadata.get('message')
- if message is not None:
- message = message.decode('utf-8')
try:
base_tree = tree.revision_tree(base_revision_id)
except errors.NoSuchRevisionInTree:
base_tree = tree.branch.repository.revision_tree(base_revision_id)
tt = transform.TransformPreview(base_tree)
tt.deserialize(records)
- return klass(tree, base_tree, tt, message)
+ return klass(tree, base_tree, tt, metadata.get('message'))
+
def make_merger(self):
"""Return a merger that can unshelve the changes."""
@@ -338,6 +348,15 @@
finally:
shelf_file.close()
+ def get_metadata(self, shelf_id):
+ """Return the metadata associated with a given shelf_id."""
+ shelf_file = self.read_shelf(shelf_id)
+ try:
+ records = Unshelver.iter_records(shelf_file)
+ finally:
+ shelf_file.close()
+ return Unshelver.parse_metadata(records)
+
def delete_shelf(self, shelf_id):
"""Delete the shelved changes for a given id.
=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- a/bzrlib/tests/blackbox/__init__.py 2008-10-08 20:40:23 +0000
+++ b/bzrlib/tests/blackbox/__init__.py 2008-12-03 05:31:27 +0000
@@ -103,6 +103,7 @@
'bzrlib.tests.blackbox.test_send',
'bzrlib.tests.blackbox.test_serve',
'bzrlib.tests.blackbox.test_shared_repository',
+ 'bzrlib.tests.blackbox.test_shelve',
'bzrlib.tests.blackbox.test_sign_my_commits',
'bzrlib.tests.blackbox.test_split',
'bzrlib.tests.blackbox.test_status',
=== added file 'bzrlib/tests/blackbox/test_shelve.py'
--- a/bzrlib/tests/blackbox/test_shelve.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/blackbox/test_shelve.py 2008-12-03 05:31:27 +0000
@@ -0,0 +1,51 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+from bzrlib import shelf
+from bzrlib.tests import TestCaseWithTransport
+
+class TestShelveList(TestCaseWithTransport):
+
+ def test_no_shelved_changes(self):
+ tree = self.make_branch_and_tree('.')
+ err = self.run_bzr('shelve --list')[1]
+ self.assertEqual('No shelved changes.\n', err)
+
+ def test_shelve_one(self):
+ tree = self.make_branch_and_tree('.')
+ creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
+ shelf_id = tree.get_shelf_manager().shelve_changes(creator, 'Foo')
+ out, err = self.run_bzr('shelve --list', retcode=1)
+ self.assertEqual('', err)
+ self.assertEqual(' 1: Foo\n', out)
+
+ def test_shelve_no_message(self):
+ tree = self.make_branch_and_tree('.')
+ creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
+ shelf_id = tree.get_shelf_manager().shelve_changes(creator)
+ out, err = self.run_bzr('shelve --list', retcode=1)
+ self.assertEqual('', err)
+ self.assertEqual(' 1: <no message>\n', out)
+
+ def test_shelf_order(self):
+ tree = self.make_branch_and_tree('.')
+ creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
+ tree.get_shelf_manager().shelve_changes(creator, 'Foo')
+ creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
+ tree.get_shelf_manager().shelve_changes(creator, 'Bar')
+ out, err = self.run_bzr('shelve --list', retcode=1)
+ self.assertEqual('', err)
+ self.assertEqual(' 2: Bar\n 1: Foo\n', out)
=== modified file 'bzrlib/tests/test_shelf.py'
--- a/bzrlib/tests/test_shelf.py 2008-11-03 19:21:41 +0000
+++ b/bzrlib/tests/test_shelf.py 2008-12-02 05:54:11 +0000
@@ -457,3 +457,12 @@
unshelver = shelf_manager.get_unshelver(shelf_id)
unshelver.make_merger().do_merge()
self.assertFileEqual('bar', 'tree/foo')
+
+ def test_get_metadata(self):
+ tree = self.make_branch_and_tree('.')
+ creator = shelf.ShelfCreator(tree, tree.basis_tree())
+ shelf_manager = tree.get_shelf_manager()
+ shelf_id = shelf_manager.shelve_changes(creator, 'foo')
+ metadata = shelf_manager.get_metadata(shelf_id)
+ self.assertEqual('foo', metadata['message'])
+ self.assertEqual('null:', metadata['revision_id'])
More information about the bazaar-commits
mailing list