Mercurial > python-hglib
changeset 227:484b56ac4aec default tip
hglib: cat accepts a template argument
author | Julien Cristau <jcristau@mozilla.com> |
---|---|
date | Mon, 17 Jun 2024 17:17:58 +0200 |
parents | 7b6ea46ea111 |
children | |
files | hglib/client.py tests/test_import.py |
diffstat | 2 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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:
--- 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'))