Rev 2255: merge result-object changes in http://sourcefrog.net/bzr/tags
Martin Pool
mbp at sourcefrog.net
Sun Feb 25 10:47:30 GMT 2007
At http://sourcefrog.net/bzr/tags
------------------------------------------------------------
revno: 2255
revision-id: mbp at sourcefrog.net-20070225104729-st8znu3255avneia
parent: mbp at sourcefrog.net-20070222055851-5u09rtof609irx60
parent: mbp at sourcefrog.net-20070225104133-nd8tyugcozbq1uox
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: tags
timestamp: Sun 2007-02-25 21:47:29 +1100
message:
merge result-object changes
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/blackbox/test_merge.py test_merge.py-20060323225809-9bc0459c19917f41
bzrlib/tests/blackbox/test_pull.py test_pull.py-20051201144907-64959364f629947f
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/branch_implementations/test_pull.py test_pull.py-20060410103942-83c35b26657414fc
bzrlib/tests/branch_implementations/test_push.py test_push.py-20070130153159-fhfap8uoifevg30j-1
bzrlib/tests/test_branch.py test_branch.py-20060116013032-97819aa07b8ab3b5
------------------------------------------------------------
revno: 2220.1.82
merged: mbp at sourcefrog.net-20070225104133-nd8tyugcozbq1uox
parent: mbp at sourcefrog.net-20070225104016-np1gvynr1nqkbnpo
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: resultobj
timestamp: Sun 2007-02-25 21:41:33 +1100
message:
Update hook docs
------------------------------------------------------------
revno: 2220.1.81
merged: mbp at sourcefrog.net-20070225104016-np1gvynr1nqkbnpo
parent: mbp at sourcefrog.net-20070223055544-ux2lcobwiudl3f53
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: resultobj
timestamp: Sun 2007-02-25 21:40:16 +1100
message:
Push now returns a PushResult rather than just an integer.
This result object is also passed to the push hooks.
pull ui slightly clearer about what has happened.
------------------------------------------------------------
revno: 2220.1.80
merged: mbp at sourcefrog.net-20070223055544-ux2lcobwiudl3f53
parent: mbp at sourcefrog.net-20070223054511-g9ctoxpgcq0d2sl4
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: resultobj
timestamp: Fri 2007-02-23 16:55:44 +1100
message:
PullResult can pretend to be an int for api compatibility with old .pull()
------------------------------------------------------------
revno: 2220.1.79
merged: mbp at sourcefrog.net-20070223054511-g9ctoxpgcq0d2sl4
parent: mbp at sourcefrog.net-20070223053935-r601f8e1xwwljm21
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: resultobj
timestamp: Fri 2007-02-23 16:45:11 +1100
message:
Cleanup imports
------------------------------------------------------------
revno: 2220.1.78
merged: mbp at sourcefrog.net-20070223053935-r601f8e1xwwljm21
parent: pqm at pqm.ubuntu.com-20070221200818-3edf47a2bd3f472b
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: resultobj
timestamp: Fri 2007-02-23 16:39:35 +1100
message:
Pull now returns a PullResult rather than just an integer.
Remove old Branch.is_control_file function.
=== modified file 'NEWS'
--- a/NEWS 2007-02-21 05:34:56 +0000
+++ b/NEWS 2007-02-25 10:47:29 +0000
@@ -106,6 +106,10 @@
you pass a Unicode string rather than an 8-bit string. Callers need
to be updated to encode first. (John Arbash Meinel)
+ * Branch.push, pull, merge now return Result objects with information
+ about what happened, rather than a scattering of various methods. These
+ are also passed to the post hooks. (Martin Pool)
+
BUGFIXES:
* ``bzr annotate`` now uses dotted revnos from the viewpoint of the
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2007-02-22 04:39:08 +0000
+++ b/bzrlib/branch.py 2007-02-25 10:47:29 +0000
@@ -407,6 +407,8 @@
"""Mirror source into this branch.
This branch is considered to be 'local', having low latency.
+
+ :returns: PullResult instance
"""
raise NotImplementedError(self.pull)
@@ -848,6 +850,8 @@
self['set_rh'] = []
# invoked after a push operation completes.
# the api signature is
+ # (push_result)
+ # containing the members
# (source, local, master, old_revno, old_revid, new_revno, new_revid)
# where local is the local branch or None, master is the target
# master branch, and the rest should be self explanatory. The source
@@ -856,6 +860,8 @@
self['post_push'] = []
# invoked after a pull operation completes.
# the api signature is
+ # (pull_result)
+ # containing the members
# (source, local, master, old_revno, old_revid, new_revno, new_revid)
# where local is the local branch or None, master is the target
# master branch, and the rest should be self explanatory. The source
@@ -1433,9 +1439,11 @@
:param _run_hooks: Private parameter - allow disabling of
hooks, used when pushing to a master branch.
"""
+ result = PullResult()
+ result.source = source
source.lock_read()
try:
- old_count, old_tip = self.last_revision_info()
+ result.old_revno, result.old_revid = self.last_revision_info()
try:
self.update_revisions(source, stop_revision)
except DivergedBranches:
@@ -1443,19 +1451,19 @@
raise
if overwrite:
self.set_revision_history(source.revision_history())
- new_count, new_tip = self.last_revision_info()
+ result.new_revno, result.new_revid = self.last_revision_info()
+ if _hook_master:
+ result.master = _hook_master
+ result.local = self
+ else:
+ result.master = self
+ result.local = None
if _run_hooks:
- if _hook_master:
- _hook_local = self
- else:
- _hook_master = self
- _hook_local = None
for hook in Branch.hooks['post_pull']:
- hook(source, _hook_local, _hook_master, old_count, old_tip,
- new_count, new_tip)
- return new_count - old_count
+ hook(result)
finally:
source.unlock()
+ return result
def _get_parent_location(self):
_locs = ['parent', 'pull', 'x-pull']
@@ -1476,9 +1484,12 @@
:param _run_hooks: Private parameter - allow disabling of
hooks, used when pushing to a master branch.
"""
+ result = PushResult()
+ result.source = self
+ result.target = target
target.lock_write()
try:
- old_count, old_tip = target.last_revision_info()
+ result.old_revno, result.old_revid = target.last_revision_info()
try:
target.update_revisions(self, stop_revision)
except DivergedBranches:
@@ -1486,19 +1497,19 @@
raise
if overwrite:
target.set_revision_history(self.revision_history())
- new_count, new_tip = target.last_revision_info()
+ result.new_revno, result.new_revid = target.last_revision_info()
+ if _hook_master:
+ result.master = _hook_master
+ result.local = target
+ else:
+ result.master = target
+ result.local = None
if _run_hooks:
- if _hook_master:
- _hook_local = target
- else:
- _hook_master = target
- _hook_local = None
for hook in Branch.hooks['post_push']:
- hook(self, _hook_local, _hook_master, old_count, old_tip,
- new_count, new_tip)
- return new_count - old_count
+ hook(result)
finally:
target.unlock()
+ return result
def get_parent(self):
"""See Branch.get_parent."""
@@ -2043,6 +2054,23 @@
return result
+######################################################################
+# results of operations
+
+class PullResult(object):
+
+ def __int__(self):
+ # DEPRECATED: pull used to return the change in revno
+ return self.new_revno - self.old_revno
+
+
+class PushResult(object):
+
+ def __int__(self):
+ # DEPRECATED: push used to return the change in revno
+ return self.new_revno - self.old_revno
+
+
class BranchCheckResult(object):
"""Results of checking branch consistency.
@@ -2063,17 +2091,6 @@
self.branch._format)
-######################################################################
-# predicates
-
-
- at deprecated_function(zero_eight)
-def is_control_file(*args, **kwargs):
- """See bzrlib.workingtree.is_control_file."""
- from bzrlib import workingtree
- return workingtree.is_control_file(*args, **kwargs)
-
-
class Converter5to6(object):
"""Perform an in-place upgrade of format 5 to format 6"""
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-02-22 04:39:08 +0000
+++ b/bzrlib/builtins.py 2007-02-25 10:47:29 +0000
@@ -598,20 +598,19 @@
old_rh = branch_to.revision_history()
if tree_to is not None:
- count = tree_to.pull(branch_from, overwrite, rev_id,
+ result = tree_to.pull(branch_from, overwrite, rev_id,
delta.ChangeReporter(tree_to.inventory))
else:
- count = branch_to.pull(branch_from, overwrite, rev_id)
- _merge_tags_if_possible(branch_from, branch_to)
- note('%d revision(s) pulled.' % (count,))
+ result = branch_to.pull(branch_from, overwrite, rev_id)
- if verbose:
+ if result.old_revid == result.new_revid:
+ note('No revisions to pull.')
+ elif verbose:
+ from bzrlib.log import show_changed_revisions
new_rh = branch_to.revision_history()
- if old_rh != new_rh:
- # Something changed
- from bzrlib.log import show_changed_revisions
- show_changed_revisions(branch_to, old_rh, new_rh,
- to_file=self.outf)
+ show_changed_revisions(branch_to, old_rh, new_rh, to_file=self.outf)
+ else:
+ note('Now on revision %d.' % result.new_revno)
class cmd_push(Command):
@@ -682,9 +681,6 @@
to_transport = transport.get_transport(location)
location_url = to_transport.base
- old_rh = []
- count = 0
-
br_to = repository_to = dir_to = None
try:
dir_to = bzrdir.BzrDir.open_from_transport(to_transport)
@@ -704,9 +700,10 @@
else:
# Found a branch, so we must have found a repository
repository_to = br_to.repository
-
+ push_result = None
old_rh = []
if dir_to is None:
+ # The destination doesn't exist; create it.
# XXX: Refactor the create_prefix/no_create_prefix code into a
# common helper function
try:
@@ -753,7 +750,8 @@
dir_to = br_from.bzrdir.clone(location_url,
revision_id=br_from.last_revision())
br_to = dir_to.open_branch()
- count = br_to.last_revision_info()[0]
+ # TODO: Some more useful message about what was copied
+ note('Created new branch.')
# We successfully created the target, remember it
if br_from.get_push_location() is None or remember:
br_from.set_push_location(br_to.base)
@@ -772,7 +770,7 @@
repository_to.fetch(br_from.repository,
revision_id=last_revision_id)
br_to = br_from.clone(dir_to, revision_id=last_revision_id)
- count = len(br_to.revision_history())
+ note('Created new branch.')
if br_from.get_push_location() is None or remember:
br_from.set_push_location(br_to.base)
else: # We have a valid to branch
@@ -787,29 +785,35 @@
except errors.NotLocalUrl:
warning('This transport does not update the working '
'tree of: %s' % (br_to.base,))
- count = br_from.push(br_to, overwrite)
+ push_result = br_from.push(br_to, overwrite)
except errors.NoWorkingTree:
- count = br_from.push(br_to, overwrite)
+ push_result = br_from.push(br_to, overwrite)
else:
tree_to.lock_write()
try:
- count = br_from.push(tree_to.branch, overwrite)
+ push_result = br_from.push(tree_to.branch, overwrite)
tree_to.update()
finally:
tree_to.unlock()
except errors.DivergedBranches:
raise errors.BzrCommandError('These branches have diverged.'
' Try using "merge" and then "push".')
- _merge_tags_if_possible(br_from, br_to)
- note('%d revision(s) pushed.' % (count,))
-
- if verbose:
+ if push_result is not None:
+ if push_result.old_revid == push_result.new_revid:
+ note('No new revisions to push.\n')
+ else:
+ note('Pushed up to revision %d.' % push_result.new_revno)
+ elif verbose:
new_rh = br_to.revision_history()
if old_rh != new_rh:
# Something changed
from bzrlib.log import show_changed_revisions
show_changed_revisions(br_to, old_rh, new_rh,
to_file=self.outf)
+ else:
+ # we probably did a clone rather than a push, so a message was
+ # emitted above
+ pass
class cmd_branch(Command):
@@ -3307,9 +3311,13 @@
return 0
if file_list is None:
if pull and merger.base_rev_id == merger.this_rev_id:
- count = merger.this_tree.pull(merger.this_branch,
+ # FIXME: deduplicate with pull
+ result = merger.this_tree.pull(merger.this_branch,
False, merger.other_rev_id)
- note('%d revision(s) pulled.' % (count,))
+ if result.old_revid == result.new_revid:
+ note('No revisions to pull.')
+ else:
+ note('Now on revision %d.' % result.new_revno)
return 0
merger.backup_files = backup_files
merger.merge_type = merge_type
=== modified file 'bzrlib/tests/blackbox/test_merge.py'
--- a/bzrlib/tests/blackbox/test_merge.py 2007-02-14 21:57:40 +0000
+++ b/bzrlib/tests/blackbox/test_merge.py 2007-02-23 05:39:35 +0000
@@ -267,7 +267,7 @@
self.pullable_branch()
os.chdir('a')
(out, err) = self.run_bzr('merge', '--pull', '../b')
- self.assertContainsRe(err, '1 revision\\(s\\) pulled')
+ self.assertContainsRe(err, 'Now on revision 2\\.')
tree_a = WorkingTree.open('.')
self.assertEqual([self.id2], tree_a.get_parent_ids())
=== modified file 'bzrlib/tests/blackbox/test_pull.py'
--- a/bzrlib/tests/blackbox/test_pull.py 2007-02-21 05:34:56 +0000
+++ b/bzrlib/tests/blackbox/test_pull.py 2007-02-25 10:47:29 +0000
@@ -300,7 +300,8 @@
output = self.run_bzr('pull', '../bundle')
self.assertEqual('', output[0])
self.assertEqual(' M a\nAll changes applied successfully.\n'
- '1 revision(s) pulled.\n', output[1])
+ 'Now on revision 2.\n',
+ output[1])
self.assertEqualDiff(tree_a.branch.revision_history(),
tree_b.branch.revision_history())
@@ -315,4 +316,4 @@
# it is legal to attempt to pull an already-merged bundle
output = self.run_bzr('pull', '../bundle')
self.assertEqual('', output[0])
- self.assertEqual('0 revision(s) pulled.\n', output[1])
+ self.assertEqual('No revisions to pull.\n', output[1])
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py 2007-02-21 05:34:56 +0000
+++ b/bzrlib/tests/blackbox/test_push.py 2007-02-25 10:47:29 +0000
@@ -85,7 +85,7 @@
self.assertEquals(('Using saved location: %s\n'
% (local_path_from_url(path),)
, 'All changes applied successfully.\n'
- '1 revision(s) pushed.\n'), out)
+ 'Pushed up to revision 2.\n'), out)
self.assertEqual(path,
branch_b.bzrdir.root_transport.base)
# test explicit --remember
@@ -98,7 +98,7 @@
b = self.make_branch('.')
out, err = self.run_bzr('push', 'pushed-location')
self.assertEqual('', out)
- self.assertEqual('0 revision(s) pushed.\n', err)
+ self.assertEqual('Created new branch.\n', err)
b2 = Branch.open('pushed-location')
self.assertEndsWith(b2.base, 'pushed-location/')
@@ -114,7 +114,7 @@
out, err = self.run_bzr('push', 'pushed-to')
os.chdir('..')
self.assertEqual('', out)
- self.assertEqual('1 revision(s) pushed.\n', err)
+ self.assertEqual('Created new branch.\n', err)
def test_push_only_pushes_history(self):
# Knit branches should only push the history for the current revision.
=== modified file 'bzrlib/tests/branch_implementations/test_pull.py'
--- a/bzrlib/tests/branch_implementations/test_pull.py 2007-02-06 02:33:42 +0000
+++ b/bzrlib/tests/branch_implementations/test_pull.py 2007-02-23 05:39:35 +0000
@@ -87,22 +87,22 @@
self.hook_calls = []
TestCaseWithBranch.setUp(self)
- def capture_post_pull_hook(self, source, local, master, old_revno,
- old_revid, new_revno, new_revid):
+ def capture_post_pull_hook(self, result):
"""Capture post pull hook calls to self.hook_calls.
The call is logged, as is some state of the two branches.
"""
- if local:
- local_locked = local.is_locked()
- local_base = local.base
+ if result.local:
+ local_locked = result.local.is_locked()
+ local_base = result.local.base
else:
local_locked = None
local_base = None
self.hook_calls.append(
- ('post_pull', source, local_base, master.base, old_revno, old_revid,
- new_revno, new_revid, source.is_locked(), local_locked,
- master.is_locked()))
+ ('post_pull', result.source, local_base, result.master.base, result.old_revno,
+ result.old_revid,
+ result.new_revno, result.new_revid, result.source.is_locked(), local_locked,
+ result.master.is_locked()))
def test_post_pull_empty_history(self):
target = self.make_branch('target')
=== modified file 'bzrlib/tests/branch_implementations/test_push.py'
--- a/bzrlib/tests/branch_implementations/test_push.py 2007-02-12 22:58:48 +0000
+++ b/bzrlib/tests/branch_implementations/test_push.py 2007-02-25 10:40:16 +0000
@@ -36,8 +36,13 @@
other.commit('my change', rev_id='M1', allow_pointless=True)
mine.merge_from_branch(other.branch)
mine.commit('merge my change', rev_id='P2')
- mine.branch.push(other.branch)
+ result = mine.branch.push(other.branch)
self.assertEqual(['P1', 'P2'], other.branch.revision_history())
+ # result object contains some structured data
+ self.assertEqual(result.old_revid, 'M1')
+ self.assertEqual(result.new_revid, 'P2')
+ # and it can be treated as an integer for compatibility
+ self.assertEqual(int(result), 0)
def test_push_merged_indirect(self):
# it should be possible to do a push from one branch into another
@@ -143,22 +148,22 @@
self.hook_calls = []
TestCaseWithBranch.setUp(self)
- def capture_post_push_hook(self, source, local, master, old_revno,
- old_revid, new_revno, new_revid):
+ def capture_post_push_hook(self, result):
"""Capture post push hook calls to self.hook_calls.
The call is logged, as is some state of the two branches.
"""
- if local:
- local_locked = local.is_locked()
- local_base = local.base
+ if result.local:
+ local_locked = result.local.is_locked()
+ local_base = result.local.base
else:
local_locked = None
local_base = None
self.hook_calls.append(
- ('post_push', source, local_base, master.base, old_revno, old_revid,
- new_revno, new_revid, source.is_locked(), local_locked,
- master.is_locked()))
+ ('post_push', result.source, local_base, result.master.base,
+ result.old_revno, result.old_revid,
+ result.new_revno, result.new_revid, result.source.is_locked(), local_locked,
+ result.master.is_locked()))
def test_post_push_empty_history(self):
target = self.make_branch('target')
=== modified file 'bzrlib/tests/test_branch.py'
--- a/bzrlib/tests/test_branch.py 2007-02-15 14:08:23 +0000
+++ b/bzrlib/tests/test_branch.py 2007-02-23 05:55:44 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006 Canonical Ltd
+# Copyright (C) 2005, 2006, 2007 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
@@ -30,9 +30,15 @@
errors,
urlutils,
)
-import bzrlib.branch
-from bzrlib.branch import (BzrBranch5,
- BzrBranchFormat5)
+from bzrlib.branch import (
+ Branch,
+ BranchHooks,
+ BranchFormat,
+ BranchReferenceFormat,
+ BzrBranch5,
+ BzrBranchFormat5,
+ PullResult,
+ )
from bzrlib.bzrdir import (BzrDirMetaFormat1, BzrDirMeta1,
BzrDir, BzrDirFormat)
from bzrlib.errors import (NotBranchError,
@@ -47,10 +53,10 @@
class TestDefaultFormat(TestCase):
def test_get_set_default_format(self):
- old_format = bzrlib.branch.BranchFormat.get_default_format()
+ old_format = BranchFormat.get_default_format()
# default is 5
- self.assertTrue(isinstance(old_format, bzrlib.branch.BzrBranchFormat5))
- bzrlib.branch.BranchFormat.set_default_format(SampleBranchFormat())
+ self.assertTrue(isinstance(old_format, BzrBranchFormat5))
+ BranchFormat.set_default_format(SampleBranchFormat())
try:
# the default branch format is used by the meta dir format
# which is not the default bzrdir format at this point
@@ -58,8 +64,8 @@
result = dir.create_branch()
self.assertEqual(result, 'A branch')
finally:
- bzrlib.branch.BranchFormat.set_default_format(old_format)
- self.assertEqual(old_format, bzrlib.branch.BranchFormat.get_default_format())
+ BranchFormat.set_default_format(old_format)
+ self.assertEqual(old_format, BranchFormat.get_default_format())
class TestBranchFormat5(TestCaseWithTransport):
@@ -99,7 +105,7 @@
# recursive section - that is, it appends the branch name.
-class SampleBranchFormat(bzrlib.branch.BranchFormat):
+class SampleBranchFormat(BranchFormat):
"""A sample format
this format is initializable, unsupported to aid in testing the
@@ -135,21 +141,21 @@
dir = format._matchingbzrdir.initialize(url)
dir.create_repository()
format.initialize(dir)
- found_format = bzrlib.branch.BranchFormat.find_format(dir)
+ found_format = BranchFormat.find_format(dir)
self.failUnless(isinstance(found_format, format.__class__))
- check_format(bzrlib.branch.BzrBranchFormat5(), "bar")
+ check_format(BzrBranchFormat5(), "bar")
def test_find_format_not_branch(self):
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
self.assertRaises(NotBranchError,
- bzrlib.branch.BranchFormat.find_format,
+ BranchFormat.find_format,
dir)
def test_find_format_unknown_format(self):
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
SampleBranchFormat().initialize(dir)
self.assertRaises(UnknownFormatError,
- bzrlib.branch.BranchFormat.find_format,
+ BranchFormat.find_format,
dir)
def test_register_unregister_format(self):
@@ -159,14 +165,14 @@
# make a branch
format.initialize(dir)
# register a format for it.
- bzrlib.branch.BranchFormat.register_format(format)
+ BranchFormat.register_format(format)
# which branch.Open will refuse (not supported)
- self.assertRaises(UnsupportedFormatError, bzrlib.branch.Branch.open, self.get_url())
+ self.assertRaises(UnsupportedFormatError, Branch.open, self.get_url())
self.make_branch_and_tree('foo')
# but open_downlevel will work
self.assertEqual(format.open(dir), bzrdir.BzrDir.open(self.get_url()).open_branch(unsupported=True))
# unregister the format
- bzrlib.branch.BranchFormat.unregister_format(format)
+ BranchFormat.unregister_format(format)
self.make_branch_and_tree('bar')
def test_checkout_format(self):
@@ -263,7 +269,7 @@
target_branch = dir.create_branch()
t.mkdir('branch')
branch_dir = bzrdirformat.initialize(self.get_url('branch'))
- made_branch = bzrlib.branch.BranchReferenceFormat().initialize(branch_dir, target_branch)
+ made_branch = BranchReferenceFormat().initialize(branch_dir, target_branch)
self.assertEqual(made_branch.base, target_branch.base)
opened_branch = branch_dir.open_branch()
self.assertEqual(opened_branch.base, target_branch.base)
@@ -273,7 +279,7 @@
def test_constructor(self):
"""Check that creating a BranchHooks instance has the right defaults."""
- hooks = bzrlib.branch.BranchHooks()
+ hooks = BranchHooks()
self.assertTrue("set_rh" in hooks, "set_rh not in %s" % hooks)
self.assertTrue("post_push" in hooks, "post_push not in %s" % hooks)
self.assertTrue("post_commit" in hooks, "post_commit not in %s" % hooks)
@@ -283,15 +289,29 @@
def test_installed_hooks_are_BranchHooks(self):
"""The installed hooks object should be a BranchHooks."""
# the installed hooks are saved in self._preserved_hooks.
- self.assertIsInstance(self._preserved_hooks, bzrlib.branch.BranchHooks)
+ self.assertIsInstance(self._preserved_hooks, BranchHooks)
def test_install_hook_raises_unknown_hook(self):
"""install_hook should raise UnknownHook if a hook is unknown."""
- hooks = bzrlib.branch.BranchHooks()
+ hooks = BranchHooks()
self.assertRaises(UnknownHook, hooks.install_hook, 'silly', None)
def test_install_hook_appends_known_hook(self):
"""install_hook should append the callable for known hooks."""
- hooks = bzrlib.branch.BranchHooks()
+ hooks = BranchHooks()
hooks.install_hook('set_rh', None)
self.assertEqual(hooks['set_rh'], [None])
+
+
+class TestPullResult(TestCase):
+
+ def test_pull_result_to_int(self):
+ # to support old code, the pull result can be used as an int
+ r = PullResult()
+ r.old_revno = 10
+ r.new_revno = 20
+ # this usage of results is not recommended for new code (because it
+ # doesn't describe very well what happened), but for api stability
+ # it's still supported
+ a = "%d revisions pulled" % r
+ self.assertEqual(a, "10 revisions pulled")
More information about the bazaar-commits
mailing list