(Arne Babenhauserheide)
2014-02-08: only write bugfiles which changed → reduce the required uploads a only write bugfiles which changed → reduce the required uploads a lot.
diff --git a/staticsite.py b/staticsite.py --- a/staticsite.py +++ b/staticsite.py @@ -644,15 +644,24 @@ def writebugs(ui, repo, target, name): f.write(templates["foot"].replace("{reponame}", "<a href='../'>"+name+"</a>")) # write all bug details for bug in openbugs + resolvedbugs: - bugsfile = bugslist = os.path.join(bugdir, bug.fullid + ".html") - content = "<h2>" + bug.description + "</h2>\n" - content += "<pre>" + bug.details + "</pre>\n" - content += "<hr>" - content += "- <a href=\"index.html\">" + _("all bugs") + "</a> -" - with open(bugsfile, "w") as bf: - bf.write(templates["head"].replace("{reponame}", "<a href='../'>"+name+"</a>").replace("{title}", name)) - bf.write(content) - bf.write(templates["foot"].replace("{reponame}", "<a href='../'>"+name+"</a>")) + bugsfile = os.path.join(bugdir, bug.fullid + ".html") + body = "<h2>" + bug.description + "</h2>\n" + body += "<pre>" + bug.details + "</pre>\n" + body += "<hr>" + body += "- <a href=\"index.html\">" + _("all bugs") + "</a> -" + content = templates["head"].replace("{reponame}", "<a href='../'>"+name+"</a>").replace("{title}", name) + content += body + content += templates["foot"].replace("{reponame}", "<a href='../'>"+name+"</a>") + needswrite = False + try: + with open(bugsfile) as bf: + if not bugsfile.read() == content: + raise Exception("bugfile content does not match content to write. Needs overwriting.") + except: # generic exception: If anything went wrong, we need to write the file. + with open(bugsfile, "w") as bf: + bf.write(templates["head"].replace("{reponame}", "<a href='../'>"+name+"</a>").replace("{title}", name)) + bf.write(content) + bf.write(templates["foot"].replace("{reponame}", "<a href='../'>"+name+"</a>")) def escapename(filename): """escape index.html as .index.html and .ind… as ..ind… and so fort."""