Mercurial > kallithea
annotate rhodecode/lib/__init__.py @ 3574:000653f7cdf9 beta
avoid displaying repr of internal classes in user facing messages
The context of the message will tell where the problem was and there is no reason to show
... does not exist for this repository <MercurialRepository at /home/marcink/repos/rhodecode>
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 21 Mar 2013 11:17:01 +0100 |
parents | b5a5a60608a7 |
children | 3563bb7b4b82 2b5f94fc3b7a |
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: |
3231
b5a5a60608a7
be blunt about that error message to not confuse people
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
22 print ("WARNING: Cannot retrieve rhodecode's revision. " |
b5a5a60608a7
be blunt about that error message to not confuse people
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
23 "disregard this if you don't know what that means. " |
b5a5a60608a7
be blunt about that error message to not confuse people
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
24 "Original error 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
|
25 return None |