comparison hgext/largefiles/reposetup.py @ 23184:3100d1cbce32

largefiles: factor out procedures to update lfdirstate for post-committing Before this patch, procedures to update lfdirstate for post-committing are scattered in "lfilesrepo.commit". In the case of "hg commit" with patterns for target files ("Case 2"), lfdirstate is updated BEFORE real committing. This patch factors out procedures to update lfdirstate for post-committing into "lfutil.markcommitted", and makes it callable via "markcommitted" of the context passed to "lfilesrepo.commitctx". "markcommitted" of the context is called, only when it is committed successfully. Passing original "markcommitted" of the context is meaningless in this patch, but required in subsequent one to prepare something before invocation of it.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 05 Nov 2014 23:24:47 +0900
parents 9174863c58e4
children 9870173e0b48
comparison
equal deleted inserted replaced
23183:51c9196a6bd0 23184:3100d1cbce32
241 self.lfstatus = True 241 self.lfstatus = True
242 return scmutil.status(*result) 242 return scmutil.status(*result)
243 243
244 # As part of committing, copy all of the largefiles into the 244 # As part of committing, copy all of the largefiles into the
245 # cache. 245 # cache.
246 def commitctx(self, *args, **kwargs): 246 def commitctx(self, ctx, *args, **kwargs):
247 node = super(lfilesrepo, self).commitctx(*args, **kwargs) 247 node = super(lfilesrepo, self).commitctx(ctx, *args, **kwargs)
248 lfutil.copyalltostore(self, node) 248 lfutil.copyalltostore(self, node)
249 class lfilesctx(ctx.__class__):
250 def markcommitted(self, node):
251 orig = super(lfilesctx, self).markcommitted
252 return lfutil.markcommitted(orig, self, node)
253 ctx.__class__ = lfilesctx
249 return node 254 return node
250 255
251 # Before commit, largefile standins have not had their 256 # Before commit, largefile standins have not had their
252 # contents updated to reflect the hash of their largefile. 257 # contents updated to reflect the hash of their largefile.
253 # Do that here. 258 # Do that here.
268 # 273 #
269 if getattr(self, "_isrebasing", False) or \ 274 if getattr(self, "_isrebasing", False) or \
270 getattr(self, "_istransplanting", False): 275 getattr(self, "_istransplanting", False):
271 result = orig(text=text, user=user, date=date, match=match, 276 result = orig(text=text, user=user, date=date, match=match,
272 force=force, editor=editor, extra=extra) 277 force=force, editor=editor, extra=extra)
273
274 if result:
275 lfdirstate = lfutil.openlfdirstate(ui, self)
276 for f in self[result].files():
277 if lfutil.isstandin(f):
278 lfile = lfutil.splitstandin(f)
279 lfutil.synclfdirstate(self, lfdirstate, lfile,
280 False)
281 lfdirstate.write()
282
283 return result 278 return result
284 # Case 1: user calls commit with no specific files or 279 # Case 1: user calls commit with no specific files or
285 # include/exclude patterns: refresh and commit all files that 280 # include/exclude patterns: refresh and commit all files that
286 # are "dirty". 281 # are "dirty".
287 if match is None or match.always(): 282 if match is None or match.always():
306 # performed and the working copy is not updated 301 # performed and the working copy is not updated
307 # yet. 302 # yet.
308 if os.path.exists(self.wjoin(lfile)): 303 if os.path.exists(self.wjoin(lfile)):
309 lfutil.updatestandin(self, 304 lfutil.updatestandin(self,
310 lfutil.standin(lfile)) 305 lfutil.standin(lfile))
311 lfdirstate.normal(lfile)
312 306
313 result = orig(text=text, user=user, date=date, match=match, 307 result = orig(text=text, user=user, date=date, match=match,
314 force=force, editor=editor, extra=extra) 308 force=force, editor=editor, extra=extra)
315 309
316 if result is not None:
317 for lfile in lfdirstate:
318 if lfile in modifiedfiles:
319 if (not os.path.exists(self.wjoin(
320 lfutil.standin(lfile)))) or \
321 (not os.path.exists(self.wjoin(lfile))):
322 lfdirstate.drop(lfile)
323
324 # This needs to be after commit; otherwise precommit hooks
325 # get the wrong status
326 lfdirstate.write()
327 return result 310 return result
328 311
329 lfiles = lfutil.listlfiles(self) 312 lfiles = lfutil.listlfiles(self)
330 match._files = self._subdirlfs(match.files(), lfiles) 313 match._files = self._subdirlfs(match.files(), lfiles)
331 314
348 lfdirstate = lfutil.openlfdirstate(ui, self) 331 lfdirstate = lfutil.openlfdirstate(ui, self)
349 for standin in standins: 332 for standin in standins:
350 lfile = lfutil.splitstandin(standin) 333 lfile = lfutil.splitstandin(standin)
351 if lfdirstate[lfile] != 'r': 334 if lfdirstate[lfile] != 'r':
352 lfutil.updatestandin(self, standin) 335 lfutil.updatestandin(self, standin)
353 lfdirstate.normal(lfile)
354 else:
355 lfdirstate.drop(lfile)
356 336
357 # Cook up a new matcher that only matches regular files or 337 # Cook up a new matcher that only matches regular files or
358 # standins corresponding to the big files requested by the 338 # standins corresponding to the big files requested by the
359 # user. Have to modify _files to prevent commit() from 339 # user. Have to modify _files to prevent commit() from
360 # complaining "not tracked" for big files. 340 # complaining "not tracked" for big files.
384 return f in standins 364 return f in standins
385 365
386 match.matchfn = matchfn 366 match.matchfn = matchfn
387 result = orig(text=text, user=user, date=date, match=match, 367 result = orig(text=text, user=user, date=date, match=match,
388 force=force, editor=editor, extra=extra) 368 force=force, editor=editor, extra=extra)
389 # This needs to be after commit; otherwise precommit hooks
390 # get the wrong status
391 lfdirstate.write()
392 return result 369 return result
393 finally: 370 finally:
394 wlock.release() 371 wlock.release()
395 372
396 def push(self, remote, force=False, revs=None, newbranch=False): 373 def push(self, remote, force=False, revs=None, newbranch=False):