diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -844,7 +844,7 @@ class changeset_templater(changeset_prin
self.ui.write(templater.stringify(self.t(key, **props)))
self.showpatch(ctx.node())
- if types['header']:
+ if types['footer']:
if not self.footer:
self.footer = templater.stringify(self.t(types['footer'],
**props))
diff --git a/tests/test-command-template b/tests/test-command-template
--- a/tests/test-command-template
+++ b/tests/test-command-template
@@ -62,6 +62,14 @@ hg log --style compact
hg log -v --style compact
hg log --debug --style compact
+# Test xml styles
+echo '# xml style works (--style xml)'
+hg log --style xml
+echo '# xml style works (-v --style xml)'
+hg log -v --style xml
+echo '# xml style works (--debug --style xml)'
+hg log --debug --style xml
+
echo '# error if style not readable'
touch q
chmod 0 q
diff --git a/tests/test-command-template.out b/tests/test-command-template.out
--- a/tests/test-command-template.out
+++ b/tests/test-command-template.out
@@ -97,6 +97,266 @@ 0:-1,-1 1e4e1b8f71e0 1970-01-12 13:4
line 1
line 2
+# xml style works (--style xml)
+
+
+
+tip
+test
+2020-01-01T10:01:00+00:00
+third
+
+
+
+User Name
+1970-01-12T13:46:40+00:00
+second
+
+
+
+
+person
+1970-01-18T08:40:01+00:00
+merge
+
+
+
+person
+1970-01-18T08:40:00+00:00
+new head
+
+
+foo
+person
+1970-01-17T04:53:20+00:00
+new branch
+
+
+person
+1970-01-16T01:06:40+00:00
+no user, no domain
+
+
+other
+1970-01-14T21:20:00+00:00
+no person
+
+
+A. N. Other
+1970-01-13T17:33:20+00:00
+other 1
+other 2
+
+other 3
+
+
+User Name
+1970-01-12T13:46:40+00:00
+line 1
+line 2
+
+
+# xml style works (-v --style xml)
+
+
+
+tip
+test
+2020-01-01T10:01:00+00:00
+third
+
+fourth
+third
+second
+
+
+fourth
+
+
+
+
+User Name
+1970-01-12T13:46:40+00:00
+second
+
+second
+
+
+
+
+
+person
+1970-01-18T08:40:01+00:00
+merge
+
+
+
+
+
+person
+1970-01-18T08:40:00+00:00
+new head
+
+d
+
+
+
+foo
+person
+1970-01-17T04:53:20+00:00
+new branch
+
+
+
+
+person
+1970-01-16T01:06:40+00:00
+no user, no domain
+
+c
+
+
+
+other
+1970-01-14T21:20:00+00:00
+no person
+
+c
+
+
+
+A. N. Other
+1970-01-13T17:33:20+00:00
+other 1
+other 2
+
+other 3
+
+b
+
+
+
+User Name
+1970-01-12T13:46:40+00:00
+line 1
+line 2
+
+a
+
+
+
+# xml style works (--debug --style xml)
+
+
+
+tip
+
+
+test
+2020-01-01T10:01:00+00:00
+third
+
+fourth
+third
+second
+
+
+fourth
+
+default
+
+
+
+
+User Name
+1970-01-12T13:46:40+00:00
+second
+
+second
+
+default
+
+
+
+
+person
+1970-01-18T08:40:01+00:00
+merge
+
+
+default
+
+
+
+
+person
+1970-01-18T08:40:00+00:00
+new head
+
+d
+
+default
+
+
+foo
+
+
+person
+1970-01-17T04:53:20+00:00
+new branch
+
+
+foo
+
+
+
+
+person
+1970-01-16T01:06:40+00:00
+no user, no domain
+
+c
+
+default
+
+
+
+
+other
+1970-01-14T21:20:00+00:00
+no person
+
+c
+
+default
+
+
+
+
+A. N. Other
+1970-01-13T17:33:20+00:00
+other 1
+other 2
+
+other 3
+
+b
+
+default
+
+
+
+
+User Name
+1970-01-12T13:46:40+00:00
+line 1
+line 2
+
+a
+
+default
+
+
# error if style not readable
abort: Permission denied: ./q
# error if no style