Rev 3838: (abentley) Use a registry to allow plugins to specify diff writers. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Nov 17 03:43:38 GMT 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3838
revision-id: pqm at pqm.ubuntu.com-20081117034335-el4e1m7v3tnjmnhu
parent: pqm at pqm.ubuntu.com-20081114025846-mke6wrhcr7scvx1z
parent: aaron at aaronbentley.com-20081115203736-6ikutv274y59s0jo
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2008-11-17 03:43:35 +0000
message:
(abentley) Use a registry to allow plugins to specify diff writers.
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/option.py option.py-20051014052914-661fb36e76e7362f
bzrlib/shelf_ui.py shelver.py-20081005210102-33worgzwrtdw0yrm-1
bzrlib/tests/test_shelf_ui.py test_shelf_ui.py-20081027155203-wtcuazg85wp9u4fv-1
------------------------------------------------------------
revno: 0.16.108
revision-id: aaron at aaronbentley.com-20081115203736-6ikutv274y59s0jo
parent: aaron at aaronbentley.com-20081115195929-2w9zzm3f9vi39f2q
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: shelf-updates
timestamp: Sat 2008-11-15 15:37:36 -0500
message:
Shelf supports multiple diff writers.
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/option.py option.py-20051014052914-661fb36e76e7362f
bzrlib/shelf_ui.py shelver.py-20081005210102-33worgzwrtdw0yrm-1
bzrlib/tests/test_shelf_ui.py test_shelf_ui.py-20081027155203-wtcuazg85wp9u4fv-1
------------------------------------------------------------
revno: 0.16.107
revision-id: aaron at aaronbentley.com-20081115195929-2w9zzm3f9vi39f2q
parent: aaron at aaronbentley.com-20081115195443-enphc227pw2vumju
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: shelf-updates
timestamp: Sat 2008-11-15 14:59:29 -0500
message:
Remove vila's colordiff change
modified:
bzrlib/shelf_ui.py shelver.py-20081005210102-33worgzwrtdw0yrm-1
------------------------------------------------------------
revno: 0.16.106
revision-id: aaron at aaronbentley.com-20081115195443-enphc227pw2vumju
parent: aaron at aaronbentley.com-20081111023239-g55qvly8vjnv07yi
parent: pqm at pqm.ubuntu.com-20081114025846-mke6wrhcr7scvx1z
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: shelf-updates
timestamp: Sat 2008-11-15 14:54:43 -0500
message:
Merge bzr.dev
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/branchbuilder.py branchbuilder.py-20070427022007-zlxpqz2lannhk6y8-1
bzrlib/btree_index.py index.py-20080624222253-p0x5f92uyh5hw734-7
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/commit.py commit.py-20050511101309-79ec1a0168e0e825
bzrlib/fetch.py fetch.py-20050818234941-26fea6105696365d
bzrlib/help_topics/en/hooks.txt hooks.txt-20070830033044-xxu2rced13f72dka-1
bzrlib/msgeditor.py msgeditor.py-20050901111708-ef6d8de98f5d8f2f
bzrlib/plugin.py plugin.py-20050622060424-829b654519533d69
bzrlib/plugins/launchpad/account.py account.py-20071011033320-50y6vfftywf4yllw-1
bzrlib/plugins/launchpad/lp_directory.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
bzrlib/plugins/launchpad/test_account.py test_account.py-20071011033320-50y6vfftywf4yllw-2
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/shelf_ui.py shelver.py-20081005210102-33worgzwrtdw0yrm-1
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_breakin.py test_breakin.py-20070424043903-qyy6zm4pj3h4sbp3-1
bzrlib/tests/blackbox/test_commit.py test_commit.py-20060212094538-ae88fc861d969db0
bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
bzrlib/tests/http_server.py httpserver.py-20061012142527-m1yxdj1xazsf8d7s-1
bzrlib/tests/per_repository/test_write_group.py test_write_group.py-20070716105516-89n34xtogq5frn0m-1
bzrlib/tests/test_btree_index.py test_index.py-20080624222253-p0x5f92uyh5hw734-13
bzrlib/tests/test_msgeditor.py test_msgeditor.py-20051202041359-920315ec6011ee51
bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
bzrlib/tests/test_plugins.py plugins.py-20050622075746-32002b55e5e943e9
bzrlib/tests/test_sftp_transport.py testsftp.py-20051027032739-247570325fec7e7e
bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
bzrlib/trace.py trace.py-20050309040759-c8ed824bdcd4748a
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
bzrlib/transport/remote.py ssh.py-20060608202016-c25gvf1ob7ypbus6-1
bzrlib/transport/sftp.py sftp.py-20051019050329-ab48ce71b7e32dfe
doc/en/user-guide/writing_a_plugin.txt writing_a_plugin.txt-20071114035000-q36a9h57ps06uvnl-7
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2008-11-13 14:42:06 +0000
+++ b/bzrlib/builtins.py 2008-11-15 20:37:36 +0000
@@ -4757,13 +4757,20 @@
'revision',
Option('all', help='Shelve all changes.'),
'message',
+ RegistryOption('writer', 'Method to use for writing diffs.',
+ bzrlib.option.diff_writer_registry,
+ value_switches=True, enum_switch=False)
]
_see_also = ['unshelve']
- def run(self, revision=None, all=False, file_list=None, message=None):
+ def run(self, revision=None, all=False, file_list=None, message=None,
+ writer=None):
from bzrlib.shelf_ui import Shelver
+ if writer is None:
+ writer = bzrlib.option.diff_writer_registry.get()
try:
- Shelver.from_args(revision, all, file_list, message).run()
+ Shelver.from_args(writer(sys.stdout), revision, all, file_list,
+ message).run()
except errors.UserAbort:
return 0
=== modified file 'bzrlib/option.py'
--- a/bzrlib/option.py 2008-10-02 06:18:42 +0000
+++ b/bzrlib/option.py 2008-11-15 20:37:36 +0000
@@ -564,3 +564,7 @@
_global_option('dry-run',
help="Show what would be done, but don't actually do anything.")
_global_option('name-from-revision', help='The path name in the old tree.')
+
+diff_writer_registry = _mod_registry.Registry()
+diff_writer_registry.register('plain', lambda x: x, 'Plaintext diff output.')
+diff_writer_registry.default_key = 'plain'
=== modified file 'bzrlib/shelf_ui.py'
--- a/bzrlib/shelf_ui.py 2008-11-11 05:50:23 +0000
+++ b/bzrlib/shelf_ui.py 2008-11-15 20:37:36 +0000
@@ -35,14 +35,10 @@
)
-# Plugins may want to override the following
-diff_writer_factory = None
-
-
class Shelver(object):
"""Interactively shelve the changes in a working tree."""
- def __init__(self, work_tree, target_tree, auto=False,
+ def __init__(self, work_tree, target_tree, diff_writer=None, auto=False,
auto_apply=False, file_list=None, message=None):
"""Constructor.
@@ -56,10 +52,8 @@
"""
self.work_tree = work_tree
self.target_tree = target_tree
- if diff_writer_factory is not None:
- self.diff_writer = diff_writer_factory(target=sys.stdout,
- check_style=False)
- else:
+ self.diff_writer = diff_writer
+ if self.diff_writer is None:
self.diff_writer = sys.stdout
self.manager = work_tree.get_shelf_manager()
self.auto = auto
@@ -68,7 +62,7 @@
self.message = message
@classmethod
- def from_args(klass, revision=None, all=False, file_list=None,
+ def from_args(klass, diff_writer, revision=None, all=False, file_list=None,
message=None, directory='.'):
"""Create a shelver from commandline arguments.
@@ -81,7 +75,8 @@
tree, path = workingtree.WorkingTree.open_containing(directory)
target_tree = builtins._get_one_revision_tree('shelf2', revision,
tree.branch, tree)
- return klass(tree, target_tree, all, all, file_list, message)
+ return klass(tree, target_tree, diff_writer, all, all, file_list,
+ message)
def run(self):
"""Interactively shelve the changes."""
=== modified file 'bzrlib/tests/test_shelf_ui.py'
--- a/bzrlib/tests/test_shelf_ui.py 2008-11-03 21:52:46 +0000
+++ b/bzrlib/tests/test_shelf_ui.py 2008-11-15 20:37:36 +0000
@@ -17,6 +17,7 @@
from cStringIO import StringIO
import os
+import sys
from bzrlib import errors, shelf_ui, tests
@@ -24,10 +25,10 @@
class ExpectShelver(shelf_ui.Shelver):
"""A variant of Shelver that intercepts console activity, for testing."""
- def __init__(self, work_tree, target_tree, path=None, auto=False,
- auto_apply=False, file_list=None, message=None):
- shelf_ui.Shelver.__init__(self, work_tree, target_tree, auto,
- auto_apply, file_list, message)
+ def __init__(self, work_tree, target_tree, diff_writer=None, path=None,
+ auto=False, auto_apply=False, file_list=None, message=None):
+ shelf_ui.Shelver.__init__(self, work_tree, target_tree, diff_writer,
+ auto, auto_apply, file_list, message)
self.expected = []
self.diff_writer = StringIO()
@@ -178,7 +179,7 @@
def test_shelve_all(self):
tree = self.create_shelvable_tree()
- ExpectShelver.from_args(all=True, directory='tree').run()
+ ExpectShelver.from_args(sys.stdout, all=True, directory='tree').run()
self.assertFileEqual(LINES_AJ, 'tree/foo')
def test_shelve_filename(self):
More information about the bazaar-commits
mailing list