048ef4889301

Add --address and --port options for the web UI.

You can now make the web interface listen on a specific address and/or port:

    hg review --web --address '0.0.0.0' --port 21333

By default it will listen on 127.0.0.1:8080 (disallowing external connections).
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 27 Mar 2010 12:22:04 -0400
parents ac324e064f82
children f841259cc87e
branches/tags (none)
files review/extension_ui.py review/web_ui.py

Changes

--- a/review/extension_ui.py	Sat Mar 27 12:11:12 2010 -0400
+++ b/review/extension_ui.py	Sat Mar 27 12:22:04 2010 -0400
@@ -16,9 +16,15 @@
 def _web_command(ui, repo, **opts):
     ui.note(messages.WEB_START)
     read_only = opts.pop('read_only')
+    address = opts.pop('address')
+    port = int(opts.pop('port'))
     
     import web_ui
-    web_ui.load_interface(ui, repo, read_only=read_only, open=False)
+    web_ui.load_interface(
+        ui, repo, read_only=read_only,
+        address=address, port=port,
+        open=False
+    )
 
 def _init_command(ui, repo, **opts):
     ui.note(messages.INIT_START)
@@ -305,6 +311,8 @@
         ('U', 'unified',     '5',   'number of lines of context to show'),
         ('w', 'web',         False, 'launch the web interface'),
         ('',  'read-only',   False, 'make the web interface read-only'),
+        ('',  'address',     '127.0.0.1', 'run the web interface on the specified address'),
+        ('',  'port',        '8080',      'run the web interface on the specified port'),
     ],
     'hg review')
 }
--- a/review/web_ui.py	Sat Mar 27 12:11:12 2010 -0400
+++ b/review/web_ui.py	Sat Mar 27 12:22:04 2010 -0400
@@ -128,7 +128,7 @@
     
 
 
-def load_interface(ui, repo, read_only=False, open=False, port=8080):
+def load_interface(ui, repo, read_only=False, open=False, address='127.0.0.1', port=8080):
     if open:
         import webbrowser
         webbrowser.open('http://localhost:%d/' % port)
@@ -137,6 +137,10 @@
         '/media': {
             'tools.staticdir.on': True,
             'tools.staticdir.dir': media_path,
+        },
+        'global': {
+            'server.socket_host': address,
+            'server.socket_port': port,
         }
     }