~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/add.py

  • Committer: Vincent Ladeuil
  • Date: 2011-07-06 09:22:00 UTC
  • mfrom: (6008 +trunk)
  • mto: (6012.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6013.
  • Revision ID: v.ladeuil+lp@free.fr-20110706092200-7iai2mwzc0sqdsvf
MergingĀ inĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import sys
20
20
 
21
 
import bzrlib.osutils
 
21
from bzrlib import (
 
22
    osutils,
 
23
    )
22
24
 
23
25
 
24
26
class AddAction(object):
38
40
        if should_print is not None:
39
41
            self.should_print = should_print
40
42
 
41
 
    def __call__(self, inv, parent_ie, path, kind, _quote=bzrlib.osutils.quotefn):
 
43
    def __call__(self, inv, parent_ie, path, kind, _quote=osutils.quotefn):
42
44
        """Add path to inventory.
43
45
 
44
46
        The default action does nothing.
48
50
        :param kind: The kind of the object being added.
49
51
        """
50
52
        if self.should_print:
51
 
            self._to_file.write('adding %s\n' % _quote(path.raw_path))
 
53
            self._to_file.write('adding %s\n' % _quote(path))
52
54
        return None
53
55
 
54
56
 
68
70
        if file_id is not None:
69
71
            if self.should_print:
70
72
                self._to_file.write('adding %s w/ file id from %s\n'
71
 
                                    % (path.raw_path, base_path))
 
73
                                    % (path, base_path))
72
74
        else:
73
75
            # we aren't doing anything special, so let the default
74
76
            # reporter happen
84
86
        Else, we look for an entry in the base tree with the same path.
85
87
        """
86
88
 
87
 
        if (parent_ie.file_id in self.base_tree):
 
89
        if self.base_tree.has_id(parent_ie.file_id):
88
90
            base_parent_ie = self.base_tree.inventory[parent_ie.file_id]
89
 
            base_child_ie = base_parent_ie.children.get(path.base_path)
 
91
            base_child_ie = base_parent_ie.children.get(
 
92
                osutils.basename(path))
90
93
            if base_child_ie is not None:
91
94
                return (base_child_ie.file_id,
92
95
                        self.base_tree.id2path(base_child_ie.file_id))
93
 
        full_base_path = bzrlib.osutils.pathjoin(self.base_path, path.raw_path)
 
96
        full_base_path = osutils.pathjoin(self.base_path, path)
94
97
        # This may return None, but it is our last attempt
95
98
        return self.base_tree.path2id(full_base_path), full_base_path