comparison hgext/largefiles/lfutil.py @ 23187:f726b05ecfe6

largefiles: update standins only at the 1st commit of "hg rebase --continue" Before this patch, "hg rebase --continue" may record incorrect standins, because largefiles extension always avoid updating standins while rebasing, even though largefiles in the working directory may be modified manually at the 1st commit of "hg rebase --continue". But, on the other hand, updating standins should be avoided at subsequent commits for efficiency reason. To update standins only at the 1st commit of "hg rebase --continue", this patch introduces state-full callable object "automatedcommithook", which updates standins by "lfutil.updatestandinsbymatch()" only at the 1st commit of resuming. Even after this patch, "repo._isrebasing = True" is still needed to avoid some status report while updating largefiles in "lfcommands.updatelfiles()". This is reason why this patch omits not "repo._isrebasing = True" in "overriderebase" but examination of "getattr(repo, "_isrebasing", False)" in "updatestandinsbymatch".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 05 Nov 2014 23:24:47 +0900
parents 9870173e0b48
children 94ac64bcf6fe
comparison
equal deleted inserted replaced
23186:6de61d0b773f 23187:f726b05ecfe6
445 # (1) updating standins, because standins should 445 # (1) updating standins, because standins should
446 # be already updated at this point 446 # be already updated at this point
447 # (2) aborting when standins are matched by "match", 447 # (2) aborting when standins are matched by "match",
448 # because automated committing may specify them directly 448 # because automated committing may specify them directly
449 # 449 #
450 if getattr(repo, "_isrebasing", False) or \ 450 if getattr(repo, "_istransplanting", False):
451 getattr(repo, "_istransplanting", False):
452 return match 451 return match
453 452
454 # Case 1: user calls commit with no specific files or 453 # Case 1: user calls commit with no specific files or
455 # include/exclude patterns: refresh and commit all files that 454 # include/exclude patterns: refresh and commit all files that
456 # are "dirty". 455 # are "dirty".
535 return f in standins 534 return f in standins
536 535
537 match.matchfn = matchfn 536 match.matchfn = matchfn
538 537
539 return match 538 return match
539
540 class automatedcommithook(object):
541 '''Statefull hook to update standins at the 1st commit of resuming
542
543 For efficiency, updating standins in the working directory should
544 be avoided while automated committing (like rebase, transplant and
545 so on), because they should be updated before committing.
546
547 But the 1st commit of resuming automated committing (e.g. ``rebase
548 --continue``) should update them, because largefiles may be
549 modified manually.
550 '''
551 def __init__(self, resuming):
552 self.resuming = resuming
553
554 def __call__(self, repo, match):
555 if self.resuming:
556 self.resuming = False # avoids updating at subsequent commits
557 return updatestandinsbymatch(repo, match)
558 else:
559 return match