~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/add.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-01 14:59:16 UTC
  • mfrom: (5870.1.44 smart-add-invdelta)
  • Revision ID: pqm@pqm.ubuntu.com-20110601145916-5uuwhu9e764po62d
(jelmer) (jelmer) Bug #146165,
 use apply_inventory_delta instead of _write_inventory for 'bzr add'" (Jelmer
 Vernooij)

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
86
88
 
87
89
        if (parent_ie.file_id in self.base_tree):
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