~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-22 07:28:45 UTC
  • Revision ID: mbp@sourcefrog.net-20050322072845-5859efd4dab29169
use abspath() for the function that makes an absolute
path to something in a branch or tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
        return "<%s of %s>" % (self.__class__.__name__,
139
139
                               self.basedir)
140
140
 
141
 
    def _rel(self, filename):
 
141
    def abspath(self, filename):
142
142
        return os.path.join(self.basedir, filename)
143
143
 
144
144
    def has_filename(self, filename):
145
 
        return os.path.exists(self._rel(filename))
 
145
        return os.path.exists(self.abspath(filename))
146
146
 
147
147
    def get_file(self, file_id):
148
148
        return self.get_file_byname(self.id2path(file_id))
149
149
 
150
150
    def get_file_byname(self, filename):
151
 
        return file(self._rel(filename), 'rb')
 
151
        return file(self.abspath(filename), 'rb')
152
152
 
153
153
    def _get_store_filename(self, file_id):
154
 
        return self._rel(self.id2path(file_id))
 
154
        return self.abspath(self.id2path(file_id))
155
155
 
156
156
    def has_id(self, file_id):
157
157
        # files that have been deleted are excluded
158
158
        if not self.inventory.has_id(file_id):
159
159
            return False
160
 
        return os.access(self._rel(self.inventory.id2path(file_id)), os.F_OK)
 
160
        return os.access(self.abspath(self.inventory.id2path(file_id)), os.F_OK)
161
161
 
162
162
    def get_file_size(self, file_id):
163
163
        return os.stat(self._get_store_filename(file_id))[ST_SIZE]
177
177
 
178
178
 
179
179
    def file_kind(self, filename):
180
 
        if isfile(self._rel(filename)):
 
180
        if isfile(self.abspath(filename)):
181
181
            return 'file'
182
 
        elif isdir(self._rel(filename)):
 
182
        elif isdir(self.abspath(filename)):
183
183
            return 'directory'
184
184
        else:
185
185
            return 'unknown'