Determining what files were touched in a changeset algorithmically

paul_nathan at selinc.com paul_nathan at selinc.com
Thu Jun 23 10:17:56 CDT 2011


Tony Mechelynck <antoine.mechelynck at gmail.com> wrote on 06/22/2011 
06:36:37 PM:

> From: Tony Mechelynck <antoine.mechelynck at gmail.com>
> To: paul_nathan at selinc.com
> Cc: mercurial at selenic.com
> Date: 06/22/2011 06:36 PM
> Subject: Re: Determining what files were touched in a changeset 
> algorithmically
> 
> On 23/06/11 01:51, paul_nathan at selinc.com wrote:
> > Greetings,
> >
> > 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
> > http://selenic.com/hg/file/8deebb577751/mercurial/templatekw.py)
> > performs a join with spaces here. This is... problematic for fast
> > algorithmic determination.
> >
> > I have thousands of changesets that need to be processed repeatedly 
and
> > shelling out on each changeset is going to be slow.
> >
> > Is there a better way? I'd like to only shell out to hg once and get 
all
> > the needed information.
> >
> > (the file names were "baz baz baz" and "foo bar spacey.txt")
> >
> > - - -
> > Regards,
> > Paul Nathan
> 
> Maybe use
> 
>    hg log --style xml
> 
> and then reprocess the XML output to get what you want? This would allow 

> you to get in a single hg run all the data for your changesets, neatly 
> organized as follows (the --config argument is there to override a 
> setting in my hgrc; and I'm using -l 5 in this example to get only the 
> five latest changesets but of course you might want to select a 
> different set of revisions):
> 

[snip]

Tony,

Strange as it might by, when I do hg log --style=xml, I don't get the 
paths. Is there some sort of internal UI settings that I'm missing there?

You have correctly ascertained my issue: I only want to do a single shell 
out to hg, instead of shelling out each revision.

- - -
Regards,
Paul Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial/attachments/20110623/079c97fa/attachment.htm>


More information about the Mercurial mailing list