[PATCH 11 of 19 STABLE] largefiles: examine whether specified pattern is a directory in the context
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Tue Feb 28 07:33:59 UTC 2012
At Mon, 27 Feb 2012 20:58:02 -0500,
Greg Ward wrote:
>
> On 27 February 2012, FUJIWARA Katsunori said:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> > # Date 1330335216 -32400
> > # Branch stable
> > # Node ID 5c5ac9b4a72636ac865f68227d291a48d3c84206
> > # Parent 0317d98735a65b478976579bd10e75315ead234d
> > largefiles: examine whether specified pattern is a directory in the context
> >
> > this patch adds 'inctxdirs()' which uses 'changectx.dirs()' to
> > examine 'directory pattern' correctly.
> >
> > in fact, original implementation can show status for largefiles
> > specified by 'directory pattern' correctly, because 'set.difference()'
> > between unknown files returned by 'localrepository.status()' and all
> > largefiles is recognized as unknown files finally.
> >
> > so this patch reduces cost of 'set.difference()' in 'working' route.
> >
> > diff -r 0317d98735a6 -r 5c5ac9b4a726 hgext/largefiles/reposetup.py
> > --- a/hgext/largefiles/reposetup.py Mon Feb 27 18:33:36 2012 +0900
> > +++ b/hgext/largefiles/reposetup.py Mon Feb 27 18:33:36 2012 +0900
> > @@ -111,6 +111,9 @@
> > def inctx(file, ctx):
> > return file in ctx
> >
> > + def inctxdirs(f, ctx):
> > + return f in ctx.dirs()
> > +
> > if match is None:
> > match = match_.always(self.root, self.getcwd())
> >
> > @@ -147,7 +150,7 @@
> > for f in files:
> > if not lfutil.isstandin(f):
> > sf = lfutil.standin(f)
> > - if inctx(sf, ctx2):
> > + if inctx(sf, ctx2) or inctxdirs(sf, ctx2):
>
> Why does inctxdirs() need to a be a function at all? It's a one-liner,
> called once. Inline it! This *is* supposedly a performance
> improvement, after all.
>
> Oh yeah: why does inctx() need to be a function? I would inline it too.
>
> And: does this really need to be done on the stable branch? Is it
> actually fixing a bug, or just a minor performance tweak? That's
> really not clear.
'inctxdirs()' should examine 'f in dirstate.rdirs()' for removed file
(fixed in patch #18).
In addition to it, exisiting 'f in dirstate.dirs()' should also
examine it for removed files.
So, I defined 'inctxdirs()' as function to centralize such
modification to it.
In working context, 'inctx()' should examine 'f in dirstate' instead
of 'f in ctx' for removed files (fixed in patch #12).
I defined 'inctx()' as fucntion, because this switching may lose code
readability.
----------------------------------------------------------------------
[FUJIWARA Katsunori] foozy at lares.dti.ne.jp
More information about the Mercurial-devel
mailing list