~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

Merge fetch-spec-everything-not-in-other.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
1380
1380
        """Return the most suitable metadir for a checkout of this branch.
1381
1381
        Weaves are used if this branch's repository uses weaves.
1382
1382
        """
1383
 
        if isinstance(self.bzrdir, bzrdir.BzrDirPreSplitOut):
1384
 
            from bzrlib.repofmt import weaverepo
1385
 
            format = bzrdir.BzrDirMetaFormat1()
1386
 
            format.repository_format = weaverepo.RepositoryFormat7()
1387
 
        else:
1388
 
            format = self.repository.bzrdir.checkout_metadir()
1389
 
            format.set_branch_format(self._format)
 
1383
        format = self.repository.bzrdir.checkout_metadir()
 
1384
        format.set_branch_format(self._format)
1390
1385
        return format
1391
1386
 
1392
1387
    def create_clone_on_transport(self, to_transport, revision_id=None,
2057
2052
            raise NotImplementedError
2058
2053
        if found_repository is None:
2059
2054
            found_repository = a_bzrdir.open_repository()
2060
 
        return BzrBranch(_format=self,
 
2055
        return BzrBranchPreSplitOut(_format=self,
2061
2056
                         _control_files=a_bzrdir._control_files,
2062
2057
                         a_bzrdir=a_bzrdir,
2063
2058
                         name=name,
2698
2693
                mode=self.bzrdir._get_file_mode())
2699
2694
 
2700
2695
 
 
2696
class BzrBranchPreSplitOut(BzrBranch):
 
2697
 
 
2698
    def _get_checkout_format(self):
 
2699
        """Return the most suitable metadir for a checkout of this branch.
 
2700
        Weaves are used if this branch's repository uses weaves.
 
2701
        """
 
2702
        from bzrlib.repofmt.weaverepo import RepositoryFormat7
 
2703
        from bzrlib.bzrdir import BzrDirMetaFormat1
 
2704
        format = BzrDirMetaFormat1()
 
2705
        format.repository_format = RepositoryFormat7()
 
2706
        return format
 
2707
 
 
2708
 
2701
2709
class BzrBranch5(BzrBranch):
2702
2710
    """A format 5 branch. This supports new features over plain branches.
2703
2711
 
3453
3461
        if local and not bound_location:
3454
3462
            raise errors.LocalRequiresBoundBranch()
3455
3463
        master_branch = None
3456
 
        if not local and bound_location and self.source.user_url != bound_location:
 
3464
        source_is_master = (self.source.user_url == bound_location)
 
3465
        if not local and bound_location and not source_is_master:
3457
3466
            # not pulling from master, so we need to update master.
3458
3467
            master_branch = self.target.get_master_branch(possible_transports)
3459
3468
            master_branch.lock_write()
3465
3474
            return self._pull(overwrite,
3466
3475
                stop_revision, _hook_master=master_branch,
3467
3476
                run_hooks=run_hooks,
3468
 
                _override_hook_target=_override_hook_target)
 
3477
                _override_hook_target=_override_hook_target,
 
3478
                merge_tags_to_master=not source_is_master)
3469
3479
        finally:
3470
3480
            if master_branch:
3471
3481
                master_branch.unlock()
3538
3548
 
3539
3549
    def _pull(self, overwrite=False, stop_revision=None,
3540
3550
             possible_transports=None, _hook_master=None, run_hooks=True,
3541
 
             _override_hook_target=None, local=False):
 
3551
             _override_hook_target=None, local=False,
 
3552
             merge_tags_to_master=True):
3542
3553
        """See Branch.pull.
3543
3554
 
3544
3555
        This function is the core worker, used by GenericInterBranch.pull to
3579
3590
            # so a tags implementation that versions tags can only 
3580
3591
            # pull in the most recent changes. -- JRV20090506
3581
3592
            result.tag_conflicts = self.source.tags.merge_to(self.target.tags,
3582
 
                overwrite)
 
3593
                overwrite, ignore_master=not merge_tags_to_master)
3583
3594
            result.new_revno, result.new_revid = self.target.last_revision_info()
3584
3595
            if _hook_master:
3585
3596
                result.master_branch = _hook_master