~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2009-05-27 08:46:32 UTC
  • mto: (4343.3.25 1.15-gc-stacking)
  • mto: This revision was merged to the branch mainline in revision 4392.
  • Revision ID: john@arbash-meinel.com-20090527084632-jfs47silmrswlgvd
Change the Repository.add_fallback_repository() contract slightly.

So the final statement for fallback repositories is:
1) When transitioning from unlocked => locked, we will lock the fallback repos
2) When transitioning from locked => unlocked, we will unlock the fallback repos
3) If self.is_locked(), add_fallback_repository() will lock the fallback repo,
   which will match (2) when self is finally unlocked.
Callers of add_fallback_repository() maintain their responsibility to match
every lock that they perform with a corresponding unlock.

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
    def _open_hook(self):
102
102
        """Called by init to allow simpler extension of the base class."""
103
103
 
104
 
    def _activate_fallback_location(self, url, lock_style):
 
104
    def _activate_fallback_location(self, url):
105
105
        """Activate the branch/repository from url as a fallback repository."""
106
106
        repo = self._get_fallback_repository(url)
107
 
        if lock_style == 'write':
108
 
            repo.lock_write()
109
 
        elif lock_style == 'read':
110
 
            repo.lock_read()
111
107
        self.repository.add_fallback_repository(repo)
112
108
 
113
109
    def break_lock(self):
656
652
                self.repository.fetch(source_repository, revision_id,
657
653
                    find_ghosts=True)
658
654
        else:
659
 
            self._activate_fallback_location(url, 'write')
 
655
            self._activate_fallback_location(url)
660
656
        # write this out after the repository is stacked to avoid setting a
661
657
        # stacked config that doesn't work.
662
658
        self._set_config_location('stacked_on_location', url)
2366
2362
                    raise AssertionError(
2367
2363
                        "'transform_fallback_location' hook %s returned "
2368
2364
                        "None, not a URL." % hook_name)
2369
 
            self._activate_fallback_location(url, None)
 
2365
            self._activate_fallback_location(url)
2370
2366
 
2371
2367
    def __init__(self, *args, **kwargs):
2372
2368
        self._ignore_fallbacks = kwargs.get('ignore_fallbacks', False)