comparison hgext/largefiles/overrides.py @ 23183:51c9196a6bd0

largefiles: remove meaningless code path for "hg pull --rebase" This patch removes "--rebase" specific code path for "hg pull" in "overridepull", because previous patch makes it meaningless: now, "rebase.rebase" ("orig" invocation in this patch) can update/commit largefiles safely without "repo._isrebasing = True". As a side effect of removing "rebase.rebase" invocation in "overridepull", this patch removes "nothing to rebase ..." message in "test-largefiles.t", which is shown only when rebase extension is enabled AFTER largefiles: before this patch: 1. "dispatch" invokes "pullrebase" of rebase as "hg pull" at first, because rebase wraps "hg pull" later 2. "pullrebase" invokes "overridepull" of largefiles as "orig", even though rebase assumes that "orig" is "pull" of commands 3. "overridepull" executes "pull" and "rebase" directly 3.1 "pull" pulls changesets and creates new head "X" 3.2 "rebase" rebases current working parent "Y" on "X" 4. "overridepull" returns to "pullrebase" 5. "pullrebase" tries to rebase, but there is nothing to be done, because "Y" is already rebased on "X". then, it shows "nothing to rebase ..." after this patch: 1. "dispatch" invokes "pullrebase" of rebase as "hg pull" 2. "pullrebase" invokes "overridepull" of largefiles as "orig" 3. "overridepull" executes "pull" as "orig" 4. "overridepull" returns to "pullrebase" 5. revision "Y" is not yet rebased, so "pullrebase" doesn't shows "nothing to rebase ..." As another side effect of removing "rebase.rebase" invocation, this patch fixes issue3861, which occurs only when rebase extension is enabled BEFORE largefiles: before this patch: 1. "dispatch" invokes "overridepull" of largefiles at first, because largefiles wrap "hg pull" later 2. "overridepull" executes "pull" and "rebase" explicitly 2.1 "pull" pulls changesets and creates new head "X" 2.2 "rebase" rebases current working parent, but fails because no revision is checked out in issue3861 case 3. "overridepull" returns to "dispatch" with exit code 1 returned from "rebase" at (2.2) 4. "hg pull" terminates with exit code 1 unexpectedly after this patch: 1. "dispatch" invokes "overridepull" of largefiles at first 2. "overridepull" invokes "pullrebase" of rebase as "orig" 3. "pullrebase" invokes "pull" as "orig" 4. "pullrebase" invokes "rebase", and it fails 5. "pullrebase" returns to "overridepull" with exit code 0 (because "pullrebase" ignores result of "pull" and "rebase") 6. "overridepull" returns to "dispatch" with exit code 0 returned from "rebase" at (5) 7. "hg pull" terminates with exit code 0
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 05 Nov 2014 23:24:47 +0900
parents 97b6e762f218
children f726b05ecfe6
comparison
equal deleted inserted replaced
23182:9b6c3947b4a7 23183:51c9196a6bd0
9 '''Overridden Mercurial commands and functions for the largefiles extension''' 9 '''Overridden Mercurial commands and functions for the largefiles extension'''
10 10
11 import os 11 import os
12 import copy 12 import copy
13 13
14 from mercurial import hg, commands, util, cmdutil, scmutil, match as match_, \ 14 from mercurial import hg, util, cmdutil, scmutil, match as match_, \
15 archival, pathutil, revset 15 archival, pathutil, revset
16 from mercurial.i18n import _ 16 from mercurial.i18n import _
17 from mercurial.node import hex 17 from mercurial.node import hex
18 from hgext import rebase
19 18
20 import lfutil 19 import lfutil
21 import lfcommands 20 import lfcommands
22 import basestore 21 import basestore
23 22
708 normallookup=True) 707 normallookup=True)
709 708
710 finally: 709 finally:
711 wlock.release() 710 wlock.release()
712 711
713 # When we rebase a repository with remotely changed largefiles, we need to 712 # after pulling changesets, we need to take some extra care to get
714 # take some extra care so that the largefiles are correctly updated in the 713 # largefiles updated remotely
715 # working copy
716 def overridepull(orig, ui, repo, source=None, **opts): 714 def overridepull(orig, ui, repo, source=None, **opts):
717 revsprepull = len(repo) 715 revsprepull = len(repo)
718 if not source: 716 if not source:
719 source = 'default' 717 source = 'default'
720 repo.lfpullsource = source 718 repo.lfpullsource = source
721 if opts.get('rebase', False): 719 result = orig(ui, repo, source, **opts)
722 repo._isrebasing = True
723 try:
724 if opts.get('update'):
725 del opts['update']
726 ui.debug('--update and --rebase are not compatible, ignoring '
727 'the update flag\n')
728 del opts['rebase']
729 origpostincoming = commands.postincoming
730 def _dummy(*args, **kwargs):
731 pass
732 commands.postincoming = _dummy
733 try:
734 result = commands.pull(ui, repo, source, **opts)
735 finally:
736 commands.postincoming = origpostincoming
737 revspostpull = len(repo)
738 if revspostpull > revsprepull:
739 result = result or rebase.rebase(ui, repo)
740 finally:
741 repo._isrebasing = False
742 else:
743 result = orig(ui, repo, source, **opts)
744 revspostpull = len(repo) 720 revspostpull = len(repo)
745 lfrevs = opts.get('lfrev', []) 721 lfrevs = opts.get('lfrev', [])
746 if opts.get('all_largefiles'): 722 if opts.get('all_largefiles'):
747 lfrevs.append('pulled()') 723 lfrevs.append('pulled()')
748 if lfrevs and revspostpull > revsprepull: 724 if lfrevs and revspostpull > revsprepull: