Commit Graph

12 Commits

Author SHA1 Message Date
Siddharth Agarwal
25418f3155 scmutil.filecache: support watching over multiple files 2013-11-16 13:29:39 -08:00
Siddharth Agarwal
a8599adaa0 test-filecache.py: add markers to the output for each event
Previously it was possible that a different, incorrect set of events might
print out 'creating' the same number of times.
2013-11-16 13:57:35 -08:00
Siddharth Agarwal
7311dfb44a test-filecache.py: make setbeforeget test clearer
'0' and 'None' as outputs tripped me up. Make the distinction between values
set externally and values computed by calling the decorated function clearer.
2013-11-16 14:10:28 -08:00
Idan Kamara
ad6fc4bb63 filecache: create an entry in _filecache when __set__ is called for a missing one
Preserve the invariant that if P is a filecached property on X then
P in X.__dict__ => P in X._filecache.

Previously, it was possible for a filecached property to become out of sync
with the filesystem if it was set before getting it first, since the initial
filecacheentry was created in __get__.

Old behaviour:

  repo.prop = x
  repo.invalidate() # prop has no entry in _filecache, it's not removed
                    # from __dict__
  repo.prop         # returns x like before without checking with the
                    # filesystem

New:

  repo.prop = x     # an empty entry is created in _filecache
  repo.invalidate() # prop is removed from __dict__
  repo.prop         # recreates prop
2012-12-17 15:25:45 +02:00
Idan Kamara
ca54b38975 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
We need to make sure that if X is in the filecache then it's also in the
filecache owner's __dict__, otherwise it will go out of sync:

repo.X                  # first access to X, records stat info in
                        # filecache and updates __dict__
repo._filecache.clear() # removes X from _filecache but it's still in __dict__
repo.invalidate()       # iterates over _filecache and removes entries
                        # from __dict__, but X isn't in _filecache, so
                        # it's kept in __dict__
repo.X                  # X is fetched from __dict__, bypassing the filecache
2013-01-09 20:37:44 +02:00
Brodie Rao
c577fac135 cleanup: replace naked excepts with more specific ones 2012-05-12 16:02:45 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Mads Kiilerich
8e24d85037 tests: launch hghave with python interpreter without relying on hash-bang 2011-11-16 03:45:14 +01:00
Greg Ward
bc1dfb1ac9 atomictempfile: make close() consistent with other file-like objects.
The usual contract is that close() makes your writes permanent, so
atomictempfile's use of close() to *discard* writes (and rename() to
keep them) is rather unexpected. Thus, change it so close() makes
things permanent and add a new discard() method to throw them away.
discard() is only used internally, in __del__(), to ensure that writes
are discarded when an atomictempfile object goes out of scope.

I audited mercurial.*, hgext.*, and ~80 third-party extensions, and
found no one using the existing semantics of close() to discard
writes, so this should be safe.
2011-08-25 20:21:04 -04:00
Lee Cantey
974aa0a16d test-filecache: change for python 2.4 compatibility 2011-07-28 02:38:01 +03:00
Matt Mackall
291c95dda6 filecache: fix check-code complaint 2011-07-25 12:58:47 -05:00
Idan Kamara
3b6032fdaf scmutil: introduce filecache
The idea is being able to associate a file with a property, and watch
that file stat info for modifications when we decide it's important for it to
be up-to-date. Once it changes, we recreate the object.

On filesystems that can't uniquely identify a file, we always recreate.

As a consequence, localrepo.invalidate() will become much less expensive in the
case where nothing changed on-disk.
2011-07-09 19:06:59 +03:00