Patchwork [02,of,11] py3: add b'' prefixes to the LFS server module

login
register
mail settings
Submitter Matt Harbison
Date Jan. 28, 2019, 5:20 a.m.
Message ID <7768ad6f53d8e08e9091.1548652848@Envy>
Download mbox | patch
Permalink /patch/38127/
State Accepted
Headers show

Comments

Matt Harbison - Jan. 28, 2019, 5:20 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1548567416 18000
#      Sun Jan 27 00:36:56 2019 -0500
# Node ID 7768ad6f53d8e08e90918e50201fc2fab4f9eff6
# Parent  2b6e1f299ac278097680b54134f87c12e90bf909
py3: add b'' prefixes to the LFS server module

There are a ton of these changes in the blobstore, as well as r'' prefixing.  So
separating these out hopefully makes review easier.

# skip-blame for b'' prefixing

Patch

diff --git a/hgext/lfs/wireprotolfsserver.py b/hgext/lfs/wireprotolfsserver.py
--- a/hgext/lfs/wireprotolfsserver.py
+++ b/hgext/lfs/wireprotolfsserver.py
@@ -43,7 +43,7 @@  def handlewsgirequest(orig, rctx, req, r
     if orig(rctx, req, res, checkperm):
         return True
 
-    if not rctx.repo.ui.configbool('experimental', 'lfs.serve'):
+    if not rctx.repo.ui.configbool(b'experimental', b'lfs.serve'):
         return False
 
     if not util.safehasattr(rctx.repo.svfs, 'lfslocalblobstore'):
@@ -54,7 +54,7 @@  def handlewsgirequest(orig, rctx, req, r
 
     try:
         if req.dispatchpath == b'.git/info/lfs/objects/batch':
-            checkperm(rctx, req, 'pull')
+            checkperm(rctx, req, b'pull')
             return _processbatchrequest(rctx.repo, req, res)
         # TODO: reserve and use a path in the proposed http wireprotocol /api/
         #       namespace?
@@ -81,7 +81,7 @@  def _sethttperror(res, code, message=Non
 def _logexception(req):
     """Write information about the current exception to wsgi.errors."""
     tb = pycompat.sysbytes(traceback.format_exc())
-    errorlog = req.rawenv[r'wsgi.errors']
+    errorlog = req.rawenv[b'wsgi.errors']
 
     uri = b''
     if req.apppath:
@@ -209,7 +209,7 @@  def _batchresponseobjects(req, objects, 
         # verified as the file is streamed to the caller.
         try:
             verifies = store.verify(oid)
-            if verifies and action == 'upload':
+            if verifies and action == b'upload':
                 # The client will skip this upload, but make sure it remains
                 # available locally.
                 store.linkfromusercache(oid)
@@ -228,7 +228,7 @@  def _batchresponseobjects(req, objects, 
 
         # Items are always listed for downloads.  They are dropped for uploads
         # IFF they already exist locally.
-        if action == 'download':
+        if action == b'download':
             if not exists:
                 rsp['error'] = {
                     'code': 404,
@@ -259,8 +259,8 @@  def _batchresponseobjects(req, objects, 
                 'Accept': 'application/vnd.git-lfs'
             }
 
-            auth = req.headers.get('Authorization', '')
-            if auth.startswith('Basic '):
+            auth = req.headers.get(b'Authorization', b'')
+            if auth.startswith(b'Basic '):
                 hdr['Authorization'] = auth
 
             return hdr
@@ -297,7 +297,7 @@  def _processbasictransfer(repo, req, res
         return True
 
     if method == b'PUT':
-        checkperm('upload')
+        checkperm(b'upload')
 
         # TODO: verify Content-Type?
 
@@ -324,7 +324,7 @@  def _processbasictransfer(repo, req, res
 
         return True
     elif method == b'GET':
-        checkperm('pull')
+        checkperm(b'pull')
 
         res.status = hgwebcommon.statusmessage(HTTP_OK)
         res.headers[b'Content-Type'] = b'application/octet-stream'