[PATCH 2 of 3] largefiles: enable islfilesrepo() prior to a commit (issue3541)

Matt Harbison matt_harbison at yahoo.com
Wed Aug 8 19:52:23 CDT 2012


Na'Tosha Bard wrote:
> 2012/8/7 Matt Harbison <matt_harbison at yahoo.com
> <mailto:matt_harbison at yahoo.com>>
>
>     # HG changeset patch
>     # User Matt Harbison <matt_harbison at yahoo.com
>     <mailto:matt_harbison at yahoo.com>>
>     # Date 1343696201 14400
>     # Node ID 40fc3ecfffc7727537a11f5a26064e97f1dd0e7b
>     # Parent  542cfb521b1297a887410173f5971afc537f2fb3
>     largefiles: enable islfilesrepo() prior to a commit (issue3541)
>
>     -def openlfdirstate(ui, repo):
>     +def openlfdirstate(ui, repo, create=True):
>     '''
>           Return a dirstate object that tracks largefiles: i.e. its root is
>           the repo root, but it is saved in .hg/largefiles/dirstate.
>     @@ -154,7 +154,7 @@
>           # If the largefiles dirstate does not exist, populate and create
>           # it. This ensures that we create it on the first meaningful
>           # largefiles operation in a new clone.
>     -    if not os.path.exists(os.path.join(admin, 'dirstate')):
>     +    if create and not os.path.exists(os.path.join(admin, 'dirstate')):
>               util.makedirs(admin)
>               matcher = getstandinmatcher(repo)
>               for standin in dirstatewalk(repo.dirstate, matcher):
>     @@ -435,8 +435,11 @@
>           return util.pconvert(os.path.normpath(path))
>
>       def islfilesrepo(repo):
>     -    return ('largefiles' in repo.requirements and
>     -            util.any(shortname + '/' in f[0] for f in
>     repo.store.datafiles()))
>     +    if ('largefiles' in repo.requirements and
>     +            util.any(shortname + '/' in f[0] for f in
>     repo.store.datafiles())):
>     +        return True
>     +
>     +    return util.any(openlfdirstate(repo.ui, repo, False))
>
>
> Does this have any effect on performance?

I didn't run any benchmarks (I'm not sure how to collect numbers or 
structure the tests to avoid caching and the usual benchmarking 
caveats), but I didn't notice any issues with admittedly trivial use.

My thinking was that by passing false here, the dirstate walk and 
initial population of lfdirstate is avoided, even if the file doesn't 
exist.  All openlfdirstate() does in the case is:

1) join a path
2) create an opener instance
3) create a largefilesdirstate instance

all of which seem trivial to me.  Any particular cases you're worried about?

--Matt


More information about the Mercurial-devel mailing list