Merge lp:~jelmer/bzr/push-suggests-parent into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 6398
Proposed branch: lp:~jelmer/bzr/push-suggests-parent
Merge into: lp:bzr
Diff against target: 79 lines (+33/-4)
3 files modified
bzrlib/builtins.py (+10/-2)
bzrlib/tests/blackbox/test_push.py (+20/-2)
doc/en/release-notes/bzr-2.5.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/bzr/push-suggests-parent
Reviewer Review Type Date Requested Status
Vincent Ladeuil Needs Fixing
Review via email: mp+86572@code.launchpad.net

Commit message

If no location is specified to "bzr push" or remembered, mention the parent alias to the user.

Description of the change

If no location is specified to "bzr push" or remembered, mention the parent alias to the user.

Several people complained that "bzr push" doesn't try to push to the parent location by
default (which we intentionally don't want to do). This is hopefully a reasonable compromise.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

It would be even better to display the parent url no ?

review: Needs Information
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On 12/21/2011 04:46 PM, Vincent Ladeuil wrote:
> Review: Needs Information
>
> It would be even better to display the parent url no ?
It's a lot quicker to type "bzr push :parent" than to type "bzr push
bzr+ssh://people.samba.org/data/bzr/jelmer/bzr-svn/trunk". And it makes
users aware of the location aliases.

I guess we could also display the parent location?

Cheers,

Jelmer

Revision history for this message
Vincent Ladeuil (vila) wrote :

>
> On 12/21/2011 04:46 PM, Vincent Ladeuil wrote:
> > Review: Needs Information
> >
> > It would be even better to display the parent url no ?
> It's a lot quicker to type "bzr push :parent" than to type "bzr push
> bzr+ssh://people.samba.org/data/bzr/jelmer/bzr-svn/trunk". And it makes
> users aware of the location aliases.

Hpmf, of course !

>
> I guess we could also display the parent location?

That's what I meant !

Revision history for this message
Vincent Ladeuil (vila) wrote :

I.e. we are in violent agreement :-D

With this tweak, please land !

review: Needs Fixing
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

It's now:

bzr: ERROR: No push location known or specified. To push to the parent branch (at bzr+ssh://bazaar.launchpad.net/+branch/bzr/), use 'bzr push :parent'.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/builtins.py'
2--- bzrlib/builtins.py 2011-12-21 16:52:39 +0000
3+++ bzrlib/builtins.py 2011-12-21 17:57:40 +0000
4@@ -1251,8 +1251,16 @@
5 if location is None:
6 stored_loc = br_from.get_push_location()
7 if stored_loc is None:
8- raise errors.BzrCommandError(gettext(
9- "No push location known or specified."))
10+ parent_loc = br_from.get_parent()
11+ if parent_loc:
12+ raise errors.BzrCommandError(gettext(
13+ "No push location known or specified. To push to the "
14+ "parent branch (at %s), use 'bzr push :parent'." %
15+ urlutils.unescape_for_display(parent_loc,
16+ self.outf.encoding)))
17+ else:
18+ raise errors.BzrCommandError(gettext(
19+ "No push location known or specified."))
20 else:
21 display_url = urlutils.unescape_for_display(stored_loc,
22 self.outf.encoding)
23
24=== modified file 'bzrlib/tests/blackbox/test_push.py'
25--- bzrlib/tests/blackbox/test_push.py 2011-10-11 12:01:51 +0000
26+++ bzrlib/tests/blackbox/test_push.py 2011-12-21 17:57:40 +0000
27@@ -33,12 +33,10 @@
28 )
29 from bzrlib.repofmt import knitrepo
30 from bzrlib.tests import (
31- blackbox,
32 http_server,
33 scenarios,
34 script,
35 test_foreign,
36- test_server,
37 )
38 from bzrlib.transport import memory
39
40@@ -58,6 +56,26 @@
41 ['push', public_url],
42 working_dir='source')
43
44+ def test_push_suggests_parent_alias(self):
45+ """Push suggests using :parent if there is a known parent branch."""
46+ tree_a = self.make_branch_and_tree('a')
47+ tree_a.commit('this is a commit')
48+ tree_b = self.make_branch_and_tree('b')
49+
50+ # If there is no parent location set, :parent isn't mentioned.
51+ out = self.run_bzr('push', working_dir='a', retcode=3)
52+ self.assertEquals(out,
53+ ('','bzr: ERROR: No push location known or specified.\n'))
54+
55+ # If there is a parent location set, the error suggests :parent.
56+ tree_a.branch.set_parent(tree_b.branch.base)
57+ out = self.run_bzr('push', working_dir='a', retcode=3)
58+ self.assertEquals(out,
59+ ('','bzr: ERROR: No push location known or specified. '
60+ 'To push to the parent branch '
61+ '(at %s), use \'bzr push :parent\'.\n' %
62+ urlutils.unescape_for_display(tree_b.branch.base, 'utf-8')))
63+
64 def test_push_remember(self):
65 """Push changes from one branch to another and test push location."""
66 transport = self.get_transport()
67
68=== modified file 'doc/en/release-notes/bzr-2.5.txt'
69--- doc/en/release-notes/bzr-2.5.txt 2011-12-21 17:42:34 +0000
70+++ doc/en/release-notes/bzr-2.5.txt 2011-12-21 17:57:40 +0000
71@@ -49,6 +49,9 @@
72 * ``bzr branches`` now indicates the active colocated branch.
73 (Jelmer Vernooij, #891667)
74
75+* ``bzr push`` now suggests using :parent if there is a parent location
76+ set. (Jelmer Vernooij)
77+
78 * ``bzr send`` now only opens a single connection, rather than two,
79 to the target branch. (Jelmer Vernooij)
80