/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Steffen Eichenberg
  • Date: 2006-11-07 14:46:52 UTC
  • mto: (2206.1.1 bzr.enhanced_move)
  • mto: This revision was merged to the branch mainline in revision 2241.
  • Revision ID: scameronde@googlemail.com-20061107144652-d7553603b5e0a6c7
the mv command is now able to move files that have already been moved on the file system

Show diffs side-by-side

added added

removed removed

Lines of Context:
425
425
 
426
426
    If the last argument is a versioned directory, all the other names
427
427
    are moved into it.  Otherwise, there must be exactly two arguments
428
 
    and the file is changed to a new name, which must not already exist.
 
428
    and the file is changed to a new name.
 
429
 
 
430
    If OLDNAME does not exist on the filesystem but is versioned and
 
431
    NEWNAME does exist on the filesystem but is not versioned, mv
 
432
    assumes that the file has been manually moved and only updates
 
433
    its internal inventory to reflect that change.
 
434
    The same is valid when moving many SOURCE files to a DESTINATION.
429
435
 
430
436
    Files cannot be moved between branches.
431
437
    """
432
438
 
433
439
    takes_args = ['names*']
 
440
    takes_options = [Option("after", help="move only the bzr identifier of the"
 
441
                                          " file (file has already been" 
 
442
                                          " moved). Use this flag if bzr is"
 
443
                                          " not able to detect this itself.")]
434
444
    aliases = ['move', 'rename']
435
445
    encoding_type = 'replace'
436
446
 
437
 
    def run(self, names_list):
 
447
    def run(self, names_list, after=False):
438
448
        if names_list is None:
439
449
            names_list = []
440
450
 
444
454
        
445
455
        if os.path.isdir(names_list[-1]):
446
456
            # move into existing directory
447
 
            for pair in tree.move(rel_names[:-1], rel_names[-1]):
 
457
            for pair in tree.move(rel_names[:-1], rel_names[-1], after):
448
458
                self.outf.write("%s => %s\n" % pair)
449
459
        else:
450
460
            if len(names_list) != 2:
451
 
                raise errors.BzrCommandError('to mv multiple files the destination '
452
 
                                             'must be a versioned directory')
453
 
            tree.rename_one(rel_names[0], rel_names[1])
 
461
                raise errors.BzrCommandError('to mv multiple files the'
 
462
                                             ' destination must be a versioned'
 
463
                                             ' directory')
 
464
            tree.rename_one(rel_names[0], rel_names[1], after)
454
465
            self.outf.write("%s => %s\n" % (rel_names[0], rel_names[1]))
455
466
            
456
467