diff tests/test-extdata.t @ 34458:a1b89c8ad32d

templater: add experimental support for extdata This is minimal and non-controversial implementation of extdata() template function. Originally extdata sources were exposed to the keyword namespace, but I've changed it to a plain function for simplicity.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 01 Oct 2017 11:13:09 +0100
parents 2c3b8fa3211b
children d5c5cc767b7e
line wrap: on
line diff
--- a/tests/test-extdata.t	Sun Oct 01 10:50:00 2017 +0100
+++ b/tests/test-extdata.t	Sun Oct 01 11:13:09 2017 +0100
@@ -10,12 +10,19 @@
   $ cat <<'EOF' >> .hg/hgrc
   > [extdata]
   > filedata = file:extdata.txt
+  > notes = notes.txt
   > shelldata = shell:cat extdata.txt | grep 2
   > EOF
   $ cat <<'EOF' > extdata.txt
-  > 2
+  > 2 another comment on 2
   > 3
   > EOF
+  $ cat <<'EOF' > notes.txt
+  > f6ed this change is great!
+  > e834 this is buggy :(
+  > 0625 first post
+  > bogusnode gives no error
+  > EOF
 
   $ hg log -qr "extdata(filedata)"
   2:f6ed99a58333
@@ -43,6 +50,31 @@
   abort: unknown extdata source 'unknown'
   [255]
 
+test template support:
+
+  $ hg log -r:3 -T "{node|short}{if(extdata('notes'), ' # {extdata('notes')}')}\n"
+  06254b906311 # first post
+  e8342c9a2ed1 # this is buggy :(
+  f6ed99a58333 # this change is great!
+  9de260b1e88e
+
+test template cache:
+
+  $ hg log -r:3 -T '{rev} "{extdata("notes")}" "{extdata("shelldata")}"\n'
+  0 "first post" ""
+  1 "this is buggy :(" ""
+  2 "this change is great!" "another comment on 2"
+  3 "" ""
+
+test bad extdata() template source
+
+  $ hg log -T "{extdata()}\n"
+  hg: parse error: extdata expects one argument
+  [255]
+  $ hg log -T "{extdata('unknown')}\n"
+  abort: unknown extdata source 'unknown'
+  [255]
+
 we don't fix up relative file URLs, but we do run shell commands in repo root
 
   $ mkdir sub