~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-27 06:47:50 UTC
  • mfrom: (4294.2.12 push.roundtrips)
  • Revision ID: pqm@pqm.ubuntu.com-20090427064750-e9obd6h83omt86ps
(robertc) Reduce roundtrips needed to push a new branch by coalescing
        many steps of the initialisation process. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
328
328
        """
329
329
        raise NotImplementedError(self.clone)
330
330
 
 
331
    def create_prefix(self):
 
332
        """Create all the directories leading down to self.base."""
 
333
        cur_transport = self
 
334
        needed = [cur_transport]
 
335
        # Recurse upwards until we can create a directory successfully
 
336
        while True:
 
337
            new_transport = cur_transport.clone('..')
 
338
            if new_transport.base == cur_transport.base:
 
339
                raise errors.BzrCommandError(
 
340
                    "Failed to create path prefix for %s."
 
341
                    % cur_transport.base)
 
342
            try:
 
343
                new_transport.mkdir('.')
 
344
            except errors.NoSuchFile:
 
345
                needed.append(new_transport)
 
346
                cur_transport = new_transport
 
347
            except errors.FileExists:
 
348
                break
 
349
            else:
 
350
                break
 
351
        # Now we only need to create child directories
 
352
        while needed:
 
353
            cur_transport = needed.pop()
 
354
            cur_transport.ensure_base()
 
355
 
331
356
    def ensure_base(self):
332
357
        """Ensure that the directory this transport references exists.
333
358
 
515
540
        """
516
541
        raise errors.NotLocalUrl(self.abspath(relpath))
517
542
 
518
 
 
519
543
    def has(self, relpath):
520
544
        """Does the file relpath exist?
521
545