git: support '{files}' template

Summary:
Change `ctx.files()` to run diff for git repos. This would make a few revsets
and templates working.

Reviewed By: danielocfb

Differential Revision: D33354722

fbshipit-source-id: c6449d7f405f2d2c568294eeebe47d371e46cb12
This commit is contained in:
Jun Wu 2022-01-20 10:19:33 -08:00 committed by Facebook GitHub Bot
parent 471b5a49a4
commit 484e37311e
2 changed files with 11 additions and 1 deletions

View File

@ -25,6 +25,7 @@ from . import (
error,
extensions,
fileset,
git,
match as matchmod,
mdiff,
mutation,
@ -576,7 +577,11 @@ class changectx(basectx):
return self._changeset.date
def files(self):
return self._changeset.files
files = self._changeset.files
# git does not provide "files" in commit message - run diff to get it
if not files and git.isgit(self._repo):
files = sorted(self.manifest().diff(self.p1().manifest()).keys())
return files
def description(self):
return self._changeset.description

View File

@ -289,3 +289,8 @@ Test push:
abort: use '--to' to specify destination bookmark
[255]
"files" metadata:
$ hg log -r $A+$B -T '{files}\n'
A
B