Rev 4481: (abentley) Provide finer control over shelve and switch output. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Jun 26 04:32:29 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4481 [merge]
revision-id: pqm at pqm.ubuntu.com-20090626033227-k6uokcs5iehqp80h
parent: pqm at pqm.ubuntu.com-20090626023505-qxubv38s4gmcsp3a
parent: aaron at aaronbentley.com-20090619211631-4fnkv2uui98xj7ux
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-06-26 04:32:27 +0100
message:
(abentley) Provide finer control over shelve and switch output.
modified:
bzrlib/shelf_ui.py shelver.py-20081005210102-33worgzwrtdw0yrm-1
bzrlib/switch.py switch.py-20071116011000-v5lnw7d2wkng9eux-1
=== modified file 'bzrlib/shelf_ui.py'
--- a/bzrlib/shelf_ui.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/shelf_ui.py 2009-06-19 21:16:31 +0000
@@ -35,12 +35,29 @@
)
+class ShelfReporter(object):
+
+ def __init__(self):
+ self.delta_reporter = delta._ChangeReporter()
+
+ def no_changes(self):
+ trace.warning('No changes to shelve.')
+
+ def shelved_id(self, shelf_id):
+ trace.note('Changes shelved with id "%d".' % shelf_id)
+
+ def selected_changes(self, transform):
+ trace.note("Selected changes:")
+ changes = transform.iter_changes()
+ delta.report_changes(changes, self.delta_reporter)
+
+
class Shelver(object):
"""Interactively shelve the changes in a working tree."""
def __init__(self, work_tree, target_tree, diff_writer=None, auto=False,
auto_apply=False, file_list=None, message=None,
- destroy=False):
+ destroy=False, reporter=None):
"""Constructor.
:param work_tree: The working tree to shelve changes from.
@@ -64,6 +81,9 @@
self.file_list = file_list
self.message = message
self.destroy = destroy
+ if reporter is None:
+ reporter = ShelfReporter()
+ self.reporter = reporter
@classmethod
def from_args(klass, diff_writer, revision=None, all=False, file_list=None,
@@ -127,10 +147,7 @@
creator.shelve_modify_target(change[1])
changes_shelved += 1
if changes_shelved > 0:
- trace.note("Selected changes:")
- changes = creator.work_transform.iter_changes()
- reporter = delta._ChangeReporter()
- delta.report_changes(changes, reporter)
+ self.reporter.selected_changes(creator.work_transform)
if (self.auto_apply or self.prompt_bool(
'Shelve %d change(s)?' % changes_shelved)):
if self.destroy:
@@ -139,9 +156,9 @@
else:
shelf_id = self.manager.shelve_changes(creator,
self.message)
- trace.note('Changes shelved with id "%d".' % shelf_id)
+ self.reporter.shelved_id(shelf_id)
else:
- trace.warning('No changes to shelve.')
+ self.reporter.no_changes()
finally:
shutil.rmtree(self.tempdir)
creator.finalize()
=== modified file 'bzrlib/switch.py'
--- a/bzrlib/switch.py 2009-05-07 05:08:46 +0000
+++ b/bzrlib/switch.py 2009-06-19 21:16:31 +0000
@@ -22,7 +22,7 @@
from bzrlib.trace import note
-def switch(control_dir, to_branch, force=False):
+def switch(control_dir, to_branch, force=False, quiet=False):
"""Switch the branch associated with a checkout.
:param control_dir: BzrDir of the checkout to change
@@ -36,7 +36,7 @@
source_repository = to_branch.repository
_set_branch_location(control_dir, to_branch, force)
tree = control_dir.open_workingtree()
- _update(tree, source_repository)
+ _update(tree, source_repository, quiet)
def _check_pending_merges(control, force=False):
@@ -118,7 +118,7 @@
return False
-def _update(tree, source_repository):
+def _update(tree, source_repository, quiet=False):
"""Update a working tree to the latest revision of its branch.
:param tree: the working tree
@@ -128,11 +128,13 @@
try:
to_branch = tree.branch
if tree.last_revision() == to_branch.last_revision():
- note("Tree is up to date at revision %d.", to_branch.revno())
+ if not quiet:
+ note("Tree is up to date at revision %d.", to_branch.revno())
return
base_tree = source_repository.revision_tree(tree.last_revision())
merge.Merge3Merger(tree, tree, base_tree, to_branch.basis_tree())
tree.set_last_revision(to_branch.last_revision())
- note('Updated to revision %d.' % to_branch.revno())
+ if not quiet:
+ note('Updated to revision %d.' % to_branch.revno())
finally:
tree.unlock()
More information about the bazaar-commits
mailing list