Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/scmutil.py @ 47759:d7515d29761d stable 5.9rc0
branching: merge default into stable
This mark the start of the 5.9 freeze.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 21 Jul 2021 22:52:09 +0200 |
parents | b66ae4468c9a |
children | 1c447fb82232 7d908ee19b5b |
comparison
equal
deleted
inserted
replaced
47054:29ea3b4c4f62 | 47759:d7515d29761d |
---|---|
17 | 17 |
18 from .i18n import _ | 18 from .i18n import _ |
19 from .node import ( | 19 from .node import ( |
20 bin, | 20 bin, |
21 hex, | 21 hex, |
22 nullid, | |
23 nullrev, | 22 nullrev, |
24 short, | 23 short, |
25 wdirid, | |
26 wdirrev, | 24 wdirrev, |
27 ) | 25 ) |
28 from .pycompat import getattr | 26 from .pycompat import getattr |
29 from .thirdparty import attr | 27 from .thirdparty import attr |
30 from . import ( | 28 from . import ( |
198 ui.error(_(b" empty string\n")) | 196 ui.error(_(b" empty string\n")) |
199 else: | 197 else: |
200 ui.error(b"\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg))) | 198 ui.error(b"\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg))) |
201 except error.CensoredNodeError as inst: | 199 except error.CensoredNodeError as inst: |
202 ui.error(_(b"abort: file censored %s\n") % inst) | 200 ui.error(_(b"abort: file censored %s\n") % inst) |
203 except error.StorageError as inst: | |
204 ui.error(_(b"abort: %s\n") % inst) | |
205 if inst.hint: | |
206 ui.error(_(b"(%s)\n") % inst.hint) | |
207 detailed_exit_code = 50 | |
208 except error.InterventionRequired as inst: | |
209 ui.error(b"%s\n" % inst) | |
210 if inst.hint: | |
211 ui.error(_(b"(%s)\n") % inst.hint) | |
212 detailed_exit_code = 240 | |
213 coarse_exit_code = 1 | |
214 except error.WdirUnsupported: | 201 except error.WdirUnsupported: |
215 ui.error(_(b"abort: working directory revision cannot be specified\n")) | 202 ui.error(_(b"abort: working directory revision cannot be specified\n")) |
216 except error.Abort as inst: | 203 except error.Error as inst: |
217 if isinstance(inst, (error.InputError, error.ParseError)): | 204 if inst.detailed_exit_code is not None: |
218 detailed_exit_code = 10 | 205 detailed_exit_code = inst.detailed_exit_code |
219 elif isinstance(inst, error.StateError): | 206 if inst.coarse_exit_code is not None: |
220 detailed_exit_code = 20 | 207 coarse_exit_code = inst.coarse_exit_code |
221 elif isinstance(inst, error.ConfigError): | |
222 detailed_exit_code = 30 | |
223 elif isinstance(inst, error.HookAbort): | |
224 detailed_exit_code = 40 | |
225 elif isinstance(inst, error.RemoteError): | |
226 detailed_exit_code = 100 | |
227 elif isinstance(inst, error.SecurityError): | |
228 detailed_exit_code = 150 | |
229 elif isinstance(inst, error.CanceledError): | |
230 detailed_exit_code = 250 | |
231 ui.error(inst.format()) | 208 ui.error(inst.format()) |
232 except error.WorkerError as inst: | 209 except error.WorkerError as inst: |
233 # Don't print a message -- the worker already should have | 210 # Don't print a message -- the worker already should have |
234 return inst.status_code | 211 return inst.status_code |
235 except ImportError as inst: | 212 except ImportError as inst: |
448 | 425 |
449 def binnode(ctx): | 426 def binnode(ctx): |
450 """Return binary node id for a given basectx""" | 427 """Return binary node id for a given basectx""" |
451 node = ctx.node() | 428 node = ctx.node() |
452 if node is None: | 429 if node is None: |
453 return wdirid | 430 return ctx.repo().nodeconstants.wdirid |
454 return node | 431 return node |
455 | 432 |
456 | 433 |
457 def intrev(ctx): | 434 def intrev(ctx): |
458 """Return integer for a given basectx that can be used in comparison or | 435 """Return integer for a given basectx that can be used in comparison or |
643 except error.FilteredIndexError: | 620 except error.FilteredIndexError: |
644 raise | 621 raise |
645 except (ValueError, OverflowError, IndexError): | 622 except (ValueError, OverflowError, IndexError): |
646 pass | 623 pass |
647 | 624 |
648 if len(symbol) == 40: | 625 if len(symbol) == 2 * repo.nodeconstants.nodelen: |
649 try: | 626 try: |
650 node = bin(symbol) | 627 node = bin(symbol) |
651 rev = repo.changelog.rev(node) | 628 rev = repo.changelog.rev(node) |
652 return repo[rev] | 629 return repo[rev] |
653 except error.FilteredLookupError: | 630 except error.FilteredLookupError: |
1106 unfi.set(b'max((::%n) - %ln)', oldnode, allreplaced) | 1083 unfi.set(b'max((::%n) - %ln)', oldnode, allreplaced) |
1107 ) | 1084 ) |
1108 if roots: | 1085 if roots: |
1109 newnode = roots[0].node() | 1086 newnode = roots[0].node() |
1110 else: | 1087 else: |
1111 newnode = nullid | 1088 newnode = repo.nullid |
1112 else: | 1089 else: |
1113 newnode = newnodes[0] | 1090 newnode = newnodes[0] |
1114 moves[oldnode] = newnode | 1091 moves[oldnode] = newnode |
1115 | 1092 |
1116 allnewnodes = [n for ns in replacements.values() for n in ns] | 1093 allnewnodes = [n for ns in replacements.values() for n in ns] |
1477 different reasons it might not end with dst being marked as copied from src. | 1454 different reasons it might not end with dst being marked as copied from src. |
1478 """ | 1455 """ |
1479 origsrc = repo.dirstate.copied(src) or src | 1456 origsrc = repo.dirstate.copied(src) or src |
1480 if dst == origsrc: # copying back a copy? | 1457 if dst == origsrc: # copying back a copy? |
1481 if repo.dirstate[dst] not in b'mn' and not dryrun: | 1458 if repo.dirstate[dst] not in b'mn' and not dryrun: |
1482 repo.dirstate.normallookup(dst) | 1459 repo.dirstate.set_tracked(dst) |
1483 else: | 1460 else: |
1484 if repo.dirstate[origsrc] == b'a' and origsrc == src: | 1461 if repo.dirstate[origsrc] == b'a' and origsrc == src: |
1485 if not ui.quiet: | 1462 if not ui.quiet: |
1486 ui.warn( | 1463 ui.warn( |
1487 _( | 1464 _( |
1504 working copy and newctx. | 1481 working copy and newctx. |
1505 """ | 1482 """ |
1506 oldctx = repo[b'.'] | 1483 oldctx = repo[b'.'] |
1507 ds = repo.dirstate | 1484 ds = repo.dirstate |
1508 copies = dict(ds.copies()) | 1485 copies = dict(ds.copies()) |
1509 ds.setparents(newctx.node(), nullid) | 1486 ds.setparents(newctx.node(), repo.nullid) |
1510 s = newctx.status(oldctx, match=match) | 1487 s = newctx.status(oldctx, match=match) |
1488 | |
1511 for f in s.modified: | 1489 for f in s.modified: |
1512 if ds[f] == b'r': | 1490 ds.update_file_p1(f, p1_tracked=True) |
1513 # modified + removed -> removed | |
1514 continue | |
1515 ds.normallookup(f) | |
1516 | 1491 |
1517 for f in s.added: | 1492 for f in s.added: |
1518 if ds[f] == b'r': | 1493 ds.update_file_p1(f, p1_tracked=False) |
1519 # added + removed -> unknown | |
1520 ds.drop(f) | |
1521 elif ds[f] != b'a': | |
1522 ds.add(f) | |
1523 | 1494 |
1524 for f in s.removed: | 1495 for f in s.removed: |
1525 if ds[f] == b'a': | 1496 ds.update_file_p1(f, p1_tracked=True) |
1526 # removed + added -> normal | |
1527 ds.normallookup(f) | |
1528 elif ds[f] != b'r': | |
1529 ds.remove(f) | |
1530 | 1497 |
1531 # Merge old parent and old working dir copies | 1498 # Merge old parent and old working dir copies |
1532 oldcopies = copiesmod.pathcopies(newctx, oldctx, match) | 1499 oldcopies = copiesmod.pathcopies(newctx, oldctx, match) |
1533 oldcopies.update(copies) | 1500 oldcopies.update(copies) |
1534 copies = { | 1501 copies = { |