[PATCH 2 of 2] fsmonitor: use vfs instead of opener (issue5938)
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Fri Oct 12 13:50:20 EDT 2018
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1539330346 -32400
# Fri Oct 12 16:45:46 2018 +0900
# Node ID e7939b7fa76137718b4f4591de7d85c8ce546df5
# Parent 2994abbbfddc09425be23a84423d34be34d474a9
# Available At https://bitbucket.org/foozy/mercurial-wip
# hg pull https://bitbucket.org/foozy/mercurial-wip -r e7939b7fa761
# EXP-Topic issue5938
fsmonitor: use vfs instead of opener (issue5938)
"opener" of localrepository object was dropped at Mercurial 4.3 (or
a7e210167c28). "vfs" should be used instead.
wlock is required to write into a file under .hg directory.
For efficiency, we should change _cmpsets() from:
1. acquire wlock
2. open log file under .hg directory with write mode
3. compare between result of watchman and Mercurial's dirstate logic
4. write out error info into a file, if error is detected
5. release wlock
to:
1. compare between result of watchman and Mercurial's dirstate logic
2. acquire wlock, if error is detected
3. open and write error info into a file
4. release wlock
But this is another issue.
diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -460,7 +460,7 @@ def overridestatus(
f = open(fn, 'wb')
else:
fn = 'fsmonitorfail.log'
- f = self.opener(fn, 'wb')
+ f = self.vfs.open(fn, 'wb')
except (IOError, OSError):
self.ui.warn(_('warning: unable to write to %s\n') % fn)
return
@@ -564,8 +564,10 @@ def overridestatus(
self.ui.fout, self.ui.ferr = fout, ferr
# clean isn't tested since it's set to True above
- _cmpsets([modified, added, removed, deleted, unknown, ignored, clean],
- rv2)
+ with self.wlock():
+ _cmpsets(
+ [modified, added, removed, deleted, unknown, ignored, clean],
+ rv2)
modified, added, removed, deleted, unknown, ignored, clean = rv2
return scmutil.status(
More information about the Mercurial-devel
mailing list