Mercurial > public > mercurial-scm > hg
diff mercurial/merge.py @ 28022:e397b58c0563
rebase: respect checkunknown and checkignored in more cases
checkunknown and checkignored are currently respected for updates and regular
merges, but not for certain kinds of rebases. To be precise, they aren't
respected for rebases when:
(1) we're rebasing while currently on the destination commit, and
(2) an untracked or ignored file F is currently in the working copy, and
(3) the same file F is in a source commit, and
(4) F has different contents in the source commit.
This happens because rebases set force to True when calling merge.update.
Setting force to True makes a lot of sense in general, but it turns out the
force option is overloaded: there's a deprecated '--force' option in merge that
allows you to merge in outstanding changes, including changes in untracked
files. We use the 'mergeforce' parameter to tell those two cases apart.
I think the behavior during rebases when checkunknown is 'abort' (the default)
is wrong -- we should abort on or overwrite differing untracked files, not try
to merge them in. However that currently breaks rebases by aborting in the
middle -- we need better handling for that case before we can change the
default.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Wed, 03 Feb 2016 13:12:06 -0800 |
parents | cffa46cbdb8f |
children | 19424f960bf5 |
line wrap: on
line diff
--- a/mercurial/merge.py Wed Feb 03 13:11:34 2016 -0800 +++ b/mercurial/merge.py Wed Feb 03 13:12:06 2016 -0800 @@ -634,6 +634,39 @@ unknownconflicts = conflicts - ignoredconflicts collectconflicts(ignoredconflicts, ignoredconfig) collectconflicts(unknownconflicts, unknownconfig) + else: + for f, (m, args, msg) in actions.iteritems(): + if m == 'cm': + fl2, anc = args + different = _checkunknownfile(repo, wctx, mctx, f) + if repo.dirstate._ignore(f): + config = ignoredconfig + else: + config = unknownconfig + + # The behavior when force is True is described by this table: + # config different mergeforce | action backup + # * n * | get n + # * y y | merge - + # abort y n | merge - (1) + # warn y n | warn + get y + # ignore y n | get y + # + # (1) this is probably the wrong behavior here -- we should + # probably abort, but some actions like rebases currently + # don't like an abort happening in the middle of + # merge.update. + if not different: + actions[f] = ('g', (fl2, False), "remote created") + elif mergeforce or config == 'abort': + actions[f] = ('m', (f, f, None, False, anc), + "remote differs from untracked local") + elif config == 'abort': + abortconflicts.add(f) + else: + if config == 'warn': + warnconflicts.add(f) + actions[f] = ('g', (fl2, True), "remote created") for f in sorted(abortconflicts): repo.ui.warn(_("%s: untracked file differs\n") % f) @@ -649,14 +682,6 @@ if m == 'c': flags, = args actions[f] = ('g', (flags, backup), msg) - elif m == 'cm': - fl2, anc = args - different = _checkunknownfile(repo, wctx, mctx, f) - if different: - actions[f] = ('m', (f, f, None, False, anc), - "remote differs from untracked local") - else: - actions[f] = ('g', (fl2, backup), "remote created") def _forgetremoved(wctx, mctx, branchmerge): """