Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 37116:704932ef8913
commands: use constants for merge things
We have nice constants now. Let's use them to make the code
easier to reason about.
Differential Revision: https://phab.mercurial-scm.org/D2702
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 05 Mar 2018 17:50:54 -0800 |
parents | f0b6fbea00cf |
children | a8a902d7176e |
comparison
equal
deleted
inserted
replaced
37115:43ffd9070da1 | 37116:704932ef8913 |
---|---|
4358 | 4358 |
4359 # Labels and keys based on merge state. Unresolved path conflicts show | 4359 # Labels and keys based on merge state. Unresolved path conflicts show |
4360 # as 'P'. Resolved path conflicts show as 'R', the same as normal | 4360 # as 'P'. Resolved path conflicts show as 'R', the same as normal |
4361 # resolved conflicts. | 4361 # resolved conflicts. |
4362 mergestateinfo = { | 4362 mergestateinfo = { |
4363 'u': ('resolve.unresolved', 'U'), | 4363 mergemod.MERGE_RECORD_UNRESOLVED: ('resolve.unresolved', 'U'), |
4364 'r': ('resolve.resolved', 'R'), | 4364 mergemod.MERGE_RECORD_RESOLVED: ('resolve.resolved', 'R'), |
4365 'pu': ('resolve.unresolved', 'P'), | 4365 mergemod.MERGE_RECORD_UNRESOLVED_PATH: ('resolve.unresolved', 'P'), |
4366 'pr': ('resolve.resolved', 'R'), | 4366 mergemod.MERGE_RECORD_RESOLVED_PATH: ('resolve.resolved', 'R'), |
4367 'd': ('resolve.driverresolved', 'D'), | 4367 mergemod.MERGE_RECORD_DRIVER_RESOLVED: ('resolve.driverresolved', |
4368 'D'), | |
4368 } | 4369 } |
4369 | 4370 |
4370 for f in ms: | 4371 for f in ms: |
4371 if not m(f): | 4372 if not m(f): |
4372 continue | 4373 continue |
4385 raise error.Abort( | 4386 raise error.Abort( |
4386 _('resolve command not applicable when not merging')) | 4387 _('resolve command not applicable when not merging')) |
4387 | 4388 |
4388 wctx = repo[None] | 4389 wctx = repo[None] |
4389 | 4390 |
4390 if ms.mergedriver and ms.mdstate() == 'u': | 4391 if (ms.mergedriver |
4392 and ms.mdstate() == mergemod.MERGE_DRIVER_STATE_UNMARKED): | |
4391 proceed = mergemod.driverpreprocess(repo, ms, wctx) | 4393 proceed = mergemod.driverpreprocess(repo, ms, wctx) |
4392 ms.commit() | 4394 ms.commit() |
4393 # allow mark and unmark to go through | 4395 # allow mark and unmark to go through |
4394 if not mark and not unmark and not proceed: | 4396 if not mark and not unmark and not proceed: |
4395 return 1 | 4397 return 1 |
4406 | 4408 |
4407 didwork = True | 4409 didwork = True |
4408 | 4410 |
4409 # don't let driver-resolved files be marked, and run the conclude | 4411 # don't let driver-resolved files be marked, and run the conclude |
4410 # step if asked to resolve | 4412 # step if asked to resolve |
4411 if ms[f] == "d": | 4413 if ms[f] == mergemod.MERGE_RECORD_DRIVER_RESOLVED: |
4412 exact = m.exact(f) | 4414 exact = m.exact(f) |
4413 if mark: | 4415 if mark: |
4414 if exact: | 4416 if exact: |
4415 ui.warn(_('not marking %s as it is driver-resolved\n') | 4417 ui.warn(_('not marking %s as it is driver-resolved\n') |
4416 % f) | 4418 % f) |
4421 else: | 4423 else: |
4422 runconclude = True | 4424 runconclude = True |
4423 continue | 4425 continue |
4424 | 4426 |
4425 # path conflicts must be resolved manually | 4427 # path conflicts must be resolved manually |
4426 if ms[f] in ("pu", "pr"): | 4428 if ms[f] in (mergemod.MERGE_RECORD_UNRESOLVED_PATH, |
4429 mergemod.MERGE_RECORD_RESOLVED_PATH): | |
4427 if mark: | 4430 if mark: |
4428 ms.mark(f, "pr") | 4431 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED_PATH) |
4429 elif unmark: | 4432 elif unmark: |
4430 ms.mark(f, "pu") | 4433 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH) |
4431 elif ms[f] == "pu": | 4434 elif ms[f] == mergemod.MERGE_RECORD_UNRESOLVED_PATH: |
4432 ui.warn(_('%s: path conflict must be resolved manually\n') | 4435 ui.warn(_('%s: path conflict must be resolved manually\n') |
4433 % f) | 4436 % f) |
4434 continue | 4437 continue |
4435 | 4438 |
4436 if mark: | 4439 if mark: |
4437 ms.mark(f, "r") | 4440 ms.mark(f, mergemod.MERGE_RECORD_RESOLVED) |
4438 elif unmark: | 4441 elif unmark: |
4439 ms.mark(f, "u") | 4442 ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED) |
4440 else: | 4443 else: |
4441 # backup pre-resolve (merge uses .orig for its own purposes) | 4444 # backup pre-resolve (merge uses .orig for its own purposes) |
4442 a = repo.wjoin(f) | 4445 a = repo.wjoin(f) |
4443 try: | 4446 try: |
4444 util.copyfile(a, a + ".resolve") | 4447 util.copyfile(a, a + ".resolve") |