comparison mercurial/commands.py @ 49365:288de6f5d724 stable 6.2rc0

branching: merge default into stable
author Rapha?l Gom?s <rgomes@octobus.net>
date Thu, 16 Jun 2022 15:28:54 +0200
parents 5bc3e76f919d 3d3d7fc6035a
children 2bbd7bc7d6c4
comparison
equal deleted inserted replaced
48897:e8ea403b1c46 49365:288de6f5d724
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> 3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
4 # 4 #
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from __future__ import absolute_import 8
9
10 import errno
11 import os 9 import os
12 import re 10 import re
13 import sys 11 import sys
14 12
15 from .i18n import _ 13 from .i18n import _
1570 except error.UnsupportedBundleSpecification as e: 1568 except error.UnsupportedBundleSpecification as e:
1571 raise error.InputError( 1569 raise error.InputError(
1572 pycompat.bytestr(e), 1570 pycompat.bytestr(e),
1573 hint=_(b"see 'hg help bundlespec' for supported values for --type"), 1571 hint=_(b"see 'hg help bundlespec' for supported values for --type"),
1574 ) 1572 )
1575 cgversion = bundlespec.contentopts[b"cg.version"] 1573 cgversion = bundlespec.params[b"cg.version"]
1576 1574
1577 # Packed bundles are a pseudo bundle format for now. 1575 # Packed bundles are a pseudo bundle format for now.
1578 if cgversion == b's1': 1576 if cgversion == b's1':
1579 raise error.InputError( 1577 raise error.InputError(
1580 _(b'packed bundles cannot be produced by "hg bundle"'), 1578 _(b'packed bundles cannot be produced by "hg bundle"'),
1599 if base: 1597 if base:
1600 if dests: 1598 if dests:
1601 raise error.InputError( 1599 raise error.InputError(
1602 _(b"--base is incompatible with specifying destinations") 1600 _(b"--base is incompatible with specifying destinations")
1603 ) 1601 )
1604 common = [repo[rev].node() for rev in base] 1602 cl = repo.changelog
1605 heads = [repo[r].node() for r in revs] if revs else None 1603 common = [cl.node(rev) for rev in base]
1604 heads = [cl.node(r) for r in revs] if revs else None
1606 outgoing = discovery.outgoing(repo, common, heads) 1605 outgoing = discovery.outgoing(repo, common, heads)
1607 missing = outgoing.missing 1606 missing = outgoing.missing
1608 excluded = outgoing.excluded 1607 excluded = outgoing.excluded
1609 else: 1608 else:
1610 missing = set() 1609 missing = set()
1679 compopts[b'threads'] = compthreads 1678 compopts[b'threads'] = compthreads
1680 1679
1681 # Bundling of obsmarker and phases is optional as not all clients 1680 # Bundling of obsmarker and phases is optional as not all clients
1682 # support the necessary features. 1681 # support the necessary features.
1683 cfg = ui.configbool 1682 cfg = ui.configbool
1684 contentopts = { 1683 obsolescence_cfg = cfg(b'experimental', b'evolution.bundle-obsmarker')
1685 b'obsolescence': cfg(b'experimental', b'evolution.bundle-obsmarker'), 1684 bundlespec.set_param(b'obsolescence', obsolescence_cfg, overwrite=False)
1686 b'obsolescence-mandatory': cfg( 1685 obs_mand_cfg = cfg(b'experimental', b'evolution.bundle-obsmarker:mandatory')
1687 b'experimental', b'evolution.bundle-obsmarker:mandatory' 1686 bundlespec.set_param(
1688 ), 1687 b'obsolescence-mandatory', obs_mand_cfg, overwrite=False
1689 b'phases': cfg(b'experimental', b'bundle-phases'), 1688 )
1690 } 1689 phases_cfg = cfg(b'experimental', b'bundle-phases')
1691 bundlespec.contentopts.update(contentopts) 1690 bundlespec.set_param(b'phases', phases_cfg, overwrite=False)
1692 1691
1693 bundle2.writenewbundle( 1692 bundle2.writenewbundle(
1694 ui, 1693 ui,
1695 repo, 1694 repo,
1696 b'bundle', 1695 b'bundle',
1697 fname, 1696 fname,
1698 bversion, 1697 bversion,
1699 outgoing, 1698 outgoing,
1700 bundlespec.contentopts, 1699 bundlespec.params,
1701 compression=bcompression, 1700 compression=bcompression,
1702 compopts=compopts, 1701 compopts=compopts,
1703 ) 1702 )
1704 1703
1705 1704
2475 helpcategory=command.CATEGORY_HELP, 2474 helpcategory=command.CATEGORY_HELP,
2476 norepo=True, 2475 norepo=True,
2477 ) 2476 )
2478 def debugcommands(ui, cmd=b'', *args): 2477 def debugcommands(ui, cmd=b'', *args):
2479 """list all available commands and options""" 2478 """list all available commands and options"""
2480 for cmd, vals in sorted(pycompat.iteritems(table)): 2479 for cmd, vals in sorted(table.items()):
2481 cmd = cmd.split(b'|')[0] 2480 cmd = cmd.split(b'|')[0]
2482 opts = b', '.join([i[1] for i in vals[1]]) 2481 opts = b', '.join([i[1] for i in vals[1]])
2483 ui.write(b'%s: %s\n' % (cmd, opts)) 2482 ui.write(b'%s: %s\n' % (cmd, opts))
2484 2483
2485 2484
2542 2541
2543 .. note:: 2542 .. note::
2544 2543
2545 :hg:`diff` may generate unexpected results for merges, as it will 2544 :hg:`diff` may generate unexpected results for merges, as it will
2546 default to comparing against the working directory's first 2545 default to comparing against the working directory's first
2547 parent changeset if no revisions are specified. 2546 parent changeset if no revisions are specified. To diff against the
2547 conflict regions, you can use `--config diff.merge=yes`.
2548 2548
2549 By default, the working directory files are compared to its first parent. To 2549 By default, the working directory files are compared to its first parent. To
2550 see the differences from another revision, use --from. To see the difference 2550 see the differences from another revision, use --from. To see the difference
2551 to another revision, use --to. For example, :hg:`diff --from .^` will show 2551 to another revision, use --to. For example, :hg:`diff --from .^` will show
2552 the differences from the working copy's grandparent to the working copy, 2552 the differences from the working copy's grandparent to the working copy,
3916 3916
3917 if b'bookmarks' in peer.listkeys(b'namespaces'): 3917 if b'bookmarks' in peer.listkeys(b'namespaces'):
3918 hexremoterev = hex(remoterev) 3918 hexremoterev = hex(remoterev)
3919 bms = [ 3919 bms = [
3920 bm 3920 bm
3921 for bm, bmr in pycompat.iteritems( 3921 for bm, bmr in peer.listkeys(b'bookmarks').items()
3922 peer.listkeys(b'bookmarks')
3923 )
3924 if bmr == hexremoterev 3922 if bmr == hexremoterev
3925 ] 3923 ]
3926 3924
3927 return sorted(bms) 3925 return sorted(bms)
3928 3926
6181 else: 6179 else:
6182 # backup pre-resolve (merge uses .orig for its own purposes) 6180 # backup pre-resolve (merge uses .orig for its own purposes)
6183 a = repo.wjoin(f) 6181 a = repo.wjoin(f)
6184 try: 6182 try:
6185 util.copyfile(a, a + b".resolve") 6183 util.copyfile(a, a + b".resolve")
6186 except (IOError, OSError) as inst: 6184 except FileNotFoundError:
6187 if inst.errno != errno.ENOENT: 6185 pass
6188 raise
6189 6186
6190 try: 6187 try:
6191 # preresolve file 6188 # preresolve file
6192 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')} 6189 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
6193 with ui.configoverride(overrides, b'resolve'): 6190 with ui.configoverride(overrides, b'resolve'):
6200 # replace filemerge's .orig file with our resolve file 6197 # replace filemerge's .orig file with our resolve file
6201 try: 6198 try:
6202 util.rename( 6199 util.rename(
6203 a + b".resolve", scmutil.backuppath(ui, repo, f) 6200 a + b".resolve", scmutil.backuppath(ui, repo, f)
6204 ) 6201 )
6205 except OSError as inst: 6202 except FileNotFoundError:
6206 if inst.errno != errno.ENOENT: 6203 pass
6207 raise
6208 6204
6209 if hasconflictmarkers: 6205 if hasconflictmarkers:
6210 ui.warn( 6206 ui.warn(
6211 _( 6207 _(
6212 b'warning: the following files still have conflict ' 6208 b'warning: the following files still have conflict '
7095 7091
7096 status = repo.status(unknown=True) 7092 status = repo.status(unknown=True)
7097 7093
7098 c = repo.dirstate.copies() 7094 c = repo.dirstate.copies()
7099 copied, renamed = [], [] 7095 copied, renamed = [], []
7100 for d, s in pycompat.iteritems(c): 7096 for d, s in c.items():
7101 if s in status.removed: 7097 if s in status.removed:
7102 status.removed.remove(s) 7098 status.removed.remove(s)
7103 renamed.append(d) 7099 renamed.append(d)
7104 else: 7100 else:
7105 copied.append(d) 7101 copied.append(d)