1
# Copyright (C) 2005-2010 Canonical Ltd
1
# Copyright (C) 2005, 2006 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
40
44
if should_print is not None:
41
45
self.should_print = should_print
43
def __call__(self, inv, parent_ie, path, kind, _quote=osutils.quotefn):
47
def __call__(self, inv, parent_ie, path, kind, _quote=bzrlib.osutils.quotefn):
44
48
"""Add path to inventory.
46
50
The default action does nothing.
86
90
Else, we look for an entry in the base tree with the same path.
89
if self.base_tree.has_id(parent_ie.file_id):
93
if (parent_ie.file_id in self.base_tree):
90
94
base_parent_ie = self.base_tree.inventory[parent_ie.file_id]
91
base_child_ie = base_parent_ie.children.get(
92
osutils.basename(path))
95
base_child_ie = base_parent_ie.children.get(path.base_path)
93
96
if base_child_ie is not None:
94
97
return (base_child_ie.file_id,
95
98
self.base_tree.id2path(base_child_ie.file_id))
96
full_base_path = osutils.pathjoin(self.base_path, path)
99
full_base_path = bzrlib.osutils.pathjoin(self.base_path, path.raw_path)
97
100
# This may return None, but it is our last attempt
98
101
return self.base_tree.path2id(full_base_path), full_base_path
104
# TODO: jam 20050105 These could be used for compatibility
105
# however, they bind against the current stdout, not the
106
# one which exists at the time they are called, so they
107
# don't work for the test suite.
109
add_action_add = AddAction()
110
add_action_null = add_action_add
111
add_action_add_and_print = AddAction(should_print=True)
112
add_action_print = add_action_add_and_print