~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-03-26 15:46:16 UTC
  • mfrom: (5741.1.3 bzr.dev)
  • Revision ID: pqm@pqm.ubuntu.com-20110326154616-y6h2rjf9bs1wvvfs
(jelmer) Move Branch.fetch implementation to InterBranch. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
682
682
            last_revision.
683
683
        :return: None
684
684
        """
685
 
        if fetch_spec is not None and last_revision is not None:
686
 
            raise AssertionError(
687
 
                "fetch_spec and last_revision are mutually exclusive.")
688
 
        if self.base == from_branch.base:
689
 
            return (0, [])
690
 
        from_branch.lock_read()
691
 
        try:
692
 
            if last_revision is None and fetch_spec is None:
693
 
                last_revision = from_branch.last_revision()
694
 
                last_revision = _mod_revision.ensure_null(last_revision)
695
 
            return self.repository.fetch(from_branch.repository,
696
 
                                         revision_id=last_revision,
697
 
                                         fetch_spec=fetch_spec)
698
 
        finally:
699
 
            from_branch.unlock()
 
685
        return InterBranch.get(from_branch, self).fetch(last_revision,
 
686
            fetch_spec)
700
687
 
701
688
    def get_bound_location(self):
702
689
        """Return the URL of the branch we are bound to.
3331
3318
        """
3332
3319
        raise NotImplementedError(self.copy_content_into)
3333
3320
 
 
3321
    @needs_write_lock
 
3322
    def fetch(self, stop_revision=None, fetch_spec=None):
 
3323
        """Fetch revisions.
 
3324
 
 
3325
        :param stop_revision: Last revision to fetch
 
3326
        :param fetch_spec: Fetch spec.
 
3327
        """
 
3328
        raise NotImplementedError(self.fetch)
 
3329
 
3334
3330
 
3335
3331
class GenericInterBranch(InterBranch):
3336
3332
    """InterBranch implementation that uses public Branch functions."""
3371
3367
            self.source.tags.merge_to(self.target.tags)
3372
3368
 
3373
3369
    @needs_write_lock
 
3370
    def fetch(self, stop_revision=None, fetch_spec=None):
 
3371
        if fetch_spec is not None and stop_revision is not None:
 
3372
            raise AssertionError(
 
3373
                "fetch_spec and last_revision are mutually exclusive.")
 
3374
        if self.target.base == self.source.base:
 
3375
            return (0, [])
 
3376
        self.source.lock_read()
 
3377
        try:
 
3378
            if stop_revision is None and fetch_spec is None:
 
3379
                stop_revision = self.source.last_revision()
 
3380
                stop_revision = _mod_revision.ensure_null(stop_revision)
 
3381
            return self.target.repository.fetch(self.source.repository,
 
3382
                revision_id=stop_revision, fetch_spec=fetch_spec)
 
3383
        finally:
 
3384
            self.source.unlock()
 
3385
 
 
3386
    @needs_write_lock
3374
3387
    def update_revisions(self, stop_revision=None, overwrite=False,
3375
3388
        graph=None, fetch_tags=True):
3376
3389
        """See InterBranch.update_revisions()."""