Mercurial > kallithea
annotate rhodecode/lib/__init__.py @ 3962:22f925aea8b4 beta
updated i18n
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 07 Jun 2013 19:30:45 +0200 |
parents | d7488551578e |
children | 5293d4bbb1ea |
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 |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3796
diff
changeset
|
15 repopath = os.path.abspath(os.path.join(os.path.dirname(__file__), |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3796
diff
changeset
|
16 '..', '..')) |
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
|
17 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
|
18 repo = get_repo(path=repopath, alias=scm) |
3796
2b5f94fc3b7a
current revision will show workdir state, not the latest revision
Marcin Kuzminski <marcin@python-works.com>
parents:
3231
diff
changeset
|
19 wk_dir = repo.workdir |
2b5f94fc3b7a
current revision will show workdir state, not the latest revision
Marcin Kuzminski <marcin@python-works.com>
parents:
3231
diff
changeset
|
20 cur_rev = wk_dir.get_changeset() |
2b5f94fc3b7a
current revision will show workdir state, not the latest revision
Marcin Kuzminski <marcin@python-works.com>
parents:
3231
diff
changeset
|
21 return (cur_rev.revision, cur_rev.short_id) |
1578
67168195a676
Catch all exception on get_current_revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1571
diff
changeset
|
22 except Exception, err: |
1571
a9888895b60d
added quiet flag into get_current_revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1541
diff
changeset
|
23 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
|
24 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
|
25 "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
|
26 "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
|
27 return None |