~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
import bzrlib.errors as errors
30
30
from bzrlib.lockable_files import LockableFiles, TransportLock
31
31
from bzrlib.lockdir import LockDir
32
 
from bzrlib.osutils import safe_unicode
33
32
from bzrlib.osutils import (
34
33
                            abspath,
35
34
                            pathjoin,
43
42
from bzrlib.symbol_versioning import *
44
43
from bzrlib.trace import mutter
45
44
from bzrlib.transactions import WriteTransaction
46
 
from bzrlib.transport import get_transport, urlunescape
 
45
from bzrlib.transport import get_transport
47
46
from bzrlib.transport.local import LocalTransport
 
47
import bzrlib.urlutils as urlutils
48
48
from bzrlib.weave import Weave
49
49
from bzrlib.xml4 import serializer_v4
50
50
import bzrlib.xml5
173
173
                    basis_repo = None
174
174
        return basis_repo, basis_branch, basis_tree
175
175
 
 
176
    # TODO: This should be given a Transport, and should chdir up; otherwise
 
177
    # this will open a new connection.
176
178
    def _make_tail(self, url):
177
 
        segments = url.split('/')
178
 
        if segments and segments[-1] not in ('', '.'):
179
 
            parent = '/'.join(segments[:-1])
180
 
            t = bzrlib.transport.get_transport(parent)
 
179
        head, tail = urlutils.split(url)
 
180
        if tail and tail != '.':
 
181
            t = bzrlib.transport.get_transport(head)
181
182
            try:
182
 
                t.mkdir(segments[-1])
 
183
                t.mkdir(tail)
183
184
            except errors.FileExists:
184
185
                pass
185
186
 
 
187
    # TODO: Should take a Transport
186
188
    @classmethod
187
189
    def create(cls, base):
188
190
        """Create a new BzrDir at the url 'base'.
196
198
        if cls is not BzrDir:
197
199
            raise AssertionError("BzrDir.create always creates the default format, "
198
200
                    "not one of %r" % cls)
199
 
        segments = base.split('/')
200
 
        if segments and segments[-1] not in ('', '.'):
201
 
            parent = '/'.join(segments[:-1])
202
 
            t = bzrlib.transport.get_transport(parent)
 
201
        head, tail = urlutils.split(base)
 
202
        if tail and tail != '.':
 
203
            t = bzrlib.transport.get_transport(head)
203
204
            try:
204
 
                t.mkdir(segments[-1])
 
205
                t.mkdir(tail)
205
206
            except errors.FileExists:
206
207
                pass
207
208
        return BzrDirFormat.get_default_format().initialize(safe_unicode(base))
515
516
        If there is one and it is either an unrecognised format or an unsupported 
516
517
        format, UnknownFormatError or UnsupportedFormatError are raised.
517
518
        If there is one, it is returned, along with the unused portion of url.
 
519
 
 
520
        :return: The BzrDir that contains the path, and a Unicode path 
 
521
                for the rest of the URL.
518
522
        """
519
523
        # this gets the normalised url back. I.e. '.' -> the full path.
520
524
        url = a_transport.base
522
526
            try:
523
527
                format = BzrDirFormat.find_format(a_transport)
524
528
                BzrDir._check_supported(format, False)
525
 
                return format.open(a_transport), a_transport.relpath(url)
 
529
                return format.open(a_transport), urlutils.unescape(a_transport.relpath(url))
526
530
            except errors.NotBranchError, e:
527
 
                mutter('not a branch in: %r %s', a_transport.base, e)
 
531
                ## mutter('not a branch in: %r %s', a_transport.base, e)
 
532
                pass
528
533
            new_t = a_transport.clone('..')
529
534
            if new_t.base == a_transport.base:
530
535
                # reached the root, whatever that may be
636
641
            source_branch.sprout(result, revision_id=revision_id)
637
642
        else:
638
643
            result.create_branch()
 
644
        # TODO: jam 20060426 we probably need a test in here in the
 
645
        #       case that the newly sprouted branch is a remote one
639
646
        if result_repo is None or result_repo.make_working_trees():
640
647
            wt = result.create_workingtree()
641
648
            if wt.inventory.root is None:
1704
1711
            store_transport = self.bzrdir.transport.clone(store_name)
1705
1712
            store = TransportStore(store_transport, prefixed=True)
1706
1713
            for urlfilename in store_transport.list_dir('.'):
1707
 
                filename = urlunescape(urlfilename)
 
1714
                filename = urlutils.unescape(urlfilename)
1708
1715
                if (filename.endswith(".weave") or
1709
1716
                    filename.endswith(".gz") or
1710
1717
                    filename.endswith(".sig")):