~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Robert Collins
  • Date: 2005-10-20 05:58:09 UTC
  • mfrom: (0.2.1)
  • mto: This revision was merged to the branch mainline in revision 1477.
  • Revision ID: robertc@robertcollins.net-20051020055809-70047c9f64e0a0a0
'bzr branch' sets the branch-name,

It will now set the branch-name to the last component of the
output directory, if one was supplied.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
 
 
17
# DO NOT change this to cStringIO - it results in control files 
 
18
# written as UCS4
 
19
# FIXIT! (Only deal with byte streams OR unicode at any one layer.)
 
20
# RBC 20051018
 
21
from StringIO import StringIO
18
22
import sys
19
23
import os
20
24
 
336
340
 
337
341
    def run(self, location=None, remember=False, clobber=False):
338
342
        from bzrlib.merge import merge
339
 
        import tempfile
340
343
        from shutil import rmtree
341
344
        import errno
342
345
        
375
378
 
376
379
    def run(self, from_location, to_location=None, revision=None, basis=None):
377
380
        from bzrlib.clone import copy_branch
378
 
        import tempfile
379
381
        import errno
380
382
        from shutil import rmtree
381
 
        cache_root = tempfile.mkdtemp()
382
383
        if revision is None:
383
384
            revision = [None]
384
385
        elif len(revision) > 1:
394
395
                raise
395
396
        br_from.lock_read()
396
397
        try:
397
 
            br_from.setup_caching(cache_root)
398
398
            if basis is not None:
399
399
                basis_branch = Branch.open_containing(basis)[0]
400
400
            else:
405
405
                revision_id = None
406
406
            if to_location is None:
407
407
                to_location = os.path.basename(from_location.rstrip("/\\"))
 
408
                name = None
 
409
            else:
 
410
                name = os.path.basename(to_location) + '\n'
408
411
            try:
409
412
                os.mkdir(to_location)
410
413
            except OSError, e:
423
426
                msg = "The branch %s has no revision %d." % (from_location, revision[0])
424
427
                raise BzrCommandError(msg)
425
428
            except bzrlib.errors.UnlistableBranch:
 
429
                rmtree(to_location)
426
430
                msg = "The branch %s cannot be used as a --basis"
 
431
                raise BzrCommandError(msg)
 
432
            if name:
 
433
                branch = Branch.open(to_location)
 
434
                name = StringIO(name)
 
435
                branch.put_controlfile('branch-name', name)
427
436
        finally:
428
437
            br_from.unlock()
429
 
            rmtree(cache_root)
430
438
 
431
439
 
432
440
class cmd_renames(Command):