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