annotate rhodecode/lib/__init__.py @ 4147:1c8f818787b3 rhodecode-2.2.5-gpl

old style: show the full link box on summary page - no overlap or truncation
author Mads Kiilerich <madski@unity3d.com>
date Wed, 02 Jul 2014 19:03:23 -0400
parents ffd45b185016
children 7e5f8c12a3fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
1 # -*- coding: utf-8 -*-
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
2 # This program is free software: you can redistribute it and/or modify
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
3 # it under the terms of the GNU General Public License as published by
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
4 # the Free Software Foundation, either version 3 of the License, or
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
5 # (at your option) any later version.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
6 #
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
7 # This program is distributed in the hope that it will be useful,
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
10 # GNU General Public License for more details.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
11 #
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
12 # You should have received a copy of the GNU General Public License
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
14 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
15 rhodecode.lib
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
16 ~~~~~~~~~~~~~
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
17
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
18 RhodeCode libs
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
19
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
20 :created_on: Oct 06, 2010
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
21 :author: marcink
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
22 :copyright: (c) 2013 RhodeCode GmbH.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
23 :license: GPLv3, see LICENSE for more details.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
24 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3960
diff changeset
25
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
26 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
27
1571
a9888895b60d added quiet flag into get_current_revision
Marcin Kuzminski <marcin@python-works.com>
parents: 1541
diff changeset
28 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
29 """
70e646b2806a fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
30 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
31 or None if repository could not be found.
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1713
diff changeset
32
1571
a9888895b60d added quiet flag into get_current_revision
Marcin Kuzminski <marcin@python-works.com>
parents: 1541
diff changeset
33 :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
34 """
70e646b2806a fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
35
70e646b2806a fixes rhodecode upgrade problem that caused setuptool to crash on importing sqlalchemy models
Marcin Kuzminski <marcin@python-works.com>
parents: 1514
diff changeset
36 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
37 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
38 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
39 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
40 '..', '..'))
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
41 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
42 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
43 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
44 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
45 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
46 except Exception, err:
1571
a9888895b60d added quiet flag into get_current_revision
Marcin Kuzminski <marcin@python-works.com>
parents: 1541
diff changeset
47 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
48 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
49 "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
50 "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
51 return None