瀏覽代碼

Announce agent in dulwich.server as well.

Jelmer Vernooij 9 年之前
父節點
當前提交
bc52b03c58
共有 3 個文件被更改,包括 18 次插入5 次删除
  1. 4 4
      dulwich/client.py
  2. 11 0
      dulwich/protocol.py
  3. 3 1
      dulwich/server.py

+ 4 - 4
dulwich/client.py

@@ -62,6 +62,7 @@ from dulwich.errors import (
     )
 from dulwich.protocol import (
     _RBUFSIZE,
+    capability_agent,
     CAPABILITY_DELETE_REFS,
     CAPABILITY_MULTI_ACK,
     CAPABILITY_MULTI_ACK_DETAILED,
@@ -94,10 +95,7 @@ def _fileno_can_read(fileno):
     """Check if a file descriptor is readable."""
     return len(select.select([fileno], [], [], 0)[0]) > 0
 
-CAPABILITY_AGENT = ("agent=dulwich/%d.%d.%d" % dulwich.__version__).encode('ascii')
-
-COMMON_CAPABILITIES = [CAPABILITY_OFS_DELTA, CAPABILITY_SIDE_BAND_64K,
-                       CAPABILITY_AGENT]
+COMMON_CAPABILITIES = [CAPABILITY_OFS_DELTA, CAPABILITY_SIDE_BAND_64K]
 FETCH_CAPABILITIES = ([CAPABILITY_THIN_PACK, CAPABILITY_MULTI_ACK,
                        CAPABILITY_MULTI_ACK_DETAILED] +
                       COMMON_CAPABILITIES)
@@ -197,7 +195,9 @@ class GitClient(object):
         self._report_activity = report_activity
         self._report_status_parser = None
         self._fetch_capabilities = set(FETCH_CAPABILITIES)
+        self._fetch_capabilities.add(capability_agent())
         self._send_capabilities = set(SEND_CAPABILITIES)
+        self._send_capabilities.add(capability_agent())
         if not thin_packs:
             self._fetch_capabilities.remove(CAPABILITY_THIN_PACK)
 

+ 11 - 0
dulwich/protocol.py

@@ -25,6 +25,7 @@ from os import (
     )
 import socket
 
+import dulwich
 from dulwich.errors import (
     HangupException,
     GitProtocolError,
@@ -57,6 +58,16 @@ CAPABILITY_REPORT_STATUS = b'report-status'
 CAPABILITY_SHALLOW = b'shallow'
 CAPABILITY_SIDE_BAND_64K = b'side-band-64k'
 CAPABILITY_THIN_PACK = b'thin-pack'
+CAPABILITY_AGENT = b'agent'
+
+
+def agent_string():
+    return ('dulwich/%d.%d.%d' % dulwich.__version__).encode('ascii')
+
+
+def capability_agent():
+    return CAPABILITY_AGENT + b'=' + agent_string()
+
 
 COMMAND_DEEPEN = b'deepen'
 COMMAND_SHALLOW = b'shallow'

+ 3 - 1
dulwich/server.py

@@ -68,6 +68,7 @@ from dulwich.pack import (
     )
 from dulwich.protocol import (
     BufferedPktLineWriter,
+    capability_agent,
     CAPABILITY_DELETE_REFS,
     CAPABILITY_INCLUDE_TAG,
     CAPABILITY_MULTI_ACK_DETAILED,
@@ -220,7 +221,8 @@ class Handler(object):
     @classmethod
     def innocuous_capabilities(cls):
         return (CAPABILITY_INCLUDE_TAG, CAPABILITY_THIN_PACK,
-                CAPABILITY_NO_PROGRESS, CAPABILITY_OFS_DELTA)
+                CAPABILITY_NO_PROGRESS, CAPABILITY_OFS_DELTA,
+                capability_agent())
 
     @classmethod
     def required_capabilities(cls):