comparison rhodecode/lib/__init__.py @ 1541:70e646b2806a beta

fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 11 Oct 2011 02:14:42 +0200
parents 87ec80c280bb
children 752b0a7b7679 a9888895b60d
comparison
equal deleted inserted replaced
1540:191f3f08236d 1541:70e646b2806a
21 # GNU General Public License for more details. 21 # GNU General Public License for more details.
22 # 22 #
23 # You should have received a copy of the GNU General Public License 23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. 24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 25
26 import os
27
26 def __get_lem(): 28 def __get_lem():
27 from pygments import lexers 29 from pygments import lexers
28 from string import lower 30 from string import lower
29 from collections import defaultdict 31 from collections import defaultdict
30 32
377 cs = repo.get_changeset(rev) 379 cs = repo.get_changeset(rev)
378 except RepositoryError: 380 except RepositoryError:
379 from rhodecode.lib.utils import EmptyChangeset 381 from rhodecode.lib.utils import EmptyChangeset
380 cs = EmptyChangeset(requested_revision=rev) 382 cs = EmptyChangeset(requested_revision=rev)
381 return cs 383 return cs
384
385
386 def get_current_revision():
387 """
388 Returns tuple of (number, id) from repository containing this package
389 or None if repository could not be found.
390 """
391
392 try:
393 from vcs import get_repo
394 from vcs.utils.helpers import get_scm
395 from vcs.exceptions import RepositoryError, VCSError
396 repopath = os.path.join(os.path.dirname(__file__), '..', '..')
397 scm = get_scm(repopath)[0]
398 repo = get_repo(path=repopath, alias=scm)
399 tip = repo.get_changeset()
400 return (tip.revision, tip.short_id)
401 except (ImportError, RepositoryError, VCSError), err:
402 print ("Cannot retrieve rhodecode's revision. Original error "
403 "was: %s" % err)
404 return None