##// END OF EJS Templates
fastannotate: remove support for flock() locking...
Augie Fackler -
r43217:0152a907 default
parent child Browse files
Show More
@@ -62,13 +62,6 b' annotate cache greatly. Run "debugbuildl'
62 # the server. (default: 10)
62 # the server. (default: 10)
63 clientfetchthreshold = 10
63 clientfetchthreshold = 10
64
64
65 # use flock instead of the file existence lock
66 # flock may not work well on some network filesystems, but they avoid
67 # creating and deleting files frequently, which is faster when updating
68 # the annotate cache in batch. if you have issues with this option, set it
69 # to False. (default: True if flock is supported, False otherwise)
70 useflock = True
71
72 # for "fctx" mode, always follow renames regardless of command line option.
65 # for "fctx" mode, always follow renames regardless of command line option.
73 # this is a BC with the original command but will reduced the space needed
66 # this is a BC with the original command but will reduced the space needed
74 # for annotate cache, and is useful for client-server setup since the
67 # for annotate cache, and is useful for client-server setup since the
@@ -100,8 +93,6 b' annotate cache greatly. Run "debugbuildl'
100 #
93 #
101 # * rename the config knob for updating the local cache from a remote server
94 # * rename the config knob for updating the local cache from a remote server
102 #
95 #
103 # * move `flock` based locking to a common area
104 #
105 # * revise wireprotocol for sharing annotate files
96 # * revise wireprotocol for sharing annotate files
106 #
97 #
107 # * figure out a sensible default for `mainbranch` (with the caveat
98 # * figure out a sensible default for `mainbranch` (with the caveat
@@ -114,7 +105,6 b' from __future__ import absolute_import'
114
105
115 from mercurial.i18n import _
106 from mercurial.i18n import _
116 from mercurial import (
107 from mercurial import (
117 configitems,
118 error as hgerror,
108 error as hgerror,
119 localrepo,
109 localrepo,
120 registrar,
110 registrar,
@@ -122,7 +112,6 b' from mercurial import ('
122
112
123 from . import (
113 from . import (
124 commands,
114 commands,
125 context,
126 protocol,
115 protocol,
127 )
116 )
128
117
@@ -139,7 +128,6 b' configitem = registrar.configitem(config'
139
128
140 configitem('fastannotate', 'modes', default=['fastannotate'])
129 configitem('fastannotate', 'modes', default=['fastannotate'])
141 configitem('fastannotate', 'server', default=False)
130 configitem('fastannotate', 'server', default=False)
142 configitem('fastannotate', 'useflock', default=configitems.dynamicdefault)
143 configitem('fastannotate', 'client', default=False)
131 configitem('fastannotate', 'client', default=False)
144 configitem('fastannotate', 'unfilteredrepo', default=True)
132 configitem('fastannotate', 'unfilteredrepo', default=True)
145 configitem('fastannotate', 'defaultformat', default=['number'])
133 configitem('fastannotate', 'defaultformat', default=['number'])
@@ -151,14 +139,6 b" configitem('fastannotate', 'clientfetcht"
151 configitem('fastannotate', 'serverbuildondemand', default=True)
139 configitem('fastannotate', 'serverbuildondemand', default=True)
152 configitem('fastannotate', 'remotepath', default='default')
140 configitem('fastannotate', 'remotepath', default='default')
153
141
154 def _flockavailable():
155 try:
156 import fcntl
157 fcntl.flock
158 except (AttributeError, ImportError):
159 return False
160 else:
161 return True
162
142
163 def uisetup(ui):
143 def uisetup(ui):
164 modes = set(ui.configlist('fastannotate', 'modes'))
144 modes = set(ui.configlist('fastannotate', 'modes'))
@@ -180,9 +160,6 b' def uisetup(ui):'
180 if ui.configbool('fastannotate', 'server'):
160 if ui.configbool('fastannotate', 'server'):
181 protocol.serveruisetup(ui)
161 protocol.serveruisetup(ui)
182
162
183 if ui.configbool('fastannotate', 'useflock', _flockavailable()):
184 context.pathhelper.lock = context.pathhelper._lockflock
185
186 def extsetup(ui):
163 def extsetup(ui):
187 # fastannotate has its own locking, without depending on repo lock
164 # fastannotate has its own locking, without depending on repo lock
188 # TODO: avoid mutating this unless the specific repo has it enabled
165 # TODO: avoid mutating this unless the specific repo has it enabled
@@ -759,21 +759,6 b' class pathhelper(object):'
759 def lock(self):
759 def lock(self):
760 return lockmod.lock(self._repo.vfs, self._vfspath + '.lock')
760 return lockmod.lock(self._repo.vfs, self._vfspath + '.lock')
761
761
762 @contextlib.contextmanager
763 def _lockflock(self):
764 """the same as 'lock' but use flock instead of lockmod.lock, to avoid
765 creating temporary symlinks."""
766 import fcntl
767 lockpath = self.linelogpath
768 util.makedirs(os.path.dirname(lockpath))
769 lockfd = os.open(lockpath, os.O_RDONLY | os.O_CREAT, 0o664)
770 fcntl.flock(lockfd, fcntl.LOCK_EX)
771 try:
772 yield
773 finally:
774 fcntl.flock(lockfd, fcntl.LOCK_UN)
775 os.close(lockfd)
776
777 @property
762 @property
778 def revmappath(self):
763 def revmappath(self):
779 return self._repo.vfs.join(self._vfspath + '.m')
764 return self._repo.vfs.join(self._vfspath + '.m')
General Comments 0
You need to be logged in to leave comments. Login now