Comments
Patch
@@ -1431,6 +1431,30 @@
if mode and cur in self.t:
self._parts[t] = cur
+ def close(self):
+ # the commandline templater is problematic with headers vs footers:
+ # - headers are potentially variable based on changeset
+ # - duplicate headers are elided (eg for changelog style)
+ # - only the last computed footer is printed
+ # - with no csets, we printed nothing
+ # - this made our XML output invalid
+ #
+ # to fix this, we detect:
+ # - no header or footer calculated yet
+ # - constant header
+ # - constant footer
+ # (we can't print variable ones because we have no cset to supply)
+
+ if not self.lastheader and not self.footer:
+ self.footer = ""
+ h = self._parts['header']
+ if h and "{" not in self.t(h):
+ self.footer += templater.stringify(self.t(h))
+ f = self._parts['footer']
+ if f and "{" not in self.t(f):
+ self.footer += templater.stringify(self.t(f))
+ return super(changeset_templater, self).close()
+
def _show(self, ctx, copies, matchfn, props):
'''show a single changeset or file revision'''
@@ -343,6 +343,11 @@
Test xml styles:
+ $ hg log -r 'not all()' -Txml
+ <?xml version="1.0"?>
+ <log>
+ </log>
+
$ hg log --style xml
<?xml version="1.0"?>
<log>