/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

[merge] bzr.dev 2255

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    branch,
31
31
    bundle,
32
32
    bzrdir,
 
33
    delta,
33
34
    config,
34
35
    errors,
35
36
    ignores,
450
451
 
451
452
    If the last argument is a versioned directory, all the other names
452
453
    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.
 
454
    and the file is changed to a new name.
 
455
 
 
456
    If OLDNAME does not exist on the filesystem but is versioned and
 
457
    NEWNAME does exist on the filesystem but is not versioned, mv
 
458
    assumes that the file has been manually moved and only updates
 
459
    its internal inventory to reflect that change.
 
460
    The same is valid when moving many SOURCE files to a DESTINATION.
454
461
 
455
462
    Files cannot be moved between branches.
456
463
    """
457
464
 
458
465
    takes_args = ['names*']
 
466
    takes_options = [Option("after", help="move only the bzr identifier"
 
467
        " of the file (file has already been moved). Use this flag if"
 
468
        " bzr is not able to detect this itself.")]
459
469
    aliases = ['move', 'rename']
460
470
    encoding_type = 'replace'
461
471
 
462
 
    def run(self, names_list):
 
472
    def run(self, names_list, after=False):
463
473
        if names_list is None:
464
474
            names_list = []
465
475
 
469
479
        
470
480
        if os.path.isdir(names_list[-1]):
471
481
            # move into existing directory
472
 
            for pair in tree.move(rel_names[:-1], rel_names[-1]):
 
482
            for pair in tree.move(rel_names[:-1], rel_names[-1], after=after):
473
483
                self.outf.write("%s => %s\n" % pair)
474
484
        else:
475
485
            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])
 
486
                raise errors.BzrCommandError('to mv multiple files the'
 
487
                                             ' destination must be a versioned'
 
488
                                             ' directory')
 
489
            tree.rename_one(rel_names[0], rel_names[1], after=after)
479
490
            self.outf.write("%s => %s\n" % (rel_names[0], rel_names[1]))
480
491
            
481
492
    
666
677
                except errors.NotLocalUrl:
667
678
                    warning('This transport does not update the working '
668
679
                            'tree of: %s' % (br_to.base,))
669
 
                    count = br_to.pull(br_from, overwrite)
 
680
                    count = br_from.push(br_to, overwrite)
670
681
                except errors.NoWorkingTree:
671
 
                    count = br_to.pull(br_from, overwrite)
 
682
                    count = br_from.push(br_to, overwrite)
672
683
                else:
673
 
                    count = tree_to.pull(br_from, overwrite)
 
684
                    tree_to.lock_write()
 
685
                    try:
 
686
                        count = br_from.push(tree_to.branch, overwrite)
 
687
                        tree_to.update()
 
688
                    finally:
 
689
                        tree_to.unlock()
674
690
            except errors.DivergedBranches:
675
691
                raise errors.BzrCommandError('These branches have diverged.'
676
692
                                        '  Try using "merge" and then "push".')
2528
2544
        try:
2529
2545
            tree.revert(file_list, 
2530
2546
                        tree.branch.repository.revision_tree(rev_id),
2531
 
                        not no_backup, pb)
 
2547
                        not no_backup, pb, report_changes=True)
2532
2548
        finally:
2533
2549
            pb.finished()
2534
2550
 
2621
2637
            other_branch = parent
2622
2638
            if other_branch is None:
2623
2639
                raise errors.BzrCommandError("No peer location known or specified.")
2624
 
            print "Using last location: " + local_branch.get_parent()
 
2640
            display_url = urlutils.unescape_for_display(parent,
 
2641
                                                        self.outf.encoding)
 
2642
            print "Using last location: " + display_url
 
2643
 
2625
2644
        remote_branch = Branch.open(other_branch)
2626
2645
        if remote_branch.base == local_branch.base:
2627
2646
            remote_branch = local_branch