##// END OF EJS Templates
py3: import/code fixes
marcink -
r987:1d5adfe8 python3
parent child Browse files
Show More
@@ -28,7 +28,7 b' self: super: {'
28 owner = "libgit2";
28 owner = "libgit2";
29 repo = "libgit2";
29 repo = "libgit2";
30 rev = "v1.0.1";
30 rev = "v1.0.1";
31 sha256 = "1cm8fvs05rj0baigs2133q5a0sm3pa234y8h6hmwhl2bz9xq3k4b";
31 sha256 = "0xqdnvrq1bnf8hxh9xjw25y2cg91agvd9jr5qwd30z2a0dzll22v";
32 };
32 };
33
33
34 cmakeFlags = [ "-DTHREADSAFE=ON" "-DUSE_HTTPS=no"];
34 cmakeFlags = [ "-DTHREADSAFE=ON" "-DUSE_HTTPS=no"];
@@ -40,13 +40,10 b' self: super: {'
40 super.curl
40 super.curl
41 ];
41 ];
42
42
43
44 });
43 });
45
44
46
47
48 # Override subversion derivation to
45 # Override subversion derivation to
49 # - activate python bindings
46 # - activate special python bindings
50 subversionrc =
47 subversionrc =
51 let
48 let
52 py3c = self.python37Packages.buildPythonPackage rec {
49 py3c = self.python37Packages.buildPythonPackage rec {
@@ -18,7 +18,7 b''
18 import sys
18 import sys
19 import traceback
19 import traceback
20 import logging
20 import logging
21 import urlparse
21 import urllib.parse
22
22
23 from vcsserver.lib.rc_cache import region_meta
23 from vcsserver.lib.rc_cache import region_meta
24 log = logging.getLogger(__name__)
24 log = logging.getLogger(__name__)
@@ -52,7 +52,7 b' def obfuscate_qs(query_string):'
52 return None
52 return None
53
53
54 parsed = []
54 parsed = []
55 for k, v in urlparse.parse_qsl(query_string, keep_blank_values=True):
55 for k, v in urllib.parse.parse_qsl(query_string, keep_blank_values=True):
56 if k in ['auth_token', 'api_key']:
56 if k in ['auth_token', 'api_key']:
57 v = "*****"
57 v = "*****"
58 parsed.append((k, v))
58 parsed.append((k, v))
@@ -71,6 +71,6 b' def raise_from_original(new_type):'
71 new_exc._org_exc_tb = traceback.format_exc(exc_traceback)
71 new_exc._org_exc_tb = traceback.format_exc(exc_traceback)
72
72
73 try:
73 try:
74 raise new_exc, None, exc_traceback
74 raise new_exc.with_traceback(exc_traceback)
75 finally:
75 finally:
76 del exc_traceback
76 del exc_traceback
@@ -22,8 +22,8 b' import posixpath as vcspath'
22 import re
22 import re
23 import stat
23 import stat
24 import traceback
24 import traceback
25 import urllib
25 import urllib.request, urllib.parse, urllib.error
26 import urllib2
26 import urllib.request, urllib.error, urllib.parse
27 from functools import wraps
27 from functools import wraps
28
28
29 import more_itertools
29 import more_itertools
@@ -327,13 +327,13 b' class GitRemote(RemoteBase):'
327
327
328 if authinfo:
328 if authinfo:
329 # create a password manager
329 # create a password manager
330 passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
330 passmgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
331 passmgr.add_password(*authinfo)
331 passmgr.add_password(*authinfo)
332
332
333 handlers.extend((httpbasicauthhandler(passmgr),
333 handlers.extend((httpbasicauthhandler(passmgr),
334 httpdigestauthhandler(passmgr)))
334 httpdigestauthhandler(passmgr)))
335
335
336 return urllib2.build_opener(*handlers)
336 return urllib.request.build_opener(*handlers)
337
337
338 def _type_id_to_name(self, type_id):
338 def _type_id_to_name(self, type_id):
339 return {
339 return {
@@ -359,9 +359,9 b' class GitRemote(RemoteBase):'
359 o.addheaders = [('User-Agent', 'git/1.7.8.0')] # fake some git
359 o.addheaders = [('User-Agent', 'git/1.7.8.0')] # fake some git
360
360
361 q = {"service": 'git-upload-pack'}
361 q = {"service": 'git-upload-pack'}
362 qs = '?%s' % urllib.urlencode(q)
362 qs = '?%s' % urllib.parse.urlencode(q)
363 cu = "%s%s" % (test_uri, qs)
363 cu = "%s%s" % (test_uri, qs)
364 req = urllib2.Request(cu, None, {})
364 req = urllib.request.Request(cu, None, {})
365
365
366 try:
366 try:
367 log.debug("Trying to open URL %s", cleaned_uri)
367 log.debug("Trying to open URL %s", cleaned_uri)
@@ -415,7 +415,7 b' class GitRemote(RemoteBase):'
415 def filter_with(ref):
415 def filter_with(ref):
416 return regex.match(ref[0]) and ref[1] == _commit_id
416 return regex.match(ref[0]) and ref[1] == _commit_id
417
417
418 branches = filter(filter_with, self.get_refs(wire).items())
418 branches = list(filter(filter_with, list(self.get_refs(wire).items())))
419 return [x[0].split('refs/heads/')[-1] for x in branches]
419 return [x[0].split('refs/heads/')[-1] for x in branches]
420
420
421 return _branch(context_uid, repo_id, commit_id)
421 return _branch(context_uid, repo_id, commit_id)
@@ -453,7 +453,7 b' class GitRemote(RemoteBase):'
453 for node in updated:
453 for node in updated:
454 # Compute subdirs if needed
454 # Compute subdirs if needed
455 dirpath, nodename = vcspath.split(node['path'])
455 dirpath, nodename = vcspath.split(node['path'])
456 dirnames = map(safe_str, dirpath and dirpath.split('/') or [])
456 dirnames = list(map(safe_str, dirpath and dirpath.split('/') or []))
457 parent = commit_tree
457 parent = commit_tree
458 ancestors = [('', parent)]
458 ancestors = [('', parent)]
459
459
@@ -519,7 +519,7 b' class GitRemote(RemoteBase):'
519 except KeyError:
519 except KeyError:
520 break
520 break
521 # Cut down the blob and all rotten trees on the way back...
521 # Cut down the blob and all rotten trees on the way back...
522 for path, tree in reversed(zip(paths, trees)):
522 for path, tree in reversed(list(zip(paths, trees))):
523 del tree[path]
523 del tree[path]
524 if tree:
524 if tree:
525 # This tree still has elements - don't remove it or any
525 # This tree still has elements - don't remove it or any
@@ -531,7 +531,7 b' class GitRemote(RemoteBase):'
531 # Create commit
531 # Create commit
532 commit = objects.Commit()
532 commit = objects.Commit()
533 commit.tree = commit_tree.id
533 commit.tree = commit_tree.id
534 for k, v in commit_data.iteritems():
534 for k, v in commit_data.items():
535 setattr(commit, k, v)
535 setattr(commit, k, v)
536 object_store.add_object(commit)
536 object_store.add_object(commit)
537
537
@@ -733,7 +733,7 b' class GitRemote(RemoteBase):'
733 raise exceptions.LookupException(e)(missing_commit_err)
733 raise exceptions.LookupException(e)(missing_commit_err)
734
734
735 commit_id = commit.hex
735 commit_id = commit.hex
736 type_id = commit.type
736 type_id = commit.type_str
737
737
738 return {
738 return {
739 'id': commit_id,
739 'id': commit_id,
@@ -754,7 +754,7 b' class GitRemote(RemoteBase):'
754 with repo_init as repo:
754 with repo_init as repo:
755 regex = re.compile('^refs/(heads|tags)/')
755 regex = re.compile('^refs/(heads|tags)/')
756 return {x.name: x.target.hex for x in
756 return {x.name: x.target.hex for x in
757 filter(lambda ref: regex.match(ref.name) ,repo.listall_reference_objects())}
757 [ref for ref in repo.listall_reference_objects() if regex.match(ref.name)]}
758
758
759 return _get_refs(context_uid, repo_id)
759 return _get_refs(context_uid, repo_id)
760
760
@@ -767,7 +767,7 b' class GitRemote(RemoteBase):'
767 repo_init = self._factory.repo_libgit2(wire)
767 repo_init = self._factory.repo_libgit2(wire)
768 regex = re.compile('^refs/heads')
768 regex = re.compile('^refs/heads')
769 with repo_init as repo:
769 with repo_init as repo:
770 branches = filter(lambda ref: regex.match(ref.name), repo.listall_reference_objects())
770 branches = [ref for ref in repo.listall_reference_objects() if regex.match(ref.name)]
771 return {x.target.hex: x.shorthand for x in branches}
771 return {x.target.hex: x.shorthand for x in branches}
772
772
773 return _get_branch_pointers(context_uid, repo_id)
773 return _get_branch_pointers(context_uid, repo_id)
@@ -849,12 +849,12 b' class GitRemote(RemoteBase):'
849 author = commit.get_object().author
849 author = commit.get_object().author
850
850
851 if author.email:
851 if author.email:
852 return u"{} <{}>".format(author.name, author.email)
852 return "{} <{}>".format(author.name, author.email)
853
853
854 try:
854 try:
855 return u"{}".format(author.name)
855 return "{}".format(author.name)
856 except Exception:
856 except Exception:
857 return u"{}".format(safe_unicode(author.raw_name))
857 return "{}".format(safe_unicode(author.raw_name))
858
858
859 return _author(repo_id, commit_id)
859 return _author(repo_id, commit_id)
860
860
@@ -958,7 +958,7 b' class GitRemote(RemoteBase):'
958 except KeyError:
958 except KeyError:
959 return None, None, None
959 return None, None, None
960
960
961 return tree.id.hex, tree.type, tree.filemode
961 return tree.id.hex, tree.type_str, tree.filemode
962 return _tree_and_type_for_path(context_uid, repo_id, commit_id, path)
962 return _tree_and_type_for_path(context_uid, repo_id, commit_id, path)
963
963
964 @reraise_safe_exceptions
964 @reraise_safe_exceptions
@@ -978,7 +978,7 b' class GitRemote(RemoteBase):'
978 for item in tree:
978 for item in tree:
979 item_sha = item.hex
979 item_sha = item.hex
980 item_mode = item.filemode
980 item_mode = item.filemode
981 item_type = item.type
981 item_type = item.type_str
982
982
983 if item_type == 'commit':
983 if item_type == 'commit':
984 # NOTE(marcink): submodules we translate to 'link' for backward compat
984 # NOTE(marcink): submodules we translate to 'link' for backward compat
@@ -16,4 +16,4 b''
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
18
18
19 from app import create_app
19 from .app import create_app
@@ -18,8 +18,8 b''
18 import io
18 import io
19 import logging
19 import logging
20 import stat
20 import stat
21 import urllib
21 import urllib.request, urllib.parse, urllib.error
22 import urllib2
22 import urllib.request, urllib.error, urllib.parse
23 import traceback
23 import traceback
24
24
25 from hgext import largefiles, rebase, purge
25 from hgext import largefiles, rebase, purge
@@ -402,21 +402,21 b' class HgRemote(RemoteBase):'
402
402
403 if authinfo:
403 if authinfo:
404 # create a password manager
404 # create a password manager
405 passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
405 passmgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
406 passmgr.add_password(*authinfo)
406 passmgr.add_password(*authinfo)
407
407
408 handlers.extend((httpbasicauthhandler(passmgr),
408 handlers.extend((httpbasicauthhandler(passmgr),
409 httpdigestauthhandler(passmgr)))
409 httpdigestauthhandler(passmgr)))
410
410
411 o = urllib2.build_opener(*handlers)
411 o = urllib.request.build_opener(*handlers)
412 o.addheaders = [('Content-Type', 'application/mercurial-0.1'),
412 o.addheaders = [('Content-Type', 'application/mercurial-0.1'),
413 ('Accept', 'application/mercurial-0.1')]
413 ('Accept', 'application/mercurial-0.1')]
414
414
415 q = {"cmd": 'between'}
415 q = {"cmd": 'between'}
416 q.update({'pairs': "%s-%s" % ('0' * 40, '0' * 40)})
416 q.update({'pairs': "%s-%s" % ('0' * 40, '0' * 40)})
417 qs = '?%s' % urllib.urlencode(q)
417 qs = '?%s' % urllib.parse.urlencode(q)
418 cu = "%s%s" % (test_uri, qs)
418 cu = "%s%s" % (test_uri, qs)
419 req = urllib2.Request(cu, None, {})
419 req = urllib.request.Request(cu, None, {})
420
420
421 try:
421 try:
422 log.debug("Trying to open URL %s", cleaned_uri)
422 log.debug("Trying to open URL %s", cleaned_uri)
@@ -564,7 +564,7 b' class HgRemote(RemoteBase):'
564 def _get_all_commit_ids(_context_uid, _repo_id, _name):
564 def _get_all_commit_ids(_context_uid, _repo_id, _name):
565 repo = self._factory.repo(wire)
565 repo = self._factory.repo(wire)
566 repo = repo.filtered(name)
566 repo = repo.filtered(name)
567 revs = map(lambda x: hex(x[7]), repo.changelog.index)
567 revs = [hex(x[7]) for x in repo.changelog.index]
568 return revs
568 return revs
569 return _get_all_commit_ids(context_uid, repo_id, name)
569 return _get_all_commit_ids(context_uid, repo_id, name)
570
570
@@ -663,7 +663,7 b' class HgRemote(RemoteBase):'
663 # Disable any prompts for this repo
663 # Disable any prompts for this repo
664 repo.ui.setconfig('ui', 'interactive', 'off', '-y')
664 repo.ui.setconfig('ui', 'interactive', 'off', '-y')
665
665
666 bookmarks = dict(repo._bookmarks).keys()
666 bookmarks = list(dict(repo._bookmarks).keys())
667 remote = peer(repo, {}, url)
667 remote = peer(repo, {}, url)
668 # Disable any prompts for this remote
668 # Disable any prompts for this remote
669 remote.ui.setconfig('ui', 'interactive', 'off', '-y')
669 remote.ui.setconfig('ui', 'interactive', 'off', '-y')
@@ -62,7 +62,7 b' def _dynamic_capabilities_wrapper(lfprot'
62
62
63 def patch_subrepo_type_mapping():
63 def patch_subrepo_type_mapping():
64 from collections import defaultdict
64 from collections import defaultdict
65 from hgcompat import subrepo, subrepoutil
65 from .hgcompat import subrepo, subrepoutil
66 from vcsserver.exceptions import SubrepoMergeException
66 from vcsserver.exceptions import SubrepoMergeException
67
67
68 class NoOpSubrepo(subrepo.abstractsubrepo):
68 class NoOpSubrepo(subrepo.abstractsubrepo):
@@ -25,7 +25,7 b' import collections'
25 import importlib
25 import importlib
26 import base64
26 import base64
27
27
28 from httplib import HTTPConnection
28 from http.client import HTTPConnection
29
29
30
30
31 import mercurial.scmutil
31 import mercurial.scmutil
@@ -15,16 +15,16 b''
15 # along with this program; if not, write to the Free Software Foundation,
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
18 from __future__ import absolute_import
18
19
19
20 import os
20 import os
21 import subprocess
21 import subprocess
22 from urllib2 import URLError
22 from urllib.error import URLError
23 import urlparse
23 import urllib.parse
24 import logging
24 import logging
25 import posixpath as vcspath
25 import posixpath as vcspath
26 import StringIO
26 import io
27 import urllib
27 import urllib.request, urllib.parse, urllib.error
28 import traceback
28 import traceback
29
29
30 import svn.client
30 import svn.client
@@ -224,7 +224,7 b' class SvnRemote(RemoteBase):'
224 removed = []
224 removed = []
225
225
226 # TODO: CHANGE_ACTION_REPLACE: Figure out where it belongs
226 # TODO: CHANGE_ACTION_REPLACE: Figure out where it belongs
227 for path, change in editor.changes.iteritems():
227 for path, change in editor.changes.items():
228 # TODO: Decide what to do with directory nodes. Subversion can add
228 # TODO: Decide what to do with directory nodes. Subversion can add
229 # empty directories.
229 # empty directories.
230
230
@@ -282,7 +282,7 b' class SvnRemote(RemoteBase):'
282 return _node_properties(repo_id, path, revision)
282 return _node_properties(repo_id, path, revision)
283
283
284 def file_annotate(self, wire, path, revision):
284 def file_annotate(self, wire, path, revision):
285 abs_path = 'file://' + urllib.pathname2url(
285 abs_path = 'file://' + urllib.request.pathname2url(
286 vcspath.join(wire['path'], path))
286 vcspath.join(wire['path'], path))
287 file_uri = svn.core.svn_path_canonicalize(abs_path)
287 file_uri = svn.core.svn_path_canonicalize(abs_path)
288
288
@@ -334,7 +334,7 b' class SvnRemote(RemoteBase):'
334 root = svn.fs.revision_root(fsobj, _revision)
334 root = svn.fs.revision_root(fsobj, _revision)
335 entries = svn.fs.dir_entries(root, path)
335 entries = svn.fs.dir_entries(root, path)
336 result = []
336 result = []
337 for entry_path, entry_info in entries.iteritems():
337 for entry_path, entry_info in entries.items():
338 result.append(
338 result.append(
339 (entry_path, NODE_TYPE_MAPPING.get(entry_info.kind, None)))
339 (entry_path, NODE_TYPE_MAPPING.get(entry_info.kind, None)))
340 return result
340 return result
@@ -369,7 +369,7 b' class SvnRemote(RemoteBase):'
369 compatible_version=compatible_version)
369 compatible_version=compatible_version)
370
370
371 def get_url_and_credentials(self, src_url):
371 def get_url_and_credentials(self, src_url):
372 obj = urlparse.urlparse(src_url)
372 obj = urllib.parse.urlparse(src_url)
373 username = obj.username or None
373 username = obj.username or None
374 password = obj.password or None
374 password = obj.password or None
375 return username, password, src_url
375 return username, password, src_url
@@ -568,7 +568,7 b' class SvnDiffer(object):'
568 (self.src_kind, self.tgt_kind))
568 (self.src_kind, self.tgt_kind))
569
569
570 def generate_diff(self):
570 def generate_diff(self):
571 buf = StringIO.StringIO()
571 buf = io.StringIO()
572 if self.tgt_kind == svn.core.svn_node_dir:
572 if self.tgt_kind == svn.core.svn_node_dir:
573 self._generate_dir_diff(buf)
573 self._generate_dir_diff(buf)
574 else:
574 else:
@@ -767,7 +767,7 b' class TxnNodeProcessor(object):'
767
767
768 def _update_file_properties(self):
768 def _update_file_properties(self):
769 properties = self.node.get('properties', {})
769 properties = self.node.get('properties', {})
770 for key, value in properties.iteritems():
770 for key, value in properties.items():
771 svn.fs.change_node_prop(
771 svn.fs.change_node_prop(
772 self.txn_root, self.node['path'], key, value)
772 self.txn_root, self.node['path'], key, value)
773
773
@@ -18,8 +18,8 b''
18 import contextlib
18 import contextlib
19 import io
19 import io
20 import threading
20 import threading
21 from BaseHTTPServer import BaseHTTPRequestHandler
21 from http.server import BaseHTTPRequestHandler
22 from SocketServer import TCPServer
22 from socketserver import TCPServer
23
23
24 import mercurial.ui
24 import mercurial.ui
25 import mock
25 import mock
General Comments 0
You need to be logged in to leave comments. Login now