hg site extension
 
(Arne Babenhauserheide)
2016-06-23: parse the pushed repo, not the local one. Resolves, for example, tip

parse the pushed repo, not the local one. Resolves, for example, breaking with hidden changesets.

diff --git a/.bugs/bugs b/.bugs/bugs
--- a/.bugs/bugs
+++ b/.bugs/bugs
@@ -8,7 +8,7 @@ avoid writing and subsequently uploading
 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
 FIX: revision 0 is omitted: change that :)                   | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:29396f1753e45b5a37ffa0ce04d96c876d6b6722, time:1319209563.68
-parse the pushed repo, not the local one.                    | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:2c26d62b62e3656ebcce43e7a24f627594911fb5, time:1322115065.37
+parse the pushed repo, not the local one.                    | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:2c26d62b62e3656ebcce43e7a24f627594911fb5, time:1322115065.37
 create a beautiful default style sheet to make the static sites look good. | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:31a87798e30ccdaeefd028426222092e06bf20b1, time:1351793911.56
 revisions more structured, as list or similar.               | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:39cacfc83da6f6beecafdb745823d7f01018206b, time:1322159357.88
 tags do not have a heading on the overview anymore           | owner:, open:False, id:485d0b451f18b5eae517b34466622b0d52340d8e, time:1351620233.63
diff --git a/staticsite.py b/staticsite.py
--- a/staticsite.py
+++ b/staticsite.py
@@ -770,7 +770,7 @@ def sortedtagnames(repo, tags):
     return [rev2tag[i] for i in sorted(rev2tag.keys())]
 
 
-def writeoverview(ui, repo, target, name):
+def writeoverview(ui, repo, targetrepo, target, name):
     """Create the overview page"""
     ui.debug("[staticsite] writeoverview: header\n")
     overview = ""
@@ -798,10 +798,10 @@ def writeoverview(ui, repo, target, name
             ui.debug("[staticsite] writenav: forks: getforkdir\n")
             nav += "<a href='" + getforkdir(target, forkname) + "'>" + forkname + "</a> "
             ui.debug("[staticsite] writenav: forks: getincoming\n")
-            incoming, fn, localother = getincoming(ui, repo, otheruri=forkuri, othername=forkname)
+            incoming, fn, localother = getincoming(ui, targetrepo, otheruri=forkuri, othername=forkname)
             nav += "<small>(" + str(len(incoming))
             ui.debug("[staticsite] writenav: forks: getoutgoing\n")
-            outgoing, fn, localother = getoutgoing(ui, repo, otheruri=forkuri, othername=forkname)
+            outgoing, fn, localother = getoutgoing(ui, targetrepo, otheruri=forkuri, othername=forkname)
             nav += "<small>↓↑</small>" + str(len(outgoing)) + ")</small> "
             
     
@@ -827,9 +827,9 @@ def writeoverview(ui, repo, target, name
     # divert all following ui output to a string, so we can just use standard functions
     overview += "\n<div id='shortlog'><h2>Changes (<a href='commits'>full changelog</a>)</h2>\n"
     ui.pushbuffer()
-    t = simpletemplater(ui, repo, templates["commitlog"].replace("{relativepath}", ""))
-    for c in range(1, min(len(repo.changelog), 5)):
-        ctx = repo.changectx(str(-c))
+    t = simpletemplater(ui, targetrepo, templates["commitlog"].replace("{relativepath}", ""))
+    for c in range(1, min(len(targetrepo.changelog), 5)):
+        ctx = targetrepo.changectx(str(-c))
         t.show(ctx)
     overview += ui.popbuffer()
     overview += "</div>"
@@ -837,28 +837,28 @@ def writeoverview(ui, repo, target, name
     # Add branch, bookmark and tag information, if they exist.
     ui.debug("[staticsite] writeoverview: branches, tags and bookmarks\n")
     branches = []
-    for branch, heads in repo.branchmap().items(): 
+    for branch, heads in targetrepo.branchmap().items(): 
         if branch and branch != "default": # not default
-            branches.extend([h for h in heads if not repo[h].closesbranch()])
+            branches.extend([h for h in heads if not targetrepo[h].closesbranch()])
     # if other branches exist, add default, too.
     if branches:
-        branches.extend(repo.branchmap()["default"])
+        branches.extend(targetrepo.branchmap()["default"])
             
     try: 
-        tags = repo.tags()
+        tags = targetrepo.tags()
     except AttributeError: 
         try: 
             # FIXME: For some reason this does not seem to give the tags anymore.
-            tags = repo._tags
+            tags = targetrepo._tags
         except AttributeError: 
             tags = {}
     try: 
-        bookmarks = repo._bookmarks
+        bookmarks = targetrepo._bookmarks
     except AttributeError:
         bookmarks = []
     if branches: # add branches
         overview += "\n<div id='branches'><h2>Branches</h2>\n"
-        overview += overviewlogstring(ui, repo, branches,
+        overview += overviewlogstring(ui, targetrepo, branches,
                                       template=templates["commitlog"].replace(
                 "{branches}", "XXXXX").replace(
                 "{date|shortdate}", "{branch}").replace(
@@ -869,10 +869,10 @@ 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, 
+        overview += overviewlogstring(ui, targetrepo, 
                                       [tags[t] 
                                        for t in reversed(sortedtagnames(
-                                               repo, tags))
+                                               targetrepo, tags))
                                        if t != "tip"],
                                       template=templates["commitlog"].replace(
                 "{tags}", "XXXXX").replace(
@@ -881,7 +881,7 @@ def writeoverview(ui, repo, target, name
         overview += "</div>"
     if len(bookmarks): 
         overview += "\n<div id='bookmarks'><h2>Bookmarks</h2>\n"
-        overview += overviewlogstring(ui, repo, bookmarks.values(),
+        overview += overviewlogstring(ui, targetrepo, bookmarks.values(),
                                       template=templates["commitlog"].replace(
                 "{bookmarks}", "XXXXX").replace(
                 "{date|shortdate}", "{bookmarks}").replace(
@@ -1203,6 +1203,8 @@ def htmlescape(text):
 def writebugs(ui, repo, target, name):
     """Write bug information, a listing and the details for each bug."""
     bugdir = os.path.join(target, "bugs")
+    ui.debug("[staticsite] bugdir: " + os.path.abspath(bugdir) + "\n")
+
     
     # create the bugs folder
     if not os.path.isdir(bugdir):
@@ -1310,7 +1312,7 @@ def writesourcetreeforchlist(ui, repo, t
             try:
                 filectx = ctx.filectx(filename)
             except LookupError, e:
-                ui.debug("File not found, likely moved ", e, "\n")
+                ui.debug("File not found, likely moved " + str(e) + "\n")
             if rawfiles: 
                 # first write the raw data
                 filepath = rawpath(target,ctx,filectx.path())
@@ -1406,26 +1408,28 @@ def parsesite(ui, repo, target, **opts):
         sjlfile = os.path.join(target, sjl)
         if not os.path.isfile(sjlfile) or not samefilecontent(sjlsrc, sjlfile):
             shutil.copyfile(sjlsrc, sjlfile)
-    
+
+    # get the target repo
+    targetrepo = hg.repository(ui, path=target)
     ui.debug("[staticsite] writeoverview\n")
     # then the overview
-    writeoverview(ui, repo, target, name)
+    writeoverview(ui, repo, targetrepo, target, name)
     
     ui.debug("[staticsite] writelog\n")
     # and the log
-    writelog(ui, repo, target, name)
+    writelog(ui, targetrepo, target, name)
     
     ui.debug("[staticsite] writecommits\n")
     # and all commit files
-    writecommits(ui, repo, target, name, force=opts["force"])
+    writecommits(ui, targetrepo, target, name, force=opts["force"])
     
     ui.debug("[staticsite] writesourcetree\n")
     # and all file data
-    writesourcetree(ui, repo, target, name, force=opts["force"])
+    writesourcetree(ui, targetrepo, target, name, force=opts["force"])
     
     ui.debug("[staticsite] writeforks\n")
-    # and all forks
-    writeforks(ui, repo, target, name)
+    # and all forks, ui contains the local config, so we can use the targetrepo
+    writeforks(ui, targetrepo, target, name)
     
     ui.debug("[staticsite] writebugs\n")
     # and all bugs