mirror of
https://github.com/facebook/sapling.git
synced 2025-01-04 03:06:30 +03:00
rebase: replace --tool :abort with rebase --noconflict
Summary: I was thinking about what we need to enable automatic restacking on non-conflicting amends (see the next diff), but I realized the --tool :abort tool I implemented in D8493065 doesn't really work well for this for three reasons: - It can't handle the case of mergedriver having to run, which is the other reason we'd have to break out of IMM. - It hard-codes the merge tool. The user might want to specify another tool that doesn't recreate conflicts or solves them differently. - It'd force callers to detect if IMM will be used (to prevent an on-disk merge hapening by mistake). A flag can implement this much more easily. - As I learned when writing D8493065, it would require hardcoded logic in every command anyway to support the non-IMM case. (Just raising an abort will leave most commands with an interrupted state.) So, I think we should replace it with this flag to make auto-restacking work very reliably (we could add it to graft, too). If there was some big demand for --tool :abort we could always add it back in the future. Reviewed By: quark-zju Differential Revision: D8701897 fbshipit-source-id: ea3b92d0a224a8ce43edb120b53bec241d92a61d
This commit is contained in:
parent
46358b47c2
commit
0be0108bed
@ -543,7 +543,11 @@ class rebaseruntime(object):
|
||||
else:
|
||||
kindstr = _("artifact rebuild required")
|
||||
|
||||
if cmdutil.uncommittedchanges(repo):
|
||||
if self.opts["noconflict"]:
|
||||
raise error.AbortMergeToolError(
|
||||
"%s (in %s) and --noconflict passed" % (kindstr, pathstr)
|
||||
)
|
||||
elif cmdutil.uncommittedchanges(repo):
|
||||
raise error.UncommitedChangesAbort(
|
||||
_(
|
||||
"must use on-disk merge for this rebase (%s in %s), but you have working copy changes"
|
||||
@ -814,6 +818,12 @@ class rebaseruntime(object):
|
||||
("t", "tool", "", _("specify merge tool")),
|
||||
("c", "continue", False, _("continue an interrupted rebase")),
|
||||
("a", "abort", False, _("abort an interrupted rebase")),
|
||||
(
|
||||
"",
|
||||
"noconflict",
|
||||
False,
|
||||
_("cancel the rebase if there are conflicts (EXPERIMENTAL)"),
|
||||
),
|
||||
]
|
||||
+ cmdutil.formatteropts,
|
||||
_("[-s REV | -b REV] [-d REV] [OPTION]"),
|
||||
@ -966,6 +976,9 @@ def rebase(ui, repo, templ=None, **opts):
|
||||
)
|
||||
inmemory = False
|
||||
|
||||
if opts.get("noconflict") and not inmemory:
|
||||
raise error.Abort("--noconflict requires in-memory merge")
|
||||
|
||||
opts = pycompat.byteskwargs(opts)
|
||||
rbsrt = rebaseruntime(repo, ui, templ, inmemory, opts)
|
||||
|
||||
|
@ -247,22 +247,6 @@ def _matcheol(file, back):
|
||||
util.writefile(file, newdata)
|
||||
|
||||
|
||||
@internaltool("abort", fullmerge)
|
||||
def _iabort(repo, mynode, orig, fcd, *args, **kwargs):
|
||||
if not fcd.changectx().isinmemory():
|
||||
# Support coming soon; it's tricker to do without IMM and has to be
|
||||
# implemented per-command.
|
||||
raise error.Abort(_("--tool :abort only works with in-memory merge"))
|
||||
|
||||
res = _imerge(repo, mynode, orig, fcd, *args, **kwargs)
|
||||
if res:
|
||||
raise error.AbortMergeToolError(
|
||||
_("hit merge conflicts, and --tool :abort passed")
|
||||
)
|
||||
else:
|
||||
return res
|
||||
|
||||
|
||||
@internaltool("prompt", nomerge)
|
||||
def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
|
||||
"""Asks the user which of the local `p1()` or the other `p2()` version to
|
||||
|
@ -1,4 +1,4 @@
|
||||
Tests the :abort merge tool
|
||||
Tests the --noconflict rebase flag
|
||||
|
||||
$ enable rebase fbamend morestatus
|
||||
$ setconfig morestatus.show=True
|
||||
@ -24,18 +24,18 @@ Tests the :abort merge tool
|
||||
|
||||
|
||||
Confirm it fails when rebasing a change that conflicts:
|
||||
$ hg rebase -r tip -d . --tool :abort
|
||||
$ hg rebase -r tip -d . --noconflict
|
||||
rebasing in-memory!
|
||||
rebasing 3:955ac081fc7c "g" (tip)
|
||||
merging c
|
||||
hit merge conflicts, and --tool :abort passed; exiting.
|
||||
hit merge conflicts (in c) and --noconflict passed; exiting.
|
||||
$ hg st
|
||||
M b
|
||||
$ cat b
|
||||
local change
|
||||
|
||||
Confirm rebase without a merge behaves the same:
|
||||
$ hg rebase -r tip -d .~1 --tool :abort
|
||||
$ hg rebase -r tip -d .~1 --noconflict
|
||||
rebasing in-memory!
|
||||
rebasing 3:955ac081fc7c "g" (tip)
|
||||
saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/955ac081fc7c-77e57574-rebase.hg
|
||||
@ -46,12 +46,8 @@ Confirm the flag fails without IMM:
|
||||
$ hg up -C .
|
||||
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||
$ hg st
|
||||
$ hg rebase -r tip -d . --tool :abort
|
||||
rebasing 3:20b9638feb86 "g" (tip)
|
||||
merging c
|
||||
transaction abort!
|
||||
rollback completed
|
||||
abort: --tool :abort only works with in-memory merge
|
||||
$ hg rebase -r tip -d . --noconflict
|
||||
abort: --noconflict requires in-memory merge
|
||||
[255]
|
||||
|
||||
Confirm that it rebases a three-way merge, but no conflict:
|
||||
@ -71,7 +67,7 @@ Confirm that it rebases a three-way merge, but no conflict:
|
||||
o 0 base
|
||||
|
||||
$ hg up -qC 0
|
||||
$ hg rebase -r 1 -d 2 --tool :abort
|
||||
$ hg rebase -r 1 -d 2 --noconflict
|
||||
rebasing in-memory!
|
||||
rebasing 1:12cba56c6d27 "extend to 10"
|
||||
merging a
|
Loading…
Reference in New Issue
Block a user