##// END OF EJS Templates
largefiles: fix inappropriate locking (issue3182)...
Levi Bard -
r15794:0d91211d default
parent child Browse files
Show More
@@ -154,11 +154,7 b' def openlfdirstate(ui, repo):'
154
154
155 # If the largefiles dirstate does not exist, populate and create
155 # If the largefiles dirstate does not exist, populate and create
156 # it. This ensures that we create it on the first meaningful
156 # it. This ensures that we create it on the first meaningful
157 # largefiles operation in a new clone. It also gives us an easy
157 # largefiles operation in a new clone.
158 # way to forcibly rebuild largefiles state:
159 # rm .hg/largefiles/dirstate && hg status
160 # Or even, if things are really messed up:
161 # rm -rf .hg/largefiles && hg status
162 if not os.path.exists(os.path.join(admin, 'dirstate')):
158 if not os.path.exists(os.path.join(admin, 'dirstate')):
163 util.makedirs(admin)
159 util.makedirs(admin)
164 matcher = getstandinmatcher(repo)
160 matcher = getstandinmatcher(repo)
@@ -172,27 +168,19 b' def openlfdirstate(ui, repo):'
172 except OSError, err:
168 except OSError, err:
173 if err.errno != errno.ENOENT:
169 if err.errno != errno.ENOENT:
174 raise
170 raise
175
176 lfdirstate.write()
177
178 return lfdirstate
171 return lfdirstate
179
172
180 def lfdirstate_status(lfdirstate, repo, rev):
173 def lfdirstate_status(lfdirstate, repo, rev):
181 wlock = repo.wlock()
174 match = match_.always(repo.root, repo.getcwd())
182 try:
175 s = lfdirstate.status(match, [], False, False, False)
183 match = match_.always(repo.root, repo.getcwd())
176 unsure, modified, added, removed, missing, unknown, ignored, clean = s
184 s = lfdirstate.status(match, [], False, False, False)
177 for lfile in unsure:
185 unsure, modified, added, removed, missing, unknown, ignored, clean = s
178 if repo[rev][standin(lfile)].data().strip() != \
186 for lfile in unsure:
179 hashfile(repo.wjoin(lfile)):
187 if repo[rev][standin(lfile)].data().strip() != \
180 modified.append(lfile)
188 hashfile(repo.wjoin(lfile)):
181 else:
189 modified.append(lfile)
182 clean.append(lfile)
190 else:
183 lfdirstate.normal(lfile)
191 clean.append(lfile)
192 lfdirstate.normal(lfile)
193 lfdirstate.write()
194 finally:
195 wlock.release()
196 return (modified, added, removed, missing, unknown, ignored, clean)
184 return (modified, added, removed, missing, unknown, ignored, clean)
197
185
198 def listlfiles(repo, rev=None, matcher=None):
186 def listlfiles(repo, rev=None, matcher=None):
@@ -910,15 +910,19 b' def override_rollback(orig, ui, repo, **'
910 result = orig(ui, repo, **opts)
910 result = orig(ui, repo, **opts)
911 merge.update(repo, node=None, branchmerge=False, force=True,
911 merge.update(repo, node=None, branchmerge=False, force=True,
912 partial=lfutil.isstandin)
912 partial=lfutil.isstandin)
913 lfdirstate = lfutil.openlfdirstate(ui, repo)
913 wlock = repo.wlock()
914 lfiles = lfutil.listlfiles(repo)
914 try:
915 oldlfiles = lfutil.listlfiles(repo, repo[None].parents()[0].rev())
915 lfdirstate = lfutil.openlfdirstate(ui, repo)
916 for file in lfiles:
916 lfiles = lfutil.listlfiles(repo)
917 if file in oldlfiles:
917 oldlfiles = lfutil.listlfiles(repo, repo[None].parents()[0].rev())
918 lfdirstate.normallookup(file)
918 for file in lfiles:
919 else:
919 if file in oldlfiles:
920 lfdirstate.add(file)
920 lfdirstate.normallookup(file)
921 lfdirstate.write()
921 else:
922 lfdirstate.add(file)
923 lfdirstate.write()
924 finally:
925 wlock.release()
922 return result
926 return result
923
927
924 def override_transplant(orig, ui, repo, *revs, **opts):
928 def override_transplant(orig, ui, repo, *revs, **opts):
@@ -147,9 +147,6 b' def reposetup(ui, repo):'
147 result = super(lfiles_repo, self).status(node1, node2, m,
147 result = super(lfiles_repo, self).status(node1, node2, m,
148 True, clean, unknown, listsubrepos)
148 True, clean, unknown, listsubrepos)
149 if working:
149 if working:
150 # hold the wlock while we read largefiles and
151 # update the lfdirstate
152 wlock = repo.wlock()
153 try:
150 try:
154 # Any non-largefiles that were explicitly listed must be
151 # Any non-largefiles that were explicitly listed must be
155 # taken out or lfdirstate.status will report an error.
152 # taken out or lfdirstate.status will report an error.
@@ -186,7 +183,6 b' def reposetup(ui, repo):'
186 else:
183 else:
187 clean.append(lfile)
184 clean.append(lfile)
188 lfdirstate.normal(lfile)
185 lfdirstate.normal(lfile)
189 lfdirstate.write()
190 else:
186 else:
191 tocheck = unsure + modified + added + clean
187 tocheck = unsure + modified + added + clean
192 modified, added, clean = [], [], []
188 modified, added, clean = [], [], []
@@ -201,10 +197,9 b' def reposetup(ui, repo):'
201 clean.append(lfile)
197 clean.append(lfile)
202 else:
198 else:
203 added.append(lfile)
199 added.append(lfile)
200 finally:
204 # Replace the original ignore function
201 # Replace the original ignore function
205 lfdirstate._ignore = orig_ignore
202 lfdirstate._ignore = orig_ignore
206 finally:
207 wlock.release()
208
203
209 for standin in ctx1.manifest():
204 for standin in ctx1.manifest():
210 if not lfutil.isstandin(standin):
205 if not lfutil.isstandin(standin):
@@ -324,10 +319,13 b' def reposetup(ui, repo):'
324 if not os.path.exists(
319 if not os.path.exists(
325 repo.wjoin(lfutil.standin(lfile))):
320 repo.wjoin(lfutil.standin(lfile))):
326 lfdirstate.drop(lfile)
321 lfdirstate.drop(lfile)
322
323 result = orig(text=text, user=user, date=date, match=match,
324 force=force, editor=editor, extra=extra)
325 # This needs to be after commit; otherwise precommit hooks
326 # get the wrong status
327 lfdirstate.write()
327 lfdirstate.write()
328
328 return result
329 return orig(text=text, user=user, date=date, match=match,
330 force=force, editor=editor, extra=extra)
331
329
332 for f in match.files():
330 for f in match.files():
333 if lfutil.isstandin(f):
331 if lfutil.isstandin(f):
@@ -359,7 +357,6 b' def reposetup(ui, repo):'
359 lfdirstate.normal(lfile)
357 lfdirstate.normal(lfile)
360 else:
358 else:
361 lfdirstate.drop(lfile)
359 lfdirstate.drop(lfile)
362 lfdirstate.write()
363
360
364 # Cook up a new matcher that only matches regular files or
361 # Cook up a new matcher that only matches regular files or
365 # standins corresponding to the big files requested by the
362 # standins corresponding to the big files requested by the
@@ -400,8 +397,12 b' def reposetup(ui, repo):'
400 return f in standins
397 return f in standins
401
398
402 match.matchfn = matchfn
399 match.matchfn = matchfn
403 return orig(text=text, user=user, date=date, match=match,
400 result = orig(text=text, user=user, date=date, match=match,
404 force=force, editor=editor, extra=extra)
401 force=force, editor=editor, extra=extra)
402 # This needs to be after commit; otherwise precommit hooks
403 # get the wrong status
404 lfdirstate.write()
405 return result
405 finally:
406 finally:
406 wlock.release()
407 wlock.release()
407
408
@@ -65,4 +65,3 b' makes copies instead of hardlinks:'
65 The largefile is not created in .hg/largefiles:
65 The largefile is not created in .hg/largefiles:
66
66
67 $ ls bob/.hg/largefiles
67 $ ls bob/.hg/largefiles
68 dirstate
General Comments 0
You need to be logged in to leave comments. Login now