~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Robert Collins
  • Date: 2005-09-28 07:03:54 UTC
  • mfrom: (1185.10.7)
  • mto: (1092.2.19)
  • mto: This revision was merged to the branch mainline in revision 1391.
  • Revision ID: robertc@robertcollins.net-20050928070354-fb49ab0b2563d5b2
Aarons branch --basis patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
372
372
 
373
373
    To retrieve the branch as of a particular revision, supply the --revision
374
374
    parameter, as in "branch foo/bar -r 5".
 
375
 
 
376
    --basis is to speed up branching from remote branches.  When specified, it
 
377
    copies all the file-contents, inventory and revision data from the basis
 
378
    branch before copying anything from the remote branch.
375
379
    """
376
380
    takes_args = ['from_location', 'to_location?']
377
 
    takes_options = ['revision']
 
381
    takes_options = ['revision', 'basis']
378
382
    aliases = ['get', 'clone']
379
383
 
380
 
    def run(self, from_location, to_location=None, revision=None):
 
384
    def run(self, from_location, to_location=None, revision=None, basis=None):
381
385
        from bzrlib.branch import copy_branch
382
386
        import tempfile
383
387
        import errno
398
402
                else:
399
403
                    raise
400
404
            br_from.setup_caching(cache_root)
 
405
            if basis is not None:
 
406
                basis_branch = Branch.open_containing(basis)
 
407
            else:
 
408
                basis_branch = None
401
409
            if len(revision) == 1 and revision[0] is not None:
402
410
                revno = revision[0].in_history(br_from)[0]
403
411
            else:
416
424
                else:
417
425
                    raise
418
426
            try:
419
 
                copy_branch(br_from, to_location, revno)
 
427
                copy_branch(br_from, to_location, revno, basis_branch)
420
428
            except bzrlib.errors.NoSuchRevision:
421
429
                rmtree(to_location)
422
430
                msg = "The branch %s has no revision %d." % (from_location, revision[0])
423
431
                raise BzrCommandError(msg)
 
432
            except bzrlib.errors.UnlistableBranch:
 
433
                msg = "The branch %s cannot be used as a --basis"
424
434
        finally:
425
435
            rmtree(cache_root)
426
436