Determining what files were touched in a changeset algorithmically

Haszlakiewicz, Eric EHASZLA at
Thu Jun 23 13:32:49 CDT 2011

> -----Original Message-----
> From: mercurial-bounces at [mailto:mercurial-
> I am working on some analysis tools for hg logs.
> hg log --template "{files}" is the naive way to do this.
> Demonstration of problem:
> $ hg log -r 34 --template "{file_mods}\n"
> baz baz baz foo bar spacey.txt
> What files were modified?
> In order to determine this, I have to run manifest on 34 and perform
> some lexical analysis for all files in that changeset to determine
> which files actually got modified.
> Reviewing the hg source code, the rendering code (showlist function in
> <> )
> performs a join with spaces here. This is... problematic for fast
> algorithmic determination.

You can do this with a custom template map file, which can be selected with the --style option.  For example, see the map-cmdline.gward referred to in this thread:

It has lines like:

changeset = '...{file_mods}{file_adds}{file_dels}{file_copies_switch}...'
file_mod = '  M {file_mod}\n'
end_file_mods = ''
file_add = '  A {file_add}\n'
end_file_adds = ''
file_del = '  R {file_del}\n'
end_file_dels = ''

 to display the changes in a much more readable fashion.  (IMO this should be the default, since the current default is pretty horrible)

Since mercurial explicitly doesn't allow newlines in filenames (due to protocol limitations, at least with earlier versions of hg), using a newline as the delimiter is guaranteed to work for every file that might be in a repository.


More information about the Mercurial mailing list