(Arne Babenhauserheide)
2014-03-14: only write the bugslist and forks index files when they changed. releases 0.6.1 only write the bugslist and forks index files when they changed.
diff --git a/staticsite.py b/staticsite.py
--- a/staticsite.py
+++ b/staticsite.py
@@ -637,7 +637,7 @@ def contentequals(filepath, content):
try:
with open(filepath) as f:
return f.read() == content
- except OSError: return not content
+ except OSError: return not content # equal, if the content is empty
except IOError: return False # file does not exist. Empty != not existing.
# TODO: check: return True if content is None?
@@ -1134,9 +1134,11 @@ def writeforks(ui, repo, target, name):
forkdir = getforkdir(target, forkname)
if not os.path.isdir(os.path.join(target, forkdir)):
os.makedirs(os.path.join(target, forkdir))
- with open(os.path.join(target, forkdir, "index.html"), "w") as f:
- f.write(
- getforkdata(ui, repo, target, name, forkname, forkuri))
+ forkindex = os.path.join(target, forkdir, "index.html")
+ forkcontent = getforkdata(ui, repo, target, name, forkname, forkuri)
+ if not contentequals(forkindex, forkcontent):
+ with open(forkindex, "w") as f:
+ f.write(forkcontent)
def writecommitsforchlist(ui, repo, target, name, chlist, force=False):
"""Write all not yet existing commit files."""
@@ -1202,10 +1204,12 @@ def writebugs(ui, repo, target, name):
for bug in resolvedbugs:
content += "<li><a href=\"" + bug.fullid + ".html\">" + bug.shortid + "</a> - " + htmlescape(bug.description) + "</li>\n"
content += "</ul>\n"
- with open(bugslist, "w") as f:
- f.write(templates["head"].replace("{reponame}", "<a href='../'>"+name+"</a>").replace("{title}", name).replace("{nav}", "").replace("{relpath}", "../"))
- f.write(content)
- f.write(templates["foot"].replace("{reponame}", "<a href='../'>"+name+"</a>"))
+ html = templates["head"].replace("{reponame}", "<a href='../'>"+name+"</a>").replace("{title}", name).replace("{nav}", "").replace("{relpath}", "../")
+ html += content
+ html += templates["foot"].replace("{reponame}", "<a href='../'>"+name+"</a>")
+ if not contentequals(bugslist, html):
+ with open(bugslist, "w") as f:
+ f.write(html)
# write all bug details
for bug in openbugs + resolvedbugs:
bugsfile = os.path.join(bugdir, bug.fullid + ".html")