sapling/eden/hg-server/tests/test-update-merge-state-t.py
John Reese 9fd86a4fae apply upgraded black 21.4b2 formatting to fbsource
Summary:
This applies the formatting changes from black v21.4b2 to all covered
projects in fbsource. Most changes are to single line docstrings, as black
will now remove leading and trailing whitespace to match PEP8. Any other
formatting changes are likely due to files that landed without formatting,
or files that previously triggered errors in black.

Any changes to code should be AST identical. Any test failures are likely
due to bad tests, or testing against the output of pyfmt.

Reviewed By: thatch

Differential Revision: D28204910

fbshipit-source-id: 804725bcd14f763e90c5ddff1d0418117c15809a
2021-05-04 22:16:51 -07:00

133 lines
3.6 KiB
Python

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % "enable morestatus"
sh % "setconfig morestatus.show=True ui.origbackuppath=.hg/origs"
def createstate(command="update"):
"""Create an interrupted state resolving 'hg update --merge' conflicts"""
sh % "newrepo"
(
sh % "drawdag"
<< r"""
B C
|/ # B/A=B\n
A
"""
)
if command == "update":
sh % 'hg up -C "$C" -q'
sh % "echo C" > "A"
sh % 'hg up --merge "$B" -q' == r"""
warning: 1 conflicts while merging A! (edit, then use 'hg resolve --mark')
[1]"""
elif command == "backout":
(
sh % "drawdag"
<< r"""
D # D/A=D\n
|
desc(B)
"""
)
sh % 'hg up -C "$D" -q'
sh % 'hg backout "$B" -q' == r"""
warning: 1 conflicts while merging A! (edit, then use 'hg resolve --mark')
[1]"""
createstate()
# There is only one working parent (which is good):
sh % 'hg parents -T "{desc}\\n"' == "B"
# 'morestatus' message:
sh % "hg status" == r"""
M A
# The repository is in an unfinished *update* state.
# Unresolved merge conflicts:
# (trailing space)
# A
# (trailing space)
# To mark files as resolved: hg resolve --mark FILE
# To continue: hg update --continue
# To abort: hg update --clean . (warning: this will discard uncommitted changes)"""
# Cannot --continue right now
sh % "hg update --continue" == r"""
abort: outstanding merge conflicts
(use 'hg resolve --list' to list, 'hg resolve --mark FILE' to mark resolved)
[255]"""
# 'morestatus' message after resolve
# BAD: The unfinished merge state is confusing and there is no clear way to get out.
sh % "hg resolve -m A" == r"""
(no more unresolved files)
continue: hg update --continue"""
sh % "hg status" == r"""
M A
# The repository is in an unfinished *update* state.
# No unresolved merge conflicts.
# To continue: hg update --continue
# To abort: hg update --clean . (warning: this will discard uncommitted changes)"""
# To get rid of the state
sh % "hg update --continue"
sh % "hg status" == "M A"
# Test abort flow
createstate()
sh % "hg update --clean . -q"
sh % "hg status"
# Test 'hg continue'
sh % "hg continue" == r"""
abort: nothing to continue
[255]"""
createstate()
sh % "hg continue" == r"""
abort: outstanding merge conflicts
(use 'hg resolve --list' to list, 'hg resolve --mark FILE' to mark resolved)
[255]"""
sh % "hg resolve -m A" == r"""
(no more unresolved files)
continue: hg update --continue"""
sh % "hg continue"
# Test 'hg continue' in a context that does not implement --continue.
# Choose 'backout' for this test. The 'backout' command does not have
# --continue.
createstate(command="backout")
sh % "hg continue" == r"""
abort: outstanding merge conflicts
(use 'hg resolve -l' to see a list of conflicted files, 'hg resolve -m' to mark files as resolved)
[255]"""
sh % "hg resolve --all -t :local" == "(no more unresolved files)"
sh % "hg status" == r"""
R B
# The repository is in an unfinished *merge* state.
# No unresolved merge conflicts."""
# The state is confusing, but 'hg continue' can resolve it.
sh % "hg continue" == "(exiting merge state)"
sh % "hg status" == "R B"