comparison mercurial/bookmarks.py @ 29300:f92afd23a099

bookmarks: make writing files out avoid ambiguity of file stat Cached attribute repo._bookmarks uses stat of '.hg/bookmarks' and '.hg/bookmarks.current' files to examine validity of cached contents. If writing these files out keeps ctime, mtime and size of them, change is overlooked, and old contents cached before change isn't invalidated as expected. To avoid ambiguity of file stat, this patch writes '.hg/bookmarks' and '.hg/bookmarks.current' files out with checkambig=True. This patch is a part of "Exact Cache Validation Plan": https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 03 Jun 2016 00:44:20 +0900
parents 052c9318e464
children af849596752c
comparison
equal deleted inserted replaced
29299:76b07a5c064b 29300:f92afd23a099
115 if rbm.active not in self: 115 if rbm.active not in self:
116 rbm.active = None 116 rbm.active = None
117 rbm._writeactive() 117 rbm._writeactive()
118 118
119 with repo.wlock(): 119 with repo.wlock():
120 file_ = repo.vfs('bookmarks', 'w', atomictemp=True) 120 file_ = repo.vfs('bookmarks', 'w', atomictemp=True,
121 checkambig=True)
121 try: 122 try:
122 self._write(file_) 123 self._write(file_)
123 except: # re-raises 124 except: # re-raises
124 file_.discard() 125 file_.discard()
125 raise 126 raise
129 def _writeactive(self): 130 def _writeactive(self):
130 if self._aclean: 131 if self._aclean:
131 return 132 return
132 with self._repo.wlock(): 133 with self._repo.wlock():
133 if self._active is not None: 134 if self._active is not None:
134 f = self._repo.vfs('bookmarks.current', 'w', atomictemp=True) 135 f = self._repo.vfs('bookmarks.current', 'w', atomictemp=True,
136 checkambig=True)
135 try: 137 try:
136 f.write(encoding.fromlocal(self._active)) 138 f.write(encoding.fromlocal(self._active))
137 finally: 139 finally:
138 f.close() 140 f.close()
139 else: 141 else: