~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: John Arbash Meinel
  • Date: 2011-01-11 20:42:36 UTC
  • mto: This revision was merged to the branch mainline in revision 5596.
  • Revision ID: john@arbash-meinel.com-20110111204236-mthyd83cgt2j4c6o
Don't use tuned_gzip.GzipFile in knit.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from stat import S_ISREG, S_IEXEC
20
20
import time
21
21
 
 
22
import bzrlib
22
23
from bzrlib import (
23
24
    errors,
24
25
    lazy_import,
25
26
    registry,
 
27
    tree,
26
28
    )
27
29
lazy_import.lazy_import(globals(), """
28
30
from bzrlib import (
50
52
    delete_any,
51
53
    file_kind,
52
54
    has_symlinks,
53
 
    lexists,
54
55
    pathjoin,
55
56
    sha_file,
56
57
    splitpath,
57
58
    supports_executable,
58
 
)
 
59
    )
59
60
from bzrlib.progress import ProgressPhase
60
61
from bzrlib.symbol_versioning import (
61
 
        deprecated_function,
62
 
        deprecated_in,
63
 
        deprecated_method,
64
 
        )
65
 
from bzrlib.trace import mutter, warning
66
 
from bzrlib import tree
 
62
    deprecated_function,
 
63
    deprecated_in,
 
64
    deprecated_method,
 
65
    )
 
66
from bzrlib.trace import warning
67
67
import bzrlib.ui
68
68
import bzrlib.urlutils as urlutils
69
69
 
130
130
            self._new_root = self.trans_id_tree_file_id(root_id)
131
131
        else:
132
132
            self._new_root = None
133
 
        # Indictor of whether the transform has been applied
 
133
        # Indicator of whether the transform has been applied
134
134
        self._done = False
135
135
        # A progress bar
136
136
        self._pb = pb
666
666
        if (self._new_name, self._new_parent) == ({}, {}):
667
667
            return conflicts
668
668
        for children in by_parent.itervalues():
669
 
            name_ids = [(self.final_name(t), t) for t in children]
670
 
            if not self._case_sensitive_target:
671
 
                name_ids = [(n.lower(), t) for n, t in name_ids]
 
669
            name_ids = []
 
670
            for child_tid in children:
 
671
                name = self.final_name(child_tid)
 
672
                if name is not None:
 
673
                    # Keep children only if they still exist in the end
 
674
                    if not self._case_sensitive_target:
 
675
                        name = name.lower()
 
676
                    name_ids.append((name, child_tid))
672
677
            name_ids.sort()
673
678
            last_name = None
674
679
            last_trans_id = None
698
703
        return conflicts
699
704
 
700
705
    def _parent_type_conflicts(self, by_parent):
701
 
        """parents must have directory 'contents'."""
 
706
        """Children must have a directory parent"""
702
707
        conflicts = []
703
708
        for parent_id, children in by_parent.iteritems():
704
709
            if parent_id is ROOT_PARENT:
705
710
                continue
706
 
            if not self._any_contents(children):
 
711
            no_children = True
 
712
            for child_id in children:
 
713
                if self.final_kind(child_id) is not None:
 
714
                    no_children = False
 
715
                    break
 
716
            if no_children:
707
717
                continue
 
718
            # There is at least a child, so we need an existing directory to
 
719
            # contain it.
708
720
            kind = self.final_kind(parent_id)
709
721
            if kind is None:
 
722
                # The directory will be deleted
710
723
                conflicts.append(('missing parent', parent_id))
711
724
            elif kind != "directory":
 
725
                # Meh, we need a *directory* to put something in it
712
726
                conflicts.append(('non-directory parent', parent_id))
713
727
        return conflicts
714
728
 
715
 
    def _any_contents(self, trans_ids):
716
 
        """Return true if any of the trans_ids, will have contents."""
717
 
        for trans_id in trans_ids:
718
 
            if self.final_kind(trans_id) is not None:
719
 
                return True
720
 
        return False
721
 
 
722
729
    def _set_executability(self, path, trans_id):
723
730
        """Set the executability of versioned files """
724
731
        if supports_executable():
815
822
        """
816
823
        orphans = []
817
824
        # Find the potential orphans, stop if one item should be kept
818
 
        for c in self.by_parent()[dir_id]:
819
 
            if self.final_file_id(c) is None:
820
 
                orphans.append(c)
 
825
        for child_tid in self.by_parent()[dir_id]:
 
826
            if child_tid in self._removed_contents:
 
827
                # The child is removed as part of the transform. Since it was
 
828
                # versioned before, it's not an orphan
 
829
                continue
 
830
            elif self.final_file_id(child_tid) is None:
 
831
                # The child is not versioned
 
832
                orphans.append(child_tid)
821
833
            else:
822
834
                # We have a versioned file here, searching for orphans is
823
835
                # meaningless.