(Arne Babenhauserheide)
2014-03-14: merge: avoid partial localization, sort tags in reverse order, show releases 0.6.0 merge: avoid partial localization, sort tags in reverse order, show branches only once, fix html errors, increased timeout to 60s and use ftp instead of FTPS, if the URL starts with ftp://.
diff --git a/.bugs/bugs b/.bugs/bugs --- a/.bugs/bugs +++ b/.bugs/bugs @@ -14,14 +14,15 @@ revisions more structured, as list or si tags do not have a heading on the overview anymore | owner:, open:False, id:485d0b451f18b5eae517b34466622b0d52340d8e, time:1351620233.63 only write .statichgrepo print.css style.css and index.html when their data changed \(or \-\-force\) → read them and compare the contents. | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:4f02149269a60fca85aa040116b2789d98c906f2, time:1319212903.98 line numbers with anchors - | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:4fe09a1f0303ba6270042ca70d2bec4d60a1249e, time:1352070288.56 -sort tags in reverse order | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:61d256ab154e64597be604d6298daa545d4a96c7, time:1322159250.01 +sort tags in reverse order | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:61d256ab154e64597be604d6298daa545d4a96c7, time:1322159250.01 link from summary to readme | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:6277e6577b3f48f9b358565f29885685f2872d29, time:1391966374.92 add proper caching of every ftp directory listing. | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:750692931106d78ffc38c1ed63013c4dac4099dd, time:1319175393.07 +shows closed heads on branches which have other heads. | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:7cee9d1974cf29013cbce2a6698559317129287e, time:1392155548.69 fork-/clone-info for each entry in [paths] with its incoming data (if it has some): | owner:, open:False, id:8621575e4016752e8987c8b294dfa9166f77eff3, time:1319147671.39 style: add round borders and color for tags and branches in the log | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:87f1c0eb28cfcc23e6fe41d3c30fee7329e355d1, time:1391920088.81 forks should contain the site-title, too, so that users can go back. | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:8e994b6fdba3a3d1882c6758f9cde0f333ed28ec, time:1391963766.44 escape html entities in bug details, too, not only in the bug listing. | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:90c4ae8b49e006a131b61f1ab0697ca83f00021e, time:1351789362.97 -partial localization of strings - files to Dateien - is worse than none. | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:921fb80eb2a2fbf57e0f6db0a949ead872624f8f, time:1351635128.79 +partial localization of strings - files to Dateien - is worse than none. | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:921fb80eb2a2fbf57e0f6db0a949ead872624f8f, time:1351635128.79 More complex Readme parsing. | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:94fbade896adbf6f696cfdb331021437dff3f30e, time:1319147671.39 diffs: add syntax highlighting | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:ad1855d35fb272aee5c13bd29c6a34400d9e4bf8, time:1391920250.64 make the link from the /commit/*.html pages to the /src/*/[index.html] pages more obvious | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:ad936eaaba1693f7c44bd59916a19e6f3b3db27e, time:1319209748.93 diff --git a/README.txt b/README.txt --- a/README.txt +++ b/README.txt @@ -34,7 +34,7 @@ Features - shows bugs tracked via the [b-extension][]. - shows the readme. - shows forks which are defined as paths in `.hg/hgrc` - from any source hg supports. -- uploads only hanged files (based on the time they were last modified), so uploads can be reasonably fast. +- uploads only changed files (based on the time they were last modified), so uploads can be reasonably fast. - Supports FTP and FTPS. Use the latter if you can (just use URLs starting with `ftps://`). - static site (no vulnerabilities, little dependencies, high performance). diff --git a/staticsite.py b/staticsite.py --- a/staticsite.py +++ b/staticsite.py @@ -27,7 +27,9 @@ import datetime import codecs from mercurial import cmdutil, util, scmutil from mercurial import commands, dispatch -from mercurial.i18n import _ +# from mercurial.i18n import _ +def _(string): # avoid partial localizations + return string from mercurial import hg, discovery, util, extensions _staticidentifier = ".statichgrepo" @@ -737,6 +739,19 @@ def overviewlogstring(ui, repo, revs, te t.show(ctx) return ui.popbuffer() + +def sortedtagnames(repo, tags): + """Get the names of tags from a tags dictionary. + + :param tags: {"tagname": rev}, example: {'v0.5.3': '\xdfd\xe8.\t \xbd\xd0y\xd7|\xd4\x82\x9b\xac\x9d0F\x1a%'} + :return: [first, second, third, fourth] + """ + rev2tag = {} + for tag in tags: + rev2tag[repo[tag].rev()] = tag + return [rev2tag[i] for i in sorted(rev2tag.keys())] + + def writeoverview(ui, repo, target, name): """Create the overview page""" ui.debug("[staticsite] writeoverview: header\n") @@ -817,7 +832,7 @@ def writeoverview(ui, repo, target, name # FIXME: For some reason this does not seem to give the tags anymore. tags = repo._tags except AttributeError: - tags = [] + tags = {} try: bookmarks = repo._bookmarks except AttributeError: @@ -835,7 +850,11 @@ def writeoverview(ui, repo, target, name overview += "</div>" if len(tags) > 1: overview += "\n<div id='tags'><h2>Tags</h2>\n" - overview += overviewlogstring(ui, repo, [tags[t] for t in tags if t != "tip"], + overview += overviewlogstring(ui, repo, + [tags[t] + for t in reversed(sortedtagnames( + repo, tags)) + if t != "tip"], template=templates["commitlog"].replace( "{tags}", "XXXXX").replace( "{date|shortdate}", "{tags}").replace( @@ -1075,7 +1094,6 @@ def getforkdata(ui, repo, target, name, print "Cannot write commits from fork", forkname, "because the repository type does not support getting the changelog." else: raise - html += "</div><!-- /incoming-->" ui.pushbuffer() for ch in chlist: @@ -1083,6 +1101,7 @@ def getforkdata(ui, repo, target, name, t.show(ctx) html += ui.popbuffer() cleanupfn() + html += "</div><!-- /incoming-->" # add outgoing commits html += "<div id='outgoing'><h2>Outgoing commits</h2>" @@ -1271,7 +1290,7 @@ def writesourcetreeforchlist(ui, repo, t try: filectx = ctx.filectx(filename) except LookupError, e: - ui.warn("File not found, likely moved ", e, "\n") + ui.debug("File not found, likely moved ", e, "\n") if rawfiles: # first write the raw data filepath = rawpath(target,ctx,filectx.path()) @@ -1409,8 +1428,12 @@ def addrepo(ui, repo, target, bookmarks, def upload(ui, repo, target, ftpstring, force): """upload the repo to the FTP server identified by the ftp string.""" + # assume ftps if no prefix was given (security by default). + isftps = not ftpstring.startswith("ftp://") if ftpstring.startswith("ftp://"): ftpstring = ftpstring[len("ftp://"):] + if ftpstring.startswith("ftps://"): + ftpstring = ftpstring[len("ftps://"):] try: user, password = ftpstring.split("@")[0].split(":") serverandpath = "@".join(ftpstring.split("@")[1:]) @@ -1420,10 +1443,14 @@ def upload(ui, repo, target, ftpstring, serverandpath = ftpstring # no @, so we just take the whole string server = serverandpath.split("/")[0] ftppath = "/".join(serverandpath.split("/")[1:]) - timeout = 10 + timeout = 60 + # Use FTP instead of FTPS, if the uri is ftp:// try: - ftp = ftplib.FTP_TLS(server, user, password, "", timeout=timeout) - ftp.prot_p() + if isftps: + ftp = ftplib.FTP_TLS(server, user, password, "", timeout=timeout) + ftp.prot_p() + else: + ftp = ftplib.FTP(server, user, password, "", timeout=timeout) except socket.timeout: ui.warn(_("connection to "), server, _(" timed out after "), timeout, _(" seconds.\n")) return @@ -1550,7 +1577,7 @@ cmdtable = { wrapcmds = { # cmd: generic, target, fixdoc, ppopts, opts 'push': (False, None, False, False, [ - ('', 'staticsite', None, 'show parent svn revision instead'), + ('', 'staticsite', None, 'upload a static site'), ]) } @@ -1585,11 +1612,9 @@ def ftppush(orig, *args, **opts): return orig(*args, **opts) # first create the site at ._site target = "._site" - ftpstring = path.replace("ftp://", "") - ftpstring = path.replace("ftps://", "") # fix the options to fit those of the site command opts["name"] = opts["sitename"] - opts["upload"] = ftpstring + opts["upload"] = path staticsite(ui, repo, target, **opts) return 0 @@ -1663,7 +1688,7 @@ class FTPRepository(peerrepository): raise util.Abort('command findoutgoing unavailable for FTP repositories') -class RepoContainer(object): +class FTPRepoContainer(object): def __init__(self): pass @@ -1675,8 +1700,20 @@ class RepoContainer(object): #context = {} return FTPRepository(ui, url, create) -hg.schemes["ftp"] = RepoContainer() -hg.schemes["ftps"] = RepoContainer() +class FTPSRepoContainer(object): + def __init__(self): + pass + + def __repr__(self): + return '<FTPRepository>' + + def instance(self, ui, url, create): + # Should this use urlmod.url(), or is manual parsing better? + #context = {} + return FTPRepository(ui, url, create) + +hg.schemes["ftp"] = FTPRepoContainer() +hg.schemes["ftps"] = FTPSRepoContainer() def test(): import subprocess as sp