Patchwork [1,of,2] templaterfilters: add new 'notfirstline' filter

mail settings
Submitter Sean Farley
Date Jan. 9, 2013, 6:12 p.m.
Message ID <e9a1700097f2e520b5b0.1357755159@laptop.local>
Download mbox | patch
Permalink /patch/511/
State Rejected
Headers show


Sean Farley - Jan. 9, 2013, 6:12 p.m.
# HG changeset patch
# User Sean Farley <>
# Date 1357671949 21600
# Node ID e9a1700097f2e520b5b0773f902cb92fe7af99ae
# Parent  97b6fc4356bb794b78ac077fd35c1cfadb76766d
templaterfilters: add new 'notfirstline' filter


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -137,10 +137,15 @@ 
         return text.splitlines(True)[0].rstrip('\r\n')
     except IndexError:
         return ''
+def notfirstline(text):
+    """:notfirstline: Any text. Returns everything except the first line of
+    text."""
+    return ''.join(text.splitlines(True)[1:])
 def hexfilter(text):
     """:hex: Any text. Convert a binary Mercurial node identifier into
     its long hexadecimal representation.
     return node.hex(text)
@@ -370,10 +375,11 @@ 
     "isodatesec": isodatesec,
     "json": json,
     "jsonescape": jsonescape,
     "localdate": localdate,
     "nonempty": nonempty,
+    "notfirstline": notfirstline,
     "obfuscate": obfuscate,
     "permissions": permissions,
     "person": person,
     "rfc3339date": rfc3339date,
     "rfc822date": rfc822date,
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -746,10 +746,11 @@ 
   $ hg help templating | egrep '(desc|diffstat|firstline|nonempty)  '
       desc          String. The text of the changeset description.
       diffstat      String. Statistics of changes with the following format:
       firstline     Any text. Returns the first line of text.
       nonempty      Any text. Returns '(none)' if the string is empty.
+      notfirstline  Any text. Returns everything except the first line of text.
 Test help hooks
   $ cat > <<EOF
   > from mercurial import help