Patchwork [3,of,3] templater: test len filter

login
register
mail settings
Submitter Anton Shestakov
Date Sept. 8, 2014, 12:06 p.m.
Message ID <3311151410177964@web19g.yandex.ru>
Download mbox | patch
Permalink /patch/5723/
State Changes Requested
Headers show

Comments

Anton Shestakov - Sept. 8, 2014, 12:06 p.m.
# HG changeset patch
# User Anton Shestakov <engored@ya.ru>
# Date 1410177351 -32400
#      Mon Sep 08 20:55:51 2014 +0900
# Node ID 5ca21458ca0863fd9aec7c643e11443da11d6190
# Parent  82b3cffda4868d23ce436adac8687645f5f7441b
templater: test len filter

Since node hash and shortened node hash both have defined length, it's a good
way to check len filter in case of strings.

As for lists of strings, children, tags and file_adds are used, because they
provide some variety and also prove that what's counted is the number of string
items in the list, and not the list stringified (they are lists of non-empty,
multi-character strings).

Patch

diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -1413,6 +1413,33 @@  Age filter:
   $ hg log -l1 --template '{date|age}\n'
   7 years from now
 
+Len filter:
+
+  $ hg log -l1 --template '{node|len} {node|short|len}\n'
+  40 12
+
+  $ hg log -G --template '{rev}: children: {children|len}, tags: {tags|len}, file_adds: {file_adds|len}'
+  @  9: children: 0, tags: 1, file_adds: 1
+  |
+  o  8: children: 1, tags: 0, file_adds: 2
+  |
+  o  7: children: 1, tags: 0, file_adds: 1
+  
+  o    6: children: 0, tags: 0, file_adds: 0
+  |\
+  | o  5: children: 1, tags: 0, file_adds: 1
+  | |
+  o |  4: children: 1, tags: 0, file_adds: 0
+  |/
+  o  3: children: 2, tags: 0, file_adds: 0
+  |
+  o  2: children: 1, tags: 0, file_adds: 1
+  |
+  o  1: children: 1, tags: 0, file_adds: 1
+  |
+  o  0: children: 1, tags: 0, file_adds: 1
+  
+
 Error on syntax:
 
   $ echo 'x = "f' >> t