(drak)
2013-04-13: merge merge
diff --git a/.bugs/bugs b/.bugs/bugs --- a/.bugs/bugs +++ b/.bugs/bugs @@ -2,7 +2,7 @@ push all bookmarks too add sourcecode coloring to the src files. | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:09715a67cfabe2de0901f0472610c2285626e0e7, time:1319147685.11 offer different and customizeable ways to parse a site, including to just call an external applications. | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:0ed55f757a6352bc3b2674153a3dc8eda91db843, time:1332932026.35 Add a list of branches, heads and tags to the summary page. | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:0fde104c4206be8245ff0716ee2e91ea3971db8f, time:1319147651.17 -include incoming commits, so I can easily check if I should pull a fork - and visitors can see what they can find in the fork. | owner:, open:True, id:14e7a48faa8965f947695744cc40d0f2bc25023b, time:1365863785.15 +include incoming commits, so I can easily check if I should pull a fork - and visitors can see what they can find in the fork. | owner:, open:False, id:14e7a48faa8965f947695744cc40d0f2bc25023b, time:1365863785.15 if b is used: a bugtracker: issue/<id>/<name> | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:1d631d51ff06b3bdca50e21da3d6a00bcb801c85, time:1319147632.52 add css classes and ids everywhere, so this can be styled with CSS. | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:2699812cf02c803fa338daf9ae039c43a30a0b5f, time:1322090683.01 get mtimes from the repo instead of querying the FTP server. We know which files were changed. | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:29210503551d0eafca67dda8d6fffbd40bf837dc, time:1319213074.57 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)