Mercurial > kallithea
annotate rhodecode/lib/utils.py @ 1528:1d7a621d396f beta
fixed action logger
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 07 Oct 2011 22:50:20 +0200 |
parents | 7d687ed11929 |
children | 04027bdb876c |
rev | line source |
---|---|
783
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
1 # -*- coding: utf-8 -*- |
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
2 """ |
833
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
807
diff
changeset
|
3 rhodecode.lib.utils |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
807
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~ |
783
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
5 |
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
6 Utilities library for RhodeCode |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
7 |
783
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
8 :created_on: Apr 18, 2010 |
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
9 :author: marcink |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
783
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
12 """ |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
16 # (at your option) any later version. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
17 # |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
21 # GNU General Public License for more details. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
22 # |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
783
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
25 |
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
26 import os |
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
27 import logging |
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
28 import datetime |
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
29 import traceback |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
30 import paste |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
31 import beaker |
1354
ed309b1fbaa4
fixes issue #197 Relative paths for pidlocks
Marcin Kuzminski <marcin@python-works.com>
parents:
1337
diff
changeset
|
32 from os.path import dirname as dn, join as jn |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
33 |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
34 from paste.script.command import Command, BadCommand |
633
fcf599cd3404
Move changes for git implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
35 |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
36 from mercurial import ui, config |
783
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
37 |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
38 from webhelpers.text import collapse, remove_formatting, strip_tags |
785
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
39 |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
40 from vcs import get_backend |
783
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
41 from vcs.backends.base import BaseChangeset |
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
42 from vcs.utils.lazy import LazyProperty |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
43 from vcs.utils.helpers import get_scm |
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
44 from vcs.exceptions import VCSError |
783
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
45 |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
46 from rhodecode.model import meta |
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
47 from rhodecode.model.caching_query import FromCache |
1292
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1243
diff
changeset
|
48 from rhodecode.model.db import Repository, User, RhodeCodeUi, UserLog, Group, \ |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1243
diff
changeset
|
49 RhodeCodeSettings |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
50 from rhodecode.model.repo import RepoModel |
756
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
51 |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
52 log = logging.getLogger(__name__) |
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
53 |
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
54 |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
55 def recursive_replace(str, replace=' '): |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
56 """Recursive replace of given sign to just one instance |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
57 |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
58 :param str: given string |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
59 :param replace: char to find and replace multiple instances |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
60 |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
61 Examples:: |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
62 >>> recursive_replace("Mighty---Mighty-Bo--sstones",'-') |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
63 'Mighty-Mighty-Bo-sstones' |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
64 """ |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
65 |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
66 if str.find(replace * 2) == -1: |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
67 return str |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
68 else: |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
69 str = str.replace(replace * 2, replace) |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
70 return recursive_replace(str, replace) |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
71 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
72 |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
73 def repo_name_slug(value): |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
74 """Return slug of name of repository |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
75 This function is called on each creation/modification |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
76 of repository to prevent bad names in repo |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
77 """ |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
78 |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
79 slug = remove_formatting(value) |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
80 slug = strip_tags(slug) |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
81 |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
82 for c in """=[]\;'"<>,/~!@#$%^&*()+{}|: """: |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
83 slug = slug.replace(c, '-') |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
84 slug = recursive_replace(slug, '-') |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
85 slug = collapse(slug, '-') |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
86 return slug |
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1007
diff
changeset
|
87 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
88 |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
89 def get_repo_slug(request): |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
90 return request.environ['pylons.routes_dict'].get('repo_name') |
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
91 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
92 |
689
ecc566f8b69f
fixes #59, notifications for user registrations + some changes to mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
93 def action_logger(user, action, repo, ipaddr='', sa=None): |
536
39203995f2c4
made action logger more global, to be used in other places to log other actions.
Marcin Kuzminski <marcin@python-works.com>
parents:
524
diff
changeset
|
94 """ |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
95 Action logger for various actions made by users |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
96 |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
97 :param user: user that made this action, can be a unique username string or |
689
ecc566f8b69f
fixes #59, notifications for user registrations + some changes to mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
98 object containing user_id attribute |
ecc566f8b69f
fixes #59, notifications for user registrations + some changes to mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
99 :param action: action to log, should be on of predefined unique actions for |
ecc566f8b69f
fixes #59, notifications for user registrations + some changes to mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
100 easy translations |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
101 :param repo: string name of repository or object containing repo_id, |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
102 that action was made on |
689
ecc566f8b69f
fixes #59, notifications for user registrations + some changes to mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
103 :param ipaddr: optional ip address from what the action was made |
ecc566f8b69f
fixes #59, notifications for user registrations + some changes to mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
104 :param sa: optional sqlalchemy session |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
105 |
536
39203995f2c4
made action logger more global, to be used in other places to log other actions.
Marcin Kuzminski <marcin@python-works.com>
parents:
524
diff
changeset
|
106 """ |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
107 |
536
39203995f2c4
made action logger more global, to be used in other places to log other actions.
Marcin Kuzminski <marcin@python-works.com>
parents:
524
diff
changeset
|
108 if not sa: |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
621
diff
changeset
|
109 sa = meta.Session() |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
110 |
536
39203995f2c4
made action logger more global, to be used in other places to log other actions.
Marcin Kuzminski <marcin@python-works.com>
parents:
524
diff
changeset
|
111 try: |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
536
diff
changeset
|
112 if hasattr(user, 'user_id'): |
654
7f5976da192c
#48 rewrite action loggers into hooks with all changesets that are inside a push
Marcin Kuzminski <marcin@python-works.com>
parents:
643
diff
changeset
|
113 user_obj = user |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
536
diff
changeset
|
114 elif isinstance(user, basestring): |
1528
1d7a621d396f
fixed action logger
Marcin Kuzminski <marcin@python-works.com>
parents:
1507
diff
changeset
|
115 user_obj = User.by_username(user) |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
536
diff
changeset
|
116 else: |
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
536
diff
changeset
|
117 raise Exception('You have to provide user object or username') |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
118 |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
119 rm = RepoModel() |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
120 if hasattr(repo, 'repo_id'): |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
121 repo_obj = rm.get(repo.repo_id, cache=False) |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
122 repo_name = repo_obj.repo_name |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
123 elif isinstance(repo, basestring): |
689
ecc566f8b69f
fixes #59, notifications for user registrations + some changes to mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
124 repo_name = repo.lstrip('/') |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
125 repo_obj = rm.get_by_repo_name(repo_name, cache=False) |
689
ecc566f8b69f
fixes #59, notifications for user registrations + some changes to mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
126 else: |
ecc566f8b69f
fixes #59, notifications for user registrations + some changes to mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
127 raise Exception('You have to provide repository to action logger') |
ecc566f8b69f
fixes #59, notifications for user registrations + some changes to mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
128 |
536
39203995f2c4
made action logger more global, to be used in other places to log other actions.
Marcin Kuzminski <marcin@python-works.com>
parents:
524
diff
changeset
|
129 user_log = UserLog() |
654
7f5976da192c
#48 rewrite action loggers into hooks with all changesets that are inside a push
Marcin Kuzminski <marcin@python-works.com>
parents:
643
diff
changeset
|
130 user_log.user_id = user_obj.user_id |
536
39203995f2c4
made action logger more global, to be used in other places to log other actions.
Marcin Kuzminski <marcin@python-works.com>
parents:
524
diff
changeset
|
131 user_log.action = action |
756
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
132 |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
133 user_log.repository_id = repo_obj.repo_id |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
536
diff
changeset
|
134 user_log.repository_name = repo_name |
756
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
135 |
536
39203995f2c4
made action logger more global, to be used in other places to log other actions.
Marcin Kuzminski <marcin@python-works.com>
parents:
524
diff
changeset
|
136 user_log.action_date = datetime.datetime.now() |
39203995f2c4
made action logger more global, to be used in other places to log other actions.
Marcin Kuzminski <marcin@python-works.com>
parents:
524
diff
changeset
|
137 user_log.user_ip = ipaddr |
39203995f2c4
made action logger more global, to be used in other places to log other actions.
Marcin Kuzminski <marcin@python-works.com>
parents:
524
diff
changeset
|
138 sa.add(user_log) |
39203995f2c4
made action logger more global, to be used in other places to log other actions.
Marcin Kuzminski <marcin@python-works.com>
parents:
524
diff
changeset
|
139 sa.commit() |
621
9893c2fc846b
removed raise from log user action
Marcin Kuzminski <marcin@python-works.com>
parents:
604
diff
changeset
|
140 |
756
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
141 log.info('Adding user %s, action %s on %s', user_obj, action, repo) |
654
7f5976da192c
#48 rewrite action loggers into hooks with all changesets that are inside a push
Marcin Kuzminski <marcin@python-works.com>
parents:
643
diff
changeset
|
142 except: |
7f5976da192c
#48 rewrite action loggers into hooks with all changesets that are inside a push
Marcin Kuzminski <marcin@python-works.com>
parents:
643
diff
changeset
|
143 log.error(traceback.format_exc()) |
536
39203995f2c4
made action logger more global, to be used in other places to log other actions.
Marcin Kuzminski <marcin@python-works.com>
parents:
524
diff
changeset
|
144 sa.rollback() |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
145 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
146 |
877
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
147 def get_repos(path, recursive=False): |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
148 """ |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
149 Scans given path for repos and return (name,(type,path)) tuple |
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
150 |
877
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
151 :param path: path to scann for repositories |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
152 :param recursive: recursive search and return names with subdirs in front |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
153 """ |
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
154 from vcs.utils.helpers import get_scm |
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
155 from vcs.exceptions import VCSError |
633
fcf599cd3404
Move changes for git implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
156 |
1221
e4784e2b03f7
strip os.sep instead of '/' in repo scanner
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
157 if path.endswith(os.sep): |
e4784e2b03f7
strip os.sep instead of '/' in repo scanner
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
158 #remove ending slash for better results |
877
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
159 path = path[:-1] |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
160 |
877
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
161 def _get_repos(p): |
1221
e4784e2b03f7
strip os.sep instead of '/' in repo scanner
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
162 if not os.access(p, os.W_OK): |
e4784e2b03f7
strip os.sep instead of '/' in repo scanner
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
163 return |
877
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
164 for dirpath in os.listdir(p): |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
165 if os.path.isfile(os.path.join(p, dirpath)): |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
166 continue |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
167 cur_path = os.path.join(p, dirpath) |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
168 try: |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
169 scm_info = get_scm(cur_path) |
1196
49ea527452d3
fixes for issue #148
Marcin Kuzminski <marcin@python-works.com>
parents:
1099
diff
changeset
|
170 yield scm_info[1].split(path)[-1].lstrip(os.sep), scm_info |
877
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
171 except VCSError: |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
172 if not recursive: |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
173 continue |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
174 #check if this dir containts other repos for recursive scan |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
175 rec_path = os.path.join(p, dirpath) |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
176 if os.path.isdir(rec_path): |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
177 for inner_scm in _get_repos(rec_path): |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
178 yield inner_scm |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
179 |
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
180 return _get_repos(path) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
181 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
182 |
1507
7d687ed11929
changed check_... functions from their stupid names to something less retarded :)
Marcin Kuzminski <marcin@python-works.com>
parents:
1505
diff
changeset
|
183 def is_valid_repo(repo_name, base_path): |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
756
diff
changeset
|
184 """ |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
185 Returns True if given path is a valid repository False otherwise |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
756
diff
changeset
|
186 :param repo_name: |
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
756
diff
changeset
|
187 :param base_path: |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
188 |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
189 :return True: if given path is a valid repository |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
756
diff
changeset
|
190 """ |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
191 full_path = os.path.join(base_path, repo_name) |
1528
1d7a621d396f
fixed action logger
Marcin Kuzminski <marcin@python-works.com>
parents:
1507
diff
changeset
|
192 |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
193 try: |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
194 get_scm(full_path) |
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
195 return True |
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
196 except VCSError: |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
197 return False |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
198 |
1507
7d687ed11929
changed check_... functions from their stupid names to something less retarded :)
Marcin Kuzminski <marcin@python-works.com>
parents:
1505
diff
changeset
|
199 def is_valid_repos_group(repos_group_name, base_path): |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
200 """ |
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
201 Returns True if given path is a repos group False otherwise |
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
202 |
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
203 :param repo_name: |
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
204 :param base_path: |
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
205 """ |
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
206 full_path = os.path.join(base_path, repos_group_name) |
1528
1d7a621d396f
fixed action logger
Marcin Kuzminski <marcin@python-works.com>
parents:
1507
diff
changeset
|
207 |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
208 # check if it's not a repo |
1507
7d687ed11929
changed check_... functions from their stupid names to something less retarded :)
Marcin Kuzminski <marcin@python-works.com>
parents:
1505
diff
changeset
|
209 if is_valid_repo(repos_group_name, base_path): |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
210 return False |
1528
1d7a621d396f
fixed action logger
Marcin Kuzminski <marcin@python-works.com>
parents:
1507
diff
changeset
|
211 |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
212 # check if it's a valid path |
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
213 if os.path.isdir(full_path): |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
214 return True |
1528
1d7a621d396f
fixed action logger
Marcin Kuzminski <marcin@python-works.com>
parents:
1507
diff
changeset
|
215 |
1505
bb6ba7442293
Fixed methods for checking if path in routes is a repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
216 return False |
1528
1d7a621d396f
fixed action logger
Marcin Kuzminski <marcin@python-works.com>
parents:
1507
diff
changeset
|
217 |
351
d09381593b12
updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
218 def ask_ok(prompt, retries=4, complaint='Yes or no, please!'): |
d09381593b12
updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
219 while True: |
d09381593b12
updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
220 ok = raw_input(prompt) |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
221 if ok in ('y', 'ye', 'yes'): |
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
222 return True |
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
223 if ok in ('n', 'no', 'nop', 'nope'): |
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
224 return False |
351
d09381593b12
updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
225 retries = retries - 1 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
226 if retries < 0: |
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
227 raise IOError |
351
d09381593b12
updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
228 print complaint |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
229 |
388
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
386
diff
changeset
|
230 #propagated from mercurial documentation |
386
a9a607a58b1c
moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
231 ui_sections = ['alias', 'auth', |
a9a607a58b1c
moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
232 'decode/encode', 'defaults', |
a9a607a58b1c
moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
233 'diff', 'email', |
a9a607a58b1c
moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
234 'extensions', 'format', |
a9a607a58b1c
moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
235 'merge-patterns', 'merge-tools', |
a9a607a58b1c
moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
236 'hooks', 'http_proxy', |
a9a607a58b1c
moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
237 'smtp', 'patch', |
a9a607a58b1c
moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
238 'paths', 'profiling', |
a9a607a58b1c
moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
239 'server', 'trusted', |
a9a607a58b1c
moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
240 'ui', 'web', ] |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
241 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
242 |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
243 def make_ui(read_from='file', path=None, checkpaths=True): |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
244 """A function that will read python rc files or database |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
245 and make an mercurial ui object from read options |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
246 |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
247 :param path: path to mercurial config file |
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
248 :param checkpaths: check the path |
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
249 :param read_from: read from 'file' or 'db' |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
250 """ |
386
a9a607a58b1c
moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
251 |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
252 baseui = ui.ui() |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
253 |
724
a9bc513a1fe3
fixed nasty bug with ui()
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
254 #clean the baseui object |
a9bc513a1fe3
fixed nasty bug with ui()
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
255 baseui._ocfg = config.config() |
a9bc513a1fe3
fixed nasty bug with ui()
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
256 baseui._ucfg = config.config() |
a9bc513a1fe3
fixed nasty bug with ui()
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
257 baseui._tcfg = config.config() |
a9bc513a1fe3
fixed nasty bug with ui()
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
258 |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
259 if read_from == 'file': |
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
260 if not os.path.isfile(path): |
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
261 log.warning('Unable to read config file %s' % path) |
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
262 return False |
388
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
386
diff
changeset
|
263 log.debug('reading hgrc from %s', path) |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
264 cfg = config.config() |
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
265 cfg.read(path) |
386
a9a607a58b1c
moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
266 for section in ui_sections: |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
267 for k, v in cfg.items(section): |
724
a9bc513a1fe3
fixed nasty bug with ui()
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
268 log.debug('settings ui from file[%s]%s:%s', section, k, v) |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
269 baseui.setconfig(section, k, v) |
724
a9bc513a1fe3
fixed nasty bug with ui()
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
270 |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
271 elif read_from == 'db': |
756
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
272 sa = meta.Session() |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
273 ret = sa.query(RhodeCodeUi)\ |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
274 .options(FromCache("sql_cache_short", |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
275 "get_hg_ui_settings")).all() |
773
876776983c3c
disabled dotencode format for mercurial 1.7 usage and hg <=1.6 compatibility
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
276 |
756
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
277 hg_ui = ret |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
278 for ui_ in hg_ui: |
392
b27d32cb3157
Implemented hooks system,
Marcin Kuzminski <marcin@python-works.com>
parents:
388
diff
changeset
|
279 if ui_.ui_active: |
773
876776983c3c
disabled dotencode format for mercurial 1.7 usage and hg <=1.6 compatibility
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
280 log.debug('settings ui from db[%s]%s:%s', ui_.ui_section, |
876776983c3c
disabled dotencode format for mercurial 1.7 usage and hg <=1.6 compatibility
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
281 ui_.ui_key, ui_.ui_value) |
392
b27d32cb3157
Implemented hooks system,
Marcin Kuzminski <marcin@python-works.com>
parents:
388
diff
changeset
|
282 baseui.setconfig(ui_.ui_section, ui_.ui_key, ui_.ui_value) |
773
876776983c3c
disabled dotencode format for mercurial 1.7 usage and hg <=1.6 compatibility
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
283 |
876776983c3c
disabled dotencode format for mercurial 1.7 usage and hg <=1.6 compatibility
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
284 meta.Session.remove() |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
285 return baseui |
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
286 |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
287 |
548
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
288 def set_rhodecode_config(config): |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
837
diff
changeset
|
289 """Updates pylons config with new settings from database |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
290 |
756
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
291 :param config: |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
292 """ |
1292
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1243
diff
changeset
|
293 hgsettings = RhodeCodeSettings.get_app_settings() |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
294 |
381
55377fdc1fc6
cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
295 for k, v in hgsettings.items(): |
55377fdc1fc6
cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
296 config[k] = v |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
301
diff
changeset
|
297 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
298 |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
689
diff
changeset
|
299 def invalidate_cache(cache_key, *args): |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
300 """Puts cache invalidation task into db for |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
659
diff
changeset
|
301 further global cache invalidation |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
659
diff
changeset
|
302 """ |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
837
diff
changeset
|
303 |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
689
diff
changeset
|
304 from rhodecode.model.scm import ScmModel |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
689
diff
changeset
|
305 |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
689
diff
changeset
|
306 if cache_key.startswith('get_repo_cached_'): |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
689
diff
changeset
|
307 name = cache_key.split('get_repo_cached_')[-1] |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
689
diff
changeset
|
308 ScmModel().mark_for_invalidation(name) |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
309 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
310 |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
311 class EmptyChangeset(BaseChangeset): |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
312 """ |
643
9dc1d92d82ed
updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
313 An dummy empty changeset. It's possible to pass hash when creating |
9dc1d92d82ed
updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
314 an EmptyChangeset |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
315 """ |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
316 |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1466
diff
changeset
|
317 def __init__(self, cs='0' * 40, repo=None, requested_revision=None, alias=None): |
643
9dc1d92d82ed
updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
318 self._empty_cs = cs |
9dc1d92d82ed
updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
319 self.revision = -1 |
9dc1d92d82ed
updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
320 self.message = '' |
9dc1d92d82ed
updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
321 self.author = '' |
9dc1d92d82ed
updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
322 self.date = '' |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
323 self.repository = repo |
1466 | 324 self.requested_revision = requested_revision |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1466
diff
changeset
|
325 self.alias = alias |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1466
diff
changeset
|
326 |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
327 @LazyProperty |
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
328 def raw_id(self): |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
837
diff
changeset
|
329 """Returns raw string identifying this changeset, useful for web |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
330 representation. |
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
331 """ |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
837
diff
changeset
|
332 |
643
9dc1d92d82ed
updated setup for all newest versions
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
333 return self._empty_cs |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
334 |
524
63212fea2471
a lot of fixes in templates,
Marcin Kuzminski <marcin@python-works.com>
parents:
520
diff
changeset
|
335 @LazyProperty |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1466
diff
changeset
|
336 def branch(self): |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1466
diff
changeset
|
337 return get_backend(self.alias).DEFAULT_BRANCH_NAME |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1466
diff
changeset
|
338 |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1466
diff
changeset
|
339 @LazyProperty |
520
eda96fb85ba7
dohh !! fixed EmptyCHangeset for new vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
497
diff
changeset
|
340 def short_id(self): |
524
63212fea2471
a lot of fixes in templates,
Marcin Kuzminski <marcin@python-works.com>
parents:
520
diff
changeset
|
341 return self.raw_id[:12] |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
342 |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
343 def get_file_changeset(self, path): |
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
344 return self |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
345 |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
346 def get_file_content(self, path): |
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
347 return u'' |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
348 |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
349 def get_file_size(self, path): |
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
350 return 0 |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
351 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
352 |
878
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
353 def map_groups(groups): |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
354 """Checks for groups existence, and creates groups structures. |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
355 It returns last group in structure |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
356 |
878
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
357 :param groups: list of groups structure |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
358 """ |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
359 sa = meta.Session() |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
360 |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
361 parent = None |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
362 group = None |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
363 for lvl, group_name in enumerate(groups[:-1]): |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
364 group = sa.query(Group).filter(Group.group_name == group_name).scalar() |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
365 |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
366 if group is None: |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
367 group = Group(group_name, parent) |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
368 sa.add(group) |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
369 sa.commit() |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
370 |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
371 parent = group |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
372 |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
373 return group |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
374 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
375 |
348
e8fc875467bd
implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents:
345
diff
changeset
|
376 def repo2db_mapper(initial_repo_list, remove_obsolete=False): |
878
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
377 """maps all repos given in initial_repo_list, non existing repositories |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
378 are created, if remove_obsolete is True it also check for db entries |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
379 that are not in initial_repo_list and removes them. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
380 |
878
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
381 :param initial_repo_list: list of repositories found by scanning methods |
859bc9e7a15d
Extended repo2db mapper with group creation via directory structures
Marcin Kuzminski <marcin@python-works.com>
parents:
877
diff
changeset
|
382 :param remove_obsolete: check for obsolete entries in database |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
383 """ |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
384 |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
621
diff
changeset
|
385 sa = meta.Session() |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
689
diff
changeset
|
386 rm = RepoModel() |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
387 user = sa.query(User).filter(User.admin == True).first() |
1039
51b70569c330
extended admin rescan to show what repositories was added and what removed
Marcin Kuzminski <marcin@python-works.com>
parents:
1032
diff
changeset
|
388 added = [] |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
389 for name, repo in initial_repo_list.items(): |
1406
a773087f5e42
fixes #220 repos groups are not detected on Windows
Marcin Kuzminski <marcin@python-works.com>
parents:
1401
diff
changeset
|
390 group = map_groups(name.split(os.sep)) |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
724
diff
changeset
|
391 if not rm.get_by_repo_name(name, cache=False): |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
392 log.info('repository %s not found creating default', name) |
1039
51b70569c330
extended admin rescan to show what repositories was added and what removed
Marcin Kuzminski <marcin@python-works.com>
parents:
1032
diff
changeset
|
393 added.append(name) |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
394 form_data = { |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
395 'repo_name': name, |
1361
87ca17540603
fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1354
diff
changeset
|
396 'repo_name_full': name, |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
397 'repo_type': repo.alias, |
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
398 'description': repo.description \ |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
656
diff
changeset
|
399 if repo.description != 'unknown' else \ |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
656
diff
changeset
|
400 '%s repository' % name, |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
401 'private': False, |
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
402 'group_id': getattr(group, 'group_id', None) |
297
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
403 } |
a074dec6ee40
restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents:
295
diff
changeset
|
404 rm.create(form_data, user, just_db=True) |
348
e8fc875467bd
implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents:
345
diff
changeset
|
405 |
1039
51b70569c330
extended admin rescan to show what repositories was added and what removed
Marcin Kuzminski <marcin@python-works.com>
parents:
1032
diff
changeset
|
406 removed = [] |
348
e8fc875467bd
implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents:
345
diff
changeset
|
407 if remove_obsolete: |
e8fc875467bd
implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents:
345
diff
changeset
|
408 #remove from database those repositories that are not in the filesystem |
e8fc875467bd
implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents:
345
diff
changeset
|
409 for repo in sa.query(Repository).all(): |
e8fc875467bd
implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents:
345
diff
changeset
|
410 if repo.repo_name not in initial_repo_list.keys(): |
1039
51b70569c330
extended admin rescan to show what repositories was added and what removed
Marcin Kuzminski <marcin@python-works.com>
parents:
1032
diff
changeset
|
411 removed.append(repo.repo_name) |
348
e8fc875467bd
implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents:
345
diff
changeset
|
412 sa.delete(repo) |
e8fc875467bd
implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents:
345
diff
changeset
|
413 sa.commit() |
e8fc875467bd
implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents:
345
diff
changeset
|
414 |
1039
51b70569c330
extended admin rescan to show what repositories was added and what removed
Marcin Kuzminski <marcin@python-works.com>
parents:
1032
diff
changeset
|
415 return added, removed |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
416 |
785
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
417 #set cache regions for beaker so celery can utilise it |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
418 def add_cache(settings): |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
419 cache_settings = {'regions': None} |
785
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
420 for key in settings.keys(): |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
421 for prefix in ['beaker.cache.', 'cache.']: |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
422 if key.startswith(prefix): |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
423 name = key.split(prefix)[1].strip() |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
424 cache_settings[name] = settings[key].strip() |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
425 if cache_settings['regions']: |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
426 for region in cache_settings['regions'].split(','): |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
427 region = region.strip() |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
428 region_settings = {} |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
429 for key, value in cache_settings.items(): |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
430 if key.startswith(region): |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
431 region_settings[key.split('.')[1]] = value |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
432 region_settings['expire'] = int(region_settings.get('expire', |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
433 60)) |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
434 region_settings.setdefault('lock_dir', |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
435 cache_settings.get('lock_dir')) |
1032
2e9f2bd28143
fixed add cache defaults missing data_dir
Marcin Kuzminski <marcin@python-works.com>
parents:
1022
diff
changeset
|
436 region_settings.setdefault('data_dir', |
2e9f2bd28143
fixed add cache defaults missing data_dir
Marcin Kuzminski <marcin@python-works.com>
parents:
1022
diff
changeset
|
437 cache_settings.get('data_dir')) |
2e9f2bd28143
fixed add cache defaults missing data_dir
Marcin Kuzminski <marcin@python-works.com>
parents:
1022
diff
changeset
|
438 |
785
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
439 if 'type' not in region_settings: |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
440 region_settings['type'] = cache_settings.get('type', |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
441 'memory') |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
442 beaker.cache.cache_regions[region] = region_settings |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
443 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
444 |
807
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
445 def get_current_revision(): |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
837
diff
changeset
|
446 """Returns tuple of (number, id) from repository containing this package |
807
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
447 or None if repository could not be found. |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
448 """ |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
837
diff
changeset
|
449 |
807
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
450 try: |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
451 from vcs import get_repo |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
452 from vcs.utils.helpers import get_scm |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
453 from vcs.exceptions import RepositoryError, VCSError |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
454 repopath = os.path.join(os.path.dirname(__file__), '..', '..') |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
455 scm = get_scm(repopath)[0] |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
456 repo = get_repo(path=repopath, alias=scm) |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
457 tip = repo.get_changeset() |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
458 return (tip.revision, tip.short_id) |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
459 except (ImportError, RepositoryError, VCSError), err: |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
460 logging.debug("Cannot retrieve rhodecode's revision. Original error " |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
461 "was: %s" % err) |
e8c9ff1da9ba
added revision into version for beta
Marcin Kuzminski <marcin@python-works.com>
parents:
785
diff
changeset
|
462 return None |
785
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
463 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
464 |
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
465 #============================================================================== |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
621
diff
changeset
|
466 # TEST FUNCTIONS AND CREATORS |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
467 #============================================================================== |
1401
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
468 def create_test_index(repo_location, config, full_index): |
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
469 """ |
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
470 Makes default test index |
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
471 |
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
472 :param config: test config |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
473 :param full_index: |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
474 """ |
1401
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
475 |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
544
diff
changeset
|
476 from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
544
diff
changeset
|
477 from rhodecode.lib.pidlock import DaemonLock, LockHeld |
1401
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
478 |
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
479 repo_location = repo_location |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
480 |
1411
90eebc0f040c
Fixed whoosh index location bug
Marcin Kuzminski <marcin@python-works.com>
parents:
1406
diff
changeset
|
481 index_location = os.path.join(config['app_conf']['index_dir']) |
1401
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
482 if not os.path.exists(index_location): |
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
483 os.makedirs(index_location) |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
484 |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
485 try: |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1361
diff
changeset
|
486 l = DaemonLock(file=jn(dn(index_location), 'make_index.lock')) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
684
diff
changeset
|
487 WhooshIndexingDaemon(index_location=index_location, |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
684
diff
changeset
|
488 repo_location=repo_location)\ |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
489 .run(full_index=full_index) |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
490 l.release() |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
491 except LockHeld: |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
492 pass |
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
493 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
494 |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
495 def create_test_env(repos_test_path, config): |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
496 """Makes a fresh database and |
473
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
395
diff
changeset
|
497 install test repository into tmp dir |
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
395
diff
changeset
|
498 """ |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
544
diff
changeset
|
499 from rhodecode.lib.db_manage import DbManage |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
684
diff
changeset
|
500 from rhodecode.tests import HG_REPO, GIT_REPO, NEW_HG_REPO, NEW_GIT_REPO, \ |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
684
diff
changeset
|
501 HG_FORK, GIT_FORK, TESTS_TMP_PATH |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
502 import tarfile |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
503 import shutil |
1416
df04752daa64
test env update
Marcin Kuzminski <marcin@python-works.com>
parents:
1411
diff
changeset
|
504 from os.path import abspath |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
505 |
1416
df04752daa64
test env update
Marcin Kuzminski <marcin@python-works.com>
parents:
1411
diff
changeset
|
506 # PART ONE create db |
783
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
507 dbconf = config['sqlalchemy.db1.url'] |
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
508 log.debug('making test db %s', dbconf) |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
509 |
1397
dc960653f8d2
Added new random directory for each test to be better sandboxed
Marcin Kuzminski <marcin@python-works.com>
parents:
1396
diff
changeset
|
510 # create test dir if it doesn't exist |
dc960653f8d2
Added new random directory for each test to be better sandboxed
Marcin Kuzminski <marcin@python-works.com>
parents:
1396
diff
changeset
|
511 if not os.path.isdir(repos_test_path): |
dc960653f8d2
Added new random directory for each test to be better sandboxed
Marcin Kuzminski <marcin@python-works.com>
parents:
1396
diff
changeset
|
512 log.debug('Creating testdir %s' % repos_test_path) |
dc960653f8d2
Added new random directory for each test to be better sandboxed
Marcin Kuzminski <marcin@python-works.com>
parents:
1396
diff
changeset
|
513 os.makedirs(repos_test_path) |
dc960653f8d2
Added new random directory for each test to be better sandboxed
Marcin Kuzminski <marcin@python-works.com>
parents:
1396
diff
changeset
|
514 |
783
71113f64b2d8
fidex corrent variables passed to dnconfig,
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
515 dbmanage = DbManage(log_sql=True, dbconf=dbconf, root=config['here'], |
552
2642f128ad46
removed egg info, update files for distutils build
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
516 tests=True) |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
517 dbmanage.create_tables(override=True) |
1099
bc3dafd0e24c
fixed test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
1039
diff
changeset
|
518 dbmanage.create_settings(dbmanage.config_prompt(repos_test_path)) |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
519 dbmanage.create_default_user() |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
520 dbmanage.admin_prompt() |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
521 dbmanage.create_permissions() |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
522 dbmanage.populate_default_permissions() |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
523 |
1416
df04752daa64
test env update
Marcin Kuzminski <marcin@python-works.com>
parents:
1411
diff
changeset
|
524 # PART TWO make test repo |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
684
diff
changeset
|
525 log.debug('making test vcs repositories') |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
684
diff
changeset
|
526 |
1396
069ee86e85ad
cleanup before start testing suite of index and data cache dirs
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
527 idx_path = config['app_conf']['index_dir'] |
069ee86e85ad
cleanup before start testing suite of index and data cache dirs
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
528 data_path = config['app_conf']['cache_dir'] |
069ee86e85ad
cleanup before start testing suite of index and data cache dirs
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
529 |
069ee86e85ad
cleanup before start testing suite of index and data cache dirs
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
530 #clean index and data |
069ee86e85ad
cleanup before start testing suite of index and data cache dirs
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
531 if idx_path and os.path.exists(idx_path): |
069ee86e85ad
cleanup before start testing suite of index and data cache dirs
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
532 log.debug('remove %s' % idx_path) |
069ee86e85ad
cleanup before start testing suite of index and data cache dirs
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
533 shutil.rmtree(idx_path) |
069ee86e85ad
cleanup before start testing suite of index and data cache dirs
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
534 |
069ee86e85ad
cleanup before start testing suite of index and data cache dirs
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
535 if data_path and os.path.exists(data_path): |
069ee86e85ad
cleanup before start testing suite of index and data cache dirs
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
536 log.debug('remove %s' % data_path) |
069ee86e85ad
cleanup before start testing suite of index and data cache dirs
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
537 shutil.rmtree(data_path) |
069ee86e85ad
cleanup before start testing suite of index and data cache dirs
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
538 |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
684
diff
changeset
|
539 #CREATE DEFAULT HG REPOSITORY |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
540 cur_dir = dn(dn(abspath(__file__))) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
684
diff
changeset
|
541 tar = tarfile.open(jn(cur_dir, 'tests', "vcs_test_hg.tar.gz")) |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
684
diff
changeset
|
542 tar.extractall(jn(TESTS_TMP_PATH, HG_REPO)) |
473
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
395
diff
changeset
|
543 tar.close() |
684
2abb398cd9a7
upgrade-db command dummy
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
544 |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1221
diff
changeset
|
545 |
785
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
546 #============================================================================== |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
547 # PASTER COMMANDS |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
548 #============================================================================== |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
549 class BasePasterCommand(Command): |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
550 """ |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
551 Abstract Base Class for paster commands. |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
552 |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
553 The celery commands are somewhat aggressive about loading |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
554 celery.conf, and since our module sets the `CELERY_LOADER` |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
555 environment variable to our loader, we have to bootstrap a bit and |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
556 make sure we've had a chance to load the pylons config off of the |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
557 command line, otherwise everything fails. |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
558 """ |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
559 min_args = 1 |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
560 min_args_error = "Please provide a paster config file as an argument." |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
561 takes_config_file = 1 |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
562 requires_config_file = True |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
563 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
833
diff
changeset
|
564 def notify_msg(self, msg, log=False): |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
833
diff
changeset
|
565 """Make a notification to user, additionally if logger is passed |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
833
diff
changeset
|
566 it logs this action using given logger |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
567 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
833
diff
changeset
|
568 :param msg: message that will be printed to user |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
833
diff
changeset
|
569 :param log: logging instance, to use to additionally log this message |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
570 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
833
diff
changeset
|
571 """ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
833
diff
changeset
|
572 if log and isinstance(log, logging): |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
833
diff
changeset
|
573 log(msg) |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
833
diff
changeset
|
574 |
785
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
575 def run(self, args): |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
576 """ |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
577 Overrides Command.run |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1196
diff
changeset
|
578 |
785
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
579 Checks for a config file argument and loads it. |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
580 """ |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
581 if len(args) < self.min_args: |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
582 raise BadCommand( |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
583 self.min_args_error % {'min_args': self.min_args, |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
584 'actual_args': len(args)}) |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
585 |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
586 # Decrement because we're going to lob off the first argument. |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
587 # @@ This is hacky |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
588 self.min_args -= 1 |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
589 self.bootstrap_config(args[0]) |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
590 self.update_parser() |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
591 return super(BasePasterCommand, self).run(args[1:]) |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
592 |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
593 def update_parser(self): |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
594 """ |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
595 Abstract method. Allows for the class's parser to be updated |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
596 before the superclass's `run` method is called. Necessary to |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
597 allow options/arguments to be passed through to the underlying |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
598 celery command. |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
599 """ |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
600 raise NotImplementedError("Abstract Method.") |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
601 |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
602 def bootstrap_config(self, conf): |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
603 """ |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
604 Loads the pylons configuration. |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
605 """ |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
606 from pylons import config as pylonsconfig |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
607 |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
608 path_to_ini_file = os.path.realpath(conf) |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
609 conf = paste.deploy.appconfig('config:' + path_to_ini_file) |
277427ac29a9
complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents:
783
diff
changeset
|
610 pylonsconfig.init_app(conf.global_conf, conf.local_conf) |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1466
diff
changeset
|
611 |