fastest way to collect filenames in working dir

Alexis S. L. Carvalho alexis at cecm.usp.br
Tue Oct 16 07:47:03 CDT 2007


Thus spake Christian Ebert:
> What is the recommended way to collect filenames (clean,
> modified, added) in the working directory if the caller uses
> walkopts? Via repo.status or repo.walk?

Rule of thumb - use status if you care about the status of the files;
use walk if you just want a list.

Both will walk the working dir in the same way, but status will have a
slightly higher overhead since it also has to check the status of every
file.

Depending on what you want to do, you could also just look at the list
of files in the dirstate:

 files = list(repo.dirstate)

(or maybe  files = [f for f in repo.dirstate if repo.dirstate[f] != 'r']
to avoid removed files)

This will be the fastest, since it won't do any listdir or lstat.

Alexis


More information about the Mercurial-devel mailing list