diff -r f200bea8470b -r 699102b10530 hgext/histedit.py --- a/hgext/histedit.py Mon Sep 23 16:29:16 2019 -0400 +++ b/hgext/histedit.py Wed Sep 25 13:50:48 2019 -0400 @@ -1970,6 +1970,32 @@ node.short(root)) ctxs = [repo[r] for r in revs] + + wctx = repo[None] + # Please don't ask me why `ancestors` is this value. I figured it + # out with print-debugging, not by actually understanding what the + # merge code is doing. :( + ancs = [repo['.']] + # Sniff-test to make sure we won't collide with untracked files in + # the working directory. If we don't do this, we can get a + # collision after we've started histedit and backing out gets ugly + # for everyone, especially the user. + for c in [ctxs[0].p1()] + ctxs: + try: + mergemod.calculateupdates( + repo, wctx, c, ancs, + # These parameters were determined by print-debugging + # what happens later on inside histedit. + False, # branchmerge + False, # force + False, # acceptremote + False, # followcopies + ) + except error.Abort: + raise error.Abort( + _("untracked files in working directory conflict with files in %s") % ( + c)) + if not rules: comment = geteditcomment(ui, node.short(root), node.short(topmost)) actions = [pick(state, r) for r in revs]