/breezy-hg/trunk

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy-hg/trunk

« back to all changes in this revision

Viewing changes to tree.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-19 21:21:33 UTC
  • Revision ID: jelmer@jelmer.uk-20181119212133-l9vwjrub3sd8tia8
Fix tests against current brz.

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
            return None, False, None
102
102
        return entry.kind, entry.executable, None
103
103
 
104
 
    def is_executable(self, path, file_id=None):
 
104
    def is_executable(self, path):
105
105
        return ('x' in self._manifest(path.encode("utf-8")))
106
106
 
107
 
    def get_symlink_target(self, path, file_id=None):
 
107
    def get_symlink_target(self, path):
108
108
        encoded_path = path.encode("utf-8")
109
109
        revlog = self._repository._hgrepo.file(encoded_path)
110
110
        return revlog.read(self._manifest[encoded_path])
111
111
 
112
 
    def get_file_text(self, path, file_id=None):
 
112
    def get_file_text(self, path):
113
113
        revlog = self._repository._hgrepo.file(path)
114
114
        try:
115
115
            return revlog.read(self._manifest[path.encode("utf-8")])
116
116
        except KeyError:
117
117
            raise errors.NoSuchFile(path)
118
118
 
119
 
    def get_file_sha1(self, path, file_id=None, stat_value=None):
120
 
        return osutils.sha_string(self.get_file_text(path, file_id))
 
119
    def get_file_sha1(self, path, stat_value=None):
 
120
        return osutils.sha_string(self.get_file_text(path))
121
121
 
122
 
    def get_file_mtime(self, path, file_id=None):
123
 
        revid = self.get_file_revision(path, file_id)
 
122
    def get_file_mtime(self, path):
 
123
        revid = self.get_file_revision(path)
124
124
        return self._repository.get_revision(revid).timestamp
125
125
 
126
 
    def kind(self, path, file_id=None):
 
126
    def kind(self, path):
127
127
        if 'l' in self._manifest(path.encode("utf-8")):
128
128
            return 'symlink'
129
129
        else:
153
153
        parent_id = self.path2id(posixpath.dirname(path))
154
154
        if 'l' in flags:
155
155
            ie = HgTreeLink(file_id, posixpath.basename(path), parent_id)
156
 
            ie.symlink_target = self.get_symlink_target(path, file_id)
 
156
            ie.symlink_target = self.get_symlink_target(path)
157
157
        else:
158
158
            ie = HgTreeFile(file_id, posixpath.basename(path), parent_id)
159
 
            text = self.get_file_text(path, file_id)
 
159
            text = self.get_file_text(path)
160
160
            ie.text_sha1 = osutils.sha_string(text)
161
161
            ie.text_size = len(text)
162
162
            ie.executable = ('x' in flags)
163
 
        ie.revision = self.get_file_revision(path, file_id)
 
163
        ie.revision = self.get_file_revision(path)
164
164
        return ie
165
165
 
166
166
    def iter_entries_by_dir(self, specific_files=None, yield_parents=False):
221
221
        self._ancestry_cache[some_revision_id] = ancestry
222
222
        return ancestry
223
223
 
224
 
    def get_file_revision(self, path, file_id=None):
 
224
    def get_file_revision(self, path):
225
225
        utf8_path = path.encode("utf-8")
226
226
        if utf8_path in self._manifest:
227
227
            # it's a file
229
229
        elif self._has_directory(utf8_path):
230
230
            return self._get_dir_last_modified(utf8_path)
231
231
        else:
232
 
            raise errors.NoSuchId(self, file_id)
 
232
            raise errors.NoSuchFile(path)
233
233
 
234
234
    def _get_dir_last_modified(self, path):
235
235
        revision = self._directories.get(path)