##// 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 26 import os
27 27 import re
28 28 import shutil
29 import time
30 29
31 30 from zope.cachedescriptors.property import Lazy as LazyProperty
32 31
33 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 35 from rhodecode.lib.utils import safe_unicode, safe_str
36 36 from rhodecode.lib.vcs import connection, path as vcspath
37 37 from rhodecode.lib.vcs.backends.base import (
@@ -269,20 +269,21 b' class GitRepository(BaseRepository):'
269 269 Returns last change made on this repository as
270 270 `datetime.datetime` object.
271 271 """
272 return utcdate_fromtimestamp(self._get_mtime(), makedate()[1])
273
274 def _get_mtime(self):
275 272 try:
276 return time.mktime(self.get_commit().date.timetuple())
273 return self.get_commit().date
277 274 except RepositoryError:
278 idx_loc = '' if self.bare else '.git'
279 # fallback to filesystem
280 in_path = os.path.join(self.path, idx_loc, "index")
281 he_path = os.path.join(self.path, idx_loc, "HEAD")
282 if os.path.exists(in_path):
283 return os.stat(in_path).st_mtime
284 else:
285 return os.stat(he_path).st_mtime
275 tzoffset = makedate()[1]
276 return utcdate_fromtimestamp(self._get_fs_mtime(), tzoffset)
277
278 def _get_fs_mtime(self):
279 idx_loc = '' if self.bare else '.git'
280 # fallback to filesystem
281 in_path = os.path.join(self.path, idx_loc, "index")
282 he_path = os.path.join(self.path, idx_loc, "HEAD")
283 if os.path.exists(in_path):
284 return os.stat(in_path).st_mtime
285 else:
286 return os.stat(he_path).st_mtime
286 287
287 288 @LazyProperty
288 289 def description(self):
@@ -367,21 +367,22 b' class MercurialRepository(BaseRepository'
367 367 def last_change(self):
368 368 """
369 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])
373
374 def _get_mtime(self):
375 372 try:
376 return date_astimestamp(self.get_commit().date)
373 return self.get_commit().date
377 374 except RepositoryError:
378 # fallback to filesystem
379 cl_path = os.path.join(self.path, '.hg', "00changelog.i")
380 st_path = os.path.join(self.path, '.hg', "store")
381 if os.path.exists(cl_path):
382 return os.stat(cl_path).st_mtime
383 else:
384 return os.stat(st_path).st_mtime
375 tzoffset = makedate()[1]
376 return utcdate_fromtimestamp(self._get_fs_mtime(), tzoffset)
377
378 def _get_fs_mtime(self):
379 # fallback to filesystem
380 cl_path = os.path.join(self.path, '.hg', "00changelog.i")
381 st_path = os.path.join(self.path, '.hg', "store")
382 if os.path.exists(cl_path):
383 return os.stat(cl_path).st_mtime
384 else:
385 return os.stat(st_path).st_mtime
385 386
386 387 def _sanitize_commit_idx(self, idx):
387 388 # Note: Mercurial has ``int(-1)`` reserved as not existing id_or_idx
General Comments 0
You need to be logged in to leave comments. Login now