Make dul-daemon a trivial wrapper around server functionality.
authorDave Borowitz <dborowitz@google.com>
Wed, 21 Jul 2010 11:33:38 +0000 (13:33 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 21 Jul 2010 11:33:38 +0000 (13:33 +0200)
NEWS
bin/dul-daemon
dulwich/server.py

diff --git a/NEWS b/NEWS
index 44233055bf6997a22f873a87065c17ce23b50e61..e80d30cef48cd13a0b9ca3cab6fc7f16350fa200 100644 (file)
--- a/NEWS
+++ b/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
 
index dbc23ea9a610567d39620a769db18adb9256f9da..020ad9441b7f53cc5af958460a22ccaad2e0f2cc 100755 (executable)
 # 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()
index 14f78b9992143cba73a73b4e0eb5413469f73e90..524a2223262b72272940a4a13ee4f9c12bb99246 100644 (file)
@@ -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()