Rev 5057: (Parth) Prevert _get_nick from dying with infinite recursion error in file:///home/pqm/archives/thelove/bzr/2.2/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Jul 14 12:26:08 BST 2010
At file:///home/pqm/archives/thelove/bzr/2.2/
------------------------------------------------------------
revno: 5057 [merge]
revision-id: pqm at pqm.ubuntu.com-20100714112606-5np7a19rr1t1pzm4
parent: pqm at pqm.ubuntu.com-20100713174545-e11rsh9si8gg1wip
parent: parth.malwankar at gmail.com-20100714090012-4rpq5rcjs86u8wgg
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.2
timestamp: Wed 2010-07-14 12:26:06 +0100
message:
(Parth) Prevert _get_nick from dying with infinite recursion error
(bug #405192)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/tests/blackbox/test_commit.py test_commit.py-20060212094538-ae88fc861d969db0
bzrlib/tests/test_errors.py test_errors.py-20060210110251-41aba2deddf936a8
=== modified file 'NEWS'
--- a/NEWS 2010-07-13 16:17:52 +0000
+++ b/NEWS 2010-07-14 06:34:38 +0000
@@ -27,6 +27,9 @@
* Don't traceback trying to unversion children files of an already
unversioned directory. (Vincent Ladeuil, #494221)
+* Recursive binding for checkouts is now detected by bzr. A clear error
+ message is shown to the user. (Parth Malwankar, #405192)
+
Improvements
************
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2010-06-30 08:34:11 +0000
+++ b/bzrlib/branch.py 2010-07-14 08:53:58 +0000
@@ -246,9 +246,13 @@
if not local and not config.has_explicit_nickname():
try:
master = self.get_master_branch(possible_transports)
+ if master and self.user_url == master.user_url:
+ raise errors.RecursiveBind(self.user_url)
if master is not None:
# return the master branch value
return master.nick
+ except errors.RecursiveBind, e:
+ raise e
except errors.BzrError, e:
# Silently fall back to local implicit nick if the master is
# unavailable
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2010-07-09 16:16:11 +0000
+++ b/bzrlib/errors.py 2010-07-14 08:53:58 +0000
@@ -3149,12 +3149,14 @@
def __init__(self, bzrdir):
self.bzrdir = bzrdir
+
class NoWhoami(BzrError):
_fmt = ('Unable to determine your name.\n'
"Please, set your name with the 'whoami' command.\n"
'E.g. bzr whoami "Your Name <name at example.com>"')
+
class InvalidPattern(BzrError):
_fmt = ('Invalid pattern(s) found. %(msg)s')
@@ -3162,3 +3164,12 @@
def __init__(self, msg):
self.msg = msg
+
+class RecursiveBind(BzrError):
+
+ _fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
+ 'Please use `bzr unbind` to fix.')
+
+ def __init__(self, branch_url):
+ self.branch_url = branch_url
+
=== modified file 'bzrlib/tests/blackbox/test_commit.py'
--- a/bzrlib/tests/blackbox/test_commit.py 2010-06-28 02:41:22 +0000
+++ b/bzrlib/tests/blackbox/test_commit.py 2010-07-14 08:53:58 +0000
@@ -22,6 +22,7 @@
import sys
from bzrlib import (
+ bzrdir,
osutils,
ignores,
msgeditor,
@@ -757,3 +758,18 @@
osutils.set_or_unset_env('BZR_EMAIL', None)
out, err = self.run_bzr(['commit', '-m', 'initial'], 3)
self.assertContainsRe(err, 'Unable to determine your name')
+
+ def test_commit_recursive_checkout(self):
+ """Ensure that a commit to a recursive checkout fails cleanly.
+ """
+ self.run_bzr(['init', 'test_branch'])
+ self.run_bzr(['checkout', 'test_branch', 'test_checkout'])
+ os.chdir('test_checkout')
+ self.run_bzr(['bind', '.']) # bind to self
+ open('foo.txt', 'w').write('hello')
+ self.run_bzr(['add'])
+ out, err = self.run_bzr(['commit', '-m', 'addedfoo'], 3)
+ self.assertEqual(out, '')
+ self.assertContainsRe(err,
+ 'Branch.*test_checkout.*appears to be bound to itself')
+
=== modified file 'bzrlib/tests/test_errors.py'
--- a/bzrlib/tests/test_errors.py 2010-07-09 16:16:11 +0000
+++ b/bzrlib/tests/test_errors.py 2010-07-14 09:00:12 +0000
@@ -660,6 +660,12 @@
self.assertEqualDiff("Invalid pattern(s) found. Bad pattern msg.",
str(error))
+ def test_recursive_bind(self):
+ error = errors.RecursiveBind('foo_bar_branch')
+ msg = ('Branch "foo_bar_branch" appears to be bound to itself. '
+ 'Please use `bzr unbind` to fix.')
+ self.assertEqualDiff(msg, str(error))
+
class PassThroughError(errors.BzrError):
More information about the bazaar-commits
mailing list