~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Vincent Ladeuil
  • Date: 2011-06-27 15:42:09 UTC
  • mfrom: (5993 +trunk)
  • mto: (5993.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 5994.
  • Revision ID: v.ladeuil+lp@free.fr-20110627154209-azubuhbuxsz109hq
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
496
496
        finally:
497
497
            file.close()
498
498
 
499
 
    def _get_ancestors(self, default_revision):
500
 
        ancestors = set([default_revision])
501
 
        for parent_id in self.get_parent_ids():
502
 
            ancestors.update(self.branch.repository.get_ancestry(
503
 
                             parent_id, topo_sorted=False))
504
 
        return ancestors
505
 
 
506
499
    def get_parent_ids(self):
507
500
        """See Tree.get_parent_ids.
508
501
 
973
966
        file and change the file_id. That is the normal mode. Second, it can
974
967
        only change the file_id without touching any physical file.
975
968
 
976
 
        rename_one uses the second mode if 'after == True' and 'to_rel' is not
977
 
        versioned but present in the working tree.
 
969
        rename_one uses the second mode if 'after == True' and 'to_rel' is
 
970
        either not versioned or newly added, and present in the working tree.
978
971
 
979
972
        rename_one uses the second mode if 'after == False' and 'from_rel' is
980
973
        versioned but no longer in the working tree, and 'to_rel' is not
1385
1378
    def revert(self, filenames=None, old_tree=None, backups=True,
1386
1379
               pb=None, report_changes=False):
1387
1380
        from bzrlib.conflicts import resolve
1388
 
        if filenames == []:
1389
 
            filenames = None
1390
 
            symbol_versioning.warn('Using [] to revert all files is deprecated'
1391
 
                ' as of bzr 0.91.  Please use None (the default) instead.',
1392
 
                DeprecationWarning, stacklevel=2)
1393
1381
        if old_tree is None:
1394
1382
            basis_tree = self.basis_tree()
1395
1383
            basis_tree.lock_read()
2573
2561
        inventory. The second mode only updates the inventory without
2574
2562
        touching the file on the filesystem.
2575
2563
 
2576
 
        move uses the second mode if 'after == True' and the target is not
2577
 
        versioned but present in the working tree.
 
2564
        move uses the second mode if 'after == True' and the target is
 
2565
        either not versioned or newly added, and present in the working tree.
2578
2566
 
2579
2567
        move uses the second mode if 'after == False' and the source is
2580
2568
        versioned but no longer in the working tree, and the target is not
2727
2715
 
2728
2716
    class _RenameEntry(object):
2729
2717
        def __init__(self, from_rel, from_id, from_tail, from_parent_id,
2730
 
                     to_rel, to_tail, to_parent_id, only_change_inv=False):
 
2718
                     to_rel, to_tail, to_parent_id, only_change_inv=False,
 
2719
                     change_id=False):
2731
2720
            self.from_rel = from_rel
2732
2721
            self.from_id = from_id
2733
2722
            self.from_tail = from_tail
2735
2724
            self.to_rel = to_rel
2736
2725
            self.to_tail = to_tail
2737
2726
            self.to_parent_id = to_parent_id
 
2727
            self.change_id = change_id
2738
2728
            self.only_change_inv = only_change_inv
2739
2729
 
2740
2730
    def _determine_mv_mode(self, rename_entries, after=False):
2752
2742
            to_rel = rename_entry.to_rel
2753
2743
            to_id = inv.path2id(to_rel)
2754
2744
            only_change_inv = False
 
2745
            change_id = False
2755
2746
 
2756
2747
            # check the inventory for source and destination
2757
2748
            if from_id is None:
2758
2749
                raise errors.BzrMoveFailedError(from_rel,to_rel,
2759
2750
                    errors.NotVersionedError(path=from_rel))
2760
2751
            if to_id is not None:
2761
 
                raise errors.BzrMoveFailedError(from_rel,to_rel,
2762
 
                    errors.AlreadyVersionedError(path=to_rel))
 
2752
                allowed = False
 
2753
                # allow it with --after but only if dest is newly added
 
2754
                if after:
 
2755
                    basis = self.basis_tree()
 
2756
                    basis.lock_read()
 
2757
                    try:
 
2758
                        if not basis.has_id(to_id):
 
2759
                            rename_entry.change_id = True
 
2760
                            allowed = True
 
2761
                    finally:
 
2762
                        basis.unlock()
 
2763
                if not allowed:
 
2764
                    raise errors.BzrMoveFailedError(from_rel,to_rel,
 
2765
                        errors.AlreadyVersionedError(path=to_rel))
2763
2766
 
2764
2767
            # try to determine the mode for rename (only change inv or change
2765
2768
            # inv and file system)
2836
2839
            except OSError, e:
2837
2840
                raise errors.BzrMoveFailedError(entry.from_rel,
2838
2841
                    entry.to_rel, e[1])
 
2842
        if entry.change_id:
 
2843
            to_id = inv.path2id(entry.to_rel)
 
2844
            inv.remove_recursive_id(to_id)
2839
2845
        inv.rename(entry.from_id, entry.to_parent_id, entry.to_tail)
2840
2846
 
2841
2847
    @needs_tree_write_lock