Mercurial > kallithea
annotate rhodecode/lib/__init__.py @ 2349:0edbffa9e2e2 codereview
fixed bug with inline changes highlighter.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 28 May 2012 00:09:39 +0200 |
parents | 8ecfed1d8f8b |
children | dc2584ba5fbc b5a5a60608a7 |
rev | line source |
---|---|
1541
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
1 import os |
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
2 |
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
3 |
1571
a9888895b60d
added quiet flag into get_current_revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1541
diff
changeset
|
4 def get_current_revision(quiet=False): |
1541
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
5 """ |
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
6 Returns tuple of (number, id) from repository containing this package |
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
7 or None if repository could not be found. |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
8 |
1571
a9888895b60d
added quiet flag into get_current_revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1541
diff
changeset
|
9 :param quiet: prints error for fetching revision if True |
1541
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
10 """ |
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
11 |
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
12 try: |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
13 from rhodecode.lib.vcs import get_repo |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
14 from rhodecode.lib.vcs.utils.helpers import get_scm |
1541
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
15 repopath = os.path.join(os.path.dirname(__file__), '..', '..') |
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
16 scm = get_scm(repopath)[0] |
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
17 repo = get_repo(path=repopath, alias=scm) |
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
18 tip = repo.get_changeset() |
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
19 return (tip.revision, tip.short_id) |
1578
67168195a676
Catch all exception on get_current_revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1571
diff
changeset
|
20 except Exception, err: |
1571
a9888895b60d
added quiet flag into get_current_revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1541
diff
changeset
|
21 if not quiet: |
a9888895b60d
added quiet flag into get_current_revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1541
diff
changeset
|
22 print ("Cannot retrieve rhodecode's revision. Original error " |
a9888895b60d
added quiet flag into get_current_revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1541
diff
changeset
|
23 "was: %s" % err) |
1541
70e646b2806a
fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
24 return None |