mercurial/commands.py
changeset 32142 d90ffee93df6
parent 32135 347ab2d47463
child 32143 964c6be36590
equal deleted inserted replaced
32141:4fadea09feca 32142:d90ffee93df6
   253              ? foo.c
   253              ? foo.c
   254 
   254 
   255     Returns 0 if all files are successfully added.
   255     Returns 0 if all files are successfully added.
   256     """
   256     """
   257 
   257 
       
   258     opts = pycompat.byteskwargs(opts)
   258     m = scmutil.match(repo[None], pats, opts)
   259     m = scmutil.match(repo[None], pats, opts)
   259     rejected = cmdutil.add(ui, repo, m, "", False, **opts)
   260     rejected = cmdutil.add(ui, repo, m, "", False, **opts)
   260     return rejected and 1 or 0
   261     return rejected and 1 or 0
   261 
   262 
   262 @command('addremove',
   263 @command('addremove',
   323                foobar.c
   324                foobar.c
   324              R foobar.c
   325              R foobar.c
   325 
   326 
   326     Returns 0 if all files are successfully added.
   327     Returns 0 if all files are successfully added.
   327     """
   328     """
       
   329     opts = pycompat.byteskwargs(opts)
   328     try:
   330     try:
   329         sim = float(opts.get('similarity') or 100)
   331         sim = float(opts.get('similarity') or 100)
   330     except ValueError:
   332     except ValueError:
   331         raise error.Abort(_('similarity must be a number'))
   333         raise error.Abort(_('similarity must be a number'))
   332     if sim < 0 or sim > 100:
   334     if sim < 0 or sim > 100:
   366     anyway, although the results will probably be neither useful
   368     anyway, although the results will probably be neither useful
   367     nor desirable.
   369     nor desirable.
   368 
   370 
   369     Returns 0 on success.
   371     Returns 0 on success.
   370     """
   372     """
       
   373     opts = pycompat.byteskwargs(opts)
   371     if not pats:
   374     if not pats:
   372         raise error.Abort(_('at least one filename or pattern is required'))
   375         raise error.Abort(_('at least one filename or pattern is required'))
   373 
   376 
   374     if opts.get('follow'):
   377     if opts.get('follow'):
   375         # --follow is deprecated and now just an alias for -f/--file
   378         # --follow is deprecated and now just an alias for -f/--file
   530     removed.
   533     removed.
   531 
   534 
   532     Returns 0 on success.
   535     Returns 0 on success.
   533     '''
   536     '''
   534 
   537 
       
   538     opts = pycompat.byteskwargs(opts)
   535     ctx = scmutil.revsingle(repo, opts.get('rev'))
   539     ctx = scmutil.revsingle(repo, opts.get('rev'))
   536     if not ctx:
   540     if not ctx:
   537         raise error.Abort(_('no working directory: please specify a revision'))
   541         raise error.Abort(_('no working directory: please specify a revision'))
   538     node = ctx.node()
   542     node = ctx.node()
   539     dest = cmdutil.makefilename(repo, dest, node)
   543     dest = cmdutil.makefilename(repo, dest, node)
   625         return _dobackout(ui, repo, node, rev, **opts)
   629         return _dobackout(ui, repo, node, rev, **opts)
   626     finally:
   630     finally:
   627         release(lock, wlock)
   631         release(lock, wlock)
   628 
   632 
   629 def _dobackout(ui, repo, node=None, rev=None, **opts):
   633 def _dobackout(ui, repo, node=None, rev=None, **opts):
       
   634     opts = pycompat.byteskwargs(opts)
   630     if opts.get('commit') and opts.get('no_commit'):
   635     if opts.get('commit') and opts.get('no_commit'):
   631         raise error.Abort(_("cannot use --commit with --no-commit"))
   636         raise error.Abort(_("cannot use --commit with --no-commit"))
   632     if opts.get('merge') and opts.get('no_commit'):
   637     if opts.get('merge') and opts.get('no_commit'):
   633         raise error.Abort(_("cannot use --merge with --no-commit"))
   638         raise error.Abort(_("cannot use --merge with --no-commit"))
   634 
   639 
   999 
  1004 
  1000       - move the '@' bookmark from another branch::
  1005       - move the '@' bookmark from another branch::
  1001 
  1006 
  1002           hg book -f @
  1007           hg book -f @
  1003     '''
  1008     '''
       
  1009     opts = pycompat.byteskwargs(opts)
  1004     force = opts.get('force')
  1010     force = opts.get('force')
  1005     rev = opts.get('rev')
  1011     rev = opts.get('rev')
  1006     delete = opts.get('delete')
  1012     delete = opts.get('delete')
  1007     rename = opts.get('rename')
  1013     rename = opts.get('rename')
  1008     inactive = opts.get('inactive')
  1014     inactive = opts.get('inactive')
  1175     When all heads of a branch are closed, the branch will be
  1181     When all heads of a branch are closed, the branch will be
  1176     considered closed.
  1182     considered closed.
  1177 
  1183 
  1178     Returns 0 on success.
  1184     Returns 0 on success.
  1179     """
  1185     """
       
  1186     opts = pycompat.byteskwargs(opts)
  1180     if label:
  1187     if label:
  1181         label = label.strip()
  1188         label = label.strip()
  1182 
  1189 
  1183     if not opts.get('clean') and not label:
  1190     if not opts.get('clean') and not label:
  1184         ui.write("%s\n" % repo.dirstate.branch())
  1191         ui.write("%s\n" % repo.dirstate.branch())
  1223     Use the command :hg:`update` to switch to an existing branch.
  1230     Use the command :hg:`update` to switch to an existing branch.
  1224 
  1231 
  1225     Returns 0.
  1232     Returns 0.
  1226     """
  1233     """
  1227 
  1234 
       
  1235     opts = pycompat.byteskwargs(opts)
  1228     ui.pager('branches')
  1236     ui.pager('branches')
  1229     fm = ui.formatter('branches', opts)
  1237     fm = ui.formatter('branches', opts)
  1230     hexfunc = fm.hexfunc
  1238     hexfunc = fm.hexfunc
  1231 
  1239 
  1232     allheads = set(repo.heads())
  1240     allheads = set(repo.heads())
  1306     Applying bundles preserves all changeset contents including
  1314     Applying bundles preserves all changeset contents including
  1307     permissions, copy/rename information, and revision history.
  1315     permissions, copy/rename information, and revision history.
  1308 
  1316 
  1309     Returns 0 on success, 1 if no changes found.
  1317     Returns 0 on success, 1 if no changes found.
  1310     """
  1318     """
       
  1319     opts = pycompat.byteskwargs(opts)
  1311     revs = None
  1320     revs = None
  1312     if 'rev' in opts:
  1321     if 'rev' in opts:
  1313         revstrings = opts['rev']
  1322         revstrings = opts['rev']
  1314         revs = scmutil.revrange(repo, revstrings)
  1323         revs = scmutil.revrange(repo, revstrings)
  1315         if revstrings and not revs:
  1324         if revstrings and not revs:
  1546 
  1555 
  1547     See :hg:`help urls` for details on specifying URLs.
  1556     See :hg:`help urls` for details on specifying URLs.
  1548 
  1557 
  1549     Returns 0 on success.
  1558     Returns 0 on success.
  1550     """
  1559     """
       
  1560     opts = pycompat.byteskwargs(opts)
  1551     if opts.get('noupdate') and opts.get('updaterev'):
  1561     if opts.get('noupdate') and opts.get('updaterev'):
  1552         raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
  1562         raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
  1553 
  1563 
  1554     r = hg.clone(ui, opts, source, dest,
  1564     r = hg.clone(ui, opts, source, dest,
  1555                  pull=opts.get('pull'),
  1565                  pull=opts.get('pull'),
  1636         return _docommit(ui, repo, *pats, **opts)
  1646         return _docommit(ui, repo, *pats, **opts)
  1637     finally:
  1647     finally:
  1638         release(lock, wlock)
  1648         release(lock, wlock)
  1639 
  1649 
  1640 def _docommit(ui, repo, *pats, **opts):
  1650 def _docommit(ui, repo, *pats, **opts):
  1641     opts = pycompat.byteskwargs(opts)
  1651     if opts.get(r'interactive'):
  1642     if opts.get('interactive'):
  1652         opts.pop(r'interactive')
  1643         opts.pop('interactive')
       
  1644         ret = cmdutil.dorecord(ui, repo, commit, None, False,
  1653         ret = cmdutil.dorecord(ui, repo, commit, None, False,
  1645                                cmdutil.recordfilter, *pats,
  1654                                cmdutil.recordfilter, *pats,
  1646                                **pycompat.strkwargs(opts))
  1655                                **opts)
  1647         # ret can be 0 (no changes to record) or the value returned by
  1656         # ret can be 0 (no changes to record) or the value returned by
  1648         # commit(), 1 if nothing changed or None on success.
  1657         # commit(), 1 if nothing changed or None on success.
  1649         return 1 if ret == 0 else ret
  1658         return 1 if ret == 0 else ret
  1650 
  1659 
       
  1660     opts = pycompat.byteskwargs(opts)
  1651     if opts.get('subrepos'):
  1661     if opts.get('subrepos'):
  1652         if opts.get('amend'):
  1662         if opts.get('amend'):
  1653             raise error.Abort(_('cannot amend with --subrepos'))
  1663             raise error.Abort(_('cannot amend with --subrepos'))
  1654         # Let --subrepos on the command line override config setting.
  1664         # Let --subrepos on the command line override config setting.
  1655         ui.setconfig('ui', 'commitsubrepos', True, 'commit')
  1665         ui.setconfig('ui', 'commitsubrepos', True, 'commit')
  1766 
  1776 
  1767     Returns 0 on success, 1 if NAME does not exist.
  1777     Returns 0 on success, 1 if NAME does not exist.
  1768 
  1778 
  1769     """
  1779     """
  1770 
  1780 
       
  1781     opts = pycompat.byteskwargs(opts)
  1771     if opts.get('edit') or opts.get('local') or opts.get('global'):
  1782     if opts.get('edit') or opts.get('local') or opts.get('global'):
  1772         if opts.get('local') and opts.get('global'):
  1783         if opts.get('local') and opts.get('global'):
  1773             raise error.Abort(_("can't use --local and --global together"))
  1784             raise error.Abort(_("can't use --local and --global together"))
  1774 
  1785 
  1775         if opts.get('local'):
  1786         if opts.get('local'):
  1868     This command takes effect with the next commit. To undo a copy
  1879     This command takes effect with the next commit. To undo a copy
  1869     before that, see :hg:`revert`.
  1880     before that, see :hg:`revert`.
  1870 
  1881 
  1871     Returns 0 on success, 1 if errors are encountered.
  1882     Returns 0 on success, 1 if errors are encountered.
  1872     """
  1883     """
       
  1884     opts = pycompat.byteskwargs(opts)
  1873     with repo.wlock(False):
  1885     with repo.wlock(False):
  1874         return cmdutil.copy(ui, repo, pats, opts)
  1886         return cmdutil.copy(ui, repo, pats, opts)
  1875 
  1887 
  1876 @command('^diff',
  1888 @command('^diff',
  1877     [('r', 'rev', [], _('revision'), _('REV')),
  1889     [('r', 'rev', [], _('revision'), _('REV')),
  1935           hg diff -r 9353^2:9353  # compare against the second parent
  1947           hg diff -r 9353^2:9353  # compare against the second parent
  1936 
  1948 
  1937     Returns 0 on success.
  1949     Returns 0 on success.
  1938     """
  1950     """
  1939 
  1951 
       
  1952     opts = pycompat.byteskwargs(opts)
  1940     revs = opts.get('rev')
  1953     revs = opts.get('rev')
  1941     change = opts.get('change')
  1954     change = opts.get('change')
  1942     stat = opts.get('stat')
  1955     stat = opts.get('stat')
  1943     reverse = opts.get('reverse')
  1956     reverse = opts.get('reverse')
  1944 
  1957 
  2091     on specifying file patterns.
  2104     on specifying file patterns.
  2092 
  2105 
  2093     Returns 0 if a match is found, 1 otherwise.
  2106     Returns 0 if a match is found, 1 otherwise.
  2094 
  2107 
  2095     """
  2108     """
  2096     ctx = scmutil.revsingle(repo, opts.get(r'rev'), None)
  2109 
       
  2110     opts = pycompat.byteskwargs(opts)
       
  2111     ctx = scmutil.revsingle(repo, opts.get('rev'), None)
  2097 
  2112 
  2098     end = '\n'
  2113     end = '\n'
  2099     if opts.get('print0'):
  2114     if opts.get('print0'):
  2100         end = '\0'
  2115         end = '\0'
  2101     fmt = '%s' + end
  2116     fmt = '%s' + end
  2133           hg forget "set:hgignore()"
  2148           hg forget "set:hgignore()"
  2134 
  2149 
  2135     Returns 0 on success.
  2150     Returns 0 on success.
  2136     """
  2151     """
  2137 
  2152 
       
  2153     opts = pycompat.byteskwargs(opts)
  2138     if not pats:
  2154     if not pats:
  2139         raise error.Abort(_('no files specified'))
  2155         raise error.Abort(_('no files specified'))
  2140 
  2156 
  2141     m = scmutil.match(repo[None], pats, opts)
  2157     m = scmutil.match(repo[None], pats, opts)
  2142     rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
  2158     rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
  2217     '''
  2233     '''
  2218     with repo.wlock():
  2234     with repo.wlock():
  2219         return _dograft(ui, repo, *revs, **opts)
  2235         return _dograft(ui, repo, *revs, **opts)
  2220 
  2236 
  2221 def _dograft(ui, repo, *revs, **opts):
  2237 def _dograft(ui, repo, *revs, **opts):
       
  2238     opts = pycompat.byteskwargs(opts)
  2222     if revs and opts.get('rev'):
  2239     if revs and opts.get('rev'):
  2223         ui.warn(_('warning: inconsistent use of --rev might give unexpected '
  2240         ui.warn(_('warning: inconsistent use of --rev might give unexpected '
  2224                   'revision ordering!\n'))
  2241                   'revision ordering!\n'))
  2225 
  2242 
  2226     revs = list(revs)
  2243     revs = list(revs)
  2434     the repository are searched, including those that don't exist in the
  2451     the repository are searched, including those that don't exist in the
  2435     current branch or have been deleted in a prior changeset.
  2452     current branch or have been deleted in a prior changeset.
  2436 
  2453 
  2437     Returns 0 if a match is found, 1 otherwise.
  2454     Returns 0 if a match is found, 1 otherwise.
  2438     """
  2455     """
       
  2456     opts = pycompat.byteskwargs(opts)
  2439     reflags = re.M
  2457     reflags = re.M
  2440     if opts.get('ignore_case'):
  2458     if opts.get('ignore_case'):
  2441         reflags |= re.I
  2459         reflags |= re.I
  2442     try:
  2460     try:
  2443         regexp = util.re.compile(pattern, reflags)
  2461         regexp = util.re.compile(pattern, reflags)
  2680     topological heads (changesets with no children) will be shown.
  2698     topological heads (changesets with no children) will be shown.
  2681 
  2699 
  2682     Returns 0 if matching heads are found, 1 if not.
  2700     Returns 0 if matching heads are found, 1 if not.
  2683     """
  2701     """
  2684 
  2702 
       
  2703     opts = pycompat.byteskwargs(opts)
  2685     start = None
  2704     start = None
  2686     if 'rev' in opts:
  2705     if 'rev' in opts:
  2687         start = scmutil.revsingle(repo, opts['rev'], None).node()
  2706         start = scmutil.revsingle(repo, opts['rev'], None).node()
  2688 
  2707 
  2689     if opts.get('topo'):
  2708     if opts.get('topo'):
  2805     including full hash identifiers.
  2824     including full hash identifiers.
  2806 
  2825 
  2807     Returns 0 if successful.
  2826     Returns 0 if successful.
  2808     """
  2827     """
  2809 
  2828 
       
  2829     opts = pycompat.byteskwargs(opts)
  2810     if not repo and not source:
  2830     if not repo and not source:
  2811         raise error.Abort(_("there is no Mercurial repository here "
  2831         raise error.Abort(_("there is no Mercurial repository here "
  2812                            "(.hg not found)"))
  2832                            "(.hg not found)"))
  2813 
  2833 
  2814     if ui.debugflag:
  2834     if ui.debugflag:
  3028           hg import --config ui.fuzz=7 fuzz.patch
  3048           hg import --config ui.fuzz=7 fuzz.patch
  3029 
  3049 
  3030     Returns 0 on success, 1 on partial success (see --partial).
  3050     Returns 0 on success, 1 on partial success (see --partial).
  3031     """
  3051     """
  3032 
  3052 
       
  3053     opts = pycompat.byteskwargs(opts)
  3033     if not patch1:
  3054     if not patch1:
  3034         raise error.Abort(_('need at least one patch to import'))
  3055         raise error.Abort(_('need at least one patch to import'))
  3035 
  3056 
  3036     patches = (patch1,) + patches
  3057     patches = (patch1,) + patches
  3037 
  3058 
  3232     It is possible to specify an ``ssh://`` URL as the destination.
  3253     It is possible to specify an ``ssh://`` URL as the destination.
  3233     See :hg:`help urls` for more information.
  3254     See :hg:`help urls` for more information.
  3234 
  3255 
  3235     Returns 0 on success.
  3256     Returns 0 on success.
  3236     """
  3257     """
       
  3258     opts = pycompat.byteskwargs(opts)
  3237     hg.peer(ui, opts, ui.expandpath(dest), create=True)
  3259     hg.peer(ui, opts, ui.expandpath(dest), create=True)
  3238 
  3260 
  3239 @command('locate',
  3261 @command('locate',
  3240     [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
  3262     [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
  3241     ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
  3263     ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
  3262 
  3284 
  3263     See :hg:`help files` for a more versatile command.
  3285     See :hg:`help files` for a more versatile command.
  3264 
  3286 
  3265     Returns 0 if a match is found, 1 otherwise.
  3287     Returns 0 if a match is found, 1 otherwise.
  3266     """
  3288     """
       
  3289     opts = pycompat.byteskwargs(opts)
  3267     if opts.get('print0'):
  3290     if opts.get('print0'):
  3268         end = '\0'
  3291         end = '\0'
  3269     else:
  3292     else:
  3270         end = '\n'
  3293         end = '\n'
  3271     rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
  3294     rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
  3468     If option --all is specified, the list of all files from all revisions
  3491     If option --all is specified, the list of all files from all revisions
  3469     is printed. This includes deleted and renamed files.
  3492     is printed. This includes deleted and renamed files.
  3470 
  3493 
  3471     Returns 0 on success.
  3494     Returns 0 on success.
  3472     """
  3495     """
       
  3496     opts = pycompat.byteskwargs(opts)
  3473     fm = ui.formatter('manifest', opts)
  3497     fm = ui.formatter('manifest', opts)
  3474 
  3498 
  3475     if opts.get('all'):
  3499     if opts.get('all'):
  3476         if rev or node:
  3500         if rev or node:
  3477             raise error.Abort(_("can't specify a revision with --all"))
  3501             raise error.Abort(_("can't specify a revision with --all"))
  3546     all changes.
  3570     all changes.
  3547 
  3571 
  3548     Returns 0 on success, 1 if there are unresolved files.
  3572     Returns 0 on success, 1 if there are unresolved files.
  3549     """
  3573     """
  3550 
  3574 
       
  3575     opts = pycompat.byteskwargs(opts)
  3551     if opts.get('rev') and node:
  3576     if opts.get('rev') and node:
  3552         raise error.Abort(_("please specify just one revision"))
  3577         raise error.Abort(_("please specify just one revision"))
  3553     if not node:
  3578     if not node:
  3554         node = opts.get('rev')
  3579         node = opts.get('rev')
  3555 
  3580 
  3625       existing only in the remote repository are treated as
  3650       existing only in the remote repository are treated as
  3626       ``deleted``, even if it is in fact added remotely.
  3651       ``deleted``, even if it is in fact added remotely.
  3627 
  3652 
  3628     Returns 0 if there are outgoing changes, 1 otherwise.
  3653     Returns 0 if there are outgoing changes, 1 otherwise.
  3629     """
  3654     """
       
  3655     opts = pycompat.byteskwargs(opts)
  3630     if opts.get('graph'):
  3656     if opts.get('graph'):
  3631         cmdutil.checkunsupportedgraphflags([], opts)
  3657         cmdutil.checkunsupportedgraphflags([], opts)
  3632         o, other = hg._outgoing(ui, repo, dest, opts)
  3658         o, other = hg._outgoing(ui, repo, dest, opts)
  3633         if not o:
  3659         if not o:
  3634             cmdutil.outgoinghooks(ui, repo, other, opts, o)
  3660             cmdutil.outgoinghooks(ui, repo, other, opts, o)
  3682     See :hg:`summary` and :hg:`help revsets` for related information.
  3708     See :hg:`summary` and :hg:`help revsets` for related information.
  3683 
  3709 
  3684     Returns 0 on success.
  3710     Returns 0 on success.
  3685     """
  3711     """
  3686 
  3712 
       
  3713     opts = pycompat.byteskwargs(opts)
  3687     ctx = scmutil.revsingle(repo, opts.get('rev'), None)
  3714     ctx = scmutil.revsingle(repo, opts.get('rev'), None)
  3688 
  3715 
  3689     if file_:
  3716     if file_:
  3690         m = scmutil.match(ctx, (file_,), opts)
  3717         m = scmutil.match(ctx, (file_,), opts)
  3691         if m.anypats() or len(m.files()) != 1:
  3718         if m.anypats() or len(m.files()) != 1:
  3744 
  3771 
  3745     See :hg:`help urls` for more information.
  3772     See :hg:`help urls` for more information.
  3746 
  3773 
  3747     Returns 0 on success.
  3774     Returns 0 on success.
  3748     """
  3775     """
       
  3776 
       
  3777     opts = pycompat.byteskwargs(opts)
  3749     ui.pager('paths')
  3778     ui.pager('paths')
  3750     if search:
  3779     if search:
  3751         pathitems = [(name, path) for name, path in ui.paths.iteritems()
  3780         pathitems = [(name, path) for name, path in ui.paths.iteritems()
  3752                      if name == search]
  3781                      if name == search]
  3753     else:
  3782     else:
  3806 
  3835 
  3807     Returns 0 on success, 1 if some phases could not be changed.
  3836     Returns 0 on success, 1 if some phases could not be changed.
  3808 
  3837 
  3809     (For more information about the phases concept, see :hg:`help phases`.)
  3838     (For more information about the phases concept, see :hg:`help phases`.)
  3810     """
  3839     """
       
  3840     opts = pycompat.byteskwargs(opts)
  3811     # search for a unique phase argument
  3841     # search for a unique phase argument
  3812     targetphase = None
  3842     targetphase = None
  3813     for idx, name in enumerate(phases.phasenames):
  3843     for idx, name in enumerate(phases.phasenames):
  3814         if opts[name]:
  3844         if opts[name]:
  3815             if targetphase is not None:
  3845             if targetphase is not None:
  3938     bookmark's name.
  3968     bookmark's name.
  3939 
  3969 
  3940     Returns 0 on success, 1 if an update had unresolved files.
  3970     Returns 0 on success, 1 if an update had unresolved files.
  3941     """
  3971     """
  3942 
  3972 
       
  3973     opts = pycompat.byteskwargs(opts)
  3943     if ui.configbool('commands', 'update.requiredest') and opts.get('update'):
  3974     if ui.configbool('commands', 'update.requiredest') and opts.get('update'):
  3944         msg = _('update destination required by configuration')
  3975         msg = _('update destination required by configuration')
  3945         hint = _('use hg pull followed by hg update DEST')
  3976         hint = _('use hg pull followed by hg update DEST')
  3946         raise error.Abort(msg, hint=hint)
  3977         raise error.Abort(msg, hint=hint)
  3947 
  3978 
  4068     URLs. If DESTINATION is omitted, a default path will be used.
  4099     URLs. If DESTINATION is omitted, a default path will be used.
  4069 
  4100 
  4070     Returns 0 if push was successful, 1 if nothing to push.
  4101     Returns 0 if push was successful, 1 if nothing to push.
  4071     """
  4102     """
  4072 
  4103 
       
  4104     opts = pycompat.byteskwargs(opts)
  4073     if opts.get('bookmark'):
  4105     if opts.get('bookmark'):
  4074         ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
  4106         ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
  4075         for b in opts['bookmark']:
  4107         for b in opts['bookmark']:
  4076             # translate -B options to -r so changesets get pushed
  4108             # translate -B options to -r so changesets get pushed
  4077             b = repo._bookmarks.expandname(b)
  4109             b = repo._bookmarks.expandname(b)
  4193          working directory, not even if ``--force`` is specified.
  4225          working directory, not even if ``--force`` is specified.
  4194 
  4226 
  4195     Returns 0 on success, 1 if any warnings encountered.
  4227     Returns 0 on success, 1 if any warnings encountered.
  4196     """
  4228     """
  4197 
  4229 
       
  4230     opts = pycompat.byteskwargs(opts)
  4198     after, force = opts.get('after'), opts.get('force')
  4231     after, force = opts.get('after'), opts.get('force')
  4199     if not pats and not after:
  4232     if not pats and not after:
  4200         raise error.Abort(_('no files specified'))
  4233         raise error.Abort(_('no files specified'))
  4201 
  4234 
  4202     m = scmutil.match(repo[None], pats, opts)
  4235     m = scmutil.match(repo[None], pats, opts)
  4222     This command takes effect at the next commit. To undo a rename
  4255     This command takes effect at the next commit. To undo a rename
  4223     before that, see :hg:`revert`.
  4256     before that, see :hg:`revert`.
  4224 
  4257 
  4225     Returns 0 on success, 1 if errors are encountered.
  4258     Returns 0 on success, 1 if errors are encountered.
  4226     """
  4259     """
       
  4260     opts = pycompat.byteskwargs(opts)
  4227     with repo.wlock(False):
  4261     with repo.wlock(False):
  4228         return cmdutil.copy(ui, repo, pats, opts, rename=True)
  4262         return cmdutil.copy(ui, repo, pats, opts, rename=True)
  4229 
  4263 
  4230 @command('resolve',
  4264 @command('resolve',
  4231     [('a', 'all', None, _('select all unresolved files')),
  4265     [('a', 'all', None, _('select all unresolved files')),
  4276        commit after a conflicting merge.
  4310        commit after a conflicting merge.
  4277 
  4311 
  4278     Returns 0 on success, 1 if any files fail a resolve attempt.
  4312     Returns 0 on success, 1 if any files fail a resolve attempt.
  4279     """
  4313     """
  4280 
  4314 
       
  4315     opts = pycompat.byteskwargs(opts)
  4281     flaglist = 'all mark unmark list no_status'.split()
  4316     flaglist = 'all mark unmark list no_status'.split()
  4282     all, mark, unmark, show, nostatus = \
  4317     all, mark, unmark, show, nostatus = \
  4283         [opts.get(o) for o in flaglist]
  4318         [opts.get(o) for o in flaglist]
  4284 
  4319 
  4285     if (show and (mark or unmark)) or (mark and unmark):
  4320     if (show and (mark or unmark)) or (mark and unmark):
  4647     number it uses.
  4682     number it uses.
  4648 
  4683 
  4649     Returns 0 on success.
  4684     Returns 0 on success.
  4650     """
  4685     """
  4651 
  4686 
       
  4687     opts = pycompat.byteskwargs(opts)
  4652     if opts["stdio"] and opts["cmdserver"]:
  4688     if opts["stdio"] and opts["cmdserver"]:
  4653         raise error.Abort(_("cannot use --stdio with --cmdserver"))
  4689         raise error.Abort(_("cannot use --stdio with --cmdserver"))
  4654 
  4690 
  4655     if opts["stdio"]:
  4691     if opts["stdio"]:
  4656         if repo is None:
  4692         if repo is None:
  4812     incoming and outgoing changes. This can be time-consuming.
  4848     incoming and outgoing changes. This can be time-consuming.
  4813 
  4849 
  4814     Returns 0 on success.
  4850     Returns 0 on success.
  4815     """
  4851     """
  4816 
  4852 
       
  4853     opts = pycompat.byteskwargs(opts)
  4817     ui.pager('summary')
  4854     ui.pager('summary')
  4818     ctx = repo[None]
  4855     ctx = repo[None]
  4819     parents = ctx.parents()
  4856     parents = ctx.parents()
  4820     pnode = parents[0].node()
  4857     pnode = parents[0].node()
  4821     marks = []
  4858     marks = []
  5120     Since tag names have priority over branch names during revision
  5157     Since tag names have priority over branch names during revision
  5121     lookup, using an existing branch name as a tag name is discouraged.
  5158     lookup, using an existing branch name as a tag name is discouraged.
  5122 
  5159 
  5123     Returns 0 on success.
  5160     Returns 0 on success.
  5124     """
  5161     """
       
  5162     opts = pycompat.byteskwargs(opts)
  5125     wlock = lock = None
  5163     wlock = lock = None
  5126     try:
  5164     try:
  5127         wlock = repo.wlock()
  5165         wlock = repo.wlock()
  5128         lock = repo.lock()
  5166         lock = repo.lock()
  5129         rev_ = "."
  5167         rev_ = "."
  5207     When the -q/--quiet switch is used, only the tag name is printed.
  5245     When the -q/--quiet switch is used, only the tag name is printed.
  5208 
  5246 
  5209     Returns 0 on success.
  5247     Returns 0 on success.
  5210     """
  5248     """
  5211 
  5249 
       
  5250     opts = pycompat.byteskwargs(opts)
  5212     ui.pager('tags')
  5251     ui.pager('tags')
  5213     fm = ui.formatter('tags', opts)
  5252     fm = ui.formatter('tags', opts)
  5214     hexfunc = fm.hexfunc
  5253     hexfunc = fm.hexfunc
  5215     tagtype = ""
  5254     tagtype = ""
  5216 
  5255 
  5251 
  5290 
  5252     This command is deprecated, please use :hg:`heads` instead.
  5291     This command is deprecated, please use :hg:`heads` instead.
  5253 
  5292 
  5254     Returns 0 on success.
  5293     Returns 0 on success.
  5255     """
  5294     """
       
  5295     opts = pycompat.byteskwargs(opts)
  5256     displayer = cmdutil.show_changeset(ui, repo, opts)
  5296     displayer = cmdutil.show_changeset(ui, repo, opts)
  5257     displayer.show(repo['tip'])
  5297     displayer.show(repo['tip'])
  5258     displayer.close()
  5298     displayer.close()
  5259 
  5299 
  5260 @command('unbundle',
  5300 @command('unbundle',
  5425     return hg.verify(repo)
  5465     return hg.verify(repo)
  5426 
  5466 
  5427 @command('version', [] + formatteropts, norepo=True)
  5467 @command('version', [] + formatteropts, norepo=True)
  5428 def version_(ui, **opts):
  5468 def version_(ui, **opts):
  5429     """output version and copyright information"""
  5469     """output version and copyright information"""
       
  5470     opts = pycompat.byteskwargs(opts)
  5430     if ui.verbose:
  5471     if ui.verbose:
  5431         ui.pager('version')
  5472         ui.pager('version')
  5432     fm = ui.formatter("version", opts)
  5473     fm = ui.formatter("version", opts)
  5433     fm.startitem()
  5474     fm.startitem()
  5434     fm.write("ver", _("Mercurial Distributed SCM (version %s)\n"),
  5475     fm.write("ver", _("Mercurial Distributed SCM (version %s)\n"),