diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -447,8 +447,7 @@ def updatestandinsbymatch(repo, match): # (2) aborting when standins are matched by "match", # because automated committing may specify them directly # - if getattr(repo, "_isrebasing", False) or \ - getattr(repo, "_istransplanting", False): + if getattr(repo, "_istransplanting", False): return match # Case 1: user calls commit with no specific files or @@ -537,3 +536,24 @@ def updatestandinsbymatch(repo, match): match.matchfn = matchfn return match + +class automatedcommithook(object): + '''Statefull hook to update standins at the 1st commit of resuming + + For efficiency, updating standins in the working directory should + be avoided while automated committing (like rebase, transplant and + so on), because they should be updated before committing. + + But the 1st commit of resuming automated committing (e.g. ``rebase + --continue``) should update them, because largefiles may be + modified manually. + ''' + def __init__(self, resuming): + self.resuming = resuming + + def __call__(self, repo, match): + if self.resuming: + self.resuming = False # avoids updating at subsequent commits + return updatestandinsbymatch(repo, match) + else: + return match diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -790,11 +790,14 @@ def hgclone(orig, ui, opts, *args, **kwa return result def overriderebase(orig, ui, repo, **opts): + resuming = opts.get('continue') + repo._lfcommithooks.append(lfutil.automatedcommithook(resuming)) repo._isrebasing = True try: return orig(ui, repo, **opts) finally: repo._isrebasing = False + repo._lfcommithooks.pop() def overridearchive(orig, repo, dest, node, kind, decode=True, matchfn=None, prefix=None, mtime=None, subrepos=None): diff --git a/tests/test-largefiles-update.t b/tests/test-largefiles-update.t --- a/tests/test-largefiles-update.t +++ b/tests/test-largefiles-update.t @@ -509,8 +509,25 @@ it is aborted by conflict. $ cat large1 large1 in #1 - $ hg rebase -q --abort - rebase aborted +Test that rebase updates standins for manually modified largefiles at +the 1st commit of resuming. + + $ echo "manually modified before 'hg rebase --continue'" > large1 + $ hg resolve -m normal1 + (no more unresolved files) + $ hg rebase --continue --config ui.interactive=True < c + > EOF + local changed .hglf/large1 which remote deleted + use (c)hanged version or (d)elete? c + + $ hg diff -c "tip~1" --nodates .hglf/large1 | grep '^[+-][0-9a-z]' + -e5bb990443d6a92aaf7223813720f7566c9dd05b + +8a4f783556e7dea21139ca0466eafce954c75c13 + $ rm -f large1 + $ hg update -q -C tip + $ cat large1 + manually modified before 'hg rebase --continue' Test that transplant updates largefiles, of which standins are safely changed, even if it is aborted by conflict of other.