comparison mercurial/commands.py @ 603:bc5d058e65e9

[PATCH] Get "hg serve" to print the URL being served -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [PATCH] Get "hg serve" to print the URL being served From: Bryan O'Sullivan <bos@serpentine.com> If invoked with verbosity, print the URL at which we are serving. Useful if you bind to any port with "-p 0", and need to know what port the server is listening on. manifest hash: d317225606fbd2ec5819e1f266575b0485dfba79 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCyL9hywK+sNU5EO8RAjFQAJoDBRl5VoGIklxA1PdFGCt8Jb3iMQCeILeD XAwnnSCy/IQ/MDfYf6z7oWI= =FNVC -----END PGP SIGNATURE-----
author mpm@selenic.com
date Sun, 03 Jul 2005 20:47:29 -0800
parents 9a8daeff0ffa
children 40a66d464ac2
comparison
equal deleted inserted replaced
602:56d81b303656 603:bc5d058e65e9
6 # of the GNU General Public License, incorporated herein by reference. 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 import os, re, sys, signal 8 import os, re, sys, signal
9 import fancyopts, ui, hg, util 9 import fancyopts, ui, hg, util
10 from demandload import * 10 from demandload import *
11 demandload(globals(), "mdiff time hgweb traceback random signal errno version") 11 demandload(globals(), "mdiff time hgweb traceback random signal socket errno version")
12 12
13 class UnknownCommand(Exception): pass 13 class UnknownCommand(Exception): pass
14 14
15 def filterfiles(filters, files): 15 def filterfiles(filters, files):
16 l = [ x for x in files if x in filters ] 16 l = [ x for x in files if x in filters ]
791 """print the root (top) of the current working dir""" 791 """print the root (top) of the current working dir"""
792 ui.write(repo.root + "\n") 792 ui.write(repo.root + "\n")
793 793
794 def serve(ui, repo, **opts): 794 def serve(ui, repo, **opts):
795 """export the repository via HTTP""" 795 """export the repository via HTTP"""
796 hgweb.server(repo.root, opts["name"], opts["templates"], 796 httpd = hgweb.create_server(repo.root, opts["name"], opts["templates"],
797 opts["address"], opts["port"]) 797 opts["address"], opts["port"])
798 if ui.verbose:
799 addr, port = httpd.socket.getsockname()
800 if addr == '0.0.0.0':
801 addr = socket.gethostname()
802 else:
803 try:
804 addr = socket.gethostbyaddr(addr)[0]
805 except: pass
806 if port != 80:
807 ui.status('listening on http://%s:%d/\n' % (addr, port))
808 else:
809 ui.status('listening on http://%s/\n' % addr)
810 httpd.serve_forever()
798 811
799 def status(ui, repo): 812 def status(ui, repo):
800 '''show changed files in the working directory 813 '''show changed files in the working directory
801 814
802 C = changed 815 C = changed