[MERGE] Refactor cmd_serve to a be easier to extend.

John Arbash Meinel john at arbash-meinel.com
Fri Jan 23 22:27:46 GMT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jonathan Lange wrote:
> Hello all,
> 
> This patch has no behavioural changes, it just explodes
> cmd_serve.run() into a few bits so that it's easier for other plugin
> authors to extend and/or reuse.
> 
> Enjoy,
> jml
> 

+    def get_smart_server(self, transport, inet, port):
+        """Construct a smart server.
+
+        :param transport: The base transport from which branches will be
+            served.
+        :param inet: If True, serve over stdin and stdout. Used for running
+            from inet.
+        :param port: The port to listen on. By default, it's `
+            medium.BZR_DEFAULT_PORT`. See `get_host_and_port` for more
+            information.
+        :return: A smart server.
+        """
         from bzrlib.smart import medium, server
+        if inet:
+            smart_server = medium.SmartServerPipeStreamMedium(
+                sys.stdin, sys.stdout, t)

^- I don't see a variable "t" in the function here. I think you want
"transport" at this point.

v- and here
+        else:
+            host, port = self.get_host_and_port(port)
+            smart_server = server.SmartTCPServer(t, host=host, port=port)
+            note('listening on port: %s' % smart_server.port)


Do tests actually pass after your refactoring? Because that certainly
seems like a gap in coverage if we never test that "run_bzr('serve')"
and "run_bzr('serve --inet')" actually work. (They may need to be
run_bzr_subprocess, and directly specify the URL to bind to, etc.


BB:tweak

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkl6RGIACgkQJdeBCYSNAANX4wCeJzIm5TWdYodtt3DNRE1BvYR7
erkAoMXlta1T0o4gUmorlEmH8HYeO5EX
=OZoB
-----END PGP SIGNATURE-----



More information about the bazaar mailing list