# HG changeset patch # User Julien Cristau # Date 1718637478 -7200 # Node ID 484b56ac4aecea21e1f7603a81bd77d5c39e478e # Parent 7b6ea46ea11146adc3a2a70761864bf752c772c8 hglib: cat accepts a template argument diff -r 7b6ea46ea111 -r 484b56ac4aec hglib/client.py --- a/hglib/client.py Tue Mar 14 10:23:08 2023 +0100 +++ b/hglib/client.py Mon Jun 17 17:17:58 2024 +0200 @@ -591,7 +591,7 @@ return bool(eh) - def cat(self, files, rev=None, output=None): + def cat(self, files, rev=None, output=None, template=None): """Return a string containing the specified files as they were at the given revision. If no revision is given, the parent of the working directory is used, or tip if no revision is checked out. @@ -606,7 +606,7 @@ "%p" root-relative path name of file being printed """ - args = cmdbuilder(b('cat'), r=rev, o=output, hidden=self.hidden, *files) + args = cmdbuilder(b('cat'), r=rev, o=output, hidden=self.hidden, T=template, *files) out = self.rawcommand(args) if not output: diff -r 7b6ea46ea111 -r 484b56ac4aec tests/test_import.py --- a/tests/test_import.py Tue Mar 14 10:23:08 2023 +0100 +++ b/tests/test_import.py Mon Jun 17 17:17:58 2024 +0200 @@ -21,6 +21,7 @@ def test_basic_cstringio(self): self.client.import_(BytesIO(patch)) self.assertEqual(self.client.cat([b('a')]), b('1\n')) + self.assertEqual(self.client.cat([b('a')], template=b'{path}\\0{data}'), b('a\x001\n')) def test_basic_file(self): f = open('patch', 'wb') @@ -37,3 +38,4 @@ self.client.import_([b('patch')]) self.assertEqual(self.client.cat([b('a')]), b('1\n')) + self.assertEqual(self.client.cat([b('a')], template=b'{path}\\0{data}'), b('a\x001\n'))