[MERGE] StackableBranch

Martin Pool mbp at canonical.com
Wed Jul 16 07:13:13 BST 2008

On Thu, Jun 19, 2008 at 11:41 AM, Aaron Bentley <aaron at aaronbentley.com> wrote:

> bb:resubmit
> I'm sorry I didn't notice this earlier, but this patch introduces
> behavior that I fear may lead to disaster.  I'm not firm on this vote,
> but it's my default position, until we've discussed it.
> Specifically, it causes stacking to happen when the source branch is
> stacked.  This will frequently not be what people want, and there is no
> way to turn off the behavior.
> Here's the code I'm talking about:
>>      def sprout(self, url, revision_id=None, force_new_repo=False,
>>                 recurse='down', possible_transports=None,
>> -               accelerator_tree=None, hardlink=False):
>> +               accelerator_tree=None, hardlink=False, stacked=False):
>>          """Create a copy of this bzrdir prepared for use as a new line of
>>          development.
>>          try:
>>              source_branch = self.open_branch()
>>              source_repository = source_branch.repository
>> +            if stacked:
>> +                stacked_branch_url = self.root_transport.base
>> +            else:
>> +                try:
>> +                    stacked_branch_url = source_branch.get_stacked_on()
>> +                except (errors.NotStacked, errors.UnstackableBranchFormat,
>> +                    errors.UnstackableRepositoryFormat):
>> +                    stacked_branch_url = None
> So if the user requested stacking, we stack against the source branch.
> That seems reasonable.  But if they didn't specify stacking, we stack
> against whatever that branch was stacked on.  Even if they're branching
> into a shared repo.
> Sooner or later, someone is going to get stacking without realizing it,
>  and they're going to get data loss when the stacked_on branch goes away.
> While it is tempting to try to solve the slow-initial-branch problem, I
> don't think this is the right way.
> I think sprout shouldn't do stacking unless either:
> - - the user requests it
> - - there's a stacking policy on the target (and there should probably be
>  an override to defeat that, also).

You're right, and there are some further complications.

At the moment the branch code always creates a new branch (and
repository and tree where applicable) in the same format as the
source.  So if the source branch is not in a format that supports
stacking, you get a somewhat confusing error about the destination not
supporting stacking.  ("But I just told you to make it...?")   I think
if you ask for stacking, we have to create a destination branch format
that supports it.

(Perhaps we should make people create the branch separately as a
protective step but I think the current behaviour is more confusing
than protective.)

On the other hand if you do not explicitly ask for a stacked branch I
would agree that you should not get one.  You do, with the current
code, at least get a message indicating the dependency, but it may
still be a bit of a trap.

Martin <http://launchpad.net/~mbp/>

More information about the bazaar mailing list