~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-01-20 02:01:04 UTC
  • mfrom: (2220.1.14 bzr.ab.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070120020104-a192555a9165b259
mv can also work on just inventory entry (Eichenberg, Kruger)

Show diffs side-by-side

added added

removed removed

Lines of Context:
450
450
 
451
451
    If the last argument is a versioned directory, all the other names
452
452
    are moved into it.  Otherwise, there must be exactly two arguments
453
 
    and the file is changed to a new name, which must not already exist.
 
453
    and the file is changed to a new name.
 
454
 
 
455
    If OLDNAME does not exist on the filesystem but is versioned and
 
456
    NEWNAME does exist on the filesystem but is not versioned, mv
 
457
    assumes that the file has been manually moved and only updates
 
458
    its internal inventory to reflect that change.
 
459
    The same is valid when moving many SOURCE files to a DESTINATION.
454
460
 
455
461
    Files cannot be moved between branches.
456
462
    """
457
463
 
458
464
    takes_args = ['names*']
 
465
    takes_options = [Option("after", help="move only the bzr identifier"
 
466
        " of the file (file has already been moved). Use this flag if"
 
467
        " bzr is not able to detect this itself.")]
459
468
    aliases = ['move', 'rename']
460
469
    encoding_type = 'replace'
461
470
 
462
 
    def run(self, names_list):
 
471
    def run(self, names_list, after=False):
463
472
        if names_list is None:
464
473
            names_list = []
465
474
 
469
478
        
470
479
        if os.path.isdir(names_list[-1]):
471
480
            # move into existing directory
472
 
            for pair in tree.move(rel_names[:-1], rel_names[-1]):
 
481
            for pair in tree.move(rel_names[:-1], rel_names[-1], after=after):
473
482
                self.outf.write("%s => %s\n" % pair)
474
483
        else:
475
484
            if len(names_list) != 2:
476
 
                raise errors.BzrCommandError('to mv multiple files the destination '
477
 
                                             'must be a versioned directory')
478
 
            tree.rename_one(rel_names[0], rel_names[1])
 
485
                raise errors.BzrCommandError('to mv multiple files the'
 
486
                                             ' destination must be a versioned'
 
487
                                             ' directory')
 
488
            tree.rename_one(rel_names[0], rel_names[1], after=after)
479
489
            self.outf.write("%s => %s\n" % (rel_names[0], rel_names[1]))
480
490
            
481
491