getting changecontext of a file and using commands.log

Greg Ward greg-hg at
Mon Aug 3 07:50:36 CDT 2009

On Fri, Jul 31, 2009 at 9:12 PM, scrappy doo<shadowcwal at> wrote:
> 1)Given a filename, is there an easy way to get all of its changecontexts in
> the repository?

I don't know the answer, but I know how to find the answer: Read The
Fine Source Code.  Specifically, start in mercurial/, look
for log(), and see what it does when you pass a filename on the
command line.

If you're more concerned with speed than ease of coding, I think this
can be done very efficiently if you go straight to the filelog.  Each
entry in a revlog has a 'linkrev' that points to revisions in
changelog and manifest.  So open the filelog of the file you're
interested in, iterate over the filelog, and for each entry fetch the
changectx with repo[entry.linkrev].

Or something like that.  I've never actually implemented that, and for
all I know it's already implemented in a handy little utility function
somewhere.  (Matt seems to have copied Guido's time machine idea:
quite often, when you want a feature you find it's already been


More information about the Mercurial-devel mailing list