~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: 2010-05-28 00:25:32 UTC
  • mfrom: (5264.1.2 command-help-bug-177500)
  • Revision ID: pqm@pqm.ubuntu.com-20100528002532-9bzj1fajyxckd1rg
(lifeless) Stop raising at runtime when a command has no help,
 instead have a test in the test suite that checks all known command objects.
 (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
#
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
18
18
 
19
19
import sys
20
20
 
21
 
from bzrlib import (
22
 
    osutils,
23
 
    )
 
21
import bzrlib.bzrdir
 
22
import bzrlib.osutils
 
23
from bzrlib.symbol_versioning import *
24
24
 
25
25
 
26
26
class AddAction(object):
40
40
        if should_print is not None:
41
41
            self.should_print = should_print
42
42
 
43
 
    def __call__(self, inv, parent_ie, path, kind, _quote=osutils.quotefn):
 
43
    def __call__(self, inv, parent_ie, path, kind, _quote=bzrlib.osutils.quotefn):
44
44
        """Add path to inventory.
45
45
 
46
46
        The default action does nothing.
50
50
        :param kind: The kind of the object being added.
51
51
        """
52
52
        if self.should_print:
53
 
            self._to_file.write('adding %s\n' % _quote(path))
 
53
            self._to_file.write('adding %s\n' % _quote(path.raw_path))
54
54
        return None
55
55
 
56
56
 
70
70
        if file_id is not None:
71
71
            if self.should_print:
72
72
                self._to_file.write('adding %s w/ file id from %s\n'
73
 
                                    % (path, base_path))
 
73
                                    % (path.raw_path, base_path))
74
74
        else:
75
75
            # we aren't doing anything special, so let the default
76
76
            # reporter happen
86
86
        Else, we look for an entry in the base tree with the same path.
87
87
        """
88
88
 
89
 
        if self.base_tree.has_id(parent_ie.file_id):
 
89
        if (parent_ie.file_id in self.base_tree):
90
90
            base_parent_ie = self.base_tree.inventory[parent_ie.file_id]
91
 
            base_child_ie = base_parent_ie.children.get(
92
 
                osutils.basename(path))
 
91
            base_child_ie = base_parent_ie.children.get(path.base_path)
93
92
            if base_child_ie is not None:
94
93
                return (base_child_ie.file_id,
95
94
                        self.base_tree.id2path(base_child_ie.file_id))
96
 
        full_base_path = osutils.pathjoin(self.base_path, path)
 
95
        full_base_path = bzrlib.osutils.pathjoin(self.base_path, path.raw_path)
97
96
        # This may return None, but it is our last attempt
98
97
        return self.base_tree.path2id(full_base_path), full_base_path
 
98
 
 
99
 
 
100
# TODO: jam 20050105 These could be used for compatibility
 
101
#       however, they bind against the current stdout, not the
 
102
#       one which exists at the time they are called, so they
 
103
#       don't work for the test suite.
 
104
# deprecated
 
105
add_action_add = AddAction()
 
106
add_action_null = add_action_add
 
107
add_action_add_and_print = AddAction(should_print=True)
 
108
add_action_print = add_action_add_and_print