Merge lp:~abudden/bzr-explorer/bound-branch-submit-pane into lp:bzr-explorer

Proposed by Dr Al
Status: Merged
Approved by: Alexander Belchenko
Approved revision: 506
Merged at revision: 512
Proposed branch: lp:~abudden/bzr-explorer/bound-branch-submit-pane
Merge into: lp:bzr-explorer
Diff against target: 191 lines (+70/-24)
5 files modified
NEWS (+4/-0)
lib/status_data.py (+12/-0)
lib/status_report.py (+28/-13)
lib/view_submit.py (+4/-1)
lib/view_workingtree.py (+22/-10)
To merge this branch: bzr merge lp:~abudden/bzr-explorer/bound-branch-submit-pane
Reviewer Review Type Date Requested Status
Alexander Belchenko Approve
Review via email: mp+59959@code.launchpad.net

Description of the change

Possibly slightly controversial, but this works round Bug 777108 by using the parent location in the submit pane for bound branches. If and when lp:~abudden/bzr/switch_parent_513709 (related to Bug 513709) lands and the parent branch is set correctly, this should make the feature branch model with bound branches much more usable.

To post a comment you must log in.
503. By Dr Al

Added better support for feature branch differences: when using bound branches, show parent location rather than submit location.

504. By Dr Al

Updated NEWS.

Revision history for this message
Alexander Belchenko (bialix) wrote :

Should bzr-explorer check for some specific bzr version then to ensure that your fix was landed?

Revision history for this message
Dr Al (abudden) wrote :

On Wednesday, 4 May 2011, Alexander Belchenko <email address hidden> wrote:
> Should bzr-explorer check for some specific bzr version then to ensure that your fix was landed?

I think that would probably be sensible (it can easily be integrated).
I'll add that when (and if) the fix lands. I just thought it would be
good to get the review started early.

Al

> --
> https://code.launchpad.net/~abudden/bzr-explorer/bound-branch-submit-pane/+merge/59959
> You are the owner of lp:~abudden/bzr-explorer/bound-branch-submit-pane.
>

--
http://sites.google.com/site/abudden

Revision history for this message
Dr Al (abudden) wrote :

The bug fix for Bug 513709 has been approved for inclusion in 2.4b3.

A bit more investigation on the Bazaar version: I don't think it is too critical after all. The fix for Bug 513709 sets the correct parent location for both the new master (parent) branch and for the working (bound) branch. Bazaar Explorer looks at the working (bound) branch when identifying the master (parent) branch. Before the patch was landed, the parent location for the master branch was set incorrectly (which is mostly irrelevant to Bazaar Explorer) and the parent location for the working (bound) branch wasn't set at all. Therefore, in branches created before 2.4b3, the submit pane won't be shown and no difference will be seen (there's nothing we can do about this sadly). With this patch, in branches created after 2.4b3, the submit pane will be shown and the correct parent will be visible. Therefore, I don't think we need to check the Bazaar version.

I hope all that makes sense!

Revision history for this message
Alexander Belchenko (bialix) wrote :

Y trust your decision here. Make sure you have tested the bzr-explorer behavior with and without your patch and let's land this.

Revision history for this message
Alexander Belchenko (bialix) wrote :

Alexander Belchenko пишет:
> Y trust your decision here. Make sure you have tested the bzr-explorer behavior with and without your patch and let's land this.
s/Y/I/

--
All the dude wanted was his rug back

Revision history for this message
Alexander Belchenko (bialix) wrote :

Al, I don't like that submit pane and don't use it. One day I want to add config option to hide it forever.

But if it important for you -- then please, test t as you think appropriate, with bound branches and plain branches, and if you're happy with result, then please land it.

Revision history for this message
Alexander Belchenko (bialix) :
review: Abstain
Revision history for this message
Alexander Belchenko (bialix) wrote :

I don't understand some parts of your patch. Don't land it, please, I'd like to ask something.

review: Needs Information
Revision history for this message
Dr Al (abudden) wrote :

No problem, I haven't had a chance to do extensive testing, so I wasn't going to just yet anyway!

Revision history for this message
Dr Al (abudden) wrote :

Okay, I've done quite a bit of testing now and haven't found any problems. What did you want to ask?

Revision history for this message
Alexander Belchenko (bialix) wrote :

OK, I think we can do a better job now and provide better label for the case when there is no submit_branch set. Right now for non-bound branches we have:

submit_url = branch.get_submit_branch() or branch.get_parent()

but the target is always target = 'submit'

Maybe we can provide correct label here as of

submit_url = branch.get_submit_branch()
if submit_url:
  target = 'submit'
  name = gettext('Submit delta')
else:
  submit_url = branch.get_parent()
  target = 'parent'
  name = gettext('Parent delta')

Revision history for this message
Dr Al (abudden) wrote :

On 12 May 2011 16:06, Alexander Belchenko <email address hidden> wrote:
> OK, I think we can do a better job now and provide better label for the case when there is no submit_branch set. Right now for non-bound branches we have:
>
> submit_url = branch.get_submit_branch() or branch.get_parent()
>
> but the target is always target = 'submit'
>
> Maybe we can provide correct label here as of
>
> submit_url = branch.get_submit_branch()
> if submit_url:
>  target = 'submit'
>  name = gettext('Submit delta')
> else:
>  submit_url = branch.get_parent()
>  target = 'parent'
>  name = gettext('Parent delta')

Sounds reasonable: I'll make that change.

Al

505. By Dr Al

Merge trunk

506. By Dr Al

Report correct target name if using parent branch.

Revision history for this message
Dr Al (abudden) wrote :

Done.

Revision history for this message
Alexander Belchenko (bialix) wrote :

Thank you, I'll merge.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2011-05-09 20:53:45 +0000
3+++ NEWS 2011-05-13 07:21:10 +0000
4@@ -38,6 +38,10 @@
5
6 * Bulgarian translation added.
7
8+Bug Fixes:
9+
10+* Use the parent branch in the submit pane when working with bound branches.
11+ (A. S. Budden, Bug #777108)
12
13 1.1.2 26-Nov-2010
14 -----------------
15
16=== modified file 'lib/status_data.py'
17--- lib/status_data.py 2011-05-08 18:49:29 +0000
18+++ lib/status_data.py 2011-05-13 07:21:10 +0000
19@@ -25,6 +25,8 @@
20
21 from bzrlib import errors, revisionspec, status
22
23+from bzrlib import branch as mod_branch
24+
25
26 def get_status_info(wt, specific_files=None, versioned=False):
27 """Get the status information for a working tree.
28@@ -101,3 +103,13 @@
29 rev_spec = revisionspec.RevisionSpec.from_string('submit:')
30 old_tree = rev_spec.as_tree(branch)
31 return changes_between_trees(new_tree, old_tree)[0]
32+
33+def get_parent_submission_info(branch):
34+ """Get the status information for a branch versus its submit branch.
35+
36+ :return: delta
37+ """
38+ new_tree = branch.basis_tree()
39+ old_branch = mod_branch.Branch.open_containing(branch.get_parent())[0]
40+ old_tree = old_branch.basis_tree()
41+ return changes_between_trees(new_tree, old_tree)[0]
42
43=== modified file 'lib/status_report.py'
44--- lib/status_report.py 2011-05-08 18:49:29 +0000
45+++ lib/status_report.py 2011-05-13 07:21:10 +0000
46@@ -271,10 +271,6 @@
47 class SubmitReport(_BaseStatusReport):
48
49 # Formatters by section
50- def _added_formatter(items):
51- # Diff is useful here because it shows what's committed which, unlike
52- # the plain status case, may vary from the current file contents
53- return _edit_with_actions_decorator(items[0], ['diff(-rsubmit:..-1)'])
54 def _deleted_formatter(items):
55 return items[0]
56 def _renamed_formatter(items):
57@@ -283,25 +279,44 @@
58 def _kind_changed_formatter(items):
59 text = "%s (%s => %s)" % (items[0], items[2], items[3])
60 return _edit_decorator(items[0], text)
61- def _modified_formatter(items):
62- return _edit_with_actions_decorator(items[0], ['diff(-rsubmit:..-1)'])
63+
64+ # Create formatters on the fly where diff is used as
65+ # the ancestor branch varies
66+ def _make_diff_based_formatter(self):
67+ if self.target == 'parent':
68+ parent_branch = self.branch.get_parent()
69+ diff_path = 'diff(-rancestor:%s..-1)' % parent_branch
70+ else:
71+ diff_path = 'diff(-rsubmit:..-1)'
72+ def _diff_based_formatter(items):
73+ return _edit_with_actions_decorator(items[0], [diff_path])
74+ return _diff_based_formatter
75+
76 formatter_map = {
77- 'Added': _added_formatter,
78+ 'Added': None, # Added in _collect_data
79 'Deleted': _deleted_formatter,
80 'Renamed': _renamed_formatter,
81 'Kind changed': _kind_changed_formatter,
82- 'Modified': _modified_formatter,
83+ 'Modified': None, # Added in _collect_data
84 }
85
86- def __init__(self, branch):
87+ def __init__(self, branch, target='submit'):
88 self.branch = branch
89+ self.target = target
90 self._collect_data()
91
92 def _collect_data(self):
93 self._data = None
94 self._exception = None
95 try:
96- delta = status_data.get_submission_info(self.branch)
97+ if self.target == 'submit':
98+ delta = status_data.get_submission_info(self.branch)
99+ elif self.target == 'parent':
100+ delta = status_data.get_parent_submission_info(self.branch)
101+ else:
102+ raise errors.BzrError("Unrecognised target type")
103+ self.formatter_map['Added'] = self._make_diff_based_formatter()
104+ self.formatter_map['Modified'] = self._make_diff_based_formatter()
105 if delta.has_changed():
106 self._data = delta
107 except errors.BzrError, ex:
108@@ -312,10 +327,10 @@
109 return html_status_message(ERROR_STATUS, unicode(self._exception))
110 elif self._data:
111 indicator = WARNING_STATUS
112- msg = gettext("Branch has changes not present in its submit branch.")
113+ msg = gettext("Branch has changes not present in its %s branch." % self.target)
114 else:
115 indicator = GOOD_STATUS
116- msg = gettext("Branch is fully merged into its submit branch.")
117+ msg = gettext("Branch is fully merged into its %s branch." % self.target)
118 return html_status_message(indicator, msg)
119
120 def body_lines(self):
121@@ -337,6 +352,6 @@
122 delta = self._data
123 if delta.has_changed():
124 open_parent_msg = gettext(
125- "Open parent branch and merge these changes")
126+ "Open %s branch and merge these changes" % self.target)
127 lines.append(_text_decorator(open_parent_msg))
128 return lines
129
130=== modified file 'lib/view_submit.py'
131--- lib/view_submit.py 2011-05-08 18:49:29 +0000
132+++ lib/view_submit.py 2011-05-13 07:21:10 +0000
133@@ -28,7 +28,10 @@
134 shown using -rsubmit:..-1, i.e. what's been committed so far
135 versus the submit branch.
136 """
137+ def __init__(self, model, action_callback, target):
138+ super(SubmitView, self).__init__(model, action_callback)
139+ self.target = target
140
141 def report_text(self):
142- report = status_report.SubmitReport(self._model.branch)
143+ report = status_report.SubmitReport(self._model.branch, self.target)
144 return report.full_report()
145
146=== modified file 'lib/view_workingtree.py'
147--- lib/view_workingtree.py 2009-12-09 23:43:32 +0000
148+++ lib/view_workingtree.py 2011-05-13 07:21:10 +0000
149@@ -39,20 +39,32 @@
150 # value ones which everyone ought to want. :-)
151 self.detail_views = []
152 branch = self.model.branch
153- # Display the delta versus the submit branch iff one is
154+ # Display the delta versus the submit or parent branch iff one is
155 # defined and it's local. Unfortunately though, merging a feature
156 # branch into trunk sets the merged-from branch as the submit
157 # branch which means we see a "silly" submit delta panel for trunk.
158- # To work around that, we don't show the panel for bound branches
159- # as trunk ought to be bound. We could look for the name
160- # "trunk" instead but that sounds even more of a hack. :-(
161+ # To work around that, we show the parent location instead of the
162+ # submit location for a bound branch.
163 if branch.get_bound_location() is None:
164- submit_url = branch.get_submit_branch() or branch.get_parent()
165- if submit_url and submit_url.startswith("file:"):
166- self.detail_views.append(
167- (view_submit.SubmitView(model, action_callback,),
168- gettext("Submit delta")),
169- )
170+ submit_url = branch.get_submit_branch()
171+ if submit_url:
172+ target = 'submit'
173+ name = gettext('Submit delta')
174+ else:
175+ submit_url = branch.get_parent()
176+ target = 'parent'
177+ name = gettext('Parent delta')
178+ else:
179+ target = 'parent'
180+ name = gettext('Parent delta')
181+ submit_url = branch.get_parent()
182+
183+ if submit_url and submit_url.startswith("file:"):
184+ self.detail_views.append(
185+ (view_submit.SubmitView(model, action_callback, target),
186+ name),
187+ )
188+
189 # TODO: add other panels to show what's on the shelf, etc.
190
191 def ui(self):

Subscribers

People subscribed via source and target branches