Rev 1931: Add experimental svn-serve subcommand. in file:///data/jelmer/bzr-svn/trunk/
Jelmer Vernooij
jelmer at samba.org
Mon Oct 6 16:08:39 BST 2008
At file:///data/jelmer/bzr-svn/trunk/
------------------------------------------------------------
revno: 1931
revision-id: jelmer at samba.org-20081006150838-386vjgt628jx7188
parent: jelmer at samba.org-20081006150030-l1ux7ua7diu4ia4d
parent: jelmer at samba.org-20081006150636-32n872ou19lq58n2
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2008-10-06 17:08:38 +0200
message:
Add experimental svn-serve subcommand.
added:
server.py server.py-20081006150454-t45tvwmbhpesdh7d-1
subvertpy/subvertpy/tests/test_server.py test_server.py-20081006150547-hj71pjqjdq4a89kf-1
modified:
NEWS news-20061231030336-h9fhq245ie0de8bs-1
__init__.py __init__.py-20051008155114-eae558e6cf149e1d
subvertpy/subvertpy/server.py server.py-20081006143330-f9p0l7eih6izgoct-1
------------------------------------------------------------
revno: 1925.1.14
revision-id: jelmer at samba.org-20081006150636-32n872ou19lq58n2
parent: jelmer at samba.org-20081006145521-053crzkfoxq8vbkj
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2008-10-06 17:06:36 +0200
message:
Fix imports add stub for server tests.
added:
subvertpy/tests/test_server.py test_server.py-20081006150547-hj71pjqjdq4a89kf-1
modified:
subvertpy/server.py server.py-20081006143330-f9p0l7eih6izgoct-1
=== modified file 'NEWS'
--- a/NEWS 2008-09-28 20:16:25 +0000
+++ b/NEWS 2008-10-06 15:08:38 +0000
@@ -32,6 +32,8 @@
* Add --until option to svn-import.
+ * Add experimental svn-serve subcommand.
+
BUG FIXES
* Set bzr signature revision property during commit if possible.
=== modified file '__init__.py'
--- a/__init__.py 2008-10-02 21:18:28 +0000
+++ b/__init__.py 2008-10-06 15:08:38 +0000
@@ -533,6 +533,63 @@
register_command(cmd_svn_layout)
+class cmd_svn_serve(Command):
+ """Provide access to a Bazaar branch using the Subversion ra_svn protocol.
+ """
+ takes_options = [
+ Option('inet',
+ help='serve on stdin/out for use from inetd or sshd'),
+ Option('port',
+ help='listen for connections on nominated port of the form '
+ '[hostname:]portnumber. Passing 0 as the port number will '
+ 'result in a dynamically allocated port.',
+ type=str),
+ Option('directory',
+ help='serve contents of directory',
+ type=unicode)
+ ]
+
+ def run(self, inet=None, port=None, directory=None):
+ from subvertpy.server import SVNServer
+ from bzrlib.plugins.svn.server import BzrServerBackend
+ import threading
+
+ if directory is None:
+ directory = os.getcwd()
+
+ if inet:
+ def send_fn(data):
+ sys.stdout.write(data)
+ sys.stdout.flush()
+ server = SVNServer(BzrServerBackend(directory), sys.stdin.read,
+ send_fn)
+ server.serve()
+ else:
+ if port is None:
+ port = 3690
+ else:
+ port = int(port)
+
+ import socket
+ server_sock = socket.socket()
+ server_sock.bind(('0.0.0.0', port))
+ server_sock.listen(5)
+ def handle_new_client(sock):
+ def handle_connection():
+ server.serve()
+ sock.close()
+ server = SVNServer(directory, lambda: sock.recv(1024), sock.send)
+ server_thread = threading.Thread(None, handle_connection, name='svn-smart-server')
+ server_thread.setDaemon(True)
+ server_thread.start()
+
+ while True:
+ sock, _ = server_sock.accept()
+ handle_new_client(sock)
+
+
+register_command(cmd_svn_serve)
+
def test_suite():
"""Returns the testsuite for bzr-svn."""
from unittest import TestSuite
=== added file 'server.py'
--- a/server.py 1970-01-01 00:00:00 +0000
+++ b/server.py 2008-10-06 15:08:38 +0000
@@ -0,0 +1,41 @@
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer at samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+"""Subversion server implementation."""
+
+from bzrlib.branch import Branch
+
+from subvertpy.server import SVNServer, ServerBackend, ServerRepositoryBackend
+
+class RepositoryBackend(ServerRepositoryBackend):
+
+ def __init__(self, branch):
+ self.branch = branch
+
+ def get_uuid(self):
+ config = self.branch.get_config()
+ uuid = config.get_user_option('svn_uuid')
+ if uuid is None:
+ import uuid
+ uuid = uuid.uuid4()
+ config.set_user_option('svn_uuid', uuid)
+ return str(uuid)
+
+
+class BzrServerBackend(ServerBackend):
+
+ def open_repository(self, path):
+ (branch, relpath) = Branch.open_containing(os.path.join(self.rootdir, location))
+ return RepositoryBackend(branch), relpath
=== modified file 'subvertpy/subvertpy/server.py'
--- a/subvertpy/subvertpy/server.py 2008-10-06 14:51:53 +0000
+++ b/subvertpy/subvertpy/server.py 2008-10-06 15:06:36 +0000
@@ -18,7 +18,7 @@
import os
import time
-from subvertpy import SVN_NODE_NONE, SVN_NODE_FILE, SVN_NODE_DIR
+from subvertpy import NODE_NONE, NODE_FILE, NODE_DIR
from subvertpy.marshall import marshall, unmarshall, literal, MarshallError
@@ -72,7 +72,7 @@
self.send_success(self.repo_backend.get_latest_revnum())
def check_path(self, path, revnum):
- return SVN_NODE_DIR
+ return NODE_DIR
def log(self, target_path, start_rev, end_rev, changed_paths,
strict_node, limit=None):
=== added file 'subvertpy/subvertpy/tests/test_server.py'
--- a/subvertpy/subvertpy/tests/test_server.py 1970-01-01 00:00:00 +0000
+++ b/subvertpy/subvertpy/tests/test_server.py 2008-10-06 15:06:36 +0000
@@ -0,0 +1,20 @@
+# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer at samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""Subversion server tests."""
+
+from subvertpy.server import SVNServer
+from subvertpy.tests import SubversionTestCase
+
More information about the bazaar-commits
mailing list