Changeset View
Changeset View
Standalone View
Standalone View
mercurial/commands.py
Show First 20 Lines • Show All 5980 Lines • ▼ Show 20 Line(s) | if show: | ||||
mergestatemod.MERGE_RECORD_UNRESOLVED_PATH: ( | mergestatemod.MERGE_RECORD_UNRESOLVED_PATH: ( | ||||
b'resolve.unresolved', | b'resolve.unresolved', | ||||
b'P', | b'P', | ||||
), | ), | ||||
mergestatemod.MERGE_RECORD_RESOLVED_PATH: ( | mergestatemod.MERGE_RECORD_RESOLVED_PATH: ( | ||||
b'resolve.resolved', | b'resolve.resolved', | ||||
b'R', | b'R', | ||||
), | ), | ||||
mergestatemod.MERGE_RECORD_DRIVER_RESOLVED: ( | |||||
b'resolve.driverresolved', | |||||
b'D', | |||||
), | |||||
} | } | ||||
for f in ms: | for f in ms: | ||||
if not m(f): | if not m(f): | ||||
continue | continue | ||||
label, key = mergestateinfo[ms[f]] | label, key = mergestateinfo[ms[f]] | ||||
fm.startitem() | fm.startitem() | ||||
fm.context(ctx=wctx) | fm.context(ctx=wctx) | ||||
fm.condwrite(not nostatus, b'mergestatus', b'%s ', key, label=label) | fm.condwrite(not nostatus, b'mergestatus', b'%s ', key, label=label) | ||||
fm.data(path=f) | fm.data(path=f) | ||||
fm.plain(b'%s\n' % uipathfn(f), label=label) | fm.plain(b'%s\n' % uipathfn(f), label=label) | ||||
fm.end() | fm.end() | ||||
return 0 | return 0 | ||||
with repo.wlock(): | with repo.wlock(): | ||||
ms = mergestatemod.mergestate.read(repo) | ms = mergestatemod.mergestate.read(repo) | ||||
if not (ms.active() or repo.dirstate.p2() != nullid): | if not (ms.active() or repo.dirstate.p2() != nullid): | ||||
raise error.Abort( | raise error.Abort( | ||||
_(b'resolve command not applicable when not merging') | _(b'resolve command not applicable when not merging') | ||||
) | ) | ||||
wctx = repo[None] | wctx = repo[None] | ||||
if ( | |||||
ms.mergedriver | |||||
and ms.mdstate() == mergestatemod.MERGE_DRIVER_STATE_UNMARKED | |||||
): | |||||
proceed = mergemod.driverpreprocess(repo, ms, wctx) | |||||
ms.commit() | |||||
# allow mark and unmark to go through | |||||
if not mark and not unmark and not proceed: | |||||
return 1 | |||||
m = scmutil.match(wctx, pats, opts) | m = scmutil.match(wctx, pats, opts) | ||||
ret = 0 | ret = 0 | ||||
didwork = False | didwork = False | ||||
runconclude = False | |||||
tocomplete = [] | tocomplete = [] | ||||
hasconflictmarkers = [] | hasconflictmarkers = [] | ||||
if mark: | if mark: | ||||
markcheck = ui.config(b'commands', b'resolve.mark-check') | markcheck = ui.config(b'commands', b'resolve.mark-check') | ||||
if markcheck not in [b'warn', b'abort']: | if markcheck not in [b'warn', b'abort']: | ||||
# Treat all invalid / unrecognized values as 'none'. | # Treat all invalid / unrecognized values as 'none'. | ||||
markcheck = False | markcheck = False | ||||
for f in ms: | for f in ms: | ||||
if not m(f): | if not m(f): | ||||
continue | continue | ||||
didwork = True | didwork = True | ||||
# don't let driver-resolved files be marked, and run the conclude | |||||
# step if asked to resolve | |||||
if ms[f] == mergestatemod.MERGE_RECORD_DRIVER_RESOLVED: | |||||
exact = m.exact(f) | |||||
if mark: | |||||
if exact: | |||||
ui.warn( | |||||
_(b'not marking %s as it is driver-resolved\n') | |||||
% uipathfn(f) | |||||
) | |||||
elif unmark: | |||||
if exact: | |||||
ui.warn( | |||||
_(b'not unmarking %s as it is driver-resolved\n') | |||||
% uipathfn(f) | |||||
) | |||||
else: | |||||
runconclude = True | |||||
continue | |||||
# path conflicts must be resolved manually | # path conflicts must be resolved manually | ||||
if ms[f] in ( | if ms[f] in ( | ||||
mergestatemod.MERGE_RECORD_UNRESOLVED_PATH, | mergestatemod.MERGE_RECORD_UNRESOLVED_PATH, | ||||
mergestatemod.MERGE_RECORD_RESOLVED_PATH, | mergestatemod.MERGE_RECORD_RESOLVED_PATH, | ||||
): | ): | ||||
if mark: | if mark: | ||||
ms.mark(f, mergestatemod.MERGE_RECORD_RESOLVED_PATH) | ms.mark(f, mergestatemod.MERGE_RECORD_RESOLVED_PATH) | ||||
elif unmark: | elif unmark: | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | with repo.wlock(): | ||||
hint = _(b"(try: hg resolve %s%s)\n") % ( | hint = _(b"(try: hg resolve %s%s)\n") % ( | ||||
flags, | flags, | ||||
b' '.join(pats), | b' '.join(pats), | ||||
) | ) | ||||
break | break | ||||
ui.warn(_(b"arguments do not match paths that need resolving\n")) | ui.warn(_(b"arguments do not match paths that need resolving\n")) | ||||
if hint: | if hint: | ||||
ui.warn(hint) | ui.warn(hint) | ||||
elif ms.mergedriver and ms.mdstate() != b's': | |||||
# run conclude step when either a driver-resolved file is requested | |||||
# or there are no driver-resolved files | |||||
# we can't use 'ret' to determine whether any files are unresolved | |||||
# because we might not have tried to resolve some | |||||
if (runconclude or not list(ms.driverresolved())) and not list( | |||||
ms.unresolved() | |||||
): | |||||
proceed = mergemod.driverconclude(repo, ms, wctx) | |||||
ms.commit() | |||||
if not proceed: | |||||
return 1 | |||||
# Nudge users into finishing an unfinished operation | |||||
unresolvedf = list(ms.unresolved()) | unresolvedf = list(ms.unresolved()) | ||||
driverresolvedf = list(ms.driverresolved()) | if not unresolvedf: | ||||
if not unresolvedf and not driverresolvedf: | |||||
ui.status(_(b'(no more unresolved files)\n')) | ui.status(_(b'(no more unresolved files)\n')) | ||||
cmdutil.checkafterresolved(repo) | cmdutil.checkafterresolved(repo) | ||||
elif not unresolvedf: | |||||
ui.status( | |||||
_( | |||||
b'(no more unresolved files -- ' | |||||
b'run "hg resolve --all" to conclude)\n' | |||||
) | |||||
) | |||||
return ret | return ret | ||||
@command( | @command( | ||||
b'revert', | b'revert', | ||||
[ | [ | ||||
(b'a', b'all', None, _(b'revert all changes when no arguments given')), | (b'a', b'all', None, _(b'revert all changes when no arguments given')), | ||||
▲ Show 20 Lines • Show All 1651 Lines • Show Last 20 Lines |