Show More
@@ -98,7 +98,7 b' class FilesController(BaseRepoController' | |||
|
98 | 98 | #reditect to given revision from form if given |
|
99 | 99 | post_revision = request.POST.get('at_rev', None) |
|
100 | 100 | if post_revision: |
|
101 | cs = self.__get_cs_or_redirect(revision, repo_name) | |
|
101 | cs = self.__get_cs_or_redirect(post_revision, repo_name) | |
|
102 | 102 | redirect(url('files_home', repo_name=c.repo_name, |
|
103 | 103 | revision=cs.raw_id, f_path=f_path)) |
|
104 | 104 | |
@@ -213,14 +213,14 b' class FilesController(BaseRepoController' | |||
|
213 | 213 | c.changeset_1 = c.rhodecode_repo.get_changeset(diff1) |
|
214 | 214 | node1 = c.changeset_1.get_node(f_path) |
|
215 | 215 | else: |
|
216 | c.changeset_1 = EmptyChangeset() | |
|
216 | c.changeset_1 = EmptyChangeset(repo=c.rhodecode_repo) | |
|
217 | 217 | node1 = FileNode('.', '', changeset=c.changeset_1) |
|
218 | 218 | |
|
219 | 219 | if diff2 not in ['', None, 'None', '0' * 12, '0' * 40]: |
|
220 | 220 | c.changeset_2 = c.rhodecode_repo.get_changeset(diff2) |
|
221 | 221 | node2 = c.changeset_2.get_node(f_path) |
|
222 | 222 | else: |
|
223 | c.changeset_2 = EmptyChangeset() | |
|
223 | c.changeset_2 = EmptyChangeset(repo=c.rhodecode_repo) | |
|
224 | 224 | node2 = FileNode('.', '', changeset=c.changeset_2) |
|
225 | 225 | except RepositoryError: |
|
226 | 226 | return redirect(url('files_home', |
@@ -68,6 +68,7 b" def recursive_replace(str, replace=' '):" | |||
|
68 | 68 | str = str.replace(replace * 2, replace) |
|
69 | 69 | return recursive_replace(str, replace) |
|
70 | 70 | |
|
71 | ||
|
71 | 72 | def repo_name_slug(value): |
|
72 | 73 | """Return slug of name of repository |
|
73 | 74 | This function is called on each creation/modification |
@@ -83,9 +84,11 b' def repo_name_slug(value):' | |||
|
83 | 84 | slug = collapse(slug, '-') |
|
84 | 85 | return slug |
|
85 | 86 | |
|
87 | ||
|
86 | 88 | def get_repo_slug(request): |
|
87 | 89 | return request.environ['pylons.routes_dict'].get('repo_name') |
|
88 | 90 | |
|
91 | ||
|
89 | 92 | def action_logger(user, action, repo, ipaddr='', sa=None): |
|
90 | 93 | """ |
|
91 | 94 | Action logger for various actions made by users |
@@ -113,7 +116,6 b' def action_logger(user, action, repo, ip' | |||
|
113 | 116 | else: |
|
114 | 117 | raise Exception('You have to provide user object or username') |
|
115 | 118 | |
|
116 | ||
|
117 | 119 | rm = RepoModel() |
|
118 | 120 | if hasattr(repo, 'repo_id'): |
|
119 | 121 | repo_obj = rm.get(repo.repo_id, cache=False) |
@@ -124,7 +126,6 b' def action_logger(user, action, repo, ip' | |||
|
124 | 126 | else: |
|
125 | 127 | raise Exception('You have to provide repository to action logger') |
|
126 | 128 | |
|
127 | ||
|
128 | 129 | user_log = UserLog() |
|
129 | 130 | user_log.user_id = user_obj.user_id |
|
130 | 131 | user_log.action = action |
@@ -142,6 +143,7 b' def action_logger(user, action, repo, ip' | |||
|
142 | 143 | log.error(traceback.format_exc()) |
|
143 | 144 | sa.rollback() |
|
144 | 145 | |
|
146 | ||
|
145 | 147 | def get_repos(path, recursive=False): |
|
146 | 148 | """ |
|
147 | 149 | Scans given path for repos and return (name,(type,path)) tuple |
@@ -178,6 +180,7 b' def get_repos(path, recursive=False):' | |||
|
178 | 180 | |
|
179 | 181 | return _get_repos(path) |
|
180 | 182 | |
|
183 | ||
|
181 | 184 | def check_repo_fast(repo_name, base_path): |
|
182 | 185 | """ |
|
183 | 186 | Check given path for existence of directory |
@@ -186,9 +189,11 b' def check_repo_fast(repo_name, base_path' | |||
|
186 | 189 | |
|
187 | 190 | :return False: if this directory is present |
|
188 | 191 | """ |
|
189 |
if os.path.isdir(os.path.join(base_path, repo_name)): |
|
|
192 | if os.path.isdir(os.path.join(base_path, repo_name)): | |
|
193 | return False | |
|
190 | 194 | return True |
|
191 | 195 | |
|
196 | ||
|
192 | 197 | def check_repo(repo_name, base_path, verify=True): |
|
193 | 198 | |
|
194 | 199 | repo_path = os.path.join(base_path, repo_name) |
@@ -207,13 +212,17 b' def check_repo(repo_name, base_path, ver' | |||
|
207 | 212 | log.info('%s repo is free for creation', repo_name) |
|
208 | 213 | return True |
|
209 | 214 | |
|
215 | ||
|
210 | 216 | def ask_ok(prompt, retries=4, complaint='Yes or no, please!'): |
|
211 | 217 | while True: |
|
212 | 218 | ok = raw_input(prompt) |
|
213 |
if ok in ('y', 'ye', 'yes'): |
|
|
214 | if ok in ('n', 'no', 'nop', 'nope'): return False | |
|
219 | if ok in ('y', 'ye', 'yes'): | |
|
220 | return True | |
|
221 | if ok in ('n', 'no', 'nop', 'nope'): | |
|
222 | return False | |
|
215 | 223 | retries = retries - 1 |
|
216 |
if retries < 0: |
|
|
224 | if retries < 0: | |
|
225 | raise IOError | |
|
217 | 226 | print complaint |
|
218 | 227 | |
|
219 | 228 | #propagated from mercurial documentation |
@@ -228,6 +237,7 b" ui_sections = ['alias', 'auth'," | |||
|
228 | 237 | 'server', 'trusted', |
|
229 | 238 | 'ui', 'web', ] |
|
230 | 239 | |
|
240 | ||
|
231 | 241 | def make_ui(read_from='file', path=None, checkpaths=True): |
|
232 | 242 | """A function that will read python rc files or database |
|
233 | 243 | and make an mercurial ui object from read options |
@@ -256,7 +266,6 b" def make_ui(read_from='file', path=None," | |||
|
256 | 266 | log.debug('settings ui from file[%s]%s:%s', section, k, v) |
|
257 | 267 | baseui.setconfig(section, k, v) |
|
258 | 268 | |
|
259 | ||
|
260 | 269 | elif read_from == 'db': |
|
261 | 270 | sa = meta.Session() |
|
262 | 271 | ret = sa.query(RhodeCodeUi)\ |
@@ -285,6 +294,7 b' def set_rhodecode_config(config):' | |||
|
285 | 294 | for k, v in hgsettings.items(): |
|
286 | 295 | config[k] = v |
|
287 | 296 | |
|
297 | ||
|
288 | 298 | def invalidate_cache(cache_key, *args): |
|
289 | 299 | """Puts cache invalidation task into db for |
|
290 | 300 | further global cache invalidation |
@@ -296,18 +306,20 b' def invalidate_cache(cache_key, *args):' | |||
|
296 | 306 | name = cache_key.split('get_repo_cached_')[-1] |
|
297 | 307 | ScmModel().mark_for_invalidation(name) |
|
298 | 308 | |
|
309 | ||
|
299 | 310 | class EmptyChangeset(BaseChangeset): |
|
300 | 311 | """ |
|
301 | 312 | An dummy empty changeset. It's possible to pass hash when creating |
|
302 | 313 | an EmptyChangeset |
|
303 | 314 | """ |
|
304 | 315 | |
|
305 | def __init__(self, cs='0' * 40): | |
|
316 | def __init__(self, cs='0' * 40, repo=None): | |
|
306 | 317 | self._empty_cs = cs |
|
307 | 318 | self.revision = -1 |
|
308 | 319 | self.message = '' |
|
309 | 320 | self.author = '' |
|
310 | 321 | self.date = '' |
|
322 | self.repository = repo | |
|
311 | 323 | |
|
312 | 324 | @LazyProperty |
|
313 | 325 | def raw_id(self): |
@@ -330,6 +342,7 b' class EmptyChangeset(BaseChangeset):' | |||
|
330 | 342 | def get_file_size(self, path): |
|
331 | 343 | return 0 |
|
332 | 344 | |
|
345 | ||
|
333 | 346 | def map_groups(groups): |
|
334 | 347 | """Checks for groups existence, and creates groups structures. |
|
335 | 348 | It returns last group in structure |
@@ -352,6 +365,7 b' def map_groups(groups):' | |||
|
352 | 365 | |
|
353 | 366 | return group |
|
354 | 367 | |
|
368 | ||
|
355 | 369 | def repo2db_mapper(initial_repo_list, remove_obsolete=False): |
|
356 | 370 | """maps all repos given in initial_repo_list, non existing repositories |
|
357 | 371 | are created, if remove_obsolete is True it also check for db entries |
@@ -391,6 +405,8 b' def repo2db_mapper(initial_repo_list, re' | |||
|
391 | 405 | sa.commit() |
|
392 | 406 | |
|
393 | 407 | return added, removed |
|
408 | ||
|
409 | ||
|
394 | 410 | class OrderedDict(dict, DictMixin): |
|
395 | 411 | |
|
396 | 412 | def __init__(self, *args, **kwds): |
@@ -518,6 +534,7 b' def add_cache(settings):' | |||
|
518 | 534 | 'memory') |
|
519 | 535 | beaker.cache.cache_regions[region] = region_settings |
|
520 | 536 | |
|
537 | ||
|
521 | 538 | def get_current_revision(): |
|
522 | 539 | """Returns tuple of (number, id) from repository containing this package |
|
523 | 540 | or None if repository could not be found. |
@@ -537,9 +554,10 b' def get_current_revision():' | |||
|
537 | 554 | "was: %s" % err) |
|
538 | 555 | return None |
|
539 | 556 | |
|
540 | #=============================================================================== | |
|
557 | ||
|
558 | #============================================================================== | |
|
541 | 559 | # TEST FUNCTIONS AND CREATORS |
|
542 |
#============================================================================== |
|
|
560 | #============================================================================== | |
|
543 | 561 | def create_test_index(repo_location, full_index): |
|
544 | 562 | """Makes default test index |
|
545 | 563 | :param repo_location: |
@@ -562,6 +580,7 b' def create_test_index(repo_location, ful' | |||
|
562 | 580 | except LockHeld: |
|
563 | 581 | pass |
|
564 | 582 | |
|
583 | ||
|
565 | 584 | def create_test_env(repos_test_path, config): |
|
566 | 585 | """Makes a fresh database and |
|
567 | 586 | install test repository into tmp dir |
@@ -582,7 +601,8 b' def create_test_env(repos_test_path, con' | |||
|
582 | 601 | ch.setLevel(logging.DEBUG) |
|
583 | 602 | |
|
584 | 603 | # create formatter |
|
585 |
formatter = logging.Formatter("%(asctime)s - %(name)s - |
|
|
604 | formatter = logging.Formatter("%(asctime)s - %(name)s -" | |
|
605 | " %(levelname)s - %(message)s") | |
|
586 | 606 | |
|
587 | 607 | # add formatter to ch |
|
588 | 608 | ch.setFormatter(formatter) |
@@ -619,10 +639,10 b' def create_test_env(repos_test_path, con' | |||
|
619 | 639 | tar.extractall(jn(TESTS_TMP_PATH, HG_REPO)) |
|
620 | 640 | tar.close() |
|
621 | 641 | |
|
642 | ||
|
622 | 643 | #============================================================================== |
|
623 | 644 | # PASTER COMMANDS |
|
624 | 645 | #============================================================================== |
|
625 | ||
|
626 | 646 | class BasePasterCommand(Command): |
|
627 | 647 | """ |
|
628 | 648 | Abstract Base Class for paster commands. |
@@ -649,7 +669,6 b' class BasePasterCommand(Command):' | |||
|
649 | 669 | if log and isinstance(log, logging): |
|
650 | 670 | log(msg) |
|
651 | 671 | |
|
652 | ||
|
653 | 672 | def run(self, args): |
|
654 | 673 | """ |
|
655 | 674 | Overrides Command.run |
General Comments 0
You need to be logged in to leave comments.
Login now