Show More
@@ -162,7 +162,7 b' def setup_configuration(app):' | |||||
162 |
|
162 | |||
163 | load_rcextensions(root_path=config['here']) |
|
163 | load_rcextensions(root_path=config['here']) | |
164 |
|
164 | |||
165 | repos_path = make_ui().configitems('paths')[0][1] |
|
165 | repos_path = make_ui().configitems(b'paths')[0][1] | |
166 | config['base_path'] = repos_path |
|
166 | config['base_path'] = repos_path | |
167 | set_app_settings(config) |
|
167 | set_app_settings(config) | |
168 |
|
168 |
@@ -108,20 +108,26 b' class CompareController(BaseRepoControll' | |||||
108 | hgrepo = other_repo._repo |
|
108 | hgrepo = other_repo._repo | |
109 |
|
109 | |||
110 | ancestors = [hgrepo[ancestor].hex() for ancestor in |
|
110 | ancestors = [hgrepo[ancestor].hex() for ancestor in | |
111 | hgrepo.revs("id(%s) & ::id(%s)", other_rev, org_rev)] |
|
111 | hgrepo.revs(b"id(%s) & ::id(%s)", other_rev, org_rev)] | |
112 | if ancestors: |
|
112 | if ancestors: | |
113 | log.debug("shortcut found: %s is already an ancestor of %s", other_rev, org_rev) |
|
113 | log.debug("shortcut found: %s is already an ancestor of %s", other_rev, org_rev) | |
114 | else: |
|
114 | else: | |
115 | log.debug("no shortcut found: %s is not an ancestor of %s", other_rev, org_rev) |
|
115 | log.debug("no shortcut found: %s is not an ancestor of %s", other_rev, org_rev) | |
116 | ancestors = [hgrepo[ancestor].hex() for ancestor in |
|
116 | ancestors = [hgrepo[ancestor].hex() for ancestor in | |
117 | hgrepo.revs("heads(::id(%s) & ::id(%s))", org_rev, other_rev)] # FIXME: expensive! |
|
117 | hgrepo.revs(b"heads(::id(%s) & ::id(%s))", org_rev, other_rev)] # FIXME: expensive! | |
118 |
|
118 | |||
119 | other_revs = hgrepo.revs("ancestors(id(%s)) and not ancestors(id(%s)) and not id(%s)", |
|
119 | other_changesets = [ | |
120 | other_rev, org_rev, org_rev) |
|
120 | other_repo.get_changeset(rev) | |
121 | other_changesets = [other_repo.get_changeset(rev) for rev in other_revs] |
|
121 | for rev in hgrepo.revs( | |
122 |
|
|
122 | b"ancestors(id(%s)) and not ancestors(id(%s)) and not id(%s)", | |
123 |
|
|
123 | other_rev, org_rev, org_rev) | |
124 | org_changesets = [org_repo.get_changeset(hgrepo[rev].hex()) for rev in org_revs] |
|
124 | ] | |
|
125 | org_changesets = [ | |||
|
126 | org_repo.get_changeset(hgrepo[rev].hex()) | |||
|
127 | for rev in hgrepo.revs( | |||
|
128 | b"ancestors(id(%s)) and not ancestors(id(%s)) and not id(%s)", | |||
|
129 | org_rev, other_rev, other_rev) | |||
|
130 | ] | |||
125 |
|
131 | |||
126 | elif alias == 'git': |
|
132 | elif alias == 'git': | |
127 | if org_repo != other_repo: |
|
133 | if org_repo != other_repo: |
@@ -97,7 +97,7 b' class PullrequestsController(BaseRepoCon' | |||||
97 | # including branches of children could be nice too |
|
97 | # including branches of children could be nice too | |
98 | peerbranches = set() |
|
98 | peerbranches = set() | |
99 | for i in repo._repo.revs( |
|
99 | for i in repo._repo.revs( | |
100 | "sort(parents(branch(id(%s)) and merge()) - branch(id(%s)), -rev)", |
|
100 | b"sort(parents(branch(id(%s)) and merge()) - branch(id(%s)), -rev)", | |
101 | branch_rev, branch_rev |
|
101 | branch_rev, branch_rev | |
102 | ): |
|
102 | ): | |
103 | for abranch in repo.get_changeset(i).branches: |
|
103 | for abranch in repo.get_changeset(i).branches: |
@@ -236,7 +236,7 b' def get_gitdiff(filenode_old, filenode_n' | |||||
236 | context = context or 3 |
|
236 | context = context or 3 | |
237 | submodules = [o for o in [filenode_new, filenode_old] if isinstance(o, SubModuleNode)] |
|
237 | submodules = [o for o in [filenode_new, filenode_old] if isinstance(o, SubModuleNode)] | |
238 | if submodules: |
|
238 | if submodules: | |
239 | return '' |
|
239 | return b'' | |
240 |
|
240 | |||
241 | for filenode in (filenode_old, filenode_new): |
|
241 | for filenode in (filenode_old, filenode_new): | |
242 | if not isinstance(filenode, FileNode): |
|
242 | if not isinstance(filenode, FileNode): | |
@@ -261,7 +261,7 b' def get_diff(scm_instance, rev1, rev2, p' | |||||
261 | ignore_whitespace=ignore_whitespace, context=context) |
|
261 | ignore_whitespace=ignore_whitespace, context=context) | |
262 | except MemoryError: |
|
262 | except MemoryError: | |
263 | h.flash('MemoryError: Diff is too big', category='error') |
|
263 | h.flash('MemoryError: Diff is too big', category='error') | |
264 | return '' |
|
264 | return b'' | |
265 |
|
265 | |||
266 |
|
266 | |||
267 | NEW_FILENODE = 1 |
|
267 | NEW_FILENODE = 1 | |
@@ -279,7 +279,7 b' class DiffProcessor(object):' | |||||
279 | mentioned in the diff together with a dict of meta information that |
|
279 | mentioned in the diff together with a dict of meta information that | |
280 | can be used to render it in a HTML template. |
|
280 | can be used to render it in a HTML template. | |
281 | """ |
|
281 | """ | |
282 | _diff_git_re = re.compile('^diff --git', re.MULTILINE) |
|
282 | _diff_git_re = re.compile(b'^diff --git', re.MULTILINE) | |
283 |
|
283 | |||
284 | def __init__(self, diff, vcs='hg', diff_limit=None, inline_diff=True): |
|
284 | def __init__(self, diff, vcs='hg', diff_limit=None, inline_diff=True): | |
285 | """ |
|
285 | """ | |
@@ -480,7 +480,7 b' def _escaper(string):' | |||||
480 | return _escape_re.sub(substitute, safe_unicode(string)) |
|
480 | return _escape_re.sub(substitute, safe_unicode(string)) | |
481 |
|
481 | |||
482 |
|
482 | |||
483 | _git_header_re = re.compile(r""" |
|
483 | _git_header_re = re.compile(br""" | |
484 | ^diff[ ]--git[ ]a/(?P<a_path>.+?)[ ]b/(?P<b_path>.+?)\n |
|
484 | ^diff[ ]--git[ ]a/(?P<a_path>.+?)[ ]b/(?P<b_path>.+?)\n | |
485 | (?:^old[ ]mode[ ](?P<old_mode>\d+)\n |
|
485 | (?:^old[ ]mode[ ](?P<old_mode>\d+)\n | |
486 | ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))? |
|
486 | ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))? | |
@@ -497,7 +497,7 b' def _escaper(string):' | |||||
497 | """, re.VERBOSE | re.MULTILINE) |
|
497 | """, re.VERBOSE | re.MULTILINE) | |
498 |
|
498 | |||
499 |
|
499 | |||
500 | _hg_header_re = re.compile(r""" |
|
500 | _hg_header_re = re.compile(br""" | |
501 | ^diff[ ]--git[ ]a/(?P<a_path>.+?)[ ]b/(?P<b_path>.+?)\n |
|
501 | ^diff[ ]--git[ ]a/(?P<a_path>.+?)[ ]b/(?P<b_path>.+?)\n | |
502 | (?:^old[ ]mode[ ](?P<old_mode>\d+)\n |
|
502 | (?:^old[ ]mode[ ](?P<old_mode>\d+)\n | |
503 | ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))? |
|
503 | ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))? | |
@@ -542,7 +542,7 b' def _get_header(vcs, diff_chunk):' | |||||
542 | rest = diff_chunk[match.end():] |
|
542 | rest = diff_chunk[match.end():] | |
543 | if rest and _header_next_check.match(rest): |
|
543 | if rest and _header_next_check.match(rest): | |
544 | raise Exception('cannot parse %s diff header: %r followed by %r' % (vcs, diff_chunk[:match.end()], rest[:1000])) |
|
544 | raise Exception('cannot parse %s diff header: %r followed by %r' % (vcs, diff_chunk[:match.end()], rest[:1000])) | |
545 | diff_lines = (_escaper(m.group(0)) for m in re.finditer(r'.*\n|.+$', rest)) # don't split on \r as str.splitlines do |
|
545 | diff_lines = (_escaper(m.group(0)) for m in re.finditer(br'.*\n|.+$', rest)) # don't split on \r as str.splitlines do | |
546 | return meta_info, diff_lines |
|
546 | return meta_info, diff_lines | |
547 |
|
547 | |||
548 |
|
548 |
@@ -110,7 +110,7 b' def log_push_action(ui, repo, node, node' | |||||
110 | cahes! The function should perhaps be renamed. |
|
110 | cahes! The function should perhaps be renamed. | |
111 | """ |
|
111 | """ | |
112 | _h = binascii.hexlify |
|
112 | _h = binascii.hexlify | |
113 |
revs = [_h(repo[r].node()) for r in revrange(repo, [ |
|
113 | revs = [_h(repo[r].node()) for r in revrange(repo, [b'%s:%s' % (node, node_last)])] | |
114 | process_pushed_raw_ids(revs) |
|
114 | process_pushed_raw_ids(revs) | |
115 | return 0 |
|
115 | return 0 | |
116 |
|
116 | |||
@@ -363,8 +363,9 b' def handle_git_post_receive(repo_path, g' | |||||
363 | if push_ref['old_rev'] == EmptyChangeset().raw_id: |
|
363 | if push_ref['old_rev'] == EmptyChangeset().raw_id: | |
364 | # update the symbolic ref if we push new repo |
|
364 | # update the symbolic ref if we push new repo | |
365 | if scm_repo.is_empty(): |
|
365 | if scm_repo.is_empty(): | |
366 |
scm_repo._repo.refs.set_symbolic_ref( |
|
366 | scm_repo._repo.refs.set_symbolic_ref( | |
367 | 'refs/heads/%s' % push_ref['name']) |
|
367 | b'HEAD', | |
|
368 | b'refs/heads/%s' % push_ref['name']) | |||
368 |
|
369 | |||
369 | # build exclude list without the ref |
|
370 | # build exclude list without the ref | |
370 | cmd = ['for-each-ref', '--format=%(refname)', 'refs/heads/*'] |
|
371 | cmd = ['for-each-ref', '--format=%(refname)', 'refs/heads/*'] |
@@ -88,8 +88,8 b' def parse_pub_key(ssh_key):' | |||||
88 | except TypeError: |
|
88 | except TypeError: | |
89 | raise SshKeyParseError(_("Incorrect SSH key - failed to decode base64 part %r") % keyvalue) |
|
89 | raise SshKeyParseError(_("Incorrect SSH key - failed to decode base64 part %r") % keyvalue) | |
90 |
|
90 | |||
91 | if not decoded.startswith('\x00\x00\x00' + chr(len(keytype)) + str(keytype) + '\x00'): |
|
91 | if not decoded.startswith(b'\x00\x00\x00' + chr(len(keytype)) + str(keytype) + b'\x00'): | |
92 | raise SshKeyParseError(_("Incorrect SSH key - base64 part is not %r as claimed but %r") % (str(keytype), str(decoded[4:].split('\0', 1)[0]))) |
|
92 | raise SshKeyParseError(_("Incorrect SSH key - base64 part is not %r as claimed but %r") % (str(keytype), str(decoded[4:].split(b'\0', 1)[0]))) | |
93 |
|
93 | |||
94 | return keytype, decoded, comment |
|
94 | return keytype, decoded, comment | |
95 |
|
95 |
@@ -337,21 +337,21 b' def make_ui(repo_path=None):' | |||||
337 | sa = meta.Session() |
|
337 | sa = meta.Session() | |
338 | for ui_ in sa.query(Ui).all(): |
|
338 | for ui_ in sa.query(Ui).all(): | |
339 | if ui_.ui_active: |
|
339 | if ui_.ui_active: | |
340 | ui_val = '' if ui_.ui_value is None else safe_str(ui_.ui_value) |
|
340 | ui_val = b'' if ui_.ui_value is None else safe_str(ui_.ui_value) | |
341 | log.debug('config from db: [%s] %s=%r', ui_.ui_section, |
|
341 | log.debug('config from db: [%s] %s=%r', ui_.ui_section, | |
342 | ui_.ui_key, ui_val) |
|
342 | ui_.ui_key, ui_val) | |
343 | baseui.setconfig(safe_str(ui_.ui_section), safe_str(ui_.ui_key), |
|
343 | baseui.setconfig(safe_str(ui_.ui_section), safe_str(ui_.ui_key), | |
344 | ui_val) |
|
344 | ui_val) | |
345 |
|
345 | |||
346 | # force set push_ssl requirement to False, Kallithea handles that |
|
346 | # force set push_ssl requirement to False, Kallithea handles that | |
347 | baseui.setconfig('web', 'push_ssl', False) |
|
347 | baseui.setconfig(b'web', b'push_ssl', False) | |
348 | baseui.setconfig('web', 'allow_push', '*') |
|
348 | baseui.setconfig(b'web', b'allow_push', b'*') | |
349 | # prevent interactive questions for ssh password / passphrase |
|
349 | # prevent interactive questions for ssh password / passphrase | |
350 | ssh = baseui.config('ui', 'ssh', default='ssh') |
|
350 | ssh = baseui.config(b'ui', b'ssh', default=b'ssh') | |
351 | baseui.setconfig('ui', 'ssh', '%s -oBatchMode=yes -oIdentitiesOnly=yes' % ssh) |
|
351 | baseui.setconfig(b'ui', b'ssh', b'%s -oBatchMode=yes -oIdentitiesOnly=yes' % ssh) | |
352 | # push / pull hooks |
|
352 | # push / pull hooks | |
353 | baseui.setconfig('hooks', 'changegroup.kallithea_log_push_action', 'python:kallithea.lib.hooks.log_push_action') |
|
353 | baseui.setconfig(b'hooks', b'changegroup.kallithea_log_push_action', b'python:kallithea.lib.hooks.log_push_action') | |
354 | baseui.setconfig('hooks', 'outgoing.kallithea_log_pull_action', 'python:kallithea.lib.hooks.log_pull_action') |
|
354 | baseui.setconfig(b'hooks', b'outgoing.kallithea_log_pull_action', b'python:kallithea.lib.hooks.log_pull_action') | |
355 |
|
355 | |||
356 | if repo_path is not None: |
|
356 | if repo_path is not None: | |
357 | hgrc_path = os.path.join(repo_path, '.hg', 'hgrc') |
|
357 | hgrc_path = os.path.join(repo_path, '.hg', 'hgrc') |
@@ -244,7 +244,7 b' class GitChangeset(BaseChangeset):' | |||||
244 | # Only used to feed diffstat |
|
244 | # Only used to feed diffstat | |
245 | rev1 = self.parents[0] if self.parents else self.repository.EMPTY_CHANGESET |
|
245 | rev1 = self.parents[0] if self.parents else self.repository.EMPTY_CHANGESET | |
246 | rev2 = self |
|
246 | rev2 = self | |
247 | return ''.join(self.repository.get_diff(rev1, rev2, |
|
247 | return b''.join(self.repository.get_diff(rev1, rev2, | |
248 | ignore_whitespace=ignore_whitespace, |
|
248 | ignore_whitespace=ignore_whitespace, | |
249 | context=context)) |
|
249 | context=context)) | |
250 |
|
250 | |||
@@ -418,7 +418,7 b' class GitChangeset(BaseChangeset):' | |||||
418 | obj_path = name |
|
418 | obj_path = name | |
419 | if objects.S_ISGITLINK(stat): |
|
419 | if objects.S_ISGITLINK(stat): | |
420 | root_tree = self.repository._repo[self._tree_id] |
|
420 | root_tree = self.repository._repo[self._tree_id] | |
421 | cf = ConfigFile.from_file(BytesIO(self.repository._repo.get_object(root_tree['.gitmodules'][1]).data)) |
|
421 | cf = ConfigFile.from_file(BytesIO(self.repository._repo.get_object(root_tree[b'.gitmodules'][1]).data)) | |
422 | url = cf.get(('submodule', obj_path), 'url') |
|
422 | url = cf.get(('submodule', obj_path), 'url') | |
423 | dirnodes.append(SubModuleNode(obj_path, url=url, changeset=id, |
|
423 | dirnodes.append(SubModuleNode(obj_path, url=url, changeset=id, | |
424 | alias=als)) |
|
424 | alias=als)) | |
@@ -457,7 +457,7 b' class GitChangeset(BaseChangeset):' | |||||
457 | _GL = lambda m: m and objects.S_ISGITLINK(m) |
|
457 | _GL = lambda m: m and objects.S_ISGITLINK(m) | |
458 | if _GL(self._stat_modes.get(path)): |
|
458 | if _GL(self._stat_modes.get(path)): | |
459 | tree = self.repository._repo[self._tree_id] |
|
459 | tree = self.repository._repo[self._tree_id] | |
460 | cf = ConfigFile.from_file(BytesIO(self.repository._repo.get_object(tree['.gitmodules'][1]).data)) |
|
460 | cf = ConfigFile.from_file(BytesIO(self.repository._repo.get_object(tree[b'.gitmodules'][1]).data)) | |
461 | url = cf.get(('submodule', path), 'url') |
|
461 | url = cf.get(('submodule', path), 'url') | |
462 | node = SubModuleNode(path, url=url, changeset=id_, |
|
462 | node = SubModuleNode(path, url=url, changeset=id_, | |
463 | alias=self.repository.alias) |
|
463 | alias=self.repository.alias) |
@@ -39,7 +39,7 b' class GitInMemoryChangeset(BaseInMemoryC' | |||||
39 | repo = self.repository._repo |
|
39 | repo = self.repository._repo | |
40 | object_store = repo.object_store |
|
40 | object_store = repo.object_store | |
41 |
|
41 | |||
42 | ENCODING = "UTF-8" # TODO: should probably be kept in sync with safe_unicode/safe_bytes and vcs/conf/settings.py DEFAULT_ENCODINGS |
|
42 | ENCODING = b"UTF-8" # TODO: should probably be kept in sync with safe_unicode/safe_bytes and vcs/conf/settings.py DEFAULT_ENCODINGS | |
43 |
|
43 | |||
44 | # Create tree and populates it with blobs |
|
44 | # Create tree and populates it with blobs | |
45 | commit_tree = self.parents[0] and repo[self.parents[0]._commit.tree] or \ |
|
45 | commit_tree = self.parents[0] and repo[self.parents[0]._commit.tree] or \ | |
@@ -47,7 +47,7 b' class GitInMemoryChangeset(BaseInMemoryC' | |||||
47 | for node in self.added + self.changed: |
|
47 | for node in self.added + self.changed: | |
48 | # Compute subdirs if needed |
|
48 | # Compute subdirs if needed | |
49 | dirpath, nodename = posixpath.split(node.path) |
|
49 | dirpath, nodename = posixpath.split(node.path) | |
50 | dirnames = safe_str(dirpath).split('/') if dirpath else [] |
|
50 | dirnames = safe_str(dirpath).split(b'/') if dirpath else [] | |
51 | parent = commit_tree |
|
51 | parent = commit_tree | |
52 | ancestors = [('', parent)] |
|
52 | ancestors = [('', parent)] | |
53 |
|
53 | |||
@@ -100,7 +100,7 b' class GitInMemoryChangeset(BaseInMemoryC' | |||||
100 | for tree in new_trees: |
|
100 | for tree in new_trees: | |
101 | object_store.add_object(tree) |
|
101 | object_store.add_object(tree) | |
102 | for node in self.removed: |
|
102 | for node in self.removed: | |
103 | paths = node.path.split('/') |
|
103 | paths = node.path.split(b'/') | |
104 | tree = commit_tree |
|
104 | tree = commit_tree | |
105 | trees = [tree] |
|
105 | trees = [tree] | |
106 | # Traverse deep into the forest... |
|
106 | # Traverse deep into the forest... | |
@@ -146,10 +146,9 b' class GitInMemoryChangeset(BaseInMemoryC' | |||||
146 |
|
146 | |||
147 | object_store.add_object(commit) |
|
147 | object_store.add_object(commit) | |
148 |
|
148 | |||
149 | ref = 'refs/heads/%s' % branch |
|
149 | # Update vcs repository object & recreate dulwich repo | |
|
150 | ref = b'refs/heads/%s' % branch | |||
150 | repo.refs[ref] = commit.id |
|
151 | repo.refs[ref] = commit.id | |
151 |
|
||||
152 | # Update vcs repository object & recreate dulwich repo |
|
|||
153 | self.repository.revisions.append(commit.id) |
|
152 | self.repository.revisions.append(commit.id) | |
154 | # invalidate parsed refs after commit |
|
153 | # invalidate parsed refs after commit | |
155 | self.repository._parsed_refs = self.repository._get_parsed_refs() |
|
154 | self.repository._parsed_refs = self.repository._get_parsed_refs() |
@@ -123,8 +123,8 b' class GitRepository(BaseRepository):' | |||||
123 | raise RepositoryError(msg) |
|
123 | raise RepositoryError(msg) | |
124 |
|
124 | |||
125 | try: |
|
125 | try: | |
126 | stdout = ''.join(p.output) |
|
126 | stdout = b''.join(p.output) | |
127 | stderr = ''.join(p.error) |
|
127 | stderr = b''.join(p.error) | |
128 | finally: |
|
128 | finally: | |
129 | p.close() |
|
129 | p.close() | |
130 | # TODO: introduce option to make commands fail if they have any stderr output? |
|
130 | # TODO: introduce option to make commands fail if they have any stderr output? | |
@@ -170,12 +170,12 b' class GitRepository(BaseRepository):' | |||||
170 | handlers = [] |
|
170 | handlers = [] | |
171 | url_obj = hg_url(url) |
|
171 | url_obj = hg_url(url) | |
172 | test_uri, authinfo = url_obj.authinfo() |
|
172 | test_uri, authinfo = url_obj.authinfo() | |
173 | url_obj.passwd = '*****' |
|
|||
174 | cleaned_uri = str(url_obj) |
|
|||
175 |
|
||||
176 | if not test_uri.endswith('info/refs'): |
|
173 | if not test_uri.endswith('info/refs'): | |
177 | test_uri = test_uri.rstrip('/') + '/info/refs' |
|
174 | test_uri = test_uri.rstrip('/') + '/info/refs' | |
178 |
|
175 | |||
|
176 | url_obj.passwd = b'*****' | |||
|
177 | cleaned_uri = str(url_obj) | |||
|
178 | ||||
179 | if authinfo: |
|
179 | if authinfo: | |
180 | # create a password manager |
|
180 | # create a password manager | |
181 | passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm() |
|
181 | passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm() | |
@@ -252,7 +252,7 b' class GitRepository(BaseRepository):' | |||||
252 | def _get_all_revisions2(self): |
|
252 | def _get_all_revisions2(self): | |
253 | # alternate implementation using dulwich |
|
253 | # alternate implementation using dulwich | |
254 | includes = [x[1][0] for x in self._parsed_refs.iteritems() |
|
254 | includes = [x[1][0] for x in self._parsed_refs.iteritems() | |
255 | if x[1][1] != 'T'] |
|
255 | if x[1][1] != b'T'] | |
256 | return [c.commit.id for c in self._repo.get_walker(include=includes)] |
|
256 | return [c.commit.id for c in self._repo.get_walker(include=includes)] | |
257 |
|
257 | |||
258 | def _get_revision(self, revision): |
|
258 | def _get_revision(self, revision): | |
@@ -282,7 +282,7 b' class GitRepository(BaseRepository):' | |||||
282 |
|
282 | |||
283 | # get by branch/tag name |
|
283 | # get by branch/tag name | |
284 | _ref_revision = self._parsed_refs.get(revision) |
|
284 | _ref_revision = self._parsed_refs.get(revision) | |
285 | if _ref_revision: # and _ref_revision[1] in ['H', 'RH', 'T']: |
|
285 | if _ref_revision: # and _ref_revision[1] in [b'H', b'RH', b'T']: | |
286 | return _ref_revision[0] |
|
286 | return _ref_revision[0] | |
287 |
|
287 | |||
288 | if revision in self.revisions: |
|
288 | if revision in self.revisions: | |
@@ -355,9 +355,7 b' class GitRepository(BaseRepository):' | |||||
355 |
|
355 | |||
356 | @LazyProperty |
|
356 | @LazyProperty | |
357 | def description(self): |
|
357 | def description(self): | |
358 |
|
|
358 | return safe_unicode(self._repo.get_description() or b'unknown') | |
359 | _desc = self._repo.get_description() |
|
|||
360 | return safe_unicode(_desc or undefined_description) |
|
|||
361 |
|
359 | |||
362 | @LazyProperty |
|
360 | @LazyProperty | |
363 | def contact(self): |
|
361 | def contact(self): | |
@@ -370,7 +368,7 b' class GitRepository(BaseRepository):' | |||||
370 | return {} |
|
368 | return {} | |
371 | sortkey = lambda ctx: ctx[0] |
|
369 | sortkey = lambda ctx: ctx[0] | |
372 | _branches = [(x[0], x[1][0]) |
|
370 | _branches = [(x[0], x[1][0]) | |
373 | for x in self._parsed_refs.iteritems() if x[1][1] == 'H'] |
|
371 | for x in self._parsed_refs.iteritems() if x[1][1] == b'H'] | |
374 | return OrderedDict(sorted(_branches, key=sortkey, reverse=False)) |
|
372 | return OrderedDict(sorted(_branches, key=sortkey, reverse=False)) | |
375 |
|
373 | |||
376 | @LazyProperty |
|
374 | @LazyProperty | |
@@ -387,7 +385,7 b' class GitRepository(BaseRepository):' | |||||
387 |
|
385 | |||
388 | sortkey = lambda ctx: ctx[0] |
|
386 | sortkey = lambda ctx: ctx[0] | |
389 | _tags = [(x[0], x[1][0]) |
|
387 | _tags = [(x[0], x[1][0]) | |
390 | for x in self._parsed_refs.iteritems() if x[1][1] == 'T'] |
|
388 | for x in self._parsed_refs.iteritems() if x[1][1] == b'T'] | |
391 | return OrderedDict(sorted(_tags, key=sortkey, reverse=True)) |
|
389 | return OrderedDict(sorted(_tags, key=sortkey, reverse=True)) | |
392 |
|
390 | |||
393 | def tag(self, name, user, revision=None, message=None, date=None, |
|
391 | def tag(self, name, user, revision=None, message=None, date=None, | |
@@ -408,7 +406,7 b' class GitRepository(BaseRepository):' | |||||
408 | changeset = self.get_changeset(revision) |
|
406 | changeset = self.get_changeset(revision) | |
409 | message = message or "Added tag %s for commit %s" % (name, |
|
407 | message = message or "Added tag %s for commit %s" % (name, | |
410 | changeset.raw_id) |
|
408 | changeset.raw_id) | |
411 | self._repo.refs["refs/tags/%s" % name] = changeset._commit.id |
|
409 | self._repo.refs[b"refs/tags/%s" % name] = changeset._commit.id | |
412 |
|
410 | |||
413 | self._parsed_refs = self._get_parsed_refs() |
|
411 | self._parsed_refs = self._get_parsed_refs() | |
414 | self.tags = self._get_tags() |
|
412 | self.tags = self._get_tags() | |
@@ -451,15 +449,15 b' class GitRepository(BaseRepository):' | |||||
451 | # cache the property |
|
449 | # cache the property | |
452 | _repo = self._repo |
|
450 | _repo = self._repo | |
453 | refs = _repo.get_refs() |
|
451 | refs = _repo.get_refs() | |
454 | keys = [('refs/heads/', 'H'), |
|
452 | keys = [(b'refs/heads/', b'H'), | |
455 | ('refs/remotes/origin/', 'RH'), |
|
453 | (b'refs/remotes/origin/', b'RH'), | |
456 | ('refs/tags/', 'T')] |
|
454 | (b'refs/tags/', b'T')] | |
457 | _refs = {} |
|
455 | _refs = {} | |
458 | for ref, sha in refs.iteritems(): |
|
456 | for ref, sha in refs.iteritems(): | |
459 | for k, type_ in keys: |
|
457 | for k, type_ in keys: | |
460 | if ref.startswith(k): |
|
458 | if ref.startswith(k): | |
461 | _key = ref[len(k):] |
|
459 | _key = ref[len(k):] | |
462 | if type_ == 'T': |
|
460 | if type_ == b'T': | |
463 | obj = _repo.get_object(sha) |
|
461 | obj = _repo.get_object(sha) | |
464 | if isinstance(obj, Tag): |
|
462 | if isinstance(obj, Tag): | |
465 | sha = _repo.get_object(sha).object[1] |
|
463 | sha = _repo.get_object(sha).object[1] | |
@@ -472,10 +470,10 b' class GitRepository(BaseRepository):' | |||||
472 | heads = {} |
|
470 | heads = {} | |
473 |
|
471 | |||
474 | for key, val in refs.items(): |
|
472 | for key, val in refs.items(): | |
475 | for ref_key in ['refs/heads/', 'refs/remotes/origin/']: |
|
473 | for ref_key in [b'refs/heads/', b'refs/remotes/origin/']: | |
476 | if key.startswith(ref_key): |
|
474 | if key.startswith(ref_key): | |
477 | n = key[len(ref_key):] |
|
475 | n = key[len(ref_key):] | |
478 | if n not in ['HEAD']: |
|
476 | if n not in [b'HEAD']: | |
479 | heads[n] = val |
|
477 | heads[n] = val | |
480 |
|
478 | |||
481 | return heads if reverse else dict((y, x) for x, y in heads.iteritems()) |
|
479 | return heads if reverse else dict((y, x) for x, y in heads.iteritems()) | |
@@ -627,9 +625,9 b' class GitRepository(BaseRepository):' | |||||
627 | # If we used 'show' command, strip first few lines (until actual diff |
|
625 | # If we used 'show' command, strip first few lines (until actual diff | |
628 | # starts) |
|
626 | # starts) | |
629 | if rev1 == self.EMPTY_CHANGESET: |
|
627 | if rev1 == self.EMPTY_CHANGESET: | |
630 | parts = stdout.split('\ndiff ', 1) |
|
628 | parts = stdout.split(b'\ndiff ', 1) | |
631 | if len(parts) > 1: |
|
629 | if len(parts) > 1: | |
632 | stdout = 'diff ' + parts[1] |
|
630 | stdout = b'diff ' + parts[1] | |
633 | return stdout |
|
631 | return stdout | |
634 |
|
632 | |||
635 | @LazyProperty |
|
633 | @LazyProperty |
@@ -7,7 +7,7 b' from kallithea.lib.vcs.exceptions import' | |||||
7 | class GitWorkdir(BaseWorkdir): |
|
7 | class GitWorkdir(BaseWorkdir): | |
8 |
|
8 | |||
9 | def get_branch(self): |
|
9 | def get_branch(self): | |
10 | headpath = self.repository._repo.refs.refpath('HEAD') |
|
10 | headpath = self.repository._repo.refs.refpath(b'HEAD') | |
11 | try: |
|
11 | try: | |
12 | content = open(headpath).read() |
|
12 | content = open(headpath).read() | |
13 | match = re.match(r'^ref: refs/heads/(?P<branch>.+)\n$', content) |
|
13 | match = re.match(r'^ref: refs/heads/(?P<branch>.+)\n$', content) | |
@@ -20,7 +20,7 b' class GitWorkdir(BaseWorkdir):' | |||||
20 | raise RepositoryError("Couldn't compute workdir's branch") |
|
20 | raise RepositoryError("Couldn't compute workdir's branch") | |
21 |
|
21 | |||
22 | def get_changeset(self): |
|
22 | def get_changeset(self): | |
23 | wk_dir_id = self.repository._repo.refs.as_dict().get('HEAD') |
|
23 | wk_dir_id = self.repository._repo.refs.as_dict().get(b'HEAD') | |
24 | return self.repository.get_changeset(wk_dir_id) |
|
24 | return self.repository.get_changeset(wk_dir_id) | |
25 |
|
25 | |||
26 | def checkout_branch(self, branch=None): |
|
26 | def checkout_branch(self, branch=None): |
@@ -194,7 +194,7 b' class MercurialChangeset(BaseChangeset):' | |||||
194 |
|
194 | |||
195 | def diff(self): |
|
195 | def diff(self): | |
196 | # Only used to feed diffstat |
|
196 | # Only used to feed diffstat | |
197 | return ''.join(self._ctx.diff()) |
|
197 | return b''.join(self._ctx.diff()) | |
198 |
|
198 | |||
199 | def _fix_path(self, path): |
|
199 | def _fix_path(self, path): | |
200 | """ |
|
200 | """ | |
@@ -236,7 +236,7 b' class MercurialChangeset(BaseChangeset):' | |||||
236 | Returns stat mode of the file at the given ``path``. |
|
236 | Returns stat mode of the file at the given ``path``. | |
237 | """ |
|
237 | """ | |
238 | fctx = self._get_filectx(path) |
|
238 | fctx = self._get_filectx(path) | |
239 | if 'x' in fctx.flags(): |
|
239 | if b'x' in fctx.flags(): | |
240 | return 0o100755 |
|
240 | return 0o100755 | |
241 | else: |
|
241 | else: | |
242 | return 0o100644 |
|
242 | return 0o100644 |
@@ -36,7 +36,7 b' class MercurialInMemoryChangeset(BaseInM' | |||||
36 |
|
36 | |||
37 | if branch is None: |
|
37 | if branch is None: | |
38 | branch = MercurialRepository.DEFAULT_BRANCH_NAME |
|
38 | branch = MercurialRepository.DEFAULT_BRANCH_NAME | |
39 | kwargs['branch'] = branch |
|
39 | kwargs[b'branch'] = branch | |
40 |
|
40 | |||
41 | def filectxfn(_repo, memctx, path): |
|
41 | def filectxfn(_repo, memctx, path): | |
42 | """ |
|
42 | """ | |
@@ -79,7 +79,7 b' class MercurialInMemoryChangeset(BaseInM' | |||||
79 |
|
79 | |||
80 | commit_ctx = memctx(repo=self.repository._repo, |
|
80 | commit_ctx = memctx(repo=self.repository._repo, | |
81 | parents=parents, |
|
81 | parents=parents, | |
82 | text='', |
|
82 | text=b'', | |
83 | files=self.get_paths(), |
|
83 | files=self.get_paths(), | |
84 | filectxfn=filectxfn, |
|
84 | filectxfn=filectxfn, | |
85 | user=author, |
|
85 | user=author, |
@@ -221,8 +221,7 b' class MercurialRepository(BaseRepository' | |||||
221 | )) |
|
221 | )) | |
222 |
|
222 | |||
223 | def _get_all_revisions(self): |
|
223 | def _get_all_revisions(self): | |
224 |
|
224 | return [self._repo[x].hex() for x in self._repo.filtered(b'visible').changelog.revs()] | ||
225 | return [self._repo[x].hex() for x in self._repo.filtered('visible').changelog.revs()] |
|
|||
226 |
|
225 | |||
227 | def get_diff(self, rev1, rev2, path='', ignore_whitespace=False, |
|
226 | def get_diff(self, rev1, rev2, path='', ignore_whitespace=False, | |
228 | context=3): |
|
227 | context=3): | |
@@ -262,7 +261,7 b' class MercurialRepository(BaseRepository' | |||||
262 | else: |
|
261 | else: | |
263 | file_filter = None |
|
262 | file_filter = None | |
264 |
|
263 | |||
265 | return ''.join(patch.diff(self._repo, rev1, rev2, match=file_filter, |
|
264 | return b''.join(patch.diff(self._repo, rev1, rev2, match=file_filter, | |
266 | opts=diffopts(git=True, |
|
265 | opts=diffopts(git=True, | |
267 | showfunc=True, |
|
266 | showfunc=True, | |
268 | ignorews=ignore_whitespace, |
|
267 | ignorews=ignore_whitespace, | |
@@ -280,23 +279,23 b' class MercurialRepository(BaseRepository' | |||||
280 | when the return code is non 200 |
|
279 | when the return code is non 200 | |
281 | """ |
|
280 | """ | |
282 | # check first if it's not an local url |
|
281 | # check first if it's not an local url | |
283 | if os.path.isdir(url) or url.startswith('file:'): |
|
282 | if os.path.isdir(url) or url.startswith(b'file:'): | |
284 | return True |
|
283 | return True | |
285 |
|
284 | |||
286 | if url.startswith('ssh:'): |
|
285 | if url.startswith(b'ssh:'): | |
287 | # in case of invalid uri or authentication issues, sshpeer will |
|
286 | # in case of invalid uri or authentication issues, sshpeer will | |
288 | # throw an exception. |
|
287 | # throw an exception. | |
289 | sshpeer.instance(repoui or ui.ui(), url, False).lookup('tip') |
|
288 | sshpeer.instance(repoui or ui.ui(), url, False).lookup(b'tip') | |
290 | return True |
|
289 | return True | |
291 |
|
290 | |||
292 | url_prefix = None |
|
291 | url_prefix = None | |
293 | if '+' in url[:url.find('://')]: |
|
292 | if b'+' in url[:url.find(b'://')]: | |
294 | url_prefix, url = url.split('+', 1) |
|
293 | url_prefix, url = url.split(b'+', 1) | |
295 |
|
294 | |||
296 | handlers = [] |
|
295 | handlers = [] | |
297 | url_obj = hg_url(url) |
|
296 | url_obj = hg_url(url) | |
298 | test_uri, authinfo = url_obj.authinfo() |
|
297 | test_uri, authinfo = url_obj.authinfo() | |
299 | url_obj.passwd = '*****' |
|
298 | url_obj.passwd = b'*****' | |
300 | cleaned_uri = str(url_obj) |
|
299 | cleaned_uri = str(url_obj) | |
301 |
|
300 | |||
302 | if authinfo: |
|
301 | if authinfo: | |
@@ -328,7 +327,7 b' class MercurialRepository(BaseRepository' | |||||
328 | if not url_prefix: # skip svn+http://... (and git+... too) |
|
327 | if not url_prefix: # skip svn+http://... (and git+... too) | |
329 | # now check if it's a proper hg repo |
|
328 | # now check if it's a proper hg repo | |
330 | try: |
|
329 | try: | |
331 | httppeer.instance(repoui or ui.ui(), url, False).lookup('tip') |
|
330 | httppeer.instance(repoui or ui.ui(), url, False).lookup(b'tip') | |
332 | except Exception as e: |
|
331 | except Exception as e: | |
333 | raise urllib2.URLError( |
|
332 | raise urllib2.URLError( | |
334 | "url [%s] does not look like an hg repo org_exc: %s" |
|
333 | "url [%s] does not look like an hg repo org_exc: %s" | |
@@ -374,15 +373,13 b' class MercurialRepository(BaseRepository' | |||||
374 |
|
373 | |||
375 | @LazyProperty |
|
374 | @LazyProperty | |
376 | def description(self): |
|
375 | def description(self): | |
377 | undefined_description = u'unknown' |
|
376 | _desc = self._repo.ui.config(b'web', b'description', None, untrusted=True) | |
378 | _desc = self._repo.ui.config('web', 'description', None, untrusted=True) |
|
377 | return safe_unicode(_desc or b'unknown') | |
379 | return safe_unicode(_desc or undefined_description) |
|
|||
380 |
|
378 | |||
381 | @LazyProperty |
|
379 | @LazyProperty | |
382 | def contact(self): |
|
380 | def contact(self): | |
383 | undefined_contact = u'Unknown' |
|
|||
384 | return safe_unicode(get_contact(self._repo.ui.config) |
|
381 | return safe_unicode(get_contact(self._repo.ui.config) | |
385 |
or |
|
382 | or b'Unknown') | |
386 |
|
383 | |||
387 | @LazyProperty |
|
384 | @LazyProperty | |
388 | def last_change(self): |
|
385 | def last_change(self): | |
@@ -413,7 +410,7 b' class MercurialRepository(BaseRepository' | |||||
413 | raise EmptyRepositoryError("There are no changesets yet") |
|
410 | raise EmptyRepositoryError("There are no changesets yet") | |
414 |
|
411 | |||
415 | if revision in [-1, None]: |
|
412 | if revision in [-1, None]: | |
416 | revision = 'tip' |
|
413 | revision = b'tip' | |
417 | elif isinstance(revision, unicode): |
|
414 | elif isinstance(revision, unicode): | |
418 | revision = safe_bytes(revision) |
|
415 | revision = safe_bytes(revision) | |
419 |
|
416 | |||
@@ -461,13 +458,13 b' class MercurialRepository(BaseRepository' | |||||
461 | return self._get_revision(revision) |
|
458 | return self._get_revision(revision) | |
462 |
|
459 | |||
463 | def _get_archives(self, archive_name='tip'): |
|
460 | def _get_archives(self, archive_name='tip'): | |
464 | allowed = self.baseui.configlist("web", "allow_archive", |
|
461 | allowed = self.baseui.configlist(b"web", b"allow_archive", | |
465 | untrusted=True) |
|
462 | untrusted=True) | |
466 |
for |
|
463 | for name, ext in [(b'zip', '.zip'), (b'gz', '.tar.gz'), (b'bz2', '.tar.bz2')]: | |
467 |
if |
|
464 | if name in allowed or self._repo.ui.configbool(b"web", | |
468 |
"allow" + |
|
465 | b"allow" + name, | |
469 | untrusted=True): |
|
466 | untrusted=True): | |
470 |
yield {"type": |
|
467 | yield {"type": name, "extension": ext, "node": archive_name} | |
471 |
|
468 | |||
472 | def _get_url(self, url): |
|
469 | def _get_url(self, url): | |
473 | """ |
|
470 | """ | |
@@ -525,18 +522,18 b' class MercurialRepository(BaseRepository' | |||||
525 | # filter branches |
|
522 | # filter branches | |
526 | filter_ = [] |
|
523 | filter_ = [] | |
527 | if branch_name: |
|
524 | if branch_name: | |
528 | filter_.append('branch("%s")' % safe_str(branch_name)) |
|
525 | filter_.append(b'branch("%s")' % safe_str(branch_name)) | |
529 | if start_date: |
|
526 | if start_date: | |
530 | filter_.append('date(">%s")' % start_date) |
|
527 | filter_.append(b'date(">%s")' % start_date) | |
531 | if end_date: |
|
528 | if end_date: | |
532 | filter_.append('date("<%s")' % end_date) |
|
529 | filter_.append(b'date("<%s")' % end_date) | |
533 | if filter_ or max_revisions: |
|
530 | if filter_ or max_revisions: | |
534 | if filter_: |
|
531 | if filter_: | |
535 | revspec = ' and '.join(filter_) |
|
532 | revspec = b' and '.join(filter_) | |
536 | else: |
|
533 | else: | |
537 | revspec = 'all()' |
|
534 | revspec = b'all()' | |
538 | if max_revisions: |
|
535 | if max_revisions: | |
539 |
revspec = 'limit(%s, % |
|
536 | revspec = b'limit(%s, %d)' % (revspec, max_revisions) | |
540 | revisions = scmutil.revrange(self._repo, [revspec]) |
|
537 | revisions = scmutil.revrange(self._repo, [revspec]) | |
541 | else: |
|
538 | else: | |
542 | revisions = self.revisions |
|
539 | revisions = self.revisions |
@@ -58,8 +58,8 b' class MercurialSshHandler(BaseSshHandler' | |||||
58 | # Note: we want a repo with config based on .hg/hgrc and can thus not use self.db_repo.scm_instance._repo.ui |
|
58 | # Note: we want a repo with config based on .hg/hgrc and can thus not use self.db_repo.scm_instance._repo.ui | |
59 | baseui = make_ui(repo_path=self.db_repo.repo_full_path) |
|
59 | baseui = make_ui(repo_path=self.db_repo.repo_full_path) | |
60 | if not self.allow_push: |
|
60 | if not self.allow_push: | |
61 | baseui.setconfig('hooks', 'pretxnopen._ssh_reject', 'python:kallithea.lib.hooks.rejectpush') |
|
61 | baseui.setconfig(b'hooks', b'pretxnopen._ssh_reject', b'python:kallithea.lib.hooks.rejectpush') | |
62 | baseui.setconfig('hooks', 'prepushkey._ssh_reject', 'python:kallithea.lib.hooks.rejectpush') |
|
62 | baseui.setconfig(b'hooks', b'prepushkey._ssh_reject', b'python:kallithea.lib.hooks.rejectpush') | |
63 |
|
63 | |||
64 | repo = hg.repository(baseui, safe_str(self.db_repo.repo_full_path)) |
|
64 | repo = hg.repository(baseui, safe_str(self.db_repo.repo_full_path)) | |
65 | log.debug("Starting Mercurial sshserver for %s", self.db_repo.repo_full_path) |
|
65 | log.debug("Starting Mercurial sshserver for %s", self.db_repo.repo_full_path) |
@@ -367,11 +367,11 b' class SubprocessIOChunker(object):' | |||||
367 | and returncode != 0 |
|
367 | and returncode != 0 | |
368 | ): # and it failed |
|
368 | ): # and it failed | |
369 | bg_out.stop() |
|
369 | bg_out.stop() | |
370 | out = ''.join(bg_out) |
|
370 | out = b''.join(bg_out) | |
371 | bg_err.stop() |
|
371 | bg_err.stop() | |
372 | err = ''.join(bg_err) |
|
372 | err = b''.join(bg_err) | |
373 | if (err.strip() == 'fatal: The remote end hung up unexpectedly' and |
|
373 | if (err.strip() == b'fatal: The remote end hung up unexpectedly' and | |
374 | out.startswith('0034shallow ') |
|
374 | out.startswith(b'0034shallow ') | |
375 | ): |
|
375 | ): | |
376 | # hack inspired by https://github.com/schacon/grack/pull/7 |
|
376 | # hack inspired by https://github.com/schacon/grack/pull/7 | |
377 | bg_out = iter([out]) |
|
377 | bg_out = iter([out]) |
@@ -261,7 +261,7 b' class CreatePullRequestAction(object):' | |||||
261 |
|
261 | |||
262 | if self.org_repo.scm_instance.alias == 'git': |
|
262 | if self.org_repo.scm_instance.alias == 'git': | |
263 | # create a ref under refs/pull/ so that commits don't get garbage-collected |
|
263 | # create a ref under refs/pull/ so that commits don't get garbage-collected | |
264 | self.org_repo.scm_instance._repo["refs/pull/%d/head" % pr.pull_request_id] = safe_str(self.org_rev) |
|
264 | self.org_repo.scm_instance._repo[b"refs/pull/%d/head" % pr.pull_request_id] = safe_str(self.org_rev) | |
265 |
|
265 | |||
266 | # reset state to under-review |
|
266 | # reset state to under-review | |
267 | from kallithea.model.changeset_status import ChangesetStatusModel |
|
267 | from kallithea.model.changeset_status import ChangesetStatusModel |
@@ -716,11 +716,11 b' class ScmModel(object):' | |||||
716 | if not os.path.isdir(loc): |
|
716 | if not os.path.isdir(loc): | |
717 | os.makedirs(loc) |
|
717 | os.makedirs(loc) | |
718 |
|
718 | |||
719 | tmpl_post = "#!%s\n" % self._get_git_hook_interpreter() |
|
719 | tmpl_post = b"#!%s\n" % self._get_git_hook_interpreter() | |
720 | tmpl_post += pkg_resources.resource_string( |
|
720 | tmpl_post += pkg_resources.resource_string( | |
721 | 'kallithea', os.path.join('config', 'post_receive_tmpl.py') |
|
721 | 'kallithea', os.path.join('config', 'post_receive_tmpl.py') | |
722 | ) |
|
722 | ) | |
723 | tmpl_pre = "#!%s\n" % self._get_git_hook_interpreter() |
|
723 | tmpl_pre = b"#!%s\n" % self._get_git_hook_interpreter() | |
724 | tmpl_pre += pkg_resources.resource_string( |
|
724 | tmpl_pre += pkg_resources.resource_string( | |
725 | 'kallithea', os.path.join('config', 'pre_receive_tmpl.py') |
|
725 | 'kallithea', os.path.join('config', 'pre_receive_tmpl.py') | |
726 | ) |
|
726 | ) | |
@@ -750,7 +750,7 b' class ScmModel(object):' | |||||
750 | log.debug('writing %s hook file !', h_type) |
|
750 | log.debug('writing %s hook file !', h_type) | |
751 | try: |
|
751 | try: | |
752 | with open(_hook_file, 'wb') as f: |
|
752 | with open(_hook_file, 'wb') as f: | |
753 | tmpl = tmpl.replace('_TMPL_', kallithea.__version__) |
|
753 | tmpl = tmpl.replace(b'_TMPL_', kallithea.__version__) | |
754 | f.write(tmpl) |
|
754 | f.write(tmpl) | |
755 | os.chmod(_hook_file, 0o755) |
|
755 | os.chmod(_hook_file, 0o755) | |
756 | except IOError as e: |
|
756 | except IOError as e: |
@@ -2509,8 +2509,8 b' class _BaseTestApi(object):' | |||||
2509 | "revisions": self.TEST_PR_REVISIONS, |
|
2509 | "revisions": self.TEST_PR_REVISIONS, | |
2510 | } |
|
2510 | } | |
2511 | self._compare_ok(random_id, expected, |
|
2511 | self._compare_ok(random_id, expected, | |
2512 | given=re.sub(r"\d\d\d\d\-\d\d\-\d\dT\d\d\:\d\d\:\d\d", |
|
2512 | given=re.sub(br"\d\d\d\d\-\d\d\-\d\dT\d\d\:\d\d\:\d\d", | |
2513 | "2000-01-01T00:00:00", response.body)) |
|
2513 | b"2000-01-01T00:00:00", response.body)) | |
2514 |
|
2514 | |||
2515 | def test_api_close_pullrequest(self): |
|
2515 | def test_api_close_pullrequest(self): | |
2516 | pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, u'close test') |
|
2516 | pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, u'close test') |
@@ -156,7 +156,7 b' class TestController(object):' | |||||
156 | 'password': password, |
|
156 | 'password': password, | |
157 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
157 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
158 |
|
158 | |||
159 | if 'Invalid username or password' in response.body: |
|
159 | if b'Invalid username or password' in response.body: | |
160 | pytest.fail('could not login using %s %s' % (username, password)) |
|
160 | pytest.fail('could not login using %s %s' % (username, password)) | |
161 |
|
161 | |||
162 | assert response.status == '302 Found' |
|
162 | assert response.status == '302 Found' |
@@ -423,7 +423,7 b' def create_test_index(repo_location, con' | |||||
423 |
|
423 | |||
424 |
|
424 | |||
425 | def failing_test_hook(ui, repo, **kwargs): |
|
425 | def failing_test_hook(ui, repo, **kwargs): | |
426 | ui.write("failing_test_hook failed\n") |
|
426 | ui.write(b"failing_test_hook failed\n") | |
427 | return 1 |
|
427 | return 1 | |
428 |
|
428 | |||
429 |
|
429 | |||
@@ -432,5 +432,5 b' def exception_test_hook(ui, repo, **kwar' | |||||
432 |
|
432 | |||
433 |
|
433 | |||
434 | def passing_test_hook(ui, repo, **kwargs): |
|
434 | def passing_test_hook(ui, repo, **kwargs): | |
435 | ui.write("passing_test_hook succeeded\n") |
|
435 | ui.write(b"passing_test_hook succeeded\n") | |
436 | return 0 |
|
436 | return 0 |
@@ -219,7 +219,7 b' class TestAuthSettingsController(TestCon' | |||||
219 | url=url(controller='admin/my_account', action='my_account'), |
|
219 | url=url(controller='admin/my_account', action='my_account'), | |
220 | extra_environ={'REMOTE_USER': 'john'}, |
|
220 | extra_environ={'REMOTE_USER': 'john'}, | |
221 | ) |
|
221 | ) | |
222 | assert 'Log Out' not in response.normal_body |
|
222 | assert b'Log Out' not in response.normal_body | |
223 |
|
223 | |||
224 | def test_crowd_save_settings(self): |
|
224 | def test_crowd_save_settings(self): | |
225 | self.log_user() |
|
225 | self.log_user() |
@@ -158,14 +158,14 b' class TestGistsController(TestController' | |||||
158 | gist = _create_gist('gist-show-me', content='GIST CONTENT') |
|
158 | gist = _create_gist('gist-show-me', content='GIST CONTENT') | |
159 | response = self.app.get(url('formatted_gist', |
|
159 | response = self.app.get(url('formatted_gist', | |
160 | gist_id=gist.gist_access_id, format='raw')) |
|
160 | gist_id=gist.gist_access_id, format='raw')) | |
161 | assert response.body == 'GIST CONTENT' |
|
161 | assert response.body == b'GIST CONTENT' | |
162 |
|
162 | |||
163 | def test_show_as_raw_individual_file(self): |
|
163 | def test_show_as_raw_individual_file(self): | |
164 | gist = _create_gist('gist-show-me-raw', content='GIST BODY') |
|
164 | gist = _create_gist('gist-show-me-raw', content='GIST BODY') | |
165 | response = self.app.get(url('formatted_gist_file', |
|
165 | response = self.app.get(url('formatted_gist_file', | |
166 | gist_id=gist.gist_access_id, format='raw', |
|
166 | gist_id=gist.gist_access_id, format='raw', | |
167 | revision='tip', f_path='gist-show-me-raw')) |
|
167 | revision='tip', f_path='gist-show-me-raw')) | |
168 | assert response.body == 'GIST BODY' |
|
168 | assert response.body == b'GIST BODY' | |
169 |
|
169 | |||
170 | def test_edit(self): |
|
170 | def test_edit(self): | |
171 | response = self.app.get(url('edit_gist', gist_id=1)) |
|
171 | response = self.app.get(url('edit_gist', gist_id=1)) |
@@ -229,7 +229,7 b' class TestGitRepository(object):' | |||||
229 | def test_changeset10(self): |
|
229 | def test_changeset10(self): | |
230 |
|
230 | |||
231 | chset10 = self.repo.get_changeset(self.repo.revisions[9]) |
|
231 | chset10 = self.repo.get_changeset(self.repo.revisions[9]) | |
232 | readme = """=== |
|
232 | readme = b"""=== | |
233 | VCS |
|
233 | VCS | |
234 | === |
|
234 | === | |
235 |
|
235 | |||
@@ -649,11 +649,11 b' class TestGitSpecificWithRepo(_BackendTe' | |||||
649 |
|
649 | |||
650 | def test_paths_slow_traversing(self): |
|
650 | def test_paths_slow_traversing(self): | |
651 | cs = self.repo.get_changeset() |
|
651 | cs = self.repo.get_changeset() | |
652 | assert cs.get_node('foobar').get_node('static').get_node('js').get_node('admin').get_node('base.js').content == 'base' |
|
652 | assert cs.get_node('foobar').get_node('static').get_node('js').get_node('admin').get_node('base.js').content == b'base' | |
653 |
|
653 | |||
654 | def test_paths_fast_traversing(self): |
|
654 | def test_paths_fast_traversing(self): | |
655 | cs = self.repo.get_changeset() |
|
655 | cs = self.repo.get_changeset() | |
656 | assert cs.get_node('foobar/static/js/admin/base.js').content == 'base' |
|
656 | assert cs.get_node('foobar/static/js/admin/base.js').content == b'base' | |
657 |
|
657 | |||
658 | def test_workdir_get_branch(self): |
|
658 | def test_workdir_get_branch(self): | |
659 | self.repo.run_git_command(['checkout', '-b', 'production']) |
|
659 | self.repo.run_git_command(['checkout', '-b', 'production']) |
@@ -219,7 +219,7 b' class TestMercurialRepository(object):' | |||||
219 | def test_changeset10(self): |
|
219 | def test_changeset10(self): | |
220 |
|
220 | |||
221 | chset10 = self.repo.get_changeset(10) |
|
221 | chset10 = self.repo.get_changeset(10) | |
222 | readme = """=== |
|
222 | readme = b"""=== | |
223 | VCS |
|
223 | VCS | |
224 | === |
|
224 | === | |
225 |
|
225 |
@@ -82,8 +82,8 b' class InMemoryChangesetTestMixin(_Backen' | |||||
82 | changeset = self.imc.commit(u'Initial', u'joe.doe@example.com') |
|
82 | changeset = self.imc.commit(u'Initial', u'joe.doe@example.com') | |
83 | assert isinstance(changeset.get_node('foo'), DirNode) |
|
83 | assert isinstance(changeset.get_node('foo'), DirNode) | |
84 | assert isinstance(changeset.get_node('foo/bar'), DirNode) |
|
84 | assert isinstance(changeset.get_node('foo/bar'), DirNode) | |
85 | assert changeset.get_node('foo/bar/image.png').content == '\0' |
|
85 | assert changeset.get_node('foo/bar/image.png').content == b'\0' | |
86 | assert changeset.get_node('foo/README.txt').content == 'readme!' |
|
86 | assert changeset.get_node('foo/README.txt').content == b'readme!' | |
87 |
|
87 | |||
88 | # commit some more files again |
|
88 | # commit some more files again | |
89 | to_add = [ |
|
89 | to_add = [ | |
@@ -95,11 +95,11 b' class InMemoryChangesetTestMixin(_Backen' | |||||
95 | ] |
|
95 | ] | |
96 | self.imc.add(*to_add) |
|
96 | self.imc.add(*to_add) | |
97 | changeset = self.imc.commit(u'Another', u'joe.doe@example.com') |
|
97 | changeset = self.imc.commit(u'Another', u'joe.doe@example.com') | |
98 | changeset.get_node('foo/bar/foobaz/bar').content == 'foo' |
|
98 | changeset.get_node('foo/bar/foobaz/bar').content == b'foo' | |
99 | changeset.get_node('foo/bar/another/bar').content == 'foo' |
|
99 | changeset.get_node('foo/bar/another/bar').content == b'foo' | |
100 | changeset.get_node('foo/baz.txt').content == 'foo' |
|
100 | changeset.get_node('foo/baz.txt').content == b'foo' | |
101 | changeset.get_node('foobar/foobaz/file').content == 'foo' |
|
101 | changeset.get_node('foobar/foobaz/file').content == b'foo' | |
102 | changeset.get_node('foobar/barbaz').content == 'foo' |
|
102 | changeset.get_node('foobar/barbaz').content == b'foo' | |
103 |
|
103 | |||
104 | def test_add_non_ascii_files(self): |
|
104 | def test_add_non_ascii_files(self): | |
105 | rev_count = len(self.repo.revisions) |
|
105 | rev_count = len(self.repo.revisions) | |
@@ -154,7 +154,7 b' class InMemoryChangesetTestMixin(_Backen' | |||||
154 | newtip = self.repo.get_changeset() |
|
154 | newtip = self.repo.get_changeset() | |
155 | assert tip != newtip |
|
155 | assert tip != newtip | |
156 | assert tip.id != newtip.id |
|
156 | assert tip.id != newtip.id | |
157 | assert newtip.get_node('foo/bar/baz').content == 'My **changed** content' |
|
157 | assert newtip.get_node('foo/bar/baz').content == b'My **changed** content' | |
158 |
|
158 | |||
159 | def test_change_non_ascii(self): |
|
159 | def test_change_non_ascii(self): | |
160 | to_add = [ |
|
160 | to_add = [ | |
@@ -181,8 +181,8 b' class InMemoryChangesetTestMixin(_Backen' | |||||
181 | assert tip != newtip |
|
181 | assert tip != newtip | |
182 | assert tip.id != newtip.id |
|
182 | assert tip.id != newtip.id | |
183 |
|
183 | |||
184 | assert newtip.get_node('ΕΌΓ³Εwik/zwierzΔ tko').content == 'My **changed** content' |
|
184 | assert newtip.get_node('ΕΌΓ³Εwik/zwierzΔ tko').content == b'My **changed** content' | |
185 | assert newtip.get_node('ΕΌΓ³Εwik/zwierzΔ tko_uni').content == 'My **changed** content' |
|
185 | assert newtip.get_node('ΕΌΓ³Εwik/zwierzΔ tko_uni').content == b'My **changed** content' | |
186 |
|
186 | |||
187 | def test_change_raise_empty_repository(self): |
|
187 | def test_change_raise_empty_repository(self): | |
188 | node = FileNode('foobar') |
|
188 | node = FileNode('foobar') |
@@ -158,10 +158,10 b' class TestNodeBasic(object):' | |||||
158 | tar_node = FileNode('test.tar.gz') |
|
158 | tar_node = FileNode('test.tar.gz') | |
159 |
|
159 | |||
160 | my_node2 = FileNode('myfile2') |
|
160 | my_node2 = FileNode('myfile2') | |
161 | my_node2._content = 'foobar' |
|
161 | my_node2._content = b'foobar' | |
162 |
|
162 | |||
163 | my_node3 = FileNode('myfile3') |
|
163 | my_node3 = FileNode('myfile3') | |
164 | my_node3._content = '\0foobar' |
|
164 | my_node3._content = b'\0foobar' | |
165 |
|
165 | |||
166 | assert py_node.mimetype == mimetypes.guess_type(py_node.name)[0] |
|
166 | assert py_node.mimetype == mimetypes.guess_type(py_node.name)[0] | |
167 | assert py_node.get_mimetype() == mimetypes.guess_type(py_node.name) |
|
167 | assert py_node.get_mimetype() == mimetypes.guess_type(py_node.name) |
@@ -110,7 +110,7 b' class TestGitRepositoryGetDiff(Repositor' | |||||
110 |
|
110 | |||
111 | def test_initial_commit_diff(self): |
|
111 | def test_initial_commit_diff(self): | |
112 | initial_rev = self.repo.revisions[0] |
|
112 | initial_rev = self.repo.revisions[0] | |
113 | assert self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev) == r'''diff --git a/foobar b/foobar |
|
113 | assert self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev) == br'''diff --git a/foobar b/foobar | |
114 | new file mode 100644 |
|
114 | new file mode 100644 | |
115 | index 0000000000000000000000000000000000000000..f6ea0495187600e7b2288c8ac19c5886383a4632 |
|
115 | index 0000000000000000000000000000000000000000..f6ea0495187600e7b2288c8ac19c5886383a4632 | |
116 | --- /dev/null |
|
116 | --- /dev/null | |
@@ -130,7 +130,7 b' index 0000000000000000000000000000000000' | |||||
130 |
|
130 | |||
131 | def test_second_changeset_diff(self): |
|
131 | def test_second_changeset_diff(self): | |
132 | revs = self.repo.revisions |
|
132 | revs = self.repo.revisions | |
133 | assert self.repo.get_diff(revs[0], revs[1]) == r'''diff --git a/foobar b/foobar |
|
133 | assert self.repo.get_diff(revs[0], revs[1]) == br'''diff --git a/foobar b/foobar | |
134 | index f6ea0495187600e7b2288c8ac19c5886383a4632..389865bb681b358c9b102d79abd8d5f941e96551 100644 |
|
134 | index f6ea0495187600e7b2288c8ac19c5886383a4632..389865bb681b358c9b102d79abd8d5f941e96551 100644 | |
135 | --- a/foobar |
|
135 | --- a/foobar | |
136 | +++ b/foobar |
|
136 | +++ b/foobar | |
@@ -151,7 +151,7 b' index 0000000000000000000000000000000000' | |||||
151 |
|
151 | |||
152 | def test_third_changeset_diff(self): |
|
152 | def test_third_changeset_diff(self): | |
153 | revs = self.repo.revisions |
|
153 | revs = self.repo.revisions | |
154 | assert self.repo.get_diff(revs[1], revs[2]) == r'''diff --git a/foobar b/foobar |
|
154 | assert self.repo.get_diff(revs[1], revs[2]) == br'''diff --git a/foobar b/foobar | |
155 | deleted file mode 100644 |
|
155 | deleted file mode 100644 | |
156 | index 389865bb681b358c9b102d79abd8d5f941e96551..0000000000000000000000000000000000000000 |
|
156 | index 389865bb681b358c9b102d79abd8d5f941e96551..0000000000000000000000000000000000000000 | |
157 | --- a/foobar |
|
157 | --- a/foobar | |
@@ -173,7 +173,7 b' index c11c37d41d33fb47741cff93fa5f9d798c' | |||||
173 |
|
173 | |||
174 | def test_fourth_changeset_diff(self): |
|
174 | def test_fourth_changeset_diff(self): | |
175 | revs = self.repo.revisions |
|
175 | revs = self.repo.revisions | |
176 | assert self.repo.get_diff(revs[2], revs[3]) == r'''diff --git a/README{ b/README{ |
|
176 | assert self.repo.get_diff(revs[2], revs[3]) == br'''diff --git a/README{ b/README{ | |
177 | new file mode 100644 |
|
177 | new file mode 100644 | |
178 | index 0000000000000000000000000000000000000000..cdc0c1b5d234feedb37bbac19cd1b6442061102d |
|
178 | index 0000000000000000000000000000000000000000..cdc0c1b5d234feedb37bbac19cd1b6442061102d | |
179 | --- /dev/null |
|
179 | --- /dev/null | |
@@ -189,7 +189,7 b' class TestHgRepositoryGetDiff(Repository' | |||||
189 |
|
189 | |||
190 | def test_initial_commit_diff(self): |
|
190 | def test_initial_commit_diff(self): | |
191 | initial_rev = self.repo.revisions[0] |
|
191 | initial_rev = self.repo.revisions[0] | |
192 | assert self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev) == r'''diff --git a/foobar b/foobar |
|
192 | assert self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev) == br'''diff --git a/foobar b/foobar | |
193 | new file mode 100644 |
|
193 | new file mode 100644 | |
194 | --- /dev/null |
|
194 | --- /dev/null | |
195 | +++ b/foobar |
|
195 | +++ b/foobar | |
@@ -207,7 +207,7 b' new file mode 100644' | |||||
207 |
|
207 | |||
208 | def test_second_changeset_diff(self): |
|
208 | def test_second_changeset_diff(self): | |
209 | revs = self.repo.revisions |
|
209 | revs = self.repo.revisions | |
210 | assert self.repo.get_diff(revs[0], revs[1]) == r'''diff --git a/foobar b/foobar |
|
210 | assert self.repo.get_diff(revs[0], revs[1]) == br'''diff --git a/foobar b/foobar | |
211 | --- a/foobar |
|
211 | --- a/foobar | |
212 | +++ b/foobar |
|
212 | +++ b/foobar | |
213 | @@ -1,1 +1,1 @@ |
|
213 | @@ -1,1 +1,1 @@ | |
@@ -226,7 +226,7 b' new file mode 100644' | |||||
226 |
|
226 | |||
227 | def test_third_changeset_diff(self): |
|
227 | def test_third_changeset_diff(self): | |
228 | revs = self.repo.revisions |
|
228 | revs = self.repo.revisions | |
229 | assert self.repo.get_diff(revs[1], revs[2]) == r'''diff --git a/foobar b/foobar |
|
229 | assert self.repo.get_diff(revs[1], revs[2]) == br'''diff --git a/foobar b/foobar | |
230 | deleted file mode 100644 |
|
230 | deleted file mode 100644 | |
231 | --- a/foobar |
|
231 | --- a/foobar | |
232 | +++ /dev/null |
|
232 | +++ /dev/null | |
@@ -246,7 +246,7 b' diff --git a/foobar3 b/foobar3' | |||||
246 |
|
246 | |||
247 | def test_fourth_changeset_diff(self): |
|
247 | def test_fourth_changeset_diff(self): | |
248 | revs = self.repo.revisions |
|
248 | revs = self.repo.revisions | |
249 | assert self.repo.get_diff(revs[2], revs[3]) == r'''diff --git a/README{ b/README{ |
|
249 | assert self.repo.get_diff(revs[2], revs[3]) == br'''diff --git a/README{ b/README{ | |
250 | new file mode 100644 |
|
250 | new file mode 100644 | |
251 | --- /dev/null |
|
251 | --- /dev/null | |
252 | +++ b/README{ |
|
252 | +++ b/README{ |
General Comments 0
You need to be logged in to leave comments.
Login now