hg site extension
 
(Arne Babenhauserheide)
2011-11-24: no longer write raw files (dumb webservers often don’t know what to

no longer write raw files (dumb webservers often don’t know what to do with them).

diff --git a/.bugs/bugs b/.bugs/bugs
--- a/.bugs/bugs
+++ b/.bugs/bugs
@@ -16,7 +16,7 @@ Idea: hg clone/push ftp://host.tld/path/
 add linenumbers to the src files.                                                                                                          | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:b7bab6f46da7d224f97d0dac55a617d3a464d301, time:1319147678.56
 commits as commit/<rev>/ for long term viability. .html as suffix is not as long lived as a simple dirname.                                | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:baaad4bdc13d7155048ce6a9dde92dc857b6a1ac, time:1319148414.16
 clone/<pathname>/ → incoming log (commits) + possibly an associated issue in b.                                                            | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:c58557260a47597ac5057703e26a94df190a2a5d, time:1319147661.8
-no longer create raw files, since they can’t be served by all webservers and waste bandwidth and space (they are no longer linked anyway). | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:d1010e1933648f65af37d969bfb45f8d834fc8bb, time:1319148721.49
+no longer create raw files, since they can’t be served by all webservers and waste bandwidth and space (they are no longer linked anyway). | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:d1010e1933648f65af37d969bfb45f8d834fc8bb, time:1319148721.49
 check the hgweb templating for parsing the site.                                                                                           | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:ef17f01dbe8ee58536fa8b345eb18d1efc639f15, time:1319208643.38
 maybe more advanced bookmarks pushing.                                                                                                     | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:ef8c12bfcc99686efc1f685a9be0be0c78922ca5, time:1322115049.48
 Treat branch heads specially: link on the main page.                                                                                       | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:f531c27b38f9ea1749ded312f4f468c9ac33b930, time:1319147696.96
diff --git a/site.py b/site.py
--- a/site.py
+++ b/site.py
@@ -230,7 +230,7 @@ def createindex(target, ctx):
     index += "</ul>"
     return index
 
-def writesourcetree(ui, repo, target, name, force):
+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, …
@@ -244,19 +244,22 @@ def writesourcetree(ui, repo, target, na
                 filectx = ctx.filectx(filename)
             except LookupError, e:
                 ui.warn("File not found, likely moved ", e, "\n")
-            # first write the raw data
-            filepath = rawpath(target,ctx,filectx.path())
-            # skip already existing files
-            if not force and isfile(filepath):
-                continue
-            try:
-                os.makedirs(dirname(filepath))
-            except OSError: pass # exists
-            with open(filepath, "w") as f:
-                f.write(filectx.data())
+            if rawfiles: 
+                # first write the raw data
+                filepath = rawpath(target,ctx,filectx.path())
+                # skip already existing files
+                if not force and isfile(filepath):
+                    continue
+                try:
+                    os.makedirs(dirname(filepath))
+                except OSError: pass # exists
+                with open(filepath, "w") as f:
+                    f.write(filectx.data())
             # then write it as html
             _filenameescaped = escapename(filectx.path())
             filepath = srcpath(target,ctx,_filenameescaped)
+            if not force and isfile(filepath):
+                continue
             try:
                 os.makedirs(dirname(filepath))
             except OSError: pass # exists