Merge lp:~jelmer/launchpad/git-server into lp:launchpad

Proposed by Jelmer Vernooij
Status: Work in progress
Proposed branch: lp:~jelmer/launchpad/git-server
Merge into: lp:launchpad
Diff against target: 128 lines (+53/-2)
4 files modified
bzrplugins/lpserve/__init__.py (+33/-2)
lib/lp/codehosting/sshserver/session.py (+6/-0)
lib/lp/codehosting/sshserver/tests/test_session.py (+8/-0)
lib/lp/services/features/flags.py (+6/-0)
To merge this branch: bzr merge lp:~jelmer/launchpad/git-server
Reviewer Review Type Date Requested Status
Launchpad code reviewers Pending
Review via email: mp+86606@code.launchpad.net

Commit message

Add the early beginnings of git+ssh support.

Description of the change

Add basic support for the Git SSH server in Launchpad, through bzr.

This is enough to make:

git clone git+ssh://bazaar.launchpad.dev/~vcs-imports/etckeeper/trunk

work on my machine, but that's about it.

What it doesn't do:
 * perform reasonably
 * update the ui to mention git+ssh
 * work for branches that have data in them that is not round-trippable (basically, anything that is not a git import) - bugs #863261 and #544776

This isn't ready yet, I'm submitting it here for the diff and to track its status. This has to be fixed before it can be reviewed/landed:

 * use a feature flag
 * path sanitization (see the FIXME)
 * tests

To post a comment you must log in.
lp:~jelmer/launchpad/git-server updated
14510. By Jelmer Vernooij

Merge lp:launchpad.

14511. By Jelmer Vernooij

Add code.git feature flag.

14512. By Jelmer Vernooij

Rename feature to code.sshserver.git.

14513. By Jelmer Vernooij

Add bug #

Unmerged revisions

14513. By Jelmer Vernooij

Add bug #

14512. By Jelmer Vernooij

Rename feature to code.sshserver.git.

14511. By Jelmer Vernooij

Add code.git feature flag.

14510. By Jelmer Vernooij

Merge lp:launchpad.

14509. By Jelmer Vernooij

Drop git format support - focus just on the server in this branch.

14508. By Jelmer Vernooij

Update source code cache.

14507. By Jelmer Vernooij

Merge lp:launchpad

14506. By Jelmer Vernooij

merge lp:launchpad

14505. By Jelmer Vernooij

Merge lp:launchpad.

14504. By Jelmer Vernooij

Update to newer version of bzr-git.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrplugins/lpserve/__init__.py'
2--- bzrplugins/lpserve/__init__.py 2011-12-21 06:14:46 +0000
3+++ bzrplugins/lpserve/__init__.py 2012-01-03 19:50:31 +0000
4@@ -58,6 +58,34 @@
5 aliases = ['lp-serve']
6
7 takes_options = [
8+<<<<<<< TREE
9+ Option('inet',
10+ help='serve on stdin/out for use from inetd or sshd'),
11+ Option('port',
12+ help='listen for connections on nominated port of the form '
13+ '[hostname:]portnumber. Passing 0 as the port number will'
14+ ' result in a dynamically allocated port. Default port is'
15+ ' 4155.',
16+ type=str),
17+ Option('directory',
18+ help='Subdirectory to serve. Defaults to /.',
19+ type=unicode),
20+ Option('upload-directory',
21+ help='upload branches to this directory. Defaults to '
22+ 'config.codehosting.hosted_branches_root.',
23+ type=unicode),
24+ Option('mirror-directory',
25+ help='serve branches from this directory. Defaults to '
26+ 'config.codehosting.mirrored_branches_root.'),
27+ Option('codehosting-endpoint',
28+ help='the url of the internal XML-RPC server. Defaults to '
29+ 'config.codehosting.codehosting_endpoint.',
30+ type=unicode),
31+ RegistryOption('protocol',
32+ help="Protocol to serve.",
33+ lazy_registry=('bzrlib.transport', 'transport_server_registry'),
34+ value_switches=True),
35+=======
36 Option(
37 'inet',
38 help="serve on stdin/out for use from inetd or sshd"),
39@@ -90,6 +118,7 @@
40 'protocol', help="Protocol to serve.",
41 lazy_registry=('bzrlib.transport', 'transport_server_registry'),
42 value_switches=True),
43+>>>>>>> MERGE-SOURCE
44 ]
45
46 takes_args = ['user_id']
47@@ -126,7 +155,7 @@
48 port = int(port)
49 return host, port
50
51- def run(self, user_id, port=None, branch_directory=None,
52+ def run(self, user_id, port=None, directory=None,
53 codehosting_endpoint_url=None, inet=False, protocol=None):
54 from lp.codehosting.bzrutils import install_oops_handler
55 from lp.codehosting.vfs import get_lp_server, hooks
56@@ -137,12 +166,14 @@
57 if protocol is None:
58 protocol = transport_server_registry.get()
59 lp_server = get_lp_server(
60- int(user_id), codehosting_endpoint_url, branch_directory,
61+ int(user_id), codehosting_endpoint_url, None,
62 seen_new_branch.seen)
63 lp_server.start_server()
64 try:
65 old_lockdir_timeout = lockdir._DEFAULT_TIMEOUT_SECONDS
66 lp_transport = get_transport(lp_server.get_url())
67+ if directory is not None:
68+ lp_transport = lp_transport.clone(directory.encode('utf-8'))
69 host, port = self.get_host_and_port(port)
70 lockdir._DEFAULT_TIMEOUT_SECONDS = 0
71 try:
72
73=== modified file 'lib/lp/codehosting/sshserver/session.py'
74--- lib/lp/codehosting/sshserver/session.py 2012-01-01 02:58:52 +0000
75+++ lib/lp/codehosting/sshserver/session.py 2012-01-03 19:50:31 +0000
76@@ -25,6 +25,7 @@
77
78 from lp.codehosting import get_bzr_path
79 from lp.services.config import config
80+from lp.services.features import getFeatureFlag
81 from lp.services.sshserver.events import AvatarEvent
82 from lp.services.sshserver.session import DoNothingSession
83
84@@ -459,6 +460,11 @@
85
86 if command == 'bzr serve --inet --directory=/ --allow-writes':
87 return command_template
88+ if getFeatureFlag('code.sshserver.git'):
89+ base_command, rest = command.split(" ", 1)
90+ if base_command in ('git-receive-pack', 'git-upload-pack'):
91+ # !!!XXX!!! JRV 2011-12-12 This could probably do with some escaping..
92+ return command_template + " --" + base_command + " --directory=%s" % rest
93 # At the moment, only bzr branch serving is allowed.
94 raise ForbiddenCommand("Not allowed to execute %r." % (command,))
95
96
97=== modified file 'lib/lp/codehosting/sshserver/tests/test_session.py'
98--- lib/lp/codehosting/sshserver/tests/test_session.py 2012-01-01 02:58:52 +0000
99+++ lib/lp/codehosting/sshserver/tests/test_session.py 2012-01-03 19:50:31 +0000
100@@ -440,3 +440,11 @@
101 ' lp-serve --inet %(user_id)s',
102 lookup_command_template(
103 'bzr serve --inet --directory=/ --allow-writes'))
104+
105+ def test_git(self):
106+ self.assertEquals(
107+ config.root + '/bin/py ' + get_bzr_path() +
108+ " lp-serve --inet %(user_id)s --git-receive-pack "
109+ "'/data/git/jelmer/dulwich.git'",
110+ lookup_command_template(
111+ "git-receive-pack '/data/git/jelmer/dulwich.git'"))
112
113=== modified file 'lib/lp/services/features/flags.py'
114--- lib/lp/services/features/flags.py 2011-12-22 22:20:19 +0000
115+++ lib/lp/services/features/flags.py 2012-01-03 19:50:31 +0000
116@@ -87,6 +87,12 @@
117 '',
118 '',
119 ''),
120+ ('code.sshserver.git',
121+ 'boolean',
122+ 'Enables git support in the SSH server.',
123+ '',
124+ '',
125+ ''),
126 ('code.incremental_diffs.enabled',
127 'boolean',
128 'Shows incremental diffs on merge proposals.',