~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-04 23:53:19 UTC
  • mfrom: (5809.2.6 private-update-revisions)
  • Revision ID: pqm@pqm.ubuntu.com-20110504235319-9yz7jg7i0mica9wk
(jelmer) Make InterBranch.update_revisions private. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
994
994
        else:
995
995
            return (0, _mod_revision.NULL_REVISION)
996
996
 
997
 
    def update_revisions(self, other, stop_revision=None, overwrite=False,
998
 
            graph=None):
999
 
        """Pull in new perfect-fit revisions.
1000
 
 
1001
 
        :param other: Another Branch to pull from
1002
 
        :param stop_revision: Updated until the given revision
1003
 
        :param overwrite: Always set the branch pointer, rather than checking
1004
 
            to see if it is a proper descendant.
1005
 
        :param graph: A Graph object that can be used to query history
1006
 
            information. This can be None.
1007
 
        :return: None
1008
 
        """
1009
 
        return InterBranch.get(other, self).update_revisions(stop_revision,
1010
 
            overwrite, graph)
1011
 
 
1012
997
    @deprecated_method(deprecated_in((2, 4, 0)))
1013
998
    def import_last_revision_info(self, source_repo, revno, revid):
1014
999
        """Set the last revision info, importing from another repo if necessary.
2611
2596
                pass
2612
2597
        return None
2613
2598
 
2614
 
    def _basic_push(self, target, overwrite, stop_revision):
2615
 
        """Basic implementation of push without bound branches or hooks.
2616
 
 
2617
 
        Must be called with source read locked and target write locked.
2618
 
        """
2619
 
        result = BranchPushResult()
2620
 
        result.source_branch = self
2621
 
        result.target_branch = target
2622
 
        result.old_revno, result.old_revid = target.last_revision_info()
2623
 
        self.update_references(target)
2624
 
        if result.old_revid != stop_revision:
2625
 
            # We assume that during 'push' this repository is closer than
2626
 
            # the target.
2627
 
            graph = self.repository.get_graph(target.repository)
2628
 
            target.update_revisions(self, stop_revision,
2629
 
                overwrite=overwrite, graph=graph)
2630
 
        if self._push_should_merge_tags():
2631
 
            result.tag_conflicts = self.tags.merge_to(target.tags, overwrite)
2632
 
        result.new_revno, result.new_revid = target.last_revision_info()
2633
 
        return result
2634
 
 
2635
2599
    def get_stacked_on_url(self):
2636
2600
        raise errors.UnstackableBranchFormat(self._format, self.user_url)
2637
2601
 
3287
3251
        raise NotImplementedError(self.pull)
3288
3252
 
3289
3253
    @needs_write_lock
3290
 
    def update_revisions(self, stop_revision=None, overwrite=False,
3291
 
            graph=None):
3292
 
        """Pull in new perfect-fit revisions.
3293
 
 
3294
 
        :param stop_revision: Updated until the given revision
3295
 
        :param overwrite: Always set the branch pointer, rather than checking
3296
 
            to see if it is a proper descendant.
3297
 
        :param graph: A Graph object that can be used to query history
3298
 
            information. This can be None.
3299
 
        :return: None
3300
 
        """
3301
 
        raise NotImplementedError(self.update_revisions)
3302
 
 
3303
 
    @needs_write_lock
3304
3254
    def push(self, overwrite=False, stop_revision=None,
3305
3255
             _override_hook_source_branch=None):
3306
3256
        """Mirror the source branch into the target branch.
3384
3334
            self.source.unlock()
3385
3335
 
3386
3336
    @needs_write_lock
3387
 
    def update_revisions(self, stop_revision=None, overwrite=False,
 
3337
    def _update_revisions(self, stop_revision=None, overwrite=False,
3388
3338
            graph=None):
3389
 
        """See InterBranch.update_revisions()."""
3390
3339
        other_revno, other_last_revision = self.source.last_revision_info()
3391
3340
        stop_revno = None # unknown
3392
3341
        if stop_revision is None:
3478
3427
        finally:
3479
3428
            self.source.unlock()
3480
3429
 
 
3430
    def _basic_push(self, overwrite, stop_revision):
 
3431
        """Basic implementation of push without bound branches or hooks.
 
3432
 
 
3433
        Must be called with source read locked and target write locked.
 
3434
        """
 
3435
        result = BranchPushResult()
 
3436
        result.source_branch = self.source
 
3437
        result.target_branch = self.target
 
3438
        result.old_revno, result.old_revid = self.target.last_revision_info()
 
3439
        self.source.update_references(self.target)
 
3440
        if result.old_revid != stop_revision:
 
3441
            # We assume that during 'push' this repository is closer than
 
3442
            # the target.
 
3443
            graph = self.source.repository.get_graph(self.target.repository)
 
3444
            self._update_revisions(stop_revision, overwrite=overwrite,
 
3445
                    graph=graph)
 
3446
        if self.source._push_should_merge_tags():
 
3447
            result.tag_conflicts = self.source.tags.merge_to(self.target.tags,
 
3448
                overwrite)
 
3449
        result.new_revno, result.new_revid = self.target.last_revision_info()
 
3450
        return result
 
3451
 
3481
3452
    def _push_with_bound_branches(self, overwrite, stop_revision,
3482
3453
            _override_hook_source_branch=None):
3483
3454
        """Push from source into target, and into target's master if any.
3498
3469
            master_branch.lock_write()
3499
3470
            try:
3500
3471
                # push into the master from the source branch.
3501
 
                self.source._basic_push(master_branch, overwrite, stop_revision)
3502
 
                # and push into the target branch from the source. Note that we
3503
 
                # push from the source branch again, because it's considered the
3504
 
                # highest bandwidth repository.
3505
 
                result = self.source._basic_push(self.target, overwrite,
3506
 
                    stop_revision)
 
3472
                master_inter = InterBranch.get(self.source, master_branch)
 
3473
                master_inter._basic_push(overwrite, stop_revision)
 
3474
                # and push into the target branch from the source. Note that
 
3475
                # we push from the source branch again, because it's considered
 
3476
                # the highest bandwidth repository.
 
3477
                result = self._basic_push(overwrite, stop_revision)
3507
3478
                result.master_branch = master_branch
3508
3479
                result.local_branch = self.target
3509
3480
                _run_hooks()
3512
3483
                master_branch.unlock()
3513
3484
        else:
3514
3485
            # no master branch
3515
 
            result = self.source._basic_push(self.target, overwrite,
3516
 
                stop_revision)
 
3486
            result = self._basic_push(overwrite, stop_revision)
3517
3487
            # TODO: Why set master_branch and local_branch if there's no
3518
3488
            # binding?  Maybe cleaner to just leave them unset? -- mbp
3519
3489
            # 20070504
3562
3532
            # -- JRV20090506
3563
3533
            result.old_revno, result.old_revid = \
3564
3534
                self.target.last_revision_info()
3565
 
            self.target.update_revisions(self.source, stop_revision,
3566
 
                overwrite=overwrite, graph=graph)
 
3535
            self._update_revisions(stop_revision, overwrite=overwrite,
 
3536
                graph=graph)
3567
3537
            # TODO: The old revid should be specified when merging tags, 
3568
3538
            # so a tags implementation that versions tags can only 
3569
3539
            # pull in the most recent changes. -- JRV20090506