[PATCH] tag: invalidate tag cache immediately after adding new tag (issue3210)

Mads Kiilerich mads at kiilerich.com
Wed Jan 18 19:14:11 CST 2012


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1326935646 -3600
# Node ID 700441aba588c8bfc5f38a7b77ee8564cd768202
# Parent  8435fa20dff9bd2199b926b37f881a2a9aa0a450
tag: invalidate tag cache immediately after adding new tag (issue3210)

New tags were written to .hgtags / .hglocaltags without updating or
invalidating the localrepo cache.

Before afd459933d5f a lock was acquired soon after the new tags had been
written, and that invalidated the cache so the new tags for example could be
seen in pretxncommit hooks. With afd459933d5f the lock had already been
acquired at this point and the missing cache invalidation was exposed.

The tag caches will now explicitly and immediately be invalidated when new tags
are added.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -322,6 +322,8 @@
 
         fp.close()
 
+        self.invalidatecaches()
+
         if '.hgtags' not in self.dirstate:
             self[None].add(['.hgtags'])
 
diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -353,6 +353,9 @@
   > def verbosehook(ui, **args):
   >     ui.note('verbose output from hook\n')
   > 
+  > def printtags(ui, repo, **args):
+  >     print repo.tags().keys()
+  > 
   > class container:
   >     unreachable = 1
   > EOF
@@ -569,3 +572,10 @@
   calling hook pre-identify.c: hooktests.verbosehook
   verbose output from hook
   cb9a9f314b8b
+
+new tags must be visible in pretxncommit (issue3210)
+
+  $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
+  $ hg tag -f foo
+  ['a', 'foo', 'tip']
+


More information about the Mercurial-devel mailing list