Merge lp:~parthm/bzr/405192-get_nick-recursion-2.2 into lp:bzr/2.2

Proposed by Parth Malwankar
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 5057
Proposed branch: lp:~parthm/bzr/405192-get_nick-recursion-2.2
Merge into: lp:bzr/2.2
Diff against target: 110 lines (+40/-0)
5 files modified
NEWS (+3/-0)
bzrlib/branch.py (+4/-0)
bzrlib/errors.py (+11/-0)
bzrlib/tests/blackbox/test_commit.py (+16/-0)
bzrlib/tests/test_errors.py (+6/-0)
To merge this branch: bzr merge lp:~parthm/bzr/405192-get_nick-recursion-2.2
Reviewer Review Type Date Requested Status
Parth Malwankar Approve
John A Meinel Approve
Review via email: mp+29841@code.launchpad.net

Commit message

Detect recursive binding for checkouts and give a clear error message to user. (#405192)

Description of the change

=== Fixes bug #405192 ===
This patch fixes branch._get_nick to detect recursive binding and give a clear error message to the user.

Sample output:
[bzr-grep-checkout]% ~/src/bzr.dev/405192-get_nick-recursion-2.2/bzr ci -m "added z"
bzr: ERROR: Recursive binding detected.
Use `bzr info` to verify and `bzr unbind|bind` to fix.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Parth Malwankar wrote:
> Parth Malwankar has proposed merging lp:~parthm/bzr/405192-get_nick-recursion-2.2 into lp:bzr/2.2.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> #405192 Self-bound checkouts errors with infinite recursion in _get_nick
> https://bugs.launchpad.net/bugs/405192
>
>
> === Fixes bug #405192 ===
> This patch fixes branch._get_nick to detect recursive binding and give a clear error message to the user.
>
> Sample output:
> [bzr-grep-checkout]% ~/src/bzr.dev/405192-get_nick-recursion-2.2/bzr ci -m "added z"
> bzr: ERROR: Recursive binding detected.
> Use `bzr info` to verify and `bzr unbind|bind` to fix.

I would probably change the error message a little bit. Something like:

 "Branch %s appears to be bound to itself, please unbind"

Otherwise the user doesn't really know any more about what to do, or
what branch is actually involved. (lightweight checkouts of a bound
branch, etc.)

Otherwise, looks good to me.

 review: needsfixing

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkw9d5QACgkQJdeBCYSNAAP3fwCeNwz3WU3UUklUhpJgiFkIuCUg
kO4AoNezZxiyaXh2HSikVp7dUUy0seUR
=AUlG
-----END PGP SIGNATURE-----

review: Needs Fixing
Revision history for this message
Parth Malwankar (parthm) wrote :

> I would probably change the error message a little bit. Something like:
>
> "Branch %s appears to be bound to itself, please unbind"
>

I have fixed the error message. Thanks for the review.

Sample output:
[bzr-grep-checkout]% ~/src/bzr.dev/405192-get_nick-recursion-2.2/bzr ci -m "added z"
bzr: ERROR: Branch "file:///home/parthm/tmp/bzr-grep-checkout/" appears to be bound to itself. Please use `bzr unbind` to fix.
[bzr-grep-checkout]%

Revision history for this message
John A Meinel (jameinel) :
review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

I can't mark this approved because of permission issues, but feel free to merge this.

Revision history for this message
Parth Malwankar (parthm) wrote :

OK. I will go ahead and merge this. Thanks.

Revision history for this message
Parth Malwankar (parthm) wrote :

Hmm. Looks like I can't mark the overall status as "approved", it doesn't show up in the list. Is this new in launchpad? I will try to merge it anyway if feed-pqm allows me.

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Parth Malwankar wrote:
> Review: Approve
> Hmm. Looks like I can't mark the overall status as "approved", it doesn't show up in the list. Is this new in launchpad? I will try to merge it anyway if feed-pqm allows me.
>

feed-pqm won't, because it isn't marked Approved. You can't mark the
status for the same reason I can't, bzr/2.2 doesn't have a Reviewer team
(such that neither of us are members).

You could probably just use pqm-submit directly, but if you are
unfamiliar with that, I can do it for now.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkw9i7sACgkQJdeBCYSNAANE8QCfe4PC6Uf+gVnabbjQjY0YAW/r
37wAn3RmVhysc4v0Al/YaAhNTj08XM29
=e+bf
-----END PGP SIGNATURE-----

Revision history for this message
Parth Malwankar (parthm) wrote :

> feed-pqm won't, because it isn't marked Approved. You can't mark the
> status for the same reason I can't, bzr/2.2 doesn't have a Reviewer team
> (such that neither of us are members).
>

You are right. It didn't get listed.

> You could probably just use pqm-submit directly, but if you are
> unfamiliar with that, I can do it for now.
>

I am not very familiar with pqm-submit. It would be great if you could submit this. Thanks.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-07-13 16:17:52 +0000
3+++ NEWS 2010-07-14 09:01:44 +0000
4@@ -27,6 +27,9 @@
5 * Don't traceback trying to unversion children files of an already
6 unversioned directory. (Vincent Ladeuil, #494221)
7
8+* Recursive binding for checkouts is now detected by bzr. A clear error
9+ message is shown to the user. (Parth Malwankar, #405192)
10+
11 Improvements
12 ************
13
14
15=== modified file 'bzrlib/branch.py'
16--- bzrlib/branch.py 2010-06-30 08:34:11 +0000
17+++ bzrlib/branch.py 2010-07-14 09:01:44 +0000
18@@ -246,9 +246,13 @@
19 if not local and not config.has_explicit_nickname():
20 try:
21 master = self.get_master_branch(possible_transports)
22+ if master and self.user_url == master.user_url:
23+ raise errors.RecursiveBind(self.user_url)
24 if master is not None:
25 # return the master branch value
26 return master.nick
27+ except errors.RecursiveBind, e:
28+ raise e
29 except errors.BzrError, e:
30 # Silently fall back to local implicit nick if the master is
31 # unavailable
32
33=== modified file 'bzrlib/errors.py'
34--- bzrlib/errors.py 2010-07-09 16:16:11 +0000
35+++ bzrlib/errors.py 2010-07-14 09:01:44 +0000
36@@ -3149,12 +3149,14 @@
37 def __init__(self, bzrdir):
38 self.bzrdir = bzrdir
39
40+
41 class NoWhoami(BzrError):
42
43 _fmt = ('Unable to determine your name.\n'
44 "Please, set your name with the 'whoami' command.\n"
45 'E.g. bzr whoami "Your Name <name@example.com>"')
46
47+
48 class InvalidPattern(BzrError):
49
50 _fmt = ('Invalid pattern(s) found. %(msg)s')
51@@ -3162,3 +3164,12 @@
52 def __init__(self, msg):
53 self.msg = msg
54
55+
56+class RecursiveBind(BzrError):
57+
58+ _fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
59+ 'Please use `bzr unbind` to fix.')
60+
61+ def __init__(self, branch_url):
62+ self.branch_url = branch_url
63+
64
65=== modified file 'bzrlib/tests/blackbox/test_commit.py'
66--- bzrlib/tests/blackbox/test_commit.py 2010-06-28 02:41:22 +0000
67+++ bzrlib/tests/blackbox/test_commit.py 2010-07-14 09:01:44 +0000
68@@ -22,6 +22,7 @@
69 import sys
70
71 from bzrlib import (
72+ bzrdir,
73 osutils,
74 ignores,
75 msgeditor,
76@@ -757,3 +758,18 @@
77 osutils.set_or_unset_env('BZR_EMAIL', None)
78 out, err = self.run_bzr(['commit', '-m', 'initial'], 3)
79 self.assertContainsRe(err, 'Unable to determine your name')
80+
81+ def test_commit_recursive_checkout(self):
82+ """Ensure that a commit to a recursive checkout fails cleanly.
83+ """
84+ self.run_bzr(['init', 'test_branch'])
85+ self.run_bzr(['checkout', 'test_branch', 'test_checkout'])
86+ os.chdir('test_checkout')
87+ self.run_bzr(['bind', '.']) # bind to self
88+ open('foo.txt', 'w').write('hello')
89+ self.run_bzr(['add'])
90+ out, err = self.run_bzr(['commit', '-m', 'addedfoo'], 3)
91+ self.assertEqual(out, '')
92+ self.assertContainsRe(err,
93+ 'Branch.*test_checkout.*appears to be bound to itself')
94+
95
96=== modified file 'bzrlib/tests/test_errors.py'
97--- bzrlib/tests/test_errors.py 2010-07-09 16:16:11 +0000
98+++ bzrlib/tests/test_errors.py 2010-07-14 09:01:44 +0000
99@@ -660,6 +660,12 @@
100 self.assertEqualDiff("Invalid pattern(s) found. Bad pattern msg.",
101 str(error))
102
103+ def test_recursive_bind(self):
104+ error = errors.RecursiveBind('foo_bar_branch')
105+ msg = ('Branch "foo_bar_branch" appears to be bound to itself. '
106+ 'Please use `bzr unbind` to fix.')
107+ self.assertEqualDiff(msg, str(error))
108+
109
110 class PassThroughError(errors.BzrError):
111

Subscribers

People subscribed via source and target branches