(Arne Babenhauserheide)
2011-10-20: get user, password and server from the commandline options. get user, password and server from the commandline options.
diff --git a/static.py b/static.py --- a/static.py +++ b/static.py @@ -46,6 +46,7 @@ from os.path import join, isdir, isfile, import shutil import re import mercurial +import ftplib from mercurial import cmdutil from mercurial import commands @@ -320,16 +321,25 @@ def addrepo(ui, repo, target): ui.popbuffer() +def upload(ui, repo, target, ftpstring): + """upload the repo to the FTP server identified by the ftp string.""" + user, password = ftpstring.split("@")[0].split(":") + serverandpath = "@".join(ftpstring.split("@")[1:]) + print user, password, serverandpath + def static(ui, repo, target=None, **opts): """Create a static copy of the repository and/or upload it to an FTP server.""" if repo.root == target: ui.warn("static target repo can’t be the current repo") return # first: just create the site. - if target is None: target = "static" + if not target: target = "static" parsesite(ui, repo, target, **opts) # add the hg repo to the static site addrepo(ui, repo, target) + if opts["upload"]: + # upload the repo + upload(ui, repo, target, opts["upload"]) @@ -338,10 +348,10 @@ cmdtable = { "static": (static, [('r', 'rev', None, 'parse the given revision'), ('a', 'all', None, 'parse all revisions (requires much space)'), - ('n', 'name', None, 'the repo name. Default: folder or last segment of the repo-path.'), - ('u', 'upload', None, 'upload the repo'), + ('n', 'name', "", 'the repo name. Default: folder or last segment of the repo-path.'), + ('u', 'upload', "", 'upload the repo to the given ftp host. Format: user:password@host/path/to/dir'), ('f', 'force', False, 'force recreating all commit files. Slow.'), - ('s', 'screenstyle', None, 'use a custom stylesheet for display on screen'), - ('p', 'printstyle', None, 'use a custom stylesheet for printing')], + ('s', 'screenstyle', "", 'use a custom stylesheet for display on screen'), + ('p', 'printstyle', "", 'use a custom stylesheet for printing')], "[options] [folder]") }