(Arne Babenhauserheide)
2013-04-13: creates commit info for incoming commits, too. creates commit info for incoming commits, too.
diff --git a/staticsite.py b/staticsite.py --- a/staticsite.py +++ b/staticsite.py @@ -493,6 +493,17 @@ def getforkdata(ui, repo, target, name, # Add incoming commits html += "<div id='incoming'><h2>Incoming commits</h2>" chlist, cleanupfn, localother = getincoming(ui, repo, otheruri=forkuri, other=other, othername=forkname) + + # write all missing incoming commits directly from the incoming repo + if chlist: + try: + writecommitsforchlist(ui, localother, target, name, chlist) + writesourcetreeforchlist(ui, localother, target, name, chlist, force=False) + except AttributeError: + if not hasattr(localother, "changelog"): + print "Cannot write commits from fork", forkname, "because the repository type does not support getting the changelog." + else: + raise ui.pushbuffer() for ch in chlist: @@ -500,7 +511,7 @@ def getforkdata(ui, repo, target, name, t.show(ctx) html += ui.popbuffer() cleanupfn() - + # add outgoing commits html += "<div id='outgoing'><h2>Outgoing commits</h2>" chlist, cleanupfn, localother = getoutgoing(ui, repo, forkuri, other=other, othername=forkname) @@ -536,17 +547,18 @@ def writeforks(ui, repo, target, name): f.write( getforkdata(ui, repo, target, name, forkname, forkuri)) -def writecommits(ui, repo, target, name, force=False): +def writecommitsforchlist(ui, repo, target, name, chlist, force=False): """Write all not yet existing commit files.""" commit = os.path.join(target, "commit") # create the folders if not os.path.isdir(commit): os.makedirs(commit) - + t = cmdutil.changeset_templater(ui, repo, patch=False, diffopts=None, mapfile=None, buffered=False) t.use_template(templates["commitlog"].replace("{relativepath}", "../")) - for c in range(len(repo.changelog)): + + for c in chlist: ctx = repo.changectx(str(c)) cpath = os.path.join(commit, ctx.hex() + ".html") if not force and os.path.isfile(cpath): @@ -561,6 +573,11 @@ def writecommits(ui, repo, target, name, cf.write("<pre>"+ui.popbuffer().replace("<", "<")+"</pre>") cf.write(templates["foot"].replace("{reponame}", "<a href='../'>"+name+"</a>")) +def writecommits(ui, repo, target, name, force=False): + """Write all not yet existing commit files.""" + chlist = range(len(repo.changelog)) + return writecommitsforchlist(ui, repo, target, name, chlist, force=force) + #: html escape codes thanks to http://wiki.python.org/moin/EscapingHtml htmlescapetable = { "&": "&", @@ -663,14 +680,14 @@ def createindex(ui, repo, target, ctx): index += "</ul>" return index -def writesourcetree(ui, repo, target, name, force, rawfiles=False): +def writesourcetreeforchlist(ui, repo, target, name, chlist, force=False, rawfiles=False): """Write manifests for all commits and websites for all files. * For each file, write sites for all revisions where the file was changed: under src/<hex>/path as html site (with linenumbers and maybe colored source), under raw/<hex>/<path> as plain files. If there is an index.html file, write it as .index.html. If there also is .index.html, turn it to ..index.html, … * For each commit write an index with links to the included files at their latest revisions before/at the commit. """ # first write all files in all commits. - for c in range(len(repo.changelog)): + for c in chlist: ctx = repo.changectx(str(c)) for filename in ctx.files(): try: @@ -702,7 +719,7 @@ def writesourcetree(ui, repo, target, na f.write(parsesrcdata(filectx.data())) f.write(templates["foot"].replace("{reponame}", name)) # then write manifests for all commits - for c in range(len(repo.changelog)): + for c in chlist: ctx = repo.changectx(str(c)) filepath = os.path.join(target,"src",ctx.hex(),"index.html") # skip already existing files @@ -716,6 +733,16 @@ def writesourcetree(ui, repo, target, na f.write(createindex(ui, repo, target, ctx)) f.write(templates["foot"].replace("{reponame}", "<a href='../../'>"+name+"</a>")) + +def writesourcetree(ui, repo, target, name, force, rawfiles=False): + """Write manifests for all commits and websites for all files. + + * For each file, write sites for all revisions where the file was changed: under src/<hex>/path as html site (with linenumbers and maybe colored source), under raw/<hex>/<path> as plain files. If there is an index.html file, write it as .index.html. If there also is .index.html, turn it to ..index.html, … + * For each commit write an index with links to the included files at their latest revisions before/at the commit. + """ + chlist = range(len(repo.changelog)) + return writesourcetreeforchlist(ui, repo, target, name, chlist, force=force, rawfiles=rawfiles) + def parsesite(ui, repo, target, **opts): """Create the static folder.""" idfile = os.path.join(target, _staticidentifier)