# HG changeset patch # User Mads Kiilerich # Date 2016-09-12 17:41:19 # Node ID d55ff973d01f14cdce6e95fa45adb07ffef1f806 # Parent c6232b791d8702044e8822db4ea996ccc73f924e lib: simplify version; drop get_current_revision - it was run every time on import time - we don't want that This functionality was already not in use with the version numbers we use. I also doubt it is possible to have version numbers where it worked - it seems like there might have been some regression that nobody noticed. Dropping it will thus not really lose any actual functionality. If we want to include the revision number in the version (for browser cache invalidation) then we should do it in a different way. Perhaps writing it to some file from setup.py . diff --git a/kallithea/__init__.py b/kallithea/__init__.py --- a/kallithea/__init__.py +++ b/kallithea/__init__.py @@ -54,15 +54,7 @@ else: # Users.extern_type and .extern_name value for local users EXTERN_TYPE_INTERNAL = 'internal' -try: - from kallithea.lib import get_current_revision - _rev = get_current_revision(quiet=True) - if _rev and len(VERSION) > 3: - VERSION += (_rev[0],) -except ImportError: - pass - -__version__ = ('.'.join((str(each) for each in VERSION[:3]))) +__version__ = '.'.join(str(each) for each in VERSION) __dbversion__ = 31 # defines current db version for migrations __platform__ = platform.system() __license__ = 'GPLv3' @@ -73,13 +65,6 @@ __url__ = 'https://kallithea-scm.org/' is_windows = __platform__ in ['Windows'] is_unix = not is_windows -if len(VERSION) > 3: - __version__ += '.'+VERSION[3] - - if len(VERSION) > 4: - __version__ += VERSION[4] - else: - __version__ += '0' # Hack for making the celery dependency kombu==1.5.1 compatible with Python # 2.7.11 which has https://hg.python.org/releases/2.7.11/rev/24bdc4940e81 diff --git a/kallithea/lib/__init__.py b/kallithea/lib/__init__.py --- a/kallithea/lib/__init__.py +++ b/kallithea/lib/__init__.py @@ -24,30 +24,3 @@ Original author and date, and relevant c :copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details. """ - -import os - -def get_current_revision(quiet=False): - """ - Returns tuple of (number, id) from repository containing this package - or None if repository could not be found. - - :param quiet: prints error for fetching revision if True - """ - - try: - from kallithea.lib.vcs import get_repo - from kallithea.lib.vcs.utils.helpers import get_scm - repopath = os.path.abspath(os.path.join(os.path.dirname(__file__), - '..', '..')) - scm = get_scm(repopath)[0] - repo = get_repo(path=repopath, alias=scm) - wk_dir = repo.workdir - cur_rev = wk_dir.get_changeset() - return (cur_rev.revision, cur_rev.short_id) - except Exception as err: - if not quiet: - print ("WARNING: Cannot retrieve kallithea's revision. " - "disregard this if you don't know what that means. " - "Original error was: %s" % err) - return None