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 4423305..e80d30c 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 dbc23ea..020ad94 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 14f78b9..524a222 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()