[PATCH] largefiles: synchronize status by synchronizing the files mtime with the lfdirstate on update

Adrian Buehlmann adrian at cadifra.com
Thu Jul 12 13:18:45 CDT 2012


On 2012-07-12 16:36, Na'Tosha Bard wrote:
> # HG changeset patch
> # User Na'Tosha Bard <natosha at unity3d.com>
> # Date 1342103731 -7200
> # Node ID b1e224d7416bfb46f2727519569ffb935896ee5f
> # Parent  c496de2ce56316d9adf3820473f68e29438a1a5f
> largefiles: synchronize status by synchronizing the files mtime with the lfdirstate on update
> 
> This speeds up status on a largefiles repo by synchronizing largefiles' mtime to what is in
> the lfdirstate upon update, preventing the files from coming back as "unsure" later, requiring
> a check of the SHA1 sum.
> 
> diff -r c496de2ce563 -r b1e224d7416b hgext/largefiles/lfcommands.py
> --- a/hgext/largefiles/lfcommands.py	Wed Jul 11 11:41:38 2012 +0200
> +++ b/hgext/largefiles/lfcommands.py	Thu Jul 12 16:35:31 2012 +0200
> @@ -483,6 +483,12 @@
>                  # recognition that such cache missing files are REMOVED.
>                  lfdirstate.normallookup(lfile)
>                  return None # don't try to set the mode
> +            else:
> +                # Synchronize largefile dirstate to the last modified time of
> +                # the file
> +                s = os.lstat(repo.wjoin(lfile))
> +                mtime = int(s.st_mtime)
> +                lfdirstate._addpath(lfile, 'n', s.st_mode, s.st_size, mtime)
>              ret = 1
>          mode = os.stat(absstandin).st_mode
>          if mode != os.stat(abslfile).st_mode:

FWIW, this patch passes test-largefiles.t on Windows.


I'm most definitely not really that competent on largefiles as I

 (a) never used the largefiles extension so far
 (b) never looked into its implementation

so this comment should not be considered blocking inclusion of this patch,
as Na'Tosha is way more experienced on the largefiles extension than I am.


I happen to be sort of a bit an expert on that _lastnormaltime member variable
of the ordinary dirstate (e.g. see 7a73c406c0fd).

I thus have a (possibly stupid) question:

Is there a specific reason for not using lfdirstate.normal(lfile)? Or at least:
why is it not needed to update _lastnormaltime? Or would it be wrong to update
_lastnormaltime?

With your patch, you seem to be bypassing the "magic" normal() does for
updating lfdirstate's _lastnormaltime (dirstate.py, line 334):

        if mtime > self._lastnormaltime:
            # Remember the most recent modification timeslot for status(),
            # to make sure we won't miss future size-preserving file content
            # modifications that happen within the same timeslot.
            self._lastnormaltime = mtime

For example, normal() is called on commit for changed files.

If a file is quickly changed again right after commit within the same timeslot
as the commit was done, _lastnormaltime will help make sure that status looks into
the file if the file's size hasn't changed (the classic one second "blind spot"
of the dirstate).


More information about the Mercurial-devel mailing list