Mercurial > kallithea
annotate rhodecode/model/scm.py @ 4147:1c8f818787b3 rhodecode-2.2.5-gpl
old style: show the full link box on summary page - no overlap or truncation
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 02 Jul 2014 19:03:23 -0400 |
parents | ffd45b185016 |
children | 7e5f8c12a3fc |
rev | line source |
---|---|
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
1 # -*- coding: utf-8 -*- |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
2 # 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
|
3 # 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
|
4 # 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
|
5 # (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:
1193
diff
changeset
|
6 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
7 # This program is distributed in the hope that it will be useful, |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
10 # 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:
1193
diff
changeset
|
11 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
12 # 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
|
13 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
14 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
15 rhodecode.model.scm |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
16 ~~~~~~~~~~~~~~~~~~~ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
17 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
18 Scm model for RhodeCode |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
19 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
20 :created_on: Apr 9, 2010 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
21 :author: marcink |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
22 :copyright: (c) 2013 RhodeCode GmbH. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
23 :license: GPLv3, see LICENSE for more details. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
24 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
25 |
2620
cd207411cf22
fixed python2.5 compat and repo mapper issue
Marcin Kuzminski <marcin@python-works.com>
parents:
2618
diff
changeset
|
26 from __future__ import with_statement |
1554
e7c6341ad3cb
fixes #245 Rescan of the repositories on Windows
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
27 import os |
2618
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
28 import re |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
29 import time |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
30 import traceback |
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
31 import logging |
1801
b6d23aa3754c
fixed problem with uploading files into rhodecode that wasn't detected as streams
Marcin Kuzminski <marcin@python-works.com>
parents:
1755
diff
changeset
|
32 import cStringIO |
2618
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
33 import pkg_resources |
3952 | 34 from os.path import join as jn |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
35 |
2354
f3417f0d54b5
fixed default sorting on main page with sorting using wrapped lower() call on database level
Marcin Kuzminski <marcin@python-works.com>
parents:
2352
diff
changeset
|
36 from sqlalchemy import func |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
37 from pylons.i18n.translation import _ |
2354
f3417f0d54b5
fixed default sorting on main page with sorting using wrapped lower() call on database level
Marcin Kuzminski <marcin@python-works.com>
parents:
2352
diff
changeset
|
38 |
2618
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
39 import rhodecode |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
40 from rhodecode.lib.vcs import get_backend |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
41 from rhodecode.lib.vcs.exceptions import RepositoryError |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
42 from rhodecode.lib.vcs.utils.lazy import LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
43 from rhodecode.lib.vcs.nodes import FileNode |
2684
2b6939a77052
Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents:
2672
diff
changeset
|
44 from rhodecode.lib.vcs.backends.base import EmptyChangeset |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
45 |
710
e2f3c8e6939d
Disable git support due to large problems with dulwich.
Marcin Kuzminski <marcin@python-works.com>
parents:
693
diff
changeset
|
46 from rhodecode import BACKENDS |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
535
diff
changeset
|
47 from rhodecode.lib import helpers as h |
3577
238486bb71ab
Switched handling of RhodeCode extra params in consistent way
Marcin Kuzminski <marcin@python-works.com>
parents:
3481
diff
changeset
|
48 from rhodecode.lib.utils2 import safe_str, safe_unicode, get_server_url,\ |
238486bb71ab
Switched handling of RhodeCode extra params in consistent way
Marcin Kuzminski <marcin@python-works.com>
parents:
3481
diff
changeset
|
49 _set_extras |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
50 from rhodecode.lib.auth import HasRepoPermissionAny, HasRepoGroupPermissionAny,\ |
3952 | 51 HasUserGroupPermissionAny |
3228
ba2e2514a01a
reposcann should skip directories with starting with '.'
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
52 from rhodecode.lib.utils import get_filesystem_repos, make_ui, \ |
3952 | 53 action_logger |
752
89b9037d68b7
fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents:
747
diff
changeset
|
54 from rhodecode.model import BaseModel |
758 | 55 from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \ |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
56 UserFollowing, UserLog, User, RepoGroup, PullRequest |
3478
796738bb697c
webinterface file commiting executes push hooks ref #594
Marcin Kuzminski <marcin@python-works.com>
parents:
3418
diff
changeset
|
57 from rhodecode.lib.hooks import log_push_action |
4070
008e460c5b9d
fixes issue #860.
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
58 from rhodecode.lib.exceptions import NonRelativePathError, IMCCommitError |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
59 |
245
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
60 log = logging.getLogger(__name__) |
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
61 |
757
c52e88b57bf4
rolled back to make transient since got some exceptions on expunge
Marcin Kuzminski <marcin@python-works.com>
parents:
753
diff
changeset
|
62 |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
63 class UserTemp(object): |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
64 def __init__(self, user_id): |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
65 self.user_id = user_id |
901
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
66 |
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
67 def __repr__(self): |
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
68 return "<%s('id:%s')>" % (self.__class__.__name__, self.user_id) |
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
69 |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
70 |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
71 class RepoTemp(object): |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
72 def __init__(self, repo_id): |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
73 self.repo_id = repo_id |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
74 |
901
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
75 def __repr__(self): |
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
76 return "<%s('id:%s')>" % (self.__class__.__name__, self.repo_id) |
765c2125e4d9
Fixed repo of Temp user and repo for better logging
Marcin Kuzminski <marcin@python-works.com>
parents:
878
diff
changeset
|
77 |
1801
b6d23aa3754c
fixed problem with uploading files into rhodecode that wasn't detected as streams
Marcin Kuzminski <marcin@python-works.com>
parents:
1755
diff
changeset
|
78 |
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:
1343
diff
changeset
|
79 class CachedRepoList(object): |
2604
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
80 """ |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
81 Cached repo list, uses in-memory cache after initialization, that is |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
82 super fast |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
83 """ |
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:
1343
diff
changeset
|
84 |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3152
diff
changeset
|
85 def __init__(self, db_repo_list, repos_path, order_by=None, perm_set=None): |
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:
1343
diff
changeset
|
86 self.db_repo_list = db_repo_list |
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:
1343
diff
changeset
|
87 self.repos_path = repos_path |
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:
1343
diff
changeset
|
88 self.order_by = order_by |
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:
1343
diff
changeset
|
89 self.reversed = (order_by or '').startswith('-') |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3152
diff
changeset
|
90 if not perm_set: |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3152
diff
changeset
|
91 perm_set = ['repository.read', 'repository.write', |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3152
diff
changeset
|
92 'repository.admin'] |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3152
diff
changeset
|
93 self.perm_set = perm_set |
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:
1343
diff
changeset
|
94 |
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:
1343
diff
changeset
|
95 def __len__(self): |
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:
1343
diff
changeset
|
96 return len(self.db_repo_list) |
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:
1343
diff
changeset
|
97 |
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:
1343
diff
changeset
|
98 def __repr__(self): |
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:
1343
diff
changeset
|
99 return '<%s (%s)>' % (self.__class__.__name__, self.__len__()) |
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:
1343
diff
changeset
|
100 |
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:
1343
diff
changeset
|
101 def __iter__(self): |
3772
910ad1ffee99
invalidation: merge .invalidate and .set_valid as .test_and_set_valid
Mads Kiilerich <madski@unity3d.com>
parents:
3759
diff
changeset
|
102 # pre-propagated valid_cache_keys to save executing select statements |
2352
90e06f53af8c
Implemented cache-map on main page to save executing select
Marcin Kuzminski <marcin@python-works.com>
parents:
2209
diff
changeset
|
103 # for each repo |
3772
910ad1ffee99
invalidation: merge .invalidate and .set_valid as .test_and_set_valid
Mads Kiilerich <madski@unity3d.com>
parents:
3759
diff
changeset
|
104 valid_cache_keys = CacheInvalidation.get_valid_cache_keys() |
2352
90e06f53af8c
Implemented cache-map on main page to save executing select
Marcin Kuzminski <marcin@python-works.com>
parents:
2209
diff
changeset
|
105 |
1428
e5467730682b
fixed some issues with cache invalidation, and simplified invalidation codes
Marcin Kuzminski <marcin@python-works.com>
parents:
1401
diff
changeset
|
106 for dbr in self.db_repo_list: |
3772
910ad1ffee99
invalidation: merge .invalidate and .set_valid as .test_and_set_valid
Mads Kiilerich <madski@unity3d.com>
parents:
3759
diff
changeset
|
107 scmr = dbr.scm_instance_cached(valid_cache_keys) |
1437
7a46d67c263c
added welcome message if no repositories are present in current view
Marcin Kuzminski <marcin@python-works.com>
parents:
1428
diff
changeset
|
108 # check permission at this level |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
109 if not HasRepoPermissionAny( |
3717 | 110 *self.perm_set)(dbr.repo_name, 'get repo check'): |
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:
1343
diff
changeset
|
111 continue |
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:
1343
diff
changeset
|
112 |
3360
85f69bf84d95
non-lightweight dashboard mode is now more error proof when it stumbles across bad or damaged repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3234
diff
changeset
|
113 try: |
85f69bf84d95
non-lightweight dashboard mode is now more error proof when it stumbles across bad or damaged repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3234
diff
changeset
|
114 last_change = scmr.last_change |
85f69bf84d95
non-lightweight dashboard mode is now more error proof when it stumbles across bad or damaged repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3234
diff
changeset
|
115 tip = h.get_changeset_safe(scmr, 'tip') |
85f69bf84d95
non-lightweight dashboard mode is now more error proof when it stumbles across bad or damaged repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3234
diff
changeset
|
116 except Exception: |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
117 log.error( |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
118 '%s this repository is present in database but it ' |
3360
85f69bf84d95
non-lightweight dashboard mode is now more error proof when it stumbles across bad or damaged repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3234
diff
changeset
|
119 'cannot be created as an scm instance, org_exc:%s' |
85f69bf84d95
non-lightweight dashboard mode is now more error proof when it stumbles across bad or damaged repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3234
diff
changeset
|
120 % (dbr.repo_name, traceback.format_exc()) |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
121 ) |
1373
66f03a87141c
Fixes issue #201
Marcin Kuzminski <marcin@python-works.com>
parents:
1370
diff
changeset
|
122 continue |
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:
1343
diff
changeset
|
123 |
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:
1343
diff
changeset
|
124 tmp_d = {} |
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:
1343
diff
changeset
|
125 tmp_d['name'] = dbr.repo_name |
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:
1343
diff
changeset
|
126 tmp_d['name_sort'] = tmp_d['name'].lower() |
2936
62e493c7f436
Added lightweight dashboard option. ref #500
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
127 tmp_d['raw_name'] = tmp_d['name'].lower() |
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:
1343
diff
changeset
|
128 tmp_d['description'] = dbr.description |
2604
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
129 tmp_d['description_sort'] = tmp_d['description'].lower() |
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:
1343
diff
changeset
|
130 tmp_d['last_change'] = last_change |
1728
07e56179633e
- fixes celery sqlalchemy session issues for async forking
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
131 tmp_d['last_change_sort'] = time.mktime(last_change.timetuple()) |
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:
1343
diff
changeset
|
132 tmp_d['tip'] = tip.raw_id |
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:
1343
diff
changeset
|
133 tmp_d['tip_sort'] = tip.revision |
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:
1343
diff
changeset
|
134 tmp_d['rev'] = tip.revision |
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:
1343
diff
changeset
|
135 tmp_d['contact'] = dbr.user.full_contact |
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:
1343
diff
changeset
|
136 tmp_d['contact_sort'] = tmp_d['contact'] |
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:
1343
diff
changeset
|
137 tmp_d['owner_sort'] = tmp_d['contact'] |
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:
1343
diff
changeset
|
138 tmp_d['repo_archives'] = list(scmr._get_archives()) |
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:
1343
diff
changeset
|
139 tmp_d['last_msg'] = tip.message |
1459
6691d4097344
added author to main page tooltip
Marcin Kuzminski <marcin@python-works.com>
parents:
1437
diff
changeset
|
140 tmp_d['author'] = tip.author |
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:
1343
diff
changeset
|
141 tmp_d['dbrepo'] = dbr.get_dict() |
1728
07e56179633e
- fixes celery sqlalchemy session issues for async forking
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
142 tmp_d['dbrepo_fork'] = dbr.fork.get_dict() if dbr.fork else {} |
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:
1343
diff
changeset
|
143 yield tmp_d |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
144 |
1801
b6d23aa3754c
fixed problem with uploading files into rhodecode that wasn't detected as streams
Marcin Kuzminski <marcin@python-works.com>
parents:
1755
diff
changeset
|
145 |
2604
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
146 class SimpleCachedRepoList(CachedRepoList): |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
147 """ |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
148 Lighter version of CachedRepoList without the scm initialisation |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
149 """ |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
150 |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
151 def __iter__(self): |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
152 for dbr in self.db_repo_list: |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
153 # check permission at this level |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
154 if not HasRepoPermissionAny( |
3717 | 155 *self.perm_set)(dbr.repo_name, 'get repo check'): |
2604
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
156 continue |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
157 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
158 tmp_d = { |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
159 'name': dbr.repo_name, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
160 'dbrepo': dbr.get_dict(), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
161 'dbrepo_fork': dbr.fork.get_dict() if dbr.fork else {} |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
162 } |
2604
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
163 yield tmp_d |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
164 |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
165 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
166 class _PermCheckIterator(object): |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
167 def __init__(self, obj_list, obj_attr, perm_set, perm_checker, extra_kwargs=None): |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3152
diff
changeset
|
168 """ |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
169 Creates iterator from given list of objects, additionally |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3152
diff
changeset
|
170 checking permission for them from perm_set var |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3152
diff
changeset
|
171 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
172 :param obj_list: list of db objects |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
173 :param obj_attr: attribute of object to pass into perm_checker |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
174 :param perm_set: list of permissions to check |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
175 :param perm_checker: callable to check permissions against |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3152
diff
changeset
|
176 """ |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
177 self.obj_list = obj_list |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
178 self.obj_attr = obj_attr |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3152
diff
changeset
|
179 self.perm_set = perm_set |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
180 self.perm_checker = perm_checker |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
181 self.extra_kwargs = extra_kwargs or {} |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
182 |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
183 def __len__(self): |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
184 return len(self.obj_list) |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
185 |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
186 def __repr__(self): |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
187 return '<%s (%s)>' % (self.__class__.__name__, self.__len__()) |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
188 |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
189 def __iter__(self): |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
190 for db_obj in self.obj_list: |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
191 # check permission at this level |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
192 name = getattr(db_obj, self.obj_attr, None) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
193 if not self.perm_checker(*self.perm_set)( |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
194 name, self.__class__.__name__, **self.extra_kwargs): |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
195 continue |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
196 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
197 yield db_obj |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
198 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
199 |
3864
1aefa8d864e4
Do read only checks on attach as fork of repo list.
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
200 class RepoList(_PermCheckIterator): |
1aefa8d864e4
Do read only checks on attach as fork of repo list.
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
201 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
202 def __init__(self, db_repo_list, perm_set=None, extra_kwargs=None): |
3864
1aefa8d864e4
Do read only checks on attach as fork of repo list.
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
203 if not perm_set: |
1aefa8d864e4
Do read only checks on attach as fork of repo list.
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
204 perm_set = ['repository.read', 'repository.write', 'repository.admin'] |
1aefa8d864e4
Do read only checks on attach as fork of repo list.
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
205 |
1aefa8d864e4
Do read only checks on attach as fork of repo list.
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
206 super(RepoList, self).__init__(obj_list=db_repo_list, |
1aefa8d864e4
Do read only checks on attach as fork of repo list.
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
207 obj_attr='repo_name', perm_set=perm_set, |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
208 perm_checker=HasRepoPermissionAny, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
209 extra_kwargs=extra_kwargs) |
3864
1aefa8d864e4
Do read only checks on attach as fork of repo list.
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
210 |
1aefa8d864e4
Do read only checks on attach as fork of repo list.
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
211 |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
212 class RepoGroupList(_PermCheckIterator): |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
213 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
214 def __init__(self, db_repo_group_list, perm_set=None, extra_kwargs=None): |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
215 if not perm_set: |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
216 perm_set = ['group.read', 'group.write', 'group.admin'] |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
217 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
218 super(RepoGroupList, self).__init__(obj_list=db_repo_group_list, |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
219 obj_attr='group_name', perm_set=perm_set, |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
220 perm_checker=HasRepoGroupPermissionAny, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
221 extra_kwargs=extra_kwargs) |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
222 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
223 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
224 class UserGroupList(_PermCheckIterator): |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
225 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
226 def __init__(self, db_user_group_list, perm_set=None, extra_kwargs=None): |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
227 if not perm_set: |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
228 perm_set = ['usergroup.read', 'usergroup.write', 'usergroup.admin'] |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
229 |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
230 super(UserGroupList, self).__init__(obj_list=db_user_group_list, |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
231 obj_attr='users_group_name', perm_set=perm_set, |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
232 perm_checker=HasUserGroupPermissionAny, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
233 extra_kwargs=extra_kwargs) |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
234 |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
235 |
752
89b9037d68b7
fixed Example celery config to ampq,
Marcin Kuzminski <marcin@python-works.com>
parents:
747
diff
changeset
|
236 class ScmModel(BaseModel): |
1716
7d1fc253549e
notification to commit author + gardening
Marcin Kuzminski <marcin@python-works.com>
parents:
1607
diff
changeset
|
237 """ |
7d1fc253549e
notification to commit author + gardening
Marcin Kuzminski <marcin@python-works.com>
parents:
1607
diff
changeset
|
238 Generic Scm Model |
58
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
239 """ |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
240 |
1755
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
241 def __get_repo(self, instance): |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
242 cls = Repository |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
243 if isinstance(instance, cls): |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
244 return instance |
2672
169807710db2
fixed possible unicode errors on repo get function
Marcin Kuzminski <marcin@python-works.com>
parents:
2655
diff
changeset
|
245 elif isinstance(instance, int) or safe_str(instance).isdigit(): |
1755
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
246 return cls.get(instance) |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
247 elif isinstance(instance, basestring): |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
248 return cls.get_by_repo_name(instance) |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
249 elif instance: |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
250 raise Exception('given object must be int, basestr or Instance' |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
251 ' of %s got %s' % (type(cls), type(instance))) |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
252 |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
253 @LazyProperty |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
254 def repos_path(self): |
1716
7d1fc253549e
notification to commit author + gardening
Marcin Kuzminski <marcin@python-works.com>
parents:
1607
diff
changeset
|
255 """ |
4089
a5888ca796b5
Fixed spelling of get's to gets
Marcin Kuzminski <marcin@python-works.com>
parents:
4070
diff
changeset
|
256 Gets the repositories root path from database |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
257 """ |
811 | 258 |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
259 q = self.sa.query(RhodeCodeUi).filter(RhodeCodeUi.ui_key == '/').one() |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
260 |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
261 return q.ui_value |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
262 |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
263 def repo_scan(self, repos_path=None): |
1716
7d1fc253549e
notification to commit author + gardening
Marcin Kuzminski <marcin@python-works.com>
parents:
1607
diff
changeset
|
264 """ |
7d1fc253549e
notification to commit author + gardening
Marcin Kuzminski <marcin@python-works.com>
parents:
1607
diff
changeset
|
265 Listing of repositories in given path. This path should not be a |
245
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
266 repository itself. Return a dictionary of repository objects |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
267 |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
268 :param repos_path: path to directory containing repositories |
245
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
269 """ |
811 | 270 |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
271 if repos_path is None: |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
272 repos_path = self.repos_path |
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
273 |
1925
9d400b585c24
fixes issue #341, logger outputed invalid path name
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
274 log.info('scanning for repositories in %s' % repos_path) |
9d400b585c24
fixes issue #341, logger outputed invalid path name
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
275 |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
1033
diff
changeset
|
276 baseui = make_ui('db') |
1751
47c2a006d43b
Summary page downloads limited to zip.
Marcin Kuzminski <marcin@python-works.com>
parents:
1728
diff
changeset
|
277 repos = {} |
690
4685f3eafd35
Fixed sumamry page description bug
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
278 |
877
bc9a73adc216
Added recursive scanning for repositories in directory
Marcin Kuzminski <marcin@python-works.com>
parents:
851
diff
changeset
|
279 for name, path in get_filesystem_repos(repos_path, recursive=True): |
1554
e7c6341ad3cb
fixes #245 Rescan of the repositories on Windows
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
280 # name need to be decomposed and put back together using the / |
e7c6341ad3cb
fixes #245 Rescan of the repositories on Windows
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
281 # since this is internal storage separator for rhodecode |
3152
46234d2d388f
fixed issues with getting repos by path on windows
Marcin Kuzminski <marcin@python-works.com>
parents:
3150
diff
changeset
|
282 name = Repository.normalize_repo_name(name) |
1716
7d1fc253549e
notification to commit author + gardening
Marcin Kuzminski <marcin@python-works.com>
parents:
1607
diff
changeset
|
283 |
245
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
284 try: |
1751
47c2a006d43b
Summary page downloads limited to zip.
Marcin Kuzminski <marcin@python-works.com>
parents:
1728
diff
changeset
|
285 if name in repos: |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
286 raise RepositoryError('Duplicate repository name %s ' |
1554
e7c6341ad3cb
fixes #245 Rescan of the repositories on Windows
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
287 'found in %s' % (name, path)) |
248
fb7f066126cc
Added support for repository located in subdirectories.
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
288 else: |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
289 |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
290 klass = get_backend(path[0]) |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
291 |
710
e2f3c8e6939d
Disable git support due to large problems with dulwich.
Marcin Kuzminski <marcin@python-works.com>
parents:
693
diff
changeset
|
292 if path[0] == 'hg' and path[0] in BACKENDS.keys(): |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
1751
diff
changeset
|
293 repos[name] = klass(safe_str(path[1]), baseui=baseui) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
294 |
710
e2f3c8e6939d
Disable git support due to large problems with dulwich.
Marcin Kuzminski <marcin@python-works.com>
parents:
693
diff
changeset
|
295 if path[0] == 'git' and path[0] in BACKENDS.keys(): |
1751
47c2a006d43b
Summary page downloads limited to zip.
Marcin Kuzminski <marcin@python-works.com>
parents:
1728
diff
changeset
|
296 repos[name] = klass(path[1]) |
245
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
297 except OSError: |
a83a1799480c
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
222
diff
changeset
|
298 continue |
3228
ba2e2514a01a
reposcann should skip directories with starting with '.'
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
299 log.debug('found %s paths with repositories' % (len(repos))) |
1751
47c2a006d43b
Summary page downloads limited to zip.
Marcin Kuzminski <marcin@python-works.com>
parents:
1728
diff
changeset
|
300 return repos |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
301 |
2604
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
302 def get_repos(self, all_repos=None, sort_key=None, simple=False): |
1343
a04fe5986109
#47 implemented basic gui for browsing repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1312
diff
changeset
|
303 """ |
a04fe5986109
#47 implemented basic gui for browsing repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1312
diff
changeset
|
304 Get all repos from db and for each repo create it's |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
305 backend instance and fill that backed with information from database |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
306 |
1343
a04fe5986109
#47 implemented basic gui for browsing repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1312
diff
changeset
|
307 :param all_repos: list of repository names as strings |
a04fe5986109
#47 implemented basic gui for browsing repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1312
diff
changeset
|
308 give specific repositories list, good for filtering |
2604
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
309 |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
310 :param sort_key: initial sorting of repos |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
311 :param simple: use SimpleCachedList - one without the SCM info |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
312 """ |
767
632b0761e617
bugfix, when user had no repos he would see all repos in my account, (correct commit)
Marcin Kuzminski <marcin@python-works.com>
parents:
758
diff
changeset
|
313 if all_repos is None: |
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:
1343
diff
changeset
|
314 all_repos = self.sa.query(Repository)\ |
1343
a04fe5986109
#47 implemented basic gui for browsing repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1312
diff
changeset
|
315 .filter(Repository.group_id == None)\ |
2354
f3417f0d54b5
fixed default sorting on main page with sorting using wrapped lower() call on database level
Marcin Kuzminski <marcin@python-works.com>
parents:
2352
diff
changeset
|
316 .order_by(func.lower(Repository.repo_name)).all() |
2604
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
317 if simple: |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
318 repo_iter = SimpleCachedRepoList(all_repos, |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
319 repos_path=self.repos_path, |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
320 order_by=sort_key) |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
321 else: |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
322 repo_iter = CachedRepoList(all_repos, |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
323 repos_path=self.repos_path, |
dfa5180cf02f
Use simplified cached repos list for quick repo switcher, in some cases it can have 2-3x speed-up since it doesn't need to init the scms
Marcin Kuzminski <marcin@python-works.com>
parents:
2520
diff
changeset
|
324 order_by=sort_key) |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
325 |
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:
1343
diff
changeset
|
326 return repo_iter |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
327 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
328 def get_repo_groups(self, all_groups=None): |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
329 if all_groups is None: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
330 all_groups = RepoGroup.query()\ |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
331 .filter(RepoGroup.group_parent_id == None).all() |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3685
diff
changeset
|
332 return [x for x in RepoGroupList(all_groups)] |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1925
diff
changeset
|
333 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
334 def mark_for_invalidation(self, repo_name, delete=False): |
2147
d25bd432bc3e
- #347 when running multiple RhodeCode instances, properly invalidates cache
Marcin Kuzminski <marcin@python-works.com>
parents:
2109
diff
changeset
|
335 """ |
3682
cf65b2c1b69d
invalidation: some documentation and refactoring, second round
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
336 Mark caches of this repo invalid in the database. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1193
diff
changeset
|
337 |
3682
cf65b2c1b69d
invalidation: some documentation and refactoring, second round
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
338 :param repo_name: the repo for which caches should be marked invalid |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
339 """ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
340 CacheInvalidation.set_invalidate(repo_name, delete=delete) |
3150
80abc924a38c
always update changeset cache after invalidation signal
Marcin Kuzminski <marcin@python-works.com>
parents:
3090
diff
changeset
|
341 repo = Repository.get_by_repo_name(repo_name) |
80abc924a38c
always update changeset cache after invalidation signal
Marcin Kuzminski <marcin@python-works.com>
parents:
3090
diff
changeset
|
342 if repo: |
80abc924a38c
always update changeset cache after invalidation signal
Marcin Kuzminski <marcin@python-works.com>
parents:
3090
diff
changeset
|
343 repo.update_changeset_cache() |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
344 |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
345 def toggle_following_repo(self, follow_repo_id, user_id): |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
346 |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
347 f = self.sa.query(UserFollowing)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
348 .filter(UserFollowing.follows_repo_id == follow_repo_id)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
349 .filter(UserFollowing.user_id == user_id).scalar() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
350 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
351 if f is not None: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
352 try: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
353 self.sa.delete(f) |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
354 action_logger(UserTemp(user_id), |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
355 'stopped_following_repo', |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
356 RepoTemp(follow_repo_id)) |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
357 return |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3589
diff
changeset
|
358 except Exception: |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
359 log.error(traceback.format_exc()) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
360 raise |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
361 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
362 try: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
363 f = UserFollowing() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
364 f.user_id = user_id |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
365 f.follows_repo_id = follow_repo_id |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
366 self.sa.add(f) |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
367 |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
368 action_logger(UserTemp(user_id), |
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
734
diff
changeset
|
369 'started_following_repo', |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
370 RepoTemp(follow_repo_id)) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3589
diff
changeset
|
371 except Exception: |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
372 log.error(traceback.format_exc()) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
373 raise |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
374 |
1213
68e34f5cf122
#150 fixes for errors on repositories mapped in db but corrupted in filesystem
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
375 def toggle_following_user(self, follow_user_id, user_id): |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
376 f = self.sa.query(UserFollowing)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
377 .filter(UserFollowing.follows_user_id == follow_user_id)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
378 .filter(UserFollowing.user_id == user_id).scalar() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
379 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
380 if f is not None: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
381 try: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
382 self.sa.delete(f) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
383 return |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3589
diff
changeset
|
384 except Exception: |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
385 log.error(traceback.format_exc()) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
386 raise |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
387 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
388 try: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
389 f = UserFollowing() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
390 f.user_id = user_id |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
391 f.follows_user_id = follow_user_id |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
392 self.sa.add(f) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3589
diff
changeset
|
393 except Exception: |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
394 log.error(traceback.format_exc()) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
395 raise |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
396 |
999
1951c35483ab
fixed following js snipet. It' can be called multiple times now next to each repository
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
397 def is_following_repo(self, repo_name, user_id, cache=False): |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
398 r = self.sa.query(Repository)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
399 .filter(Repository.repo_name == repo_name).scalar() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
400 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
401 f = self.sa.query(UserFollowing)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
402 .filter(UserFollowing.follows_repository == r)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
403 .filter(UserFollowing.user_id == user_id).scalar() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
404 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
405 return f is not None |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
406 |
999
1951c35483ab
fixed following js snipet. It' can be called multiple times now next to each repository
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
407 def is_following_user(self, username, user_id, cache=False): |
1530
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1508
diff
changeset
|
408 u = User.get_by_username(username) |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
409 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
410 f = self.sa.query(UserFollowing)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
411 .filter(UserFollowing.follows_user == u)\ |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
412 .filter(UserFollowing.user_id == user_id).scalar() |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
413 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
726
diff
changeset
|
414 return f is not None |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
415 |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
416 def get_followers(self, repo): |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
417 repo = self._get_repo(repo) |
1282
faaadfc3c359
fixed condition evaluated for gitrepo that returned null, simplified scm functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1265
diff
changeset
|
418 |
faaadfc3c359
fixed condition evaluated for gitrepo that returned null, simplified scm functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1265
diff
changeset
|
419 return self.sa.query(UserFollowing)\ |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
420 .filter(UserFollowing.follows_repository == repo).count() |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
421 |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
422 def get_forks(self, repo): |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
423 repo = self._get_repo(repo) |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
424 return self.sa.query(Repository)\ |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
425 .filter(Repository.fork == repo).count() |
1282
faaadfc3c359
fixed condition evaluated for gitrepo that returned null, simplified scm functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1265
diff
changeset
|
426 |
2440
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
427 def get_pull_requests(self, repo): |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
428 repo = self._get_repo(repo) |
1bc579bcd67a
- pull request generates overview based on it's params
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
429 return self.sa.query(PullRequest)\ |
3580
7b9d4f6bb04e
show only open pull requests in the counter, and use repo context bar in pull requests view
Marcin Kuzminski <marcin@python-works.com>
parents:
3577
diff
changeset
|
430 .filter(PullRequest.other_repo == repo)\ |
7b9d4f6bb04e
show only open pull requests in the counter, and use repo context bar in pull requests view
Marcin Kuzminski <marcin@python-works.com>
parents:
3577
diff
changeset
|
431 .filter(PullRequest.status != PullRequest.STATUS_CLOSED).count() |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
432 |
1755
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
433 def mark_as_fork(self, repo, fork, user): |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
434 repo = self.__get_repo(repo) |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
435 fork = self.__get_repo(fork) |
2629
d2901d906ef3
Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2620
diff
changeset
|
436 if fork and repo.repo_id == fork.repo_id: |
d2901d906ef3
Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2620
diff
changeset
|
437 raise Exception("Cannot set repository as fork of itself") |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
438 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
439 if fork and repo.repo_type != fork.repo_type: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
440 raise RepositoryError("Cannot set repository as fork of repository with other type") |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
441 |
1755
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
442 repo.fork = fork |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
443 self.sa.add(repo) |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
444 return repo |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
445 |
3878
7d29355db6f4
fixes #834 hooks error on remote pulling
Marcin Kuzminski <marcin@python-works.com>
parents:
3864
diff
changeset
|
446 def _handle_rc_scm_extras(self, username, repo_name, repo_alias, |
7d29355db6f4
fixes #834 hooks error on remote pulling
Marcin Kuzminski <marcin@python-works.com>
parents:
3864
diff
changeset
|
447 action=None): |
3826
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
448 from rhodecode import CONFIG |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
449 from rhodecode.lib.base import _get_ip_addr |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
450 try: |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
451 from pylons import request |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
452 environ = request.environ |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
453 except TypeError: |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
454 # we might use this outside of request context, let's fake the |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
455 # environ data |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
456 from webob import Request |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
457 environ = Request.blank('').environ |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
458 extras = { |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
459 'ip': _get_ip_addr(environ), |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
460 'username': username, |
3878
7d29355db6f4
fixes #834 hooks error on remote pulling
Marcin Kuzminski <marcin@python-works.com>
parents:
3864
diff
changeset
|
461 'action': action or 'push_local', |
3826
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
462 'repository': repo_name, |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
463 'scm': repo_alias, |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
464 'config': CONFIG['__file__'], |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
465 'server_url': get_server_url(environ), |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
466 'make_lock': None, |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
467 'locked_by': [None, None] |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
468 } |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
469 _set_extras(extras) |
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
470 |
3481
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
471 def _handle_push(self, repo, username, action, repo_name, revisions): |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
472 """ |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
473 Triggers push action hooks |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
474 |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
475 :param repo: SCM repo |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
476 :param username: username who pushes |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
477 :param action: push/push_loca/push_remote |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
478 :param repo_name: name of repo |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
479 :param revisions: list of revisions that we pushed |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
480 """ |
3826
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
481 self._handle_rc_scm_extras(username, repo_name, repo_alias=repo.alias) |
3478
796738bb697c
webinterface file commiting executes push hooks ref #594
Marcin Kuzminski <marcin@python-works.com>
parents:
3418
diff
changeset
|
482 _scm_repo = repo._repo |
3826
00e2c162d8bc
move out setting rc_extras for in-memory-push handlers to separate function
Marcin Kuzminski <marcin@python-works.com>
parents:
3772
diff
changeset
|
483 # trigger push hook |
3481
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
484 if repo.alias == 'hg': |
3478
796738bb697c
webinterface file commiting executes push hooks ref #594
Marcin Kuzminski <marcin@python-works.com>
parents:
3418
diff
changeset
|
485 log_push_action(_scm_repo.ui, _scm_repo, node=revisions[0]) |
3481
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
486 elif repo.alias == 'git': |
3589
35454cd8233b
kill depracated .ui objects on git repos
Marcin Kuzminski <marcin@python-works.com>
parents:
3580
diff
changeset
|
487 log_push_action(None, _scm_repo, _git_revs=revisions) |
3478
796738bb697c
webinterface file commiting executes push hooks ref #594
Marcin Kuzminski <marcin@python-works.com>
parents:
3418
diff
changeset
|
488 |
3481
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
489 def _get_IMC_module(self, scm_type): |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
490 """ |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
491 Returns InMemoryCommit class based on scm_type |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
492 |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
493 :param scm_type: |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
494 """ |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
495 if scm_type == 'hg': |
3952 | 496 from rhodecode.lib.vcs.backends.hg import MercurialInMemoryChangeset |
497 return MercurialInMemoryChangeset | |
498 | |
499 if scm_type == 'git': | |
500 from rhodecode.lib.vcs.backends.git import GitInMemoryChangeset | |
501 return GitInMemoryChangeset | |
502 | |
503 raise Exception('Invalid scm_type, must be one of hg,git got %s' | |
504 % (scm_type,)) | |
3481
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
505 |
2514
9b734e9530c2
fixed pull method repo lookup
Marcin Kuzminski <marcin@python-works.com>
parents:
2462
diff
changeset
|
506 def pull_changes(self, repo, username): |
9b734e9530c2
fixed pull method repo lookup
Marcin Kuzminski <marcin@python-works.com>
parents:
2462
diff
changeset
|
507 dbrepo = self.__get_repo(repo) |
1508
4aba7be311e8
API added checks for a valid repository on pull command
Marcin Kuzminski <marcin@python-works.com>
parents:
1485
diff
changeset
|
508 clone_uri = dbrepo.clone_uri |
4aba7be311e8
API added checks for a valid repository on pull command
Marcin Kuzminski <marcin@python-works.com>
parents:
1485
diff
changeset
|
509 if not clone_uri: |
4aba7be311e8
API added checks for a valid repository on pull command
Marcin Kuzminski <marcin@python-works.com>
parents:
1485
diff
changeset
|
510 raise Exception("This repository doesn't have a clone uri") |
1530
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1508
diff
changeset
|
511 |
1370
ef9a30e22ea6
Fixed remote pull command from todays code refactoring
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
512 repo = dbrepo.scm_instance |
3478
796738bb697c
webinterface file commiting executes push hooks ref #594
Marcin Kuzminski <marcin@python-works.com>
parents:
3418
diff
changeset
|
513 repo_name = dbrepo.repo_name |
1114
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
514 try: |
2383
e576410f911d
Don't do git pull on remote repos since they are bare now, we need to use git fetch on them
Marcin Kuzminski <marcin@python-works.com>
parents:
2354
diff
changeset
|
515 if repo.alias == 'git': |
e576410f911d
Don't do git pull on remote repos since they are bare now, we need to use git fetch on them
Marcin Kuzminski <marcin@python-works.com>
parents:
2354
diff
changeset
|
516 repo.fetch(clone_uri) |
3880
a228a33d868e
Fake post-push actions when doing git fetch. It's still want show
Marcin Kuzminski <marcin@python-works.com>
parents:
3878
diff
changeset
|
517 # git doesn't really have something like post-fetch action |
a228a33d868e
Fake post-push actions when doing git fetch. It's still want show
Marcin Kuzminski <marcin@python-works.com>
parents:
3878
diff
changeset
|
518 # we fake that now. #TODO: extract fetched revisions somehow |
a228a33d868e
Fake post-push actions when doing git fetch. It's still want show
Marcin Kuzminski <marcin@python-works.com>
parents:
3878
diff
changeset
|
519 # here |
a228a33d868e
Fake post-push actions when doing git fetch. It's still want show
Marcin Kuzminski <marcin@python-works.com>
parents:
3878
diff
changeset
|
520 self._handle_push(repo, |
a228a33d868e
Fake post-push actions when doing git fetch. It's still want show
Marcin Kuzminski <marcin@python-works.com>
parents:
3878
diff
changeset
|
521 username=username, |
a228a33d868e
Fake post-push actions when doing git fetch. It's still want show
Marcin Kuzminski <marcin@python-works.com>
parents:
3878
diff
changeset
|
522 action='push_remote', |
a228a33d868e
Fake post-push actions when doing git fetch. It's still want show
Marcin Kuzminski <marcin@python-works.com>
parents:
3878
diff
changeset
|
523 repo_name=repo_name, |
a228a33d868e
Fake post-push actions when doing git fetch. It's still want show
Marcin Kuzminski <marcin@python-works.com>
parents:
3878
diff
changeset
|
524 revisions=[]) |
2383
e576410f911d
Don't do git pull on remote repos since they are bare now, we need to use git fetch on them
Marcin Kuzminski <marcin@python-works.com>
parents:
2354
diff
changeset
|
525 else: |
3878
7d29355db6f4
fixes #834 hooks error on remote pulling
Marcin Kuzminski <marcin@python-works.com>
parents:
3864
diff
changeset
|
526 self._handle_rc_scm_extras(username, dbrepo.repo_name, |
7d29355db6f4
fixes #834 hooks error on remote pulling
Marcin Kuzminski <marcin@python-works.com>
parents:
3864
diff
changeset
|
527 repo.alias, action='push_remote') |
2383
e576410f911d
Don't do git pull on remote repos since they are bare now, we need to use git fetch on them
Marcin Kuzminski <marcin@python-works.com>
parents:
2354
diff
changeset
|
528 repo.pull(clone_uri) |
3878
7d29355db6f4
fixes #834 hooks error on remote pulling
Marcin Kuzminski <marcin@python-works.com>
parents:
3864
diff
changeset
|
529 |
3478
796738bb697c
webinterface file commiting executes push hooks ref #594
Marcin Kuzminski <marcin@python-works.com>
parents:
3418
diff
changeset
|
530 self.mark_for_invalidation(repo_name) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3589
diff
changeset
|
531 except Exception: |
1114
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
532 log.error(traceback.format_exc()) |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
533 raise |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
534 |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
535 def commit_change(self, repo, repo_name, cs, user, author, message, |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
536 content, f_path): |
2684
2b6939a77052
Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents:
2672
diff
changeset
|
537 """ |
2b6939a77052
Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents:
2672
diff
changeset
|
538 Commits changes |
2b6939a77052
Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents:
2672
diff
changeset
|
539 |
2b6939a77052
Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents:
2672
diff
changeset
|
540 :param repo: SCM instance |
2b6939a77052
Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents:
2672
diff
changeset
|
541 |
2b6939a77052
Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents:
2672
diff
changeset
|
542 """ |
3481
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
543 user = self._get_user(user) |
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
544 IMC = self._get_IMC_module(repo.alias) |
1311
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
545 |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
546 # decoding here will force that we have proper encoded values |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
547 # in any other case this will throw exceptions and deny commit |
1401
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1380
diff
changeset
|
548 content = safe_str(content) |
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1380
diff
changeset
|
549 path = safe_str(f_path) |
2199
31ebf7010566
various fixes for git and mercurial with InMemoryCommit backend and non-ascii files
Marcin Kuzminski <marcin@python-works.com>
parents:
2147
diff
changeset
|
550 # message and author needs to be unicode |
31ebf7010566
various fixes for git and mercurial with InMemoryCommit backend and non-ascii files
Marcin Kuzminski <marcin@python-works.com>
parents:
2147
diff
changeset
|
551 # proper backend should then translate that into required type |
31ebf7010566
various fixes for git and mercurial with InMemoryCommit backend and non-ascii files
Marcin Kuzminski <marcin@python-works.com>
parents:
2147
diff
changeset
|
552 message = safe_unicode(message) |
31ebf7010566
various fixes for git and mercurial with InMemoryCommit backend and non-ascii files
Marcin Kuzminski <marcin@python-works.com>
parents:
2147
diff
changeset
|
553 author = safe_unicode(author) |
3836
14a6e9ffd9c8
fixed issue with web-editor that didn't preserve executable bit
Marcin Kuzminski <marcin@python-works.com>
parents:
3826
diff
changeset
|
554 imc = IMC(repo) |
14a6e9ffd9c8
fixed issue with web-editor that didn't preserve executable bit
Marcin Kuzminski <marcin@python-works.com>
parents:
3826
diff
changeset
|
555 imc.change(FileNode(path, content, mode=cs.get_file_mode(f_path))) |
4070
008e460c5b9d
fixes issue #860.
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
556 try: |
008e460c5b9d
fixes issue #860.
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
557 tip = imc.commit(message=message, author=author, |
008e460c5b9d
fixes issue #860.
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
558 parents=[cs], branch=cs.branch) |
008e460c5b9d
fixes issue #860.
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
559 except Exception, e: |
008e460c5b9d
fixes issue #860.
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
560 log.error(traceback.format_exc()) |
008e460c5b9d
fixes issue #860.
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
561 raise IMCCommitError(str(e)) |
008e460c5b9d
fixes issue #860.
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
562 finally: |
008e460c5b9d
fixes issue #860.
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
563 # always clear caches, if commit fails we want fresh object also |
008e460c5b9d
fixes issue #860.
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
564 self.mark_for_invalidation(repo_name) |
3478
796738bb697c
webinterface file commiting executes push hooks ref #594
Marcin Kuzminski <marcin@python-works.com>
parents:
3418
diff
changeset
|
565 self._handle_push(repo, |
796738bb697c
webinterface file commiting executes push hooks ref #594
Marcin Kuzminski <marcin@python-works.com>
parents:
3418
diff
changeset
|
566 username=user.username, |
796738bb697c
webinterface file commiting executes push hooks ref #594
Marcin Kuzminski <marcin@python-works.com>
parents:
3418
diff
changeset
|
567 action='push_local', |
796738bb697c
webinterface file commiting executes push hooks ref #594
Marcin Kuzminski <marcin@python-works.com>
parents:
3418
diff
changeset
|
568 repo_name=repo_name, |
796738bb697c
webinterface file commiting executes push hooks ref #594
Marcin Kuzminski <marcin@python-works.com>
parents:
3418
diff
changeset
|
569 revisions=[tip.raw_id]) |
2684
2b6939a77052
Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents:
2672
diff
changeset
|
570 return tip |
1311
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1282
diff
changeset
|
571 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
572 def _sanitize_path(self, f_path): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
573 if f_path.startswith('/') or f_path.startswith('.') or '../' in f_path: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
574 raise NonRelativePathError('%s is not an relative path' % f_path) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
575 if f_path: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
576 f_path = os.path.normpath(f_path) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
577 return f_path |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
578 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
579 def get_nodes(self, repo_name, revision, root_path='/', flat=True): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
580 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
581 recursive walk in root dir and return a set of all path in that dir |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
582 based on repository walk function |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
583 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
584 :param repo_name: name of repository |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
585 :param revision: revision for which to list nodes |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
586 :param root_path: root path to list |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
587 :param flat: return as a list, if False returns a dict with decription |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
588 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
589 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
590 _files = list() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
591 _dirs = list() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
592 try: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
593 _repo = self.__get_repo(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
594 changeset = _repo.scm_instance.get_changeset(revision) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
595 root_path = root_path.lstrip('/') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
596 for topnode, dirs, files in changeset.walk(root_path): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
597 for f in files: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
598 _files.append(f.path if flat else {"name": f.path, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
599 "type": "file"}) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
600 for d in dirs: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
601 _dirs.append(d.path if flat else {"name": d.path, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
602 "type": "dir"}) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
603 except RepositoryError: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
604 log.debug(traceback.format_exc()) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
605 raise |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
606 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
607 return _dirs, _files |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
608 |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
609 def create_nodes(self, user, repo, message, nodes, parent_cs=None, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
610 author=None, trigger_push_hook=True): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
611 """ |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
612 Commits given multiple nodes into repo |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
613 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
614 :param user: RhodeCode User object or user_id, the commiter |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
615 :param repo: RhodeCode Repository object |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
616 :param message: commit message |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
617 :param nodes: mapping {filename:{'content':content},...} |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
618 :param parent_cs: parent changeset, can be empty than it's initial commit |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
619 :param author: author of commit, cna be different that commiter only for git |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
620 :param trigger_push_hook: trigger push hooks |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
621 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
622 :returns: new commited changeset |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
623 """ |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
624 |
3481
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
625 user = self._get_user(user) |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
626 scm_instance = repo.scm_instance_no_cache() |
3481
c9214877d43e
If commit operation is used out of pylons request scope use blank request instead
Marcin Kuzminski <marcin@python-works.com>
parents:
3478
diff
changeset
|
627 |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
628 processed_nodes = [] |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
629 for f_path in nodes: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
630 f_path = self._sanitize_path(f_path) |
3912
91f440a11b94
fixes issues #849 IMC failed for non-ascii files
Marcin Kuzminski <marcin@python-works.com>
parents:
3880
diff
changeset
|
631 content = nodes[f_path]['content'] |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
632 f_path = safe_str(f_path) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
633 # decoding here will force that we have proper encoded values |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
634 # in any other case this will throw exceptions and deny commit |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
635 if isinstance(content, (basestring,)): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
636 content = safe_str(content) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
637 elif isinstance(content, (file, cStringIO.OutputType,)): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
638 content = content.read() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
639 else: |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
640 raise Exception('Content is of unrecognized type %s' % ( |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
641 type(content) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
642 )) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
643 processed_nodes.append((f_path, content)) |
1530
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1508
diff
changeset
|
644 |
2199
31ebf7010566
various fixes for git and mercurial with InMemoryCommit backend and non-ascii files
Marcin Kuzminski <marcin@python-works.com>
parents:
2147
diff
changeset
|
645 message = safe_unicode(message) |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
646 commiter = user.full_contact |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
647 author = safe_unicode(author) if author else commiter |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1459
diff
changeset
|
648 |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
649 IMC = self._get_IMC_module(scm_instance.alias) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
650 imc = IMC(scm_instance) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
651 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
652 if not parent_cs: |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
653 parent_cs = EmptyChangeset(alias=scm_instance.alias) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
654 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
655 if isinstance(parent_cs, EmptyChangeset): |
2199
31ebf7010566
various fixes for git and mercurial with InMemoryCommit backend and non-ascii files
Marcin Kuzminski <marcin@python-works.com>
parents:
2147
diff
changeset
|
656 # EmptyChangeset means we we're editing empty repository |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1459
diff
changeset
|
657 parents = None |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1459
diff
changeset
|
658 else: |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
659 parents = [parent_cs] |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
660 # add multiple nodes |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
661 for path, content in processed_nodes: |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
662 imc.add(FileNode(path, content=content)) |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1459
diff
changeset
|
663 |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
664 tip = imc.commit(message=message, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
665 author=author, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
666 parents=parents, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
667 branch=parent_cs.branch) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
668 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
669 self.mark_for_invalidation(repo.repo_name) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
670 if trigger_push_hook: |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
671 self._handle_push(scm_instance, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
672 username=user.username, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
673 action='push_local', |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
674 repo_name=repo.repo_name, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
3836
diff
changeset
|
675 revisions=[tip.raw_id]) |
2684
2b6939a77052
Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents:
2672
diff
changeset
|
676 return tip |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1459
diff
changeset
|
677 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
678 def update_nodes(self, user, repo, message, nodes, parent_cs=None, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
679 author=None, trigger_push_hook=True): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
680 user = self._get_user(user) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
681 scm_instance = repo.scm_instance_no_cache() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
682 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
683 message = safe_unicode(message) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
684 commiter = user.full_contact |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
685 author = safe_unicode(author) if author else commiter |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
686 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
687 imc_class = self._get_IMC_module(scm_instance.alias) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
688 imc = imc_class(scm_instance) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
689 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
690 if not parent_cs: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
691 parent_cs = EmptyChangeset(alias=scm_instance.alias) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
692 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
693 if isinstance(parent_cs, EmptyChangeset): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
694 # EmptyChangeset means we we're editing empty repository |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
695 parents = None |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
696 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
697 parents = [parent_cs] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
698 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
699 # add multiple nodes |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
700 for _filename, data in nodes.items(): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
701 # new filename, can be renamed from the old one |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
702 filename = self._sanitize_path(data['filename']) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
703 old_filename = self._sanitize_path(_filename) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
704 content = data['content'] |
1810
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1801
diff
changeset
|
705 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
706 filenode = FileNode(old_filename, content=content) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
707 op = data['op'] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
708 if op == 'add': |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
709 imc.add(filenode) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
710 elif op == 'del': |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
711 imc.remove(filenode) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
712 elif op == 'mod': |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
713 if filename != old_filename: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
714 #TODO: handle renames, needs vcs lib changes |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
715 imc.remove(filenode) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
716 imc.add(FileNode(filename, content=content)) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
717 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
718 imc.change(filenode) |
1810
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1801
diff
changeset
|
719 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
720 # commit changes |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
721 tip = imc.commit(message=message, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
722 author=author, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
723 parents=parents, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
724 branch=parent_cs.branch) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
725 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
726 self.mark_for_invalidation(repo.repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
727 if trigger_push_hook: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
728 self._handle_push(scm_instance, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
729 username=user.username, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
730 action='push_local', |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
731 repo_name=repo.repo_name, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
732 revisions=[tip.raw_id]) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
733 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
734 def delete_nodes(self, user, repo, message, nodes, parent_cs=None, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
735 author=None, trigger_push_hook=True): |
1810
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1801
diff
changeset
|
736 """ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
737 Deletes given multiple nodes into repo |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
738 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
739 :param user: RhodeCode User object or user_id, the commiter |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
740 :param repo: RhodeCode Repository object |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
741 :param message: commit message |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
742 :param nodes: mapping {filename:{'content':content},...} |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
743 :param parent_cs: parent changeset, can be empty than it's initial commit |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
744 :param author: author of commit, cna be different that commiter only for git |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
745 :param trigger_push_hook: trigger push hooks |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
746 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
747 :returns: new commited changeset after deletion |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
748 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
749 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
750 user = self._get_user(user) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
751 scm_instance = repo.scm_instance_no_cache() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
752 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
753 processed_nodes = [] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
754 for f_path in nodes: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
755 f_path = self._sanitize_path(f_path) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
756 # content can be empty but for compatabilty it allows same dicts |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
757 # structure as add_nodes |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
758 content = nodes[f_path].get('content') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
759 processed_nodes.append((f_path, content)) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
760 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
761 message = safe_unicode(message) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
762 commiter = user.full_contact |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
763 author = safe_unicode(author) if author else commiter |
1810
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1801
diff
changeset
|
764 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
765 IMC = self._get_IMC_module(scm_instance.alias) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
766 imc = IMC(scm_instance) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
767 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
768 if not parent_cs: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
769 parent_cs = EmptyChangeset(alias=scm_instance.alias) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
770 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
771 if isinstance(parent_cs, EmptyChangeset): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
772 # EmptyChangeset means we we're editing empty repository |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
773 parents = None |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
774 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
775 parents = [parent_cs] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
776 # add multiple nodes |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
777 for path, content in processed_nodes: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
778 imc.remove(FileNode(path, content=content)) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
779 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
780 tip = imc.commit(message=message, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
781 author=author, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
782 parents=parents, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
783 branch=parent_cs.branch) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
784 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
785 self.mark_for_invalidation(repo.repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
786 if trigger_push_hook: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
787 self._handle_push(scm_instance, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
788 username=user.username, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
789 action='push_local', |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
790 repo_name=repo.repo_name, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
791 revisions=[tip.raw_id]) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
792 return tip |
1810
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1801
diff
changeset
|
793 |
784
30d3161c6683
Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
767
diff
changeset
|
794 def get_unread_journal(self): |
30d3161c6683
Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
767
diff
changeset
|
795 return self.sa.query(UserLog).count() |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
796 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
797 def get_repo_landing_revs(self, repo=None): |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
798 """ |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
799 Generates select option with tags branches and bookmarks (for hg only) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
800 grouped by type |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
801 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
802 :param repo: |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
803 """ |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
804 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
805 hist_l = [] |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
806 choices = [] |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
807 repo = self.__get_repo(repo) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
808 hist_l.append(['rev:tip', _('latest tip')]) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
809 choices.append('rev:tip') |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
810 if not repo: |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
811 return choices, hist_l |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
812 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
813 repo = repo.scm_instance |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
814 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
815 branches_group = ([(u'branch:%s' % k, k) for k, v in |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
816 repo.branches.iteritems()], _("Branches")) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
817 hist_l.append(branches_group) |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
818 choices.extend([x[0] for x in branches_group[0]]) |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
819 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
820 if repo.alias == 'hg': |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
821 bookmarks_group = ([(u'book:%s' % k, k) for k, v in |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
822 repo.bookmarks.iteritems()], _("Bookmarks")) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
823 hist_l.append(bookmarks_group) |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
824 choices.extend([x[0] for x in bookmarks_group[0]]) |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
825 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4089
diff
changeset
|
826 tags_group = ([(u'tag:%s' % k, k) for k, v in |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
827 repo.tags.iteritems()], _("Tags")) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
828 hist_l.append(tags_group) |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
829 choices.extend([x[0] for x in tags_group[0]]) |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2383
diff
changeset
|
830 |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
831 return choices, hist_l |
2618
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
832 |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
833 def install_git_hook(self, repo, force_create=False): |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
834 """ |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
835 Creates a rhodecode hook inside a git repository |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
836 |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
837 :param repo: Instance of VCS repo |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
838 :param force_create: Create even if same name hook exists |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
839 """ |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
840 |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
841 loc = jn(repo.path, 'hooks') |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
842 if not repo.bare: |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
843 loc = jn(repo.path, '.git', 'hooks') |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
844 if not os.path.isdir(loc): |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
845 os.makedirs(loc) |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
846 |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
847 tmpl_post = pkg_resources.resource_string( |
2618
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
848 'rhodecode', jn('config', 'post_receive_tmpl.py') |
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
849 ) |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
850 tmpl_pre = pkg_resources.resource_string( |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
851 'rhodecode', jn('config', 'pre_receive_tmpl.py') |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
852 ) |
2618
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
853 |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
854 for h_type, tmpl in [('pre', tmpl_pre), ('post', tmpl_post)]: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
855 _hook_file = jn(loc, '%s-receive' % h_type) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
856 _rhodecode_hook = False |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
857 log.debug('Installing git hook in repo %s' % repo) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
858 if os.path.exists(_hook_file): |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
859 # let's take a look at this hook, maybe it's rhodecode ? |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
860 log.debug('hook exists, checking if it is from rhodecode') |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
861 with open(_hook_file, 'rb') as f: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
862 data = f.read() |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
863 matches = re.compile(r'(?:%s)\s*=\s*(.*)' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
864 % 'RC_HOOK_VER').search(data) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
865 if matches: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
866 try: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
867 ver = matches.groups()[0] |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
868 log.debug('got %s it is rhodecode' % (ver)) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
869 _rhodecode_hook = True |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3589
diff
changeset
|
870 except Exception: |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
871 log.error(traceback.format_exc()) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
872 else: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
873 # there is no hook in this dir, so we want to create one |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
874 _rhodecode_hook = True |
2618
e1370dcb9908
Created install_git_hook more verbose version of previos code.
Marcin Kuzminski <marcin@python-works.com>
parents:
2604
diff
changeset
|
875 |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
876 if _rhodecode_hook or force_create: |
3952 | 877 log.debug('writing %s hook file !' % (h_type,)) |
3980
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
878 try: |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
879 with open(_hook_file, 'wb') as f: |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
880 tmpl = tmpl.replace('_TMPL_', rhodecode.__version__) |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
881 f.write(tmpl) |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
882 os.chmod(_hook_file, 0755) |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
883 except IOError, e: |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
884 log.error('error writing %s: %s' % (_hook_file, e)) |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
885 else: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2684
diff
changeset
|
886 log.debug('skipping writing hook file') |