allura
Revision | 029847379a77264d6cd1fd0ea7a54fe73d979005 (tree) |
---|---|
Zeit | 2012-06-28 01:59:41 |
Autor | Tim Van Steenburgh <tvansteenburgh@gmai...> |
Commiter | Tim Van Steenburgh |
[#4126] Fix scm file stats to work with new model.
Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>
@@ -470,6 +470,10 @@ class Blob(object): | ||
470 | 470 | return iter(self.open()) |
471 | 471 | |
472 | 472 | @LazyProperty |
473 | + def size(self): | |
474 | + return self.repo.blob_size(self) | |
475 | + | |
476 | + @LazyProperty | |
473 | 477 | def text(self): |
474 | 478 | return self.open().read() |
475 | 479 |
@@ -1,8 +1,8 @@ | ||
1 | 1 | from nose.tools import assert_raises |
2 | 2 | |
3 | 3 | from alluratest.controller import setup_basic_test, setup_global_objects |
4 | -from allura.command import script, set_neighborhood_features, rssfeeds, \ | |
5 | -create_neighborhood | |
4 | +from allura.command import script, set_neighborhood_features, \ | |
5 | + create_neighborhood | |
6 | 6 | from allura import model as M |
7 | 7 | from forgeblog import model as BM |
8 | 8 | from allura.lib.exceptions import InvalidNBFeatureValueError |
@@ -240,7 +240,7 @@ class GitImplementation(M.RepositoryImplementation): | ||
240 | 240 | self._object(blob._id).data_stream) |
241 | 241 | |
242 | 242 | def blob_size(self, blob): |
243 | - return self._object(blob.object_id).data_stream.size | |
243 | + return self._object(blob._id).data_stream.size | |
244 | 244 | |
245 | 245 | def _setup_hooks(self): |
246 | 246 | 'Set up the git post-commit hook' |
@@ -230,7 +230,7 @@ class HgImplementation(M.RepositoryImplementation): | ||
230 | 230 | return StringIO(fctx.data()) |
231 | 231 | |
232 | 232 | def blob_size(self, blob): |
233 | - fctx = self._hg[blob.commit.object_id][h.really_unicode(blob.path()).encode('utf-8')[1:]] | |
233 | + fctx = self._hg[blob.commit._id][h.really_unicode(blob.path()).encode('utf-8')[1:]] | |
234 | 234 | return fctx.size() |
235 | 235 | |
236 | 236 | def _setup_hooks(self): |
@@ -382,7 +382,7 @@ class SVNImplementation(M.RepositoryImplementation): | ||
382 | 382 | try: |
383 | 383 | data = self._svn.list( |
384 | 384 | self._url + blob.path(), |
385 | - revision=self._revision(blob.commit.object_id), | |
385 | + revision=self._revision(blob.commit._id), | |
386 | 386 | dirent_fields=pysvn.SVN_DIRENT_SIZE) |
387 | 387 | except pysvn.ClientError: |
388 | 388 | log.info('ClientError getting filesize %r %r, returning 0', blob.path(), self._repo, exc_info=True) |
@@ -393,7 +393,7 @@ class SVNImplementation(M.RepositoryImplementation): | ||
393 | 393 | except (IndexError, KeyError): |
394 | 394 | log.info('Error getting filesize: bad data from svn client %r %r, returning 0', blob.path(), self._repo, exc_info=True) |
395 | 395 | size = 0 |
396 | - | |
396 | + | |
397 | 397 | return size |
398 | 398 | |
399 | 399 | def _setup_hooks(self): |