/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/url_policy_open.py

  • Committer: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Branch opening with URL-based restrictions."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
import threading
22
20
 
23
21
from . import (
24
22
    errors,
 
23
    trace,
25
24
    urlutils,
26
25
    )
27
26
from .branch import Branch
28
27
from .controldir import (
29
28
    ControlDir,
 
29
    ControlDirFormat,
 
30
    )
 
31
from .transport import (
 
32
    do_catching_redirections,
 
33
    get_transport,
30
34
    )
31
35
 
32
36
 
200
204
        """
201
205
        self.policy = policy
202
206
        self._seen_urls = set()
 
207
        if probers is None:
 
208
            probers = ControlDirFormat.all_probers()
203
209
        self.probers = probers
204
210
 
205
211
    @classmethod
276
282
            # spurious loop exceptions.
277
283
            self._seen_urls = set()
278
284
 
 
285
    def _open_dir(self, url):
 
286
        """Simple BzrDir.open clone that only uses specific probers.
 
287
 
 
288
        :param url: URL to open
 
289
        :return: ControlDir instance
 
290
        """
 
291
        def redirected(transport, e, redirection_notice):
 
292
            self.policy.check_one_url(e.target)
 
293
            redirected_transport = transport._redirected_to(
 
294
                e.source, e.target)
 
295
            if redirected_transport is None:
 
296
                raise errors.NotBranchError(e.source)
 
297
            trace.note(
 
298
                '%s is%s redirected to %s',
 
299
                transport.base, e.permanently, redirected_transport.base)
 
300
            return redirected_transport
 
301
 
 
302
        def find_format(transport):
 
303
            last_error = errors.NotBranchError(transport.base)
 
304
            for prober_kls in self.probers:
 
305
                prober = prober_kls()
 
306
                try:
 
307
                    return transport, prober.probe_transport(transport)
 
308
                except errors.NotBranchError as e:
 
309
                    last_error = e
 
310
            else:
 
311
                raise last_error
 
312
        transport = get_transport(url)
 
313
        transport, format = do_catching_redirections(
 
314
            find_format, transport, redirected)
 
315
        return format.open(transport)
 
316
 
279
317
    def follow_reference(self, url):
280
318
        """Get the branch-reference value at the specified url.
281
319
 
282
320
        This exists as a separate method only to be overriden in unit tests.
283
321
        """
284
 
        controldir = ControlDir.open(url, probers=self.probers)
 
322
        controldir = self._open_dir(url)
285
323
        return controldir.get_branch_reference()
286
324
 
287
 
    def open(self, url):
 
325
    def open(self, url, ignore_fallbacks=False):
288
326
        """Open the Bazaar branch at url, first checking it.
289
327
 
290
328
        What is acceptable means is defined by the policy's `follow_reference`
295
333
 
296
334
        url = self.check_and_follow_branch_reference(url)
297
335
 
298
 
        def open_branch(url):
299
 
            dir = ControlDir.open(url, probers=self.probers)
300
 
            return dir.open_branch()
 
336
        def open_branch(url, ignore_fallbacks):
 
337
            dir = self._open_dir(url)
 
338
            return dir.open_branch(ignore_fallbacks=ignore_fallbacks)
301
339
        return self.run_with_transform_fallback_location_hook_installed(
302
 
            open_branch, url)
 
340
            open_branch, url, ignore_fallbacks)
303
341
 
304
342
 
305
343
def open_only_scheme(allowed_scheme, url):