Patchwork [2,of,2,V3] lfs: add an experimental config to override User-Agent for the blob transfer

login
register
mail settings
Submitter Matt Harbison
Date Dec. 14, 2017, 6:53 p.m.
Message ID <a2ae07e57a0c91274018.1513277629@MATT7H-PC.attotech.com>
Download mbox | patch
Permalink /patch/26283/
State Accepted
Headers show

Comments

Matt Harbison - Dec. 14, 2017, 6:53 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1513109762 18000
#      Tue Dec 12 15:16:02 2017 -0500
# Node ID a2ae07e57a0c91274018299afb250f0b921e4eb4
# Parent  5482c3c48da7a5e8050aa0a39670a4ce3e5f8a79
lfs: add an experimental config to override User-Agent for the blob transfer

This will allow developers to test against various server implementations.  I
didn't put it under [devel] because it's possible that some user needs to use it
in the field.
Augie Fackler - Dec. 15, 2017, 11:20 p.m.
On Thu, Dec 14, 2017 at 01:53:49PM -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1513109762 18000
> #      Tue Dec 12 15:16:02 2017 -0500
> # Node ID a2ae07e57a0c91274018299afb250f0b921e4eb4
> # Parent  5482c3c48da7a5e8050aa0a39670a4ce3e5f8a79
> lfs: add an experimental config to override User-Agent for the blob transfer

queued, thanks


(It's tempting to send some crazy git version, like git/42.0, but I
think what you did is sensible.)

Patch

diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -63,6 +63,10 @@  testedwith = 'ships-with-hg-core'
 configtable = {}
 configitem = registrar.configitem(configtable)
 
+configitem('experimental', 'lfs.user-agent',
+    default=None,
+)
+
 configitem('lfs', 'url',
     default=configitem.dynamicdefault,
 )
diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
--- a/hgext/lfs/blobstore.py
+++ b/hgext/lfs/blobstore.py
@@ -101,7 +101,9 @@  class _gitlfsremote(object):
         self.ui = ui
         baseurl, authinfo = url.authinfo()
         self.baseurl = baseurl.rstrip('/')
-        useragent = 'mercurial/%s git/2.15.1' % util.version()
+        useragent = repo.ui.config('experimental', 'lfs.user-agent')
+        if not useragent:
+            useragent = 'mercurial/%s git/2.15.1' % util.version()
         self.urlopener = urlmod.opener(ui, authinfo, useragent)
         self.retry = ui.configint('lfs', 'retry')