Mercurial > kallithea
annotate rhodecode/model/repo.py @ 1217:a3b2b4b4e440
fixes for issue #149
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 05 Apr 2011 18:04:06 +0200 |
parents | af6ca51fb80f |
children | bf263968da47 |
rev | line source |
---|---|
786
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
1 # -*- coding: utf-8 -*- |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
2 """ |
811 | 3 rhodecode.model.repo |
4 ~~~~~~~~~~~~~~~~~~~~ | |
786
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
5 |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
6 Repository model for rhodecode |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
7 |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
8 :created_on: Jun 5, 2010 |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
9 :author: marcink |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
786
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
12 """ |
1217
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
16 # (at your option) any later version. |
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
17 # |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # GNU General Public License for more details. |
1217
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
22 # |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
1217
a3b2b4b4e440
fixes for issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
786
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
25 import os |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
26 import shutil |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
27 import logging |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
28 import traceback |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
29 from datetime import datetime |
786
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
30 |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
31 from sqlalchemy.orm import joinedload, make_transient |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
32 |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
33 from vcs.utils.lazy import LazyProperty |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
34 from vcs.backends import get_backend |
786
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
35 |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
36 from rhodecode.model import BaseModel |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
37 from rhodecode.model.caching_query import FromCache |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
38 from rhodecode.model.db import Repository, RepoToPerm, User, Permission, \ |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
39 Statistics, RhodeCodeUi |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
40 from rhodecode.model.user import UserModel |
786
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
41 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 log = logging.getLogger(__name__) |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 |
752
89b9037d68b7
fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
44 class RepoModel(BaseModel): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
45 |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
46 @LazyProperty |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
47 def repos_path(self): |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
48 """Get's the repositories root path from database |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
49 """ |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
50 |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
51 q = self.sa.query(RhodeCodeUi).filter(RhodeCodeUi.ui_key == '/').one() |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
52 return q.ui_value |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
53 |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
54 def get(self, repo_id, cache=False): |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
55 repo = self.sa.query(Repository)\ |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
56 .filter(Repository.repo_id == repo_id) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
57 |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
58 if cache: |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
59 repo = repo.options(FromCache("sql_cache_short", |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
60 "get_repo_%s" % repo_id)) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
61 return repo.scalar() |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
62 |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
63 |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
64 def get_by_repo_name(self, repo_name, cache=False): |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
65 repo = self.sa.query(Repository)\ |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
66 .filter(Repository.repo_name == repo_name) |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
67 |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
68 if cache: |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
69 repo = repo.options(FromCache("sql_cache_short", |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
70 "get_repo_%s" % repo_name)) |
752
89b9037d68b7
fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
71 return repo.scalar() |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
72 |
298
15e96b5a2685
autocomplete for repository managment of users
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
73 def get_users_js(self): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
74 |
328
cec5cbc956c0
Repository managment permissions, fixed found bugs updated js, added extra checks for doubled users and non active ones
Marcin Kuzminski <marcin@python-works.com>
parents:
299
diff
changeset
|
75 users = self.sa.query(User).filter(User.active == True).all() |
298
15e96b5a2685
autocomplete for repository managment of users
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
76 u_tmpl = '''{id:%s, fname:"%s", lname:"%s", nname:"%s"},''' |
15e96b5a2685
autocomplete for repository managment of users
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
77 users_array = '[%s];' % '\n'.join([u_tmpl % (u.user_id, u.name, |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
78 u.lastname, u.username) |
298
15e96b5a2685
autocomplete for repository managment of users
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
79 for u in users]) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
80 return users_array |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
81 |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
82 |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
83 def update(self, repo_name, form_data): |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
84 try: |
822
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
85 cur_repo = self.get_by_repo_name(repo_name, cache=False) |
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
86 user_model = UserModel(self.sa) |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
87 |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
88 #update permissions |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
89 for username, perm in form_data['perms_updates']: |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
90 r2p = self.sa.query(RepoToPerm)\ |
822
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
91 .filter(RepoToPerm.user == user_model.get_by_username(username))\ |
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
92 .filter(RepoToPerm.repository == cur_repo)\ |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
93 .one() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
94 |
822
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
95 r2p.permission = self.sa.query(Permission)\ |
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
96 .filter(Permission.permission_name == perm)\ |
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
97 .scalar() |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
98 self.sa.add(r2p) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
99 |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
100 #set new permissions |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
101 for username, perm in form_data['perms_new']: |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
102 r2p = RepoToPerm() |
822
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
103 r2p.repository = cur_repo |
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
104 r2p.user = user_model.get_by_username(username, cache=False) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
105 |
822
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
106 r2p.permission = self.sa.query(Permission)\ |
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
107 .filter(Permission.permission_name == perm)\ |
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
108 .scalar() |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
109 self.sa.add(r2p) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
110 |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
111 #update current repo |
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
112 for k, v in form_data.items(): |
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
113 if k == 'user': |
822
d5a71348ee4d
small code fixes to repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
811
diff
changeset
|
114 cur_repo.user = user_model.get(v) |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
115 else: |
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
116 setattr(cur_repo, k, v) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
117 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
118 self.sa.add(cur_repo) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
119 |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
120 if repo_name != form_data['repo_name']: |
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
121 #rename our data |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
122 self.__rename_repo(repo_name, form_data['repo_name']) |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
123 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
124 self.sa.commit() |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
125 except: |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
126 log.error(traceback.format_exc()) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
127 self.sa.rollback() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
128 raise |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
129 |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
130 def create(self, form_data, cur_user, just_db=False, fork=False): |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
131 try: |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
132 if fork: |
651
ae292c3b94ed
some css updates.
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
133 #force str since hg doesn't go with unicode |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
134 repo_name = str(form_data['fork_name']) |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
135 org_name = str(form_data['repo_name']) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
136 |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
137 else: |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
138 org_name = repo_name = str(form_data['repo_name']) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
139 new_repo = Repository() |
846
121c17037d7a
fixed stupid typo, on default enable_repository
Marcin Kuzminski <marcin@python-works.com>
parents:
842
diff
changeset
|
140 new_repo.enable_statistics = True |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
141 for k, v in form_data.items(): |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
142 if k == 'repo_name': |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
143 v = repo_name |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
144 setattr(new_repo, k, v) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
145 |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
146 if fork: |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
147 parent_repo = self.sa.query(Repository)\ |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
148 .filter(Repository.repo_name == org_name).scalar() |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
149 new_repo.fork = parent_repo |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
150 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
151 new_repo.user_id = cur_user.user_id |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
152 self.sa.add(new_repo) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
153 |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
154 #create default permission |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
155 repo_to_perm = RepoToPerm() |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
156 default = 'repository.read' |
752
89b9037d68b7
fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
157 for p in UserModel(self.sa).get_by_username('default', cache=False).user_perms: |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
158 if p.permission.permission_name.startswith('repository.'): |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
159 default = p.permission.permission_name |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
160 break |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
161 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
162 default_perm = 'repository.none' if form_data['private'] else default |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
163 |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
164 repo_to_perm.permission_id = self.sa.query(Permission)\ |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
165 .filter(Permission.permission_name == default_perm)\ |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
166 .one().permission_id |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
167 |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
168 repo_to_perm.repository = new_repo |
752
89b9037d68b7
fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
169 repo_to_perm.user_id = UserModel(self.sa)\ |
89b9037d68b7
fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
170 .get_by_username('default', cache=False).user_id |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
171 |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
172 self.sa.add(repo_to_perm) |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
173 |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
174 if not just_db: |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
175 self.__create_repo(repo_name, form_data['repo_type']) |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
176 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
177 self.sa.commit() |
786
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
178 |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
179 #now automatically start following this repository as owner |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
180 from rhodecode.model.scm import ScmModel |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
181 ScmModel(self.sa).toggle_following_repo(new_repo.repo_id, |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
182 cur_user.user_id) |
2889a4446960
when new repo is created make user follow it automatically,
Marcin Kuzminski <marcin@python-works.com>
parents:
752
diff
changeset
|
183 |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
184 except: |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
185 log.error(traceback.format_exc()) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
186 self.sa.rollback() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
187 raise |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
188 |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
189 def create_fork(self, form_data, cur_user): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
190 from rhodecode.lib.celerylib import tasks, run_task |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
191 run_task(tasks.create_repo_fork, form_data, cur_user) |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
192 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
193 def delete(self, repo): |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
194 try: |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
195 self.sa.delete(repo) |
668
dff6d5cb8bba
fixed deletion of repository on filesystem, works based on scm type for git and hg.
Marcin Kuzminski <marcin@python-works.com>
parents:
659
diff
changeset
|
196 self.__delete_repo(repo) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
197 self.sa.commit() |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
198 except: |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
199 log.error(traceback.format_exc()) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
200 self.sa.rollback() |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
201 raise |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
202 |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
203 def delete_perm_user(self, form_data, repo_name): |
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
204 try: |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
205 self.sa.query(RepoToPerm)\ |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
206 .filter(RepoToPerm.repository \ |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
207 == self.get_by_repo_name(repo_name))\ |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
208 .filter(RepoToPerm.user_id == form_data['user_id']).delete() |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
209 self.sa.commit() |
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
210 except: |
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
211 log.error(traceback.format_exc()) |
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
212 self.sa.rollback() |
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
213 raise |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
214 |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
215 def delete_stats(self, repo_name): |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
216 try: |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
217 self.sa.query(Statistics)\ |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
218 .filter(Statistics.repository == \ |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
219 self.get_by_repo_name(repo_name)).delete() |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
220 self.sa.commit() |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
221 except: |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
222 log.error(traceback.format_exc()) |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
223 self.sa.rollback() |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
224 raise |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
225 |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
226 |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
651
diff
changeset
|
227 def __create_repo(self, repo_name, alias): |
787
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
228 """ |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
229 makes repository on filesystem |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
230 :param repo_name: |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
231 :param alias: |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
232 """ |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
233 from rhodecode.lib.utils import check_repo |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
234 repo_path = os.path.join(self.repos_path, repo_name) |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
235 if check_repo(repo_name, self.repos_path): |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
236 log.info('creating repo %s in %s', repo_name, repo_path) |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
651
diff
changeset
|
237 backend = get_backend(alias) |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
651
diff
changeset
|
238 backend(repo_path, create=True) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
239 |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
240 def __rename_repo(self, old, new): |
787
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
241 """ |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
242 renames repository on filesystem |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
243 :param old: old name |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
244 :param new: new name |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
245 """ |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
328
diff
changeset
|
246 log.info('renaming repo from %s to %s', old, new) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
247 |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
248 old_path = os.path.join(self.repos_path, old) |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
249 new_path = os.path.join(self.repos_path, new) |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
328
diff
changeset
|
250 if os.path.isdir(new_path): |
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
328
diff
changeset
|
251 raise Exception('Was trying to rename to already existing dir %s', |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
252 new_path) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
253 shutil.move(old_path, new_path) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
254 |
668
dff6d5cb8bba
fixed deletion of repository on filesystem, works based on scm type for git and hg.
Marcin Kuzminski <marcin@python-works.com>
parents:
659
diff
changeset
|
255 def __delete_repo(self, repo): |
787
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
256 """ |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
257 removes repo from filesystem, the removal is acctually made by |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
258 added rm__ prefix into dir, and rename internat .hg/.git dirs so this |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
259 repository is no longer valid for rhodecode, can be undeleted later on |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
260 by reverting the renames on this repository |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
261 :param repo: repo object |
4502ceec31be
docs update for repo model
Marcin Kuzminski <marcin@python-works.com>
parents:
786
diff
changeset
|
262 """ |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
263 rm_path = os.path.join(self.repos_path, repo.repo_name) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
264 log.info("Removing %s", rm_path) |
668
dff6d5cb8bba
fixed deletion of repository on filesystem, works based on scm type for git and hg.
Marcin Kuzminski <marcin@python-works.com>
parents:
659
diff
changeset
|
265 #disable hg/git |
dff6d5cb8bba
fixed deletion of repository on filesystem, works based on scm type for git and hg.
Marcin Kuzminski <marcin@python-works.com>
parents:
659
diff
changeset
|
266 alias = repo.repo_type |
dff6d5cb8bba
fixed deletion of repository on filesystem, works based on scm type for git and hg.
Marcin Kuzminski <marcin@python-works.com>
parents:
659
diff
changeset
|
267 shutil.move(os.path.join(rm_path, '.%s' % alias), |
dff6d5cb8bba
fixed deletion of repository on filesystem, works based on scm type for git and hg.
Marcin Kuzminski <marcin@python-works.com>
parents:
659
diff
changeset
|
268 os.path.join(rm_path, 'rm__.%s' % alias)) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
269 #disable repo |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
270 shutil.move(rm_path, os.path.join(self.repos_path, 'rm__%s__%s' \ |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
271 % (datetime.today().isoformat(), |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
846
diff
changeset
|
272 repo.repo_name))) |