##// END OF EJS Templates
hg,git: change method of extracting last_change to use actualy date object...
marcink -
r1349:e7cd3f1f default
parent child Browse files
Show More
@@ -26,12 +26,12 b' import logging'
26 import os
26 import os
27 import re
27 import re
28 import shutil
28 import shutil
29 import time
30
29
31 from zope.cachedescriptors.property import Lazy as LazyProperty
30 from zope.cachedescriptors.property import Lazy as LazyProperty
32
31
33 from rhodecode.lib.compat import OrderedDict
32 from rhodecode.lib.compat import OrderedDict
34 from rhodecode.lib.datelib import makedate, utcdate_fromtimestamp
33 from rhodecode.lib.datelib import (
34 utcdate_fromtimestamp, makedate, date_astimestamp)
35 from rhodecode.lib.utils import safe_unicode, safe_str
35 from rhodecode.lib.utils import safe_unicode, safe_str
36 from rhodecode.lib.vcs import connection, path as vcspath
36 from rhodecode.lib.vcs import connection, path as vcspath
37 from rhodecode.lib.vcs.backends.base import (
37 from rhodecode.lib.vcs.backends.base import (
@@ -269,12 +269,13 b' class GitRepository(BaseRepository):'
269 Returns last change made on this repository as
269 Returns last change made on this repository as
270 `datetime.datetime` object.
270 `datetime.datetime` object.
271 """
271 """
272 return utcdate_fromtimestamp(self._get_mtime(), makedate()[1])
272 try:
273 return self.get_commit().date
274 except RepositoryError:
275 tzoffset = makedate()[1]
276 return utcdate_fromtimestamp(self._get_fs_mtime(), tzoffset)
273
277
274 def _get_mtime(self):
278 def _get_fs_mtime(self):
275 try:
276 return time.mktime(self.get_commit().date.timetuple())
277 except RepositoryError:
278 idx_loc = '' if self.bare else '.git'
279 idx_loc = '' if self.bare else '.git'
279 # fallback to filesystem
280 # fallback to filesystem
280 in_path = os.path.join(self.path, idx_loc, "index")
281 in_path = os.path.join(self.path, idx_loc, "index")
@@ -367,14 +367,15 b' class MercurialRepository(BaseRepository'
367 def last_change(self):
367 def last_change(self):
368 """
368 """
369 Returns last change made on this repository as
369 Returns last change made on this repository as
370 `datetime.datetime` object
370 `datetime.datetime` object.
371 """
371 """
372 return utcdate_fromtimestamp(self._get_mtime(), makedate()[1])
372 try:
373 return self.get_commit().date
374 except RepositoryError:
375 tzoffset = makedate()[1]
376 return utcdate_fromtimestamp(self._get_fs_mtime(), tzoffset)
373
377
374 def _get_mtime(self):
378 def _get_fs_mtime(self):
375 try:
376 return date_astimestamp(self.get_commit().date)
377 except RepositoryError:
378 # fallback to filesystem
379 # fallback to filesystem
379 cl_path = os.path.join(self.path, '.hg', "00changelog.i")
380 cl_path = os.path.join(self.path, '.hg', "00changelog.i")
380 st_path = os.path.join(self.path, '.hg', "store")
381 st_path = os.path.join(self.path, '.hg', "store")
General Comments 0
You need to be logged in to leave comments. Login now