Kaynağa Gözat

Make dul-daemon a trivial wrapper around server functionality.

Dave Borowitz 14 yıl önce
ebeveyn
işleme
d932b3a447
3 değiştirilmiş dosya ile 22 ekleme ve 14 silme
  1. 3 0
      NEWS
  2. 3 14
      bin/dul-daemon
  3. 16 0
      dulwich/server.py

+ 3 - 0
NEWS

@@ -40,6 +40,9 @@
   * dulwich.pack.write_pack_index_v{1,2} now take a file-like object
     rather than a filename. (Jelmer Vernooij)
 
+  * Make dul-daemon a trivial wrapper around server functionality.
+    (Dave Borowitz)
+
 
 0.6.0	2010-05-22
 

+ 3 - 14
bin/dul-daemon

@@ -17,18 +17,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
-import sys
-from dulwich.log_utils import default_logging_config
-from dulwich.repo import Repo
-from dulwich.server import DictBackend, TCPGitServer
+from dulwich.server import main
 
-if __name__ == "__main__":
-    if len(sys.argv) > 1:
-        gitdir = sys.argv[1]
-    else:
-        gitdir = "."
-
-    default_logging_config()
-    backend = DictBackend({"/": Repo(gitdir)})
-    server = TCPGitServer(backend, 'localhost')
-    server.serve_forever()
+if __name__ == '__main__':
+    main()

+ 16 - 0
dulwich/server.py

@@ -58,6 +58,9 @@ from dulwich.protocol import (
     extract_capabilities,
     extract_want_line_capabilities,
     )
+from dulwich.repo import (
+    Repo,
+    )
 
 
 logger = log_utils.getLogger(__name__)
@@ -708,3 +711,16 @@ class TCPGitServer(SocketServer.TCPServer):
     def handle_error(self, request, client_address):
         logger.exception('Exception happened during processing of request '
                          'from %s', client_address)
+
+
+def main(argv=sys.argv):
+    """Entry point for starting a TCP git server."""
+    if len(argv) > 1:
+        gitdir = argv[1]
+    else:
+        gitdir = '.'
+
+    log_utils.default_logging_config()
+    backend = DictBackend({'/': Repo(gitdir)})
+    server = TCPGitServer(backend, 'localhost')
+    server.serve_forever()