launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #23080
[Merge] ~cjwatson/turnip:pygit2-0.27.2 into turnip:master
Colin Watson has proposed merging ~cjwatson/turnip:pygit2-0.27.2 into turnip:master.
Commit message:
Upgrade to pygit2 0.27.2
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/turnip/+git/turnip/+merge/358843
The necessary dependencies are in ppa:cjwatson/ubuntu/launchpad and https://code.launchpad.net/~cjwatson/turnip/+git/dependencies/+merge/358842.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/turnip:pygit2-0.27.2 into turnip:master.
diff --git a/requirements.txt b/requirements.txt
index d22846f..6d50d36 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -33,7 +33,7 @@ pyasn1==0.1.7
pycparser==2.10
pycrypto==2.6.1
pyflakes==0.8.1
-pygit2==0.24.2
+pygit2==0.27.2
pyramid==1.5.4
python-mimeparse==0.1.4
# XXX: deryck 2012-08-10
diff --git a/setup.py b/setup.py
index 38b6681..c7ccd2a 100755
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@ requires = [
'cornice',
'lazr.sshserver>=0.1.7',
'Paste',
- 'pygit2>=0.24.0,<0.25.0',
+ 'pygit2>=0.27.2,<0.28.0',
'python-openid',
'PyYAML',
'Twisted[conch]',
diff --git a/system-dependencies.txt b/system-dependencies.txt
index 092754d..93068aa 100644
--- a/system-dependencies.txt
+++ b/system-dependencies.txt
@@ -2,7 +2,7 @@ build-essential
cgit
git
libffi-dev
-libgit2-24
+libgit2-27
libssl-dev
python-dev
python-virtualenv
diff --git a/turnip/api/store.py b/turnip/api/store.py
index 2e53e5a..248330e 100644
--- a/turnip/api/store.py
+++ b/turnip/api/store.py
@@ -55,9 +55,20 @@ def format_commit(git_object):
raise GitError('Invalid type: object {} is not a commit.'.format(
git_object.oid.hex))
parents = [parent.hex for parent in git_object.parent_ids]
+ # A regression in pygit2 0.27.1 means that we have to decode the commit
+ # message ourselves. See:
+ # https://github.com/libgit2/pygit2/issues/839
+ if git_object.message_encoding is not None:
+ message = git_object.raw_message.decode(
+ encoding=git_object.message_encoding, errors="strict")
+ else:
+ # If the encoding is not explicit, it may not be UTF-8, so it is not
+ # safe to decode it strictly.
+ message = git_object.raw_message.decode(
+ encoding="UTF-8", errors="replace")
return {
'sha1': git_object.oid.hex,
- 'message': git_object.message,
+ 'message': message,
'author': format_signature(git_object.author),
'committer': format_signature(git_object.committer),
'parents': parents,
@@ -144,8 +155,8 @@ def import_into_subordinate(sub_root, from_root):
from_repo = Repository(from_root)
sub_repo = Repository(sub_root)
for ref in from_repo.listall_references():
- sub_repo.create_reference(
- ref, from_repo.lookup_reference(ref).target, force=True)
+ sub_repo.references.create(
+ ref, from_repo.references[ref].target, force=True)
def init_repo(repo_path, clone_from=None, clone_refs=False,
@@ -181,8 +192,7 @@ def init_repo(repo_path, clone_from=None, clone_refs=False,
from_repo = Repository(clone_from)
to_repo = Repository(repo_path)
for ref in from_repo.listall_references():
- to_repo.create_reference(
- ref, from_repo.lookup_reference(ref).target)
+ to_repo.references.create(ref, from_repo.references[ref].target)
ensure_config(repo_path) # set repository configuration defaults
return repo_path
@@ -226,7 +236,7 @@ def open_repo(repo_store, repo_name, force_ephemeral=False):
def get_default_branch(repo_path):
repo = Repository(repo_path)
- return repo.lookup_reference('HEAD').target
+ return repo.references['HEAD'].target
def set_default_branch(repo_path, target):
@@ -274,7 +284,7 @@ def get_refs(repo_store, repo_name):
with open_repo(repo_store, repo_name) as repo:
refs = {}
for ref in repo.listall_references():
- git_object = repo.lookup_reference(ref).peel()
+ git_object = repo.references[ref].peel()
# Filter non-unicode refs, as refs are treated as unicode
# given json is unable to represent arbitrary byte strings.
try:
@@ -289,7 +299,7 @@ def get_refs(repo_store, repo_name):
def get_ref(repo_store, repo_name, ref):
"""Return a specific ref for a git repository."""
with open_repo(repo_store, repo_name) as repo:
- git_object = repo.lookup_reference(ref.encode('utf-8')).peel()
+ git_object = repo.references[ref.encode('utf-8')].peel()
ref_obj = format_ref(ref, git_object)
return ref_obj
diff --git a/turnip/api/tests/test_api.py b/turnip/api/tests/test_api.py
index 1bbfb60..adbf3be 100644
--- a/turnip/api/tests/test_api.py
+++ b/turnip/api/tests/test_api.py
@@ -47,8 +47,8 @@ class ApiTestCase(TestCase):
def assertReferencesEqual(self, repo, expected, observed):
self.assertEqual(
- repo.lookup_reference(expected).peel().oid,
- repo.lookup_reference(observed).peel().oid)
+ repo.references[expected].peel().oid,
+ repo.references[observed].peel().oid)
def get_ref(self, ref):
resp = self.app.get('/repo/{}/{}'.format(self.repo_path, ref))
@@ -104,7 +104,7 @@ class ApiTestCase(TestCase):
factory = RepoFactory(self.repo_store, num_branches=2, num_commits=1)
factory.build()
factory.repo.set_head('refs/heads/branch-0')
- factory.repo.lookup_reference('refs/heads/branch-0').delete()
+ factory.repo.references.delete('refs/heads/branch-0')
resp = self.app.get('/repo/{}'.format(self.repo_path))
self.assertEqual(200, resp.status_code)
diff --git a/turnip/api/tests/test_helpers.py b/turnip/api/tests/test_helpers.py
index 19d397c..28ed9df 100644
--- a/turnip/api/tests/test_helpers.py
+++ b/turnip/api/tests/test_helpers.py
@@ -82,9 +82,9 @@ class RepoFactory(object):
def set_head(self, oid):
try:
- master_ref = self.repo.lookup_reference('refs/heads/master')
+ master_ref = self.repo.references['refs/heads/master']
except KeyError:
- master_ref = self.repo.create_reference('refs/heads/master', oid)
+ master_ref = self.repo.references.create('refs/heads/master', oid)
finally:
master_ref.set_target(oid)
@@ -124,9 +124,9 @@ class RepoFactory(object):
if i == num_commits - 1:
ref = 'refs/heads/master'
try:
- self.repo.lookup_reference(ref)
+ self.repo.references[ref]
except KeyError:
- self.repo.create_reference(ref, commit_oid)
+ self.repo.references.create(ref, commit_oid)
self.repo.set_head(commit_oid)
def generate_tags(self, num_tags):
diff --git a/turnip/api/tests/test_store.py b/turnip/api/tests/test_store.py
index ce6a5a1..3ef6dc7 100644
--- a/turnip/api/tests/test_store.py
+++ b/turnip/api/tests/test_store.py
@@ -73,7 +73,7 @@ class InitTestCase(TestCase):
orig = RepoFactory(
self.orig_path, num_branches=3, num_commits=2).build()
self.orig_refs = orig.listall_references()
- self.master_oid = orig.lookup_reference('refs/heads/master').target
+ self.master_oid = orig.references['refs/heads/master'].target
self.orig_objs = os.path.join(self.orig_path, '.git/objects')
def test_from_scratch(self):