hgbook.red-bean.com, hook-writing, and documentation

Greg Ward greg-hg at gerg.ca
Sat Apr 24 15:48:30 CDT 2010


On Fri, Apr 23, 2010 at 9:10 AM, Ben Sizer <bens at monumentalgames.com> wrote:
> I also found out that "for filename in repo[none]", despite the docs implying that it would iterate over the files you've changed, actually in my case iterates over every single file in the repository. Rather strange. (But no doubt someone who understands Mercurial better than I would disagree.) Iterating over repo[none].files() was what I needed.

Are you reading http://mercurial.selenic.com/wiki/MercurialApi,
section 5 "Change Contexts"?  If so, it seems fairly clear to me:

  * for filename in changectx - loops over all files in the changeset
(in sorted order)
[...]
  * ctx.files() - the files changed in the changeset

I would hope you get the same behaviour for a changectx (representing
an actual changeset) and repo[None], which is actually a workingctx
object representing the working dir (what will become your next
changeset).  It sounds to me like the behaviour you saw confirms that,
and it's exactly what I would have expected from the docs in that wiki
page.

If the wiki is unclear, how would you improve it?

Greg


More information about the Mercurial mailing list