comparison mercurial/commands.py @ 45957:89a2afe31e82

formating: upgrade to black 20.8b1 This required a couple of small tweaks to un-confuse black, but now it works. Big formatting changes come from: * Dramatically improved collection-splitting logic upstream * Black having a strong (correct IMO) opinion that """ is better than ''' Differential Revision: https://phab.mercurial-scm.org/D9430
author Augie Fackler <raf@durin42.com>
date Fri, 27 Nov 2020 17:03:29 -0500
parents 777e8d88f703
children c3d0b3c29ec4
comparison
equal deleted inserted replaced
45956:346af7687c6f 45957:89a2afe31e82
603 + walkopts, 603 + walkopts,
604 _(b'[OPTION]... DEST'), 604 _(b'[OPTION]... DEST'),
605 helpcategory=command.CATEGORY_IMPORT_EXPORT, 605 helpcategory=command.CATEGORY_IMPORT_EXPORT,
606 ) 606 )
607 def archive(ui, repo, dest, **opts): 607 def archive(ui, repo, dest, **opts):
608 '''create an unversioned archive of a repository revision 608 """create an unversioned archive of a repository revision
609 609
610 By default, the revision used is the parent of the working 610 By default, the revision used is the parent of the working
611 directory; use -r/--rev to specify a different revision. 611 directory; use -r/--rev to specify a different revision.
612 612
613 The archive type is automatically detected based on file 613 The archive type is automatically detected based on file
642 prepended. Use -p/--prefix to specify a format string for the 642 prepended. Use -p/--prefix to specify a format string for the
643 prefix. The default is the basename of the archive, with suffixes 643 prefix. The default is the basename of the archive, with suffixes
644 removed. 644 removed.
645 645
646 Returns 0 on success. 646 Returns 0 on success.
647 ''' 647 """
648 648
649 opts = pycompat.byteskwargs(opts) 649 opts = pycompat.byteskwargs(opts)
650 rev = opts.get(b'rev') 650 rev = opts.get(b'rev')
651 if rev: 651 if rev:
652 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn') 652 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
716 + commitopts2, 716 + commitopts2,
717 _(b'[OPTION]... [-r] REV'), 717 _(b'[OPTION]... [-r] REV'),
718 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, 718 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
719 ) 719 )
720 def backout(ui, repo, node=None, rev=None, **opts): 720 def backout(ui, repo, node=None, rev=None, **opts):
721 '''reverse effect of earlier changeset 721 """reverse effect of earlier changeset
722 722
723 Prepare a new changeset with the effect of REV undone in the 723 Prepare a new changeset with the effect of REV undone in the
724 current working directory. If no conflicts were encountered, 724 current working directory. If no conflicts were encountered,
725 it will be committed immediately. 725 it will be committed immediately.
726 726
766 See :hg:`help revert` for a way to restore files to the state 766 See :hg:`help revert` for a way to restore files to the state
767 of another revision. 767 of another revision.
768 768
769 Returns 0 on success, 1 if nothing to backout or there are unresolved 769 Returns 0 on success, 1 if nothing to backout or there are unresolved
770 files. 770 files.
771 ''' 771 """
772 with repo.wlock(), repo.lock(): 772 with repo.wlock(), repo.lock():
773 return _dobackout(ui, repo, node, rev, **opts) 773 return _dobackout(ui, repo, node, rev, **opts)
774 774
775 775
776 def _dobackout(ui, repo, node=None, rev=None, **opts): 776 def _dobackout(ui, repo, node=None, rev=None, **opts):
1164 + formatteropts, 1164 + formatteropts,
1165 _(b'hg bookmarks [OPTIONS]... [NAME]...'), 1165 _(b'hg bookmarks [OPTIONS]... [NAME]...'),
1166 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, 1166 helpcategory=command.CATEGORY_CHANGE_ORGANIZATION,
1167 ) 1167 )
1168 def bookmark(ui, repo, *names, **opts): 1168 def bookmark(ui, repo, *names, **opts):
1169 '''create a new bookmark or list existing bookmarks 1169 """create a new bookmark or list existing bookmarks
1170 1170
1171 Bookmarks are labels on changesets to help track lines of development. 1171 Bookmarks are labels on changesets to help track lines of development.
1172 Bookmarks are unversioned and can be moved, renamed and deleted. 1172 Bookmarks are unversioned and can be moved, renamed and deleted.
1173 Deleting or moving a bookmark has no effect on the associated changesets. 1173 Deleting or moving a bookmark has no effect on the associated changesets.
1174 1174
1222 hg book -f @ 1222 hg book -f @
1223 1223
1224 - print only the active bookmark name:: 1224 - print only the active bookmark name::
1225 1225
1226 hg book -ql . 1226 hg book -ql .
1227 ''' 1227 """
1228 opts = pycompat.byteskwargs(opts) 1228 opts = pycompat.byteskwargs(opts)
1229 force = opts.get(b'force') 1229 force = opts.get(b'force')
1230 rev = opts.get(b'rev') 1230 rev = opts.get(b'rev')
1231 inactive = opts.get(b'inactive') # meaning add/rename to inactive bookmark 1231 inactive = opts.get(b'inactive') # meaning add/rename to inactive bookmark
1232 1232
2802 ) 2802 )
2803 2803
2804 2804
2805 @command( 2805 @command(
2806 b'forget', 2806 b'forget',
2807 [(b'i', b'interactive', None, _(b'use interactive mode')),] 2807 [
2808 (b'i', b'interactive', None, _(b'use interactive mode')),
2809 ]
2808 + walkopts 2810 + walkopts
2809 + dryrunopts, 2811 + dryrunopts,
2810 _(b'[OPTION]... FILE...'), 2812 _(b'[OPTION]... FILE...'),
2811 helpcategory=command.CATEGORY_WORKING_DIRECTORY, 2813 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
2812 helpbasic=True, 2814 helpbasic=True,
2902 + dryrunopts, 2904 + dryrunopts,
2903 _(b'[OPTION]... [-r REV]... REV...'), 2905 _(b'[OPTION]... [-r REV]... REV...'),
2904 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, 2906 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
2905 ) 2907 )
2906 def graft(ui, repo, *revs, **opts): 2908 def graft(ui, repo, *revs, **opts):
2907 '''copy changes from other branches onto the current branch 2909 """copy changes from other branches onto the current branch
2908 2910
2909 This command uses Mercurial's merge logic to copy individual 2911 This command uses Mercurial's merge logic to copy individual
2910 changes from other branches without merging branches in the 2912 changes from other branches without merging branches in the
2911 history graph. This is sometimes known as 'backporting' or 2913 history graph. This is sometimes known as 'backporting' or
2912 'cherry-picking'. By default, graft will copy user, date, and 2914 'cherry-picking'. By default, graft will copy user, date, and
2995 hg graft -r featureX --base "ancestor('featureX', 'default')" 2997 hg graft -r featureX --base "ancestor('featureX', 'default')"
2996 2998
2997 See :hg:`help revisions` for more about specifying revisions. 2999 See :hg:`help revisions` for more about specifying revisions.
2998 3000
2999 Returns 0 on successful completion, 1 if there are unresolved files. 3001 Returns 0 on successful completion, 1 if there are unresolved files.
3000 ''' 3002 """
3001 with repo.wlock(): 3003 with repo.wlock():
3002 return _dograft(ui, repo, *revs, **opts) 3004 return _dograft(ui, repo, *revs, **opts)
3003 3005
3004 3006
3005 def _dograft(ui, repo, *revs, **opts): 3007 def _dograft(ui, repo, *revs, **opts):
5259 b'f', 5261 b'f',
5260 b'force', 5262 b'force',
5261 None, 5263 None,
5262 _(b'run even when remote repository is unrelated'), 5264 _(b'run even when remote repository is unrelated'),
5263 ), 5265 ),
5264 (b'', b'confirm', None, _(b'confirm pull before applying changes'),), 5266 (
5267 b'',
5268 b'confirm',
5269 None,
5270 _(b'confirm pull before applying changes'),
5271 ),
5265 ( 5272 (
5266 b'r', 5273 b'r',
5267 b'rev', 5274 b'rev',
5268 [], 5275 [],
5269 _(b'a remote changeset intended to be added'), 5276 _(b'a remote changeset intended to be added'),
5516 5523
5517 opts = pycompat.byteskwargs(opts) 5524 opts = pycompat.byteskwargs(opts)
5518 5525
5519 if opts.get(b'all_bookmarks'): 5526 if opts.get(b'all_bookmarks'):
5520 cmdutil.check_incompatible_arguments( 5527 cmdutil.check_incompatible_arguments(
5521 opts, b'all_bookmarks', [b'bookmark', b'rev'], 5528 opts,
5529 b'all_bookmarks',
5530 [b'bookmark', b'rev'],
5522 ) 5531 )
5523 opts[b'bookmark'] = list(repo._bookmarks) 5532 opts[b'bookmark'] = list(repo._bookmarks)
5524 5533
5525 if opts.get(b'bookmark'): 5534 if opts.get(b'bookmark'):
5526 ui.setconfig(b'bookmarks', b'pushing', opts[b'bookmark'], b'push') 5535 ui.setconfig(b'bookmarks', b'pushing', opts[b'bookmark'], b'push')
5606 return result 5615 return result
5607 5616
5608 5617
5609 @command( 5618 @command(
5610 b'recover', 5619 b'recover',
5611 [(b'', b'verify', False, b"run `hg verify` after successful recover"),], 5620 [
5621 (b'', b'verify', False, b"run `hg verify` after successful recover"),
5622 ],
5612 helpcategory=command.CATEGORY_MAINTENANCE, 5623 helpcategory=command.CATEGORY_MAINTENANCE,
5613 ) 5624 )
5614 def recover(ui, repo, **opts): 5625 def recover(ui, repo, **opts):
5615 """roll back an interrupted transaction 5626 """roll back an interrupted transaction
5616 5627
6446 + cmdutil.walkopts, 6457 + cmdutil.walkopts,
6447 _(b'hg shelve [OPTION]... [FILE]...'), 6458 _(b'hg shelve [OPTION]... [FILE]...'),
6448 helpcategory=command.CATEGORY_WORKING_DIRECTORY, 6459 helpcategory=command.CATEGORY_WORKING_DIRECTORY,
6449 ) 6460 )
6450 def shelve(ui, repo, *pats, **opts): 6461 def shelve(ui, repo, *pats, **opts):
6451 '''save and set aside changes from the working directory 6462 """save and set aside changes from the working directory
6452 6463
6453 Shelving takes files that "hg status" reports as not clean, saves 6464 Shelving takes files that "hg status" reports as not clean, saves
6454 the modifications to a bundle (a shelved change), and reverts the 6465 the modifications to a bundle (a shelved change), and reverts the
6455 files so that their state in the working directory becomes clean. 6466 files so that their state in the working directory becomes clean.
6456 6467
6477 option. For each shelved change, this will print its name, age, 6488 option. For each shelved change, this will print its name, age,
6478 and description; use ``--patch`` or ``--stat`` for more details. 6489 and description; use ``--patch`` or ``--stat`` for more details.
6479 6490
6480 To delete specific shelved changes, use ``--delete``. To delete 6491 To delete specific shelved changes, use ``--delete``. To delete
6481 all shelved changes, use ``--cleanup``. 6492 all shelved changes, use ``--cleanup``.
6482 ''' 6493 """
6483 opts = pycompat.byteskwargs(opts) 6494 opts = pycompat.byteskwargs(opts)
6484 allowables = [ 6495 allowables = [
6485 (b'addremove', {b'create'}), # 'create' is pseudo action 6496 (b'addremove', {b'create'}), # 'create' is pseudo action
6486 (b'unknown', {b'create'}), 6497 (b'unknown', {b'create'}),
6487 (b'cleanup', {b'cleanup'}), 6498 (b'cleanup', {b'cleanup'}),
7705 fn.end() 7716 fn.end()
7706 fm.end() 7717 fm.end()
7707 7718
7708 7719
7709 def loadcmdtable(ui, name, cmdtable): 7720 def loadcmdtable(ui, name, cmdtable):
7710 """Load command functions from specified cmdtable 7721 """Load command functions from specified cmdtable"""
7711 """
7712 overrides = [cmd for cmd in cmdtable if cmd in table] 7722 overrides = [cmd for cmd in cmdtable if cmd in table]
7713 if overrides: 7723 if overrides:
7714 ui.warn( 7724 ui.warn(
7715 _(b"extension '%s' overrides commands: %s\n") 7725 _(b"extension '%s' overrides commands: %s\n")
7716 % (name, b" ".join(overrides)) 7726 % (name, b" ".join(overrides))