[PATCH] Remove 'repo' from the arguments of serve( ) function
Goffredo Baroncelli
kreijack at libero.it
Mon Jun 27 19:03:26 UTC 2005
Hi,
with this patch is now possible to start 'hg serve' outside a repository directory, passing
the repository as argument. Before, due to the fact that the serve() function in commands.py
required an istance of localrepository class, the command had to be started from the
repository directory.
The command is backward compatible, if no repository is passed as argument the command search
in the current dir or in its parents the repository.
Goffredo
-------------------------
diff -r 5914e27dc717 doc/hg.1.txt
--- a/doc/hg.1.txt Sun Jun 26 00:31:43 2005
+++ b/doc/hg.1.txt Sun Jun 26 23:54:22 2005
@@ -187,7 +187,7 @@
aliases: rm
-serve [-a addr -n name -p port -t templatedir]::
+serve [-a addr -n name -p port -t templatedir] [repodir]::
Start a local HTTP repository browser and pull server.
options:
@@ -195,6 +195,8 @@
-p, --port <n> port to use (default: 8000)
-n, --name <name> name to show in web pages (default: working dir)
-t, --templatedir <path> web templates to use
+
+ repodir repository directory
status::
Show changed files in the working directory.
diff -r 5914e27dc717 mercurial/commands.py
--- a/mercurial/commands.py Sun Jun 26 00:31:43 2005
+++ b/mercurial/commands.py Sun Jun 26 23:54:22 2005
@@ -610,11 +610,23 @@
"""print the root (top) of the current working dir"""
ui.write(repo.root + "\n")
-def serve(ui, repo, **opts):
+def serve(ui, *param, **opts):
"""export the repository via HTTP"""
- hgweb.server(repo.root, opts["name"], opts["templates"],
+ if len(param) < 1:
+ p = os.getcwd()
+ while not os.path.isdir(os.path.join(p, ".hg")):
+ oldp = p
+ p = os.path.dirname(p)
+ if p == oldp: raise "No repo found"
+ root = p
+ else:
+ root = param[0]
+ if not os.path.join(root, ".hg"):
+ raise "repository %s not found" % root
+
+ hgweb.server(root, opts["name"], opts["templates"],
opts["address"], opts["port"])
-
+
def status(ui, repo):
'''show changed files in the working directory
@@ -761,7 +773,7 @@
('a', 'address', '', 'interface address'),
('n', 'name', os.getcwd(), 'repository name'),
('t', 'templates', "", 'template map')],
- "hg serve [options]"),
+ "hg serve [options] [repository]"),
"status": (status, [], 'hg status'),
"tag": (tag, [('t', 'text', "", 'commit text'),
('d', 'date', "", 'date'),
@@ -779,7 +791,7 @@
"version": (show_version, [], 'hg version'),
}
-norepo = "init version help debugindex debugindexdot"
+norepo = "init version help debugindex debugindexdot serve"
def find(cmd):
i = None
--
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack AT inwind DOT it>
Key fingerprint = CE3C 7E01 6782 30A3 5B87 87C0 BB86 505C 6B2A CFF9
More information about the Mercurial
mailing list