~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to bzrtools.py

  • Committer: Aaron Bentley
  • Date: 2007-07-26 15:52:55 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070726155255-cawzo84zpzoulzbr
Allow importing directly from a URL

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import sys
25
25
 
26
26
import bzrlib
 
27
from bzrlib import urlutils
27
28
import bzrlib.errors
28
29
from bzrlib.errors import (BzrCommandError, NotBranchError, NoSuchFile,
29
30
                           UnsupportedFormatError, TransportError,
30
31
                           NoWorkingTree, PermissionDenied)
31
32
from bzrlib.bzrdir import BzrDir, BzrDirFormat
 
33
from bzrlib.transport import get_transport
32
34
 
33
35
def temp_tree():
34
36
    dirname = tempfile.mkdtemp("temp-branch")
362
364
    return format.open(t)
363
365
 
364
366
 
 
367
def open_from_url(location):
 
368
    location = urlutils.normalize_url(location)
 
369
    dirname, basename = urlutils.split(location)
 
370
    return get_transport(dirname).get(basename)
 
371
 
 
372
 
365
373
def run_tests():
366
374
    import doctest
367
375
    result = doctest.testmod()