# HG changeset patch # User Manuel Jacob <me@manueljacob.de> # Date 1588560099 -7200 # Mon May 04 04:41:39 2020 +0200 # Node ID da65c2fdeac40e917544bdd9884e59ef3ee4bd4b # Parent cd897a67ec0b6ec60a8b93d2b6ac82cda16b9958 py3: byteify doctests diff --git a/hggit/git_handler.py b/hggit/git_handler.py --- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -653,19 +653,19 @@ >>> from collections import namedtuple >>> from mercurial.ui import ui >>> mockrepo = namedtuple('localrepo', ['vfs', 'sharedpath', 'path']) - >>> mockrepo.vfs = '' - >>> mockrepo.sharedpath = '' - >>> mockrepo.path = '' + >>> mockrepo.vfs = b'' + >>> mockrepo.sharedpath = b'' + >>> mockrepo.path = b'' >>> g = GitHandler(mockrepo, ui()).get_valid_git_username_email - >>> g('John Doe') + >>> g(b'John Doe') 'John Doe' - >>> g('john@doe.com') + >>> g(b'john@doe.com') 'john@doe.com' - >>> g(' <john@doe.com> ') + >>> g(b' <john@doe.com> ') 'john@doe.com' - >>> g(' <random<\n<garbage\n> > > ') + >>> g(b' <random<\n<garbage\n> > > ') 'random???garbage?' - >>> g('Typo in hgrc >but.hg-git@handles.it.gracefully>') + >>> g(b'Typo in hgrc >but.hg-git@handles.it.gracefully>') 'Typo in hgrc ?but.hg-git@handles.it.gracefully' """ return RE_GIT_SANITIZE_AUTHOR.sub(b'?', name.lstrip(b'< ').rstrip(b'> ')) @@ -1672,17 +1672,17 @@ >>> from dulwich.client import HttpGitClient, SSHGitClient >>> from mercurial.ui import ui >>> mockrepo = namedtuple('localrepo', ['vfs', 'sharedpath', 'path']) - >>> mockrepo.vfs = '' - >>> mockrepo.sharedpath = '' - >>> mockrepo.path = '' + >>> mockrepo.vfs = b'' + >>> mockrepo.sharedpath = b'' + >>> mockrepo.path = b'' >>> g = GitHandler(mockrepo, ui()) >>> tp = g.get_transport_and_path - >>> client, url = tp('http://fqdn.com/test.git') + >>> client, url = tp(b'http://fqdn.com/test.git') >>> print(isinstance(client, HttpGitClient)) True >>> print(url) http://fqdn.com/test.git - >>> client, url = tp('git@fqdn.com:user/repo.git') + >>> client, url = tp(b'git@fqdn.com:user/repo.git') >>> print(isinstance(client, SSHGitClient)) True >>> print(url) diff --git a/hggit/hg2git.py b/hggit/hg2git.py --- a/hggit/hg2git.py +++ b/hggit/hg2git.py @@ -37,7 +37,7 @@ ... def warn(self, s): ... print(s) >>> u = fakeui() - >>> audit_git_path(u, 'foo/git~100/wat') + >>> audit_git_path(u, b'foo/git~100/wat') ... # doctest: +ELLIPSIS warning: path 'foo/git~100/wat' contains a potentially dangerous ... It may not be legal to check out in Git. @@ -49,7 +49,7 @@ It may not be legal to check out in Git. It may also be rejected by some git server configurations. <BLANKLINE> - >>> audit_git_path(u, 'this/is/safe') + >>> audit_git_path(u, b'this/is/safe') """ dangerous = False for c in path.split(os.path.sep): diff --git a/hggit/util.py b/hggit/util.py --- a/hggit/util.py +++ b/hggit/util.py @@ -73,17 +73,17 @@ Tests: - >>> print(isgitsshuri('http://fqdn.com/hg')) + >>> print(isgitsshuri(b'http://fqdn.com/hg')) False - >>> print(isgitsshuri('http://fqdn.com/test.git')) + >>> print(isgitsshuri(b'http://fqdn.com/test.git')) False - >>> print(isgitsshuri('git@github.com:user/repo.git')) + >>> print(isgitsshuri(b'git@github.com:user/repo.git')) True - >>> print(isgitsshuri('github-123.com:user/repo.git')) + >>> print(isgitsshuri(b'github-123.com:user/repo.git')) True - >>> print(isgitsshuri('git@127.0.0.1:repo.git')) + >>> print(isgitsshuri(b'git@127.0.0.1:repo.git')) True - >>> print(isgitsshuri('git@[2001:db8::1]:repository.git')) + >>> print(isgitsshuri(b'git@[2001:db8::1]:repository.git')) True """ for scheme in gitschemes: diff --git a/tests/test-extra.t b/tests/test-extra.t --- a/tests/test-extra.t +++ b/tests/test-extra.t @@ -132,20 +132,20 @@ >>> from dulwich.porcelain import open_repo >>> repo = open_repo('.') >>> c = Commit() - >>> c.author = 'test <test@example.org>' + >>> c.author = b'test <test@example.org>' >>> c.author_time = 0 >>> c.author_timezone = 0 >>> c.committer = c.author >>> c.commit_time = 0 >>> c.commit_timezone = 0 - >>> c.parents = ['$commit_sha'] - >>> c.tree = '$tree_sha' - >>> c.message = 'extra commit\n' - >>> c.extra.extend([('zzz:zzz', 'data:zzz'), ('aaa:aaa', 'data:aaa'), - ... ('HG:extra', 'hgaaa:dataaaa'), - ... ('HG:extra', 'hgzzz:datazzz')]) + >>> c.parents = [b'$commit_sha'] + >>> c.tree = b'$tree_sha' + >>> c.message = b'extra commit\n' + >>> c.extra.extend([(b'zzz:zzz', b'data:zzz'), (b'aaa:aaa', b'data:aaa'), + ... (b'HG:extra', b'hgaaa:dataaaa'), + ... (b'HG:extra', b'hgzzz:datazzz')]) >>> repo.object_store.add_object(c) - >>> repo.refs.set_if_equals('refs/heads/master', None, c.id) + >>> repo.refs.set_if_equals(b'refs/heads/master', None, c.id) True $ git cat-file commit master