comparison hgext/eol.py @ 13475:c7bef25ca393 stable

eol: handle LockUnavailable error (issue2569) If the repository is not locked when clearing the dirstate, then running test-eol.t in a loop fails sooner or later with: ERROR: /home/mg/src/mercurial-crew/tests/test-eol.t output changed --- /home/mg/src/mercurial-crew/tests/test-eol.t +++ /home/mg/src/mercurial-crew/tests/test-eol.t.err @@ -343,6 +343,7 @@ % hg status (eol activated) M win.txt % hg commit + nothing changed % hg status $ testmixed CRLF However, if we cannot lock the repository, then we can also not make a commit and so we can simply ignore a LockUnavailable error.
author Martin Geisler <mg@aragost.com>
date Fri, 25 Feb 2011 12:32:15 +0100
parents bffa00360e13
children 50b825c1adb1
comparison
equal deleted inserted replaced
13474:6c2e476b7a11 13475:c7bef25ca393
80 See :hg:`help patterns` for more information about the glob patterns 80 See :hg:`help patterns` for more information about the glob patterns
81 used. 81 used.
82 """ 82 """
83 83
84 from mercurial.i18n import _ 84 from mercurial.i18n import _
85 from mercurial import util, config, extensions, match 85 from mercurial import util, config, extensions, match, error
86 import re, os 86 import re, os
87 87
88 # Matches a lone LF, i.e., one that is not part of CRLF. 88 # Matches a lone LF, i.e., one that is not part of CRLF.
89 singlelf = re.compile('(^|[^\r])\n') 89 singlelf = re.compile('(^|[^\r])\n')
90 # Matches a single EOL which can either be a CRLF where repeated CR 90 # Matches a single EOL which can either be a CRLF where repeated CR
252 try: 252 try:
253 wlock = self.wlock() 253 wlock = self.wlock()
254 for f, e in self.dirstate._map.iteritems(): 254 for f, e in self.dirstate._map.iteritems():
255 self.dirstate._map[f] = (e[0], e[1], -1, 0) 255 self.dirstate._map[f] = (e[0], e[1], -1, 0)
256 self.dirstate._dirty = True 256 self.dirstate._dirty = True
257 # Touch the cache to update mtime. TODO: are we sure this 257 # Touch the cache to update mtime.
258 # always enought to update the mtime, or should we write a
259 # bit to the file?
260 self.opener("eol.cache", "w").close() 258 self.opener("eol.cache", "w").close()
261 finally: 259 wlock.release()
262 if wlock is not None: 260 except error.LockUnavailable:
263 wlock.release() 261 # If we cannot lock the repository and clear the
262 # dirstate, then a commit might not see all files
263 # as modified. But if we cannot lock the
264 # repository, then we can also not make a commit,
265 # so ignore the error.
266 pass
264 267
265 def commitctx(self, ctx, error=False): 268 def commitctx(self, ctx, error=False):
266 for f in sorted(ctx.added() + ctx.modified()): 269 for f in sorted(ctx.added() + ctx.modified()):
267 if not self._eolfile(f): 270 if not self._eolfile(f):
268 continue 271 continue