[PATCH 2 of 2 V3] move tags.cache and branchheads.cache to a collected cache folder .hg/caches/

Adrian Buehlmann adrian at cadifra.com
Tue Jan 4 02:10:10 CST 2011


On 2011-01-04 07:09, Jason Harris wrote:
> # HG changeset patch
> # User jfh <jason at jasonfharris.com>
> # Date 1294119540 -3600
> # Node ID 129f5c8fcf76598918c68f39b4156b10d84fa08e
> # Parent  65a39818367f9657a291cade204e7f574e919dbc
> move tags.cache and branchheads.cache to a collected cache folder .hg/caches/
> 
> The generation of cache files like tags.cache and branchheads.cache is not an
> actual reflection of things changing in the whole of the .hg directory (like eg
> a commit or a rebase or something) but instead these cache files are just part
> of bookkeeping. As such its convenient to allow various clients to ignore file
> events to do with these cache files which would otherwise cause a double
> refresh. Eg one refresh might occur after a commit, but the act of refreshing
> after the commit would cause Mercurial to generate a new branchheads.cache which
> would then cause a second refresh, for clients.
> 
> However if these cache files are moved into a directory like eg .hg/caches/ then
> GUI clients on OSX (and possibly other platforms) can happily ignore file events
> in this cache directory.
> 
> Part II: Refactor requested by Adrian Buehlmann.

Could my name please removed here? In general, feedback from list
postings by third parties aren't referenced in this manner in change
messages.

> Adrian asked that these changes to move the caches into their own directory, be
> wrapped up in a new copener.

Just for the record: The patch below is not what I have proposed. See
the archives.

> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -33,6 +33,7 @@
>          self.auditor = util.path_auditor(self.root, self._checknested)
>          self.opener = util.opener(self.path)
>          self.wopener = util.opener(self.root)
> +        self.copener = util.opener(os.path.join(self.path, "caches"))
>          self.baseui = baseui
>          self.ui = baseui.copy()
>  
> @@ -93,6 +94,7 @@
>          self.sopener = self.store.opener
>          self.sjoin = self.store.join
>          self.opener.createmode = self.store.createmode
> +        self.copener.createmode = self.store.createmode
>          self._applyrequirements(requirements)
>          if create:
>              self._writerequirements()
> @@ -439,8 +441,7 @@
>      def _readbranchcache(self):
>          partial = {}
>          try:
> -            fn = os.path.join("caches", "branchheads.cache")
> -            f = self.opener(fn)
> +            f = self.copener("branchheads.cache")
>              lines = f.read().split('\n')
>              f.close()
>          except (IOError, OSError):
> @@ -468,8 +469,7 @@
>  
>      def _writebranchcache(self, branches, tip, tiprev):
>          try:
> -            fn = os.path.join("caches", "branchheads.cache")
> -            f = self.opener(fn, "w", atomictemp=True)
> +            f = self.copener("branchheads.cache", "w", atomictemp=True)
>              f.write("%s %s\n" % (hex(tip), tiprev))
>              for label, nodes in branches.iteritems():
>                  for node in nodes:
> diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
> --- a/mercurial/statichttprepo.py
> +++ b/mercurial/statichttprepo.py
> @@ -90,6 +90,7 @@
>  
>          opener = build_opener(ui, authinfo)
>          self.opener = opener(self.path)
> +        self.copener = opener(self.path + "/caches")
>  
>          # find requirements
>          try:
> diff --git a/mercurial/tags.py b/mercurial/tags.py
> --- a/mercurial/tags.py
> +++ b/mercurial/tags.py
> @@ -155,7 +155,7 @@
>      set, caller is responsible for reading tag info from each head.'''
>  
>      try:
> -        cachefile = repo.opener(os.path.join('caches', 'tags.cache'), 'r')
> +        cachefile = repo.copener('tags.cache', 'r')
>          # force reading the file for static-http
>          cachelines = iter(cachefile)
>      except IOError:
> @@ -252,8 +252,7 @@
>  def _writetagcache(ui, repo, heads, tagfnode, cachetags):
>  
>      try:
> -        fn = os.path.join('caches', 'tags.cache')
> -        cachefile = repo.opener(fn, 'w', atomictemp=True)
> +        cachefile = repo.copener('tags.cache', 'w', atomictemp=True)
>      except (OSError, IOError):
>          return
>  
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
> 
> 


More information about the Mercurial-devel mailing list