lfs: add an experimental config to override User-Agent for the blob transfer
authorMatt Harbison <matt_harbison@yahoo.com>
Tue, 12 Dec 2017 15:16:02 -0500
changeset 35440 e333d27514b0
parent 35439 e7bb5fc4570c
child 35441 98cc121099fe
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.
hgext/lfs/__init__.py
hgext/lfs/blobstore.py
--- a/hgext/lfs/__init__.py	Thu Dec 14 13:04:08 2017 -0500
+++ b/hgext/lfs/__init__.py	Tue Dec 12 15:16:02 2017 -0500
@@ -64,6 +64,10 @@
 configtable = {}
 configitem = registrar.configitem(configtable)
 
+configitem('experimental', 'lfs.user-agent',
+    default=None,
+)
+
 configitem('lfs', 'url',
     default=configitem.dynamicdefault,
 )
--- a/hgext/lfs/blobstore.py	Thu Dec 14 13:04:08 2017 -0500
+++ b/hgext/lfs/blobstore.py	Tue Dec 12 15:16:02 2017 -0500
@@ -125,7 +125,9 @@
         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')