extension using revsets etc.
Mads Kiilerich
mads at kiilerich.com
Sun Apr 10 15:05:49 CDT 2011
Matthew Watson wrote, On 04/08/2011 04:06 PM:
> Hi Guys,
>
> I've got an extension that I want to be able to accept revsets for
> convenience and consistency's sake.
>
> I've got an arg *nodes that gets passed in and I was doing the
> following, basically from looking at what log does in commands.py:
>
> matchfn = cmdutil.matchall(repo)
> fopts = {}
> fopts['rev'] = nodes
> if not nodes:
> fopts['rev'] = "0:%s" % repo['tip'].rev()
> def prep(ctx, fns):
> True
> for ctx in cmdutil.walkchangerevs(repo, matchfn, fopts, prep):
> felognode(ui, repo, ctx, **opts)
>
> felognode does a lot of inspection of the commit, loads manifests and diffs etc.
>
> Problem is that this approach doesn't seem to garbage colect anything
> - after about 4000 commits, my python process is up to 12GB memory and
> the machine is swapping like crazy. Is there a better way to do this
> where the contexts, the filectx and manifest(s) are getting garbage
> collected as I go along? Or a better way to process a generic --rev
> arg into a list of commit numbers to process?
>
> Also, I'm not really sure of the role of the "prep" function, whether
> I should be doing my output within that or within the body of the for
> loop.
I think the answer depends on what you really want to do. Could you post
a complete but minimal example that demonstrates the question/problem?
The most obvious explanation could be that you somehow keep a reference
to everything and thus prevents the gc from working.
It would perhaps be simpler to use cmdutil.revrange.
/Mads
More information about the Mercurial-devel
mailing list