1

I want to check what files have been modified in current commit and base on that I want to modify or not specified file and add it to that commit.

I was thinking about using script on pretxncommit hook who gives me information that I need but I don't see any possible way to add new modified file to that commit.

Is there any way to do that?

Laston
  • 71
  • 4
  • I suppose, you selected The Bad Way(tm) of solving task by fooling commits. Use controlling hooks, block incomplete changesets, add needed files by hand - it's safer – Lazy Badger Jul 29 '19 at 13:20

1 Answers1

0

it would not be at pretxncommit because at that point the changeset is already built

you'd need to hook earlier, likely on precommit

precommit: Controlling. This is run before starting a commit.

pretxncommit: Controlling. This is run after a new changeset has been created in the local repository, but before the transaction that will make it permanent completes.

https://book.mercurial-scm.org/read/hook.html

arhak
  • 2,488
  • 1
  • 24
  • 38
  • You can't use `precommit` hook for this task, just because "It is run before Mercurial has any of the metadata for the commit, such as the files to be committed, the commit message, or the commit date"/ BTW, `pretxncommit` is also out of game: "This hook can access the metadata associated with the almost-new changeset, but it should not do anything permanent with this data" – Lazy Badger Jul 29 '19 at 13:18
  • I thought you could combine `hg diff` with `hg status` to figure it out (at `precommit` time), then take the desired action upon it – arhak Jul 30 '19 at 08:43