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