Mercurial > kallithea
comparison rhodecode/model/scm.py @ 1401:b7563ad4e7ee beta
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 30 Jun 2011 01:25:37 +0200 |
parents | 39ae0f0972b9 |
children | e5467730682b |
comparison
equal
deleted
inserted
replaced
1400:0d7b56b97953 | 1401:b7563ad4e7ee |
---|---|
25 import os | 25 import os |
26 import time | 26 import time |
27 import traceback | 27 import traceback |
28 import logging | 28 import logging |
29 | 29 |
30 from mercurial import ui | |
31 | |
32 from sqlalchemy.exc import DatabaseError | 30 from sqlalchemy.exc import DatabaseError |
33 from sqlalchemy.orm import make_transient | |
34 | |
35 from beaker.cache import cache_region, region_invalidate | |
36 | 31 |
37 from vcs import get_backend | 32 from vcs import get_backend |
38 from vcs.utils.helpers import get_scm | 33 from vcs.utils.helpers import get_scm |
39 from vcs.exceptions import RepositoryError, VCSError | 34 from vcs.exceptions import RepositoryError, VCSError |
40 from vcs.utils.lazy import LazyProperty | 35 from vcs.utils.lazy import LazyProperty |
41 from vcs.nodes import FileNode | 36 from vcs.nodes import FileNode |
42 | 37 |
43 from rhodecode import BACKENDS | 38 from rhodecode import BACKENDS |
44 from rhodecode.lib import helpers as h | 39 from rhodecode.lib import helpers as h |
40 from rhodecode.lib import safe_str | |
45 from rhodecode.lib.auth import HasRepoPermissionAny | 41 from rhodecode.lib.auth import HasRepoPermissionAny |
46 from rhodecode.lib.utils import get_repos as get_filesystem_repos, make_ui, \ | 42 from rhodecode.lib.utils import get_repos as get_filesystem_repos, make_ui, \ |
47 action_logger | 43 action_logger |
48 from rhodecode.model import BaseModel | 44 from rhodecode.model import BaseModel |
49 from rhodecode.model.user import UserModel | 45 from rhodecode.model.user import UserModel |
50 from rhodecode.model.repo import RepoModel | |
51 from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \ | 46 from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \ |
52 UserFollowing, UserLog | 47 UserFollowing, UserLog |
53 from rhodecode.model.caching_query import FromCache | |
54 | 48 |
55 log = logging.getLogger(__name__) | 49 log = logging.getLogger(__name__) |
56 | 50 |
57 | 51 |
58 class UserTemp(object): | 52 class UserTemp(object): |
180 else: | 174 else: |
181 | 175 |
182 klass = get_backend(path[0]) | 176 klass = get_backend(path[0]) |
183 | 177 |
184 if path[0] == 'hg' and path[0] in BACKENDS.keys(): | 178 if path[0] == 'hg' and path[0] in BACKENDS.keys(): |
185 repos_list[name] = klass(path[1], baseui=baseui) | 179 |
180 # for mercurial we need to have an str path | |
181 repos_list[name] = klass(safe_str(path[1]), | |
182 baseui=baseui) | |
186 | 183 |
187 if path[0] == 'git' and path[0] in BACKENDS.keys(): | 184 if path[0] == 'git' and path[0] in BACKENDS.keys(): |
188 repos_list[name] = klass(path[1]) | 185 repos_list[name] = klass(path[1]) |
189 except OSError: | 186 except OSError: |
190 continue | 187 continue |
362 elif repo.alias == 'git': | 359 elif repo.alias == 'git': |
363 from vcs.backends.git import GitInMemoryChangeset as IMC | 360 from vcs.backends.git import GitInMemoryChangeset as IMC |
364 | 361 |
365 # decoding here will force that we have proper encoded values | 362 # decoding here will force that we have proper encoded values |
366 # in any other case this will throw exceptions and deny commit | 363 # in any other case this will throw exceptions and deny commit |
367 content = content.encode('utf8') | 364 content = safe_str(content) |
368 message = message.encode('utf8') | 365 message = safe_str(message) |
369 path = f_path.encode('utf8') | 366 path = safe_str(f_path) |
370 author = author.encode('utf8') | 367 author = safe_str(author) |
371 m = IMC(repo) | 368 m = IMC(repo) |
372 m.change(FileNode(path, content)) | 369 m.change(FileNode(path, content)) |
373 tip = m.commit(message=message, | 370 tip = m.commit(message=message, |
374 author=author, | 371 author=author, |
375 parents=[cs], branch=cs.branch) | 372 parents=[cs], branch=cs.branch) |