mercurial/commands.py
changeset 10973 49a07f441496
parent 10963 9e314c5e6890
child 10993 c1b43d786889
equal deleted inserted replaced
10972:0a2c6948f5f4 10973:49a07f441496
    30     If no names are given, add all files to the repository.
    30     If no names are given, add all files to the repository.
    31 
    31 
    32     .. container:: verbose
    32     .. container:: verbose
    33 
    33 
    34        An example showing how new (unknown) files are added
    34        An example showing how new (unknown) files are added
    35        automatically by ``hg add``::
    35        automatically by :hg:`add`::
    36 
    36 
    37          $ ls
    37          $ ls
    38          foo.c
    38          foo.c
    39          $ hg status
    39          $ hg status
    40          ? foo.c
    40          ? foo.c
   169     :``tgz``:   tar archive, compressed using gzip
   169     :``tgz``:   tar archive, compressed using gzip
   170     :``uzip``:  zip archive, uncompressed
   170     :``uzip``:  zip archive, uncompressed
   171     :``zip``:   zip archive, compressed using deflate
   171     :``zip``:   zip archive, compressed using deflate
   172 
   172 
   173     The exact name of the destination archive or directory is given
   173     The exact name of the destination archive or directory is given
   174     using a format string; see 'hg help export' for details.
   174     using a format string; see :hg:`help export` for details.
   175 
   175 
   176     Each member added to an archive file has a directory prefix
   176     Each member added to an archive file has a directory prefix
   177     prepended. Use -p/--prefix to specify a format string for the
   177     prepended. Use -p/--prefix to specify a format string for the
   178     prefix. The default is the basename of the archive, with suffixes
   178     prefix. The default is the basename of the archive, with suffixes
   179     removed.
   179     removed.
   228     The --merge option remembers the parent of the working directory
   228     The --merge option remembers the parent of the working directory
   229     before starting the backout, then merges the new head with that
   229     before starting the backout, then merges the new head with that
   230     changeset afterwards. This saves you from doing the merge by hand.
   230     changeset afterwards. This saves you from doing the merge by hand.
   231     The result of this merge is not committed, as with a normal merge.
   231     The result of this merge is not committed, as with a normal merge.
   232 
   232 
   233     See 'hg help dates' for a list of formats valid for -d/--date.
   233     See :hg:`help dates` for a list of formats valid for -d/--date.
   234     '''
   234     '''
   235     if rev and node:
   235     if rev and node:
   236         raise util.Abort(_("please specify just one revision"))
   236         raise util.Abort(_("please specify just one revision"))
   237 
   237 
   238     if not rev:
   238     if not rev:
   454 
   454 
   455     Use -C/--clean to reset the working directory branch to that of
   455     Use -C/--clean to reset the working directory branch to that of
   456     the parent of the working directory, negating a previous branch
   456     the parent of the working directory, negating a previous branch
   457     change.
   457     change.
   458 
   458 
   459     Use the command 'hg update' to switch to an existing branch. Use
   459     Use the command :hg:`update` to switch to an existing branch. Use
   460     'hg commit --close-branch' to mark this branch as closed.
   460     :hg:`commit --close-branch` to mark this branch as closed.
   461     """
   461     """
   462 
   462 
   463     if opts.get('clean'):
   463     if opts.get('clean'):
   464         label = repo[None].parents()[0].branch()
   464         label = repo[None].parents()[0].branch()
   465         repo.dirstate.setbranch(label)
   465         repo.dirstate.setbranch(label)
   483     been marked closed (see hg commit --close-branch).
   483     been marked closed (see hg commit --close-branch).
   484 
   484 
   485     If -a/--active is specified, only show active branches. A branch
   485     If -a/--active is specified, only show active branches. A branch
   486     is considered active if it contains repository heads.
   486     is considered active if it contains repository heads.
   487 
   487 
   488     Use the command 'hg update' to switch to an existing branch.
   488     Use the command :hg:`update` to switch to an existing branch.
   489     """
   489     """
   490 
   490 
   491     hexfunc = ui.debugflag and hex or short
   491     hexfunc = ui.debugflag and hex or short
   492     activebranches = [repo[n].branch() for n in repo.heads()]
   492     activebranches = [repo[n].branch() for n in repo.heads()]
   493     def testactive(tag, node):
   493     def testactive(tag, node):
   635     basename of the source.
   635     basename of the source.
   636 
   636 
   637     The location of the source is added to the new repository's
   637     The location of the source is added to the new repository's
   638     .hg/hgrc file, as the default to be used for future pulls.
   638     .hg/hgrc file, as the default to be used for future pulls.
   639 
   639 
   640     See 'hg help urls' for valid source format details.
   640     See :hg:`help urls` for valid source format details.
   641 
   641 
   642     It is possible to specify an ``ssh://`` URL as the destination, but no
   642     It is possible to specify an ``ssh://`` URL as the destination, but no
   643     .hg/hgrc and working directory will be created on the remote side.
   643     .hg/hgrc and working directory will be created on the remote side.
   644     Please see 'hg help urls' for important details about ``ssh://`` URLs.
   644     Please see :hg:`help urls` for important details about ``ssh://`` URLs.
   645 
   645 
   646     A set of changesets (tags, or branch names) to pull may be specified
   646     A set of changesets (tags, or branch names) to pull may be specified
   647     by listing each changeset (tag, or branch name) with -r/--rev.
   647     by listing each changeset (tag, or branch name) with -r/--rev.
   648     If -r/--rev is used, the cloned repository will contain only a subset
   648     If -r/--rev is used, the cloned repository will contain only a subset
   649     of the changesets of the source repository. Only the set of changesets
   649     of the changesets of the source repository. Only the set of changesets
   703 
   703 
   704     Commit changes to the given files into the repository. Unlike a
   704     Commit changes to the given files into the repository. Unlike a
   705     centralized RCS, this operation is a local operation. See hg push
   705     centralized RCS, this operation is a local operation. See hg push
   706     for a way to actively distribute your changes.
   706     for a way to actively distribute your changes.
   707 
   707 
   708     If a list of files is omitted, all changes reported by "hg status"
   708     If a list of files is omitted, all changes reported by :hg:`status`
   709     will be committed.
   709     will be committed.
   710 
   710 
   711     If you are committing the result of a merge, do not provide any
   711     If you are committing the result of a merge, do not provide any
   712     filenames or -I/-X filters.
   712     filenames or -I/-X filters.
   713 
   713 
   714     If no commit message is specified, the configured editor is
   714     If no commit message is specified, the configured editor is
   715     started to prompt you for a message.
   715     started to prompt you for a message.
   716 
   716 
   717     See 'hg help dates' for a list of formats valid for -d/--date.
   717     See :hg:`help dates` for a list of formats valid for -d/--date.
   718     """
   718     """
   719     extra = {}
   719     extra = {}
   720     if opts.get('close_branch'):
   720     if opts.get('close_branch'):
   721         extra['close'] = 1
   721         extra['close'] = 1
   722     e = cmdutil.commiteditor
   722     e = cmdutil.commiteditor
  1149     Without the -a/--text option, diff will avoid generating diffs of
  1149     Without the -a/--text option, diff will avoid generating diffs of
  1150     files it detects as binary. With -a, diff will generate a diff
  1150     files it detects as binary. With -a, diff will generate a diff
  1151     anyway, probably with undesirable results.
  1151     anyway, probably with undesirable results.
  1152 
  1152 
  1153     Use the -g/--git option to generate diffs in the git extended diff
  1153     Use the -g/--git option to generate diffs in the git extended diff
  1154     format. For more information, read 'hg help diffs'.
  1154     format. For more information, read :hg:`help diffs`.
  1155     """
  1155     """
  1156 
  1156 
  1157     revs = opts.get('rev')
  1157     revs = opts.get('rev')
  1158     change = opts.get('change')
  1158     change = opts.get('change')
  1159     stat = opts.get('stat')
  1159     stat = opts.get('stat')
  1217     Without the -a/--text option, export will avoid generating diffs
  1217     Without the -a/--text option, export will avoid generating diffs
  1218     of files it detects as binary. With -a, export will generate a
  1218     of files it detects as binary. With -a, export will generate a
  1219     diff anyway, probably with undesirable results.
  1219     diff anyway, probably with undesirable results.
  1220 
  1220 
  1221     Use the -g/--git option to generate diffs in the git extended diff
  1221     Use the -g/--git option to generate diffs in the git extended diff
  1222     format. See 'hg help diffs' for more information.
  1222     format. See :hg:`help diffs` for more information.
  1223 
  1223 
  1224     With the --switch-parent option, the diff will be against the
  1224     With the --switch-parent option, the diff will be against the
  1225     second parent. It can be useful to review a merge.
  1225     second parent. It can be useful to review a merge.
  1226     """
  1226     """
  1227     changesets += tuple(opts.get('rev', []))
  1227     changesets += tuple(opts.get('rev', []))
  1876     With -s/--similarity, hg will attempt to discover renames and
  1876     With -s/--similarity, hg will attempt to discover renames and
  1877     copies in the patch in the same way as 'addremove'.
  1877     copies in the patch in the same way as 'addremove'.
  1878 
  1878 
  1879     To read a patch from standard input, use "-" as the patch name. If
  1879     To read a patch from standard input, use "-" as the patch name. If
  1880     a URL is specified, the patch will be downloaded from it.
  1880     a URL is specified, the patch will be downloaded from it.
  1881     See 'hg help dates' for a list of formats valid for -d/--date.
  1881     See :hg:`help dates` for a list of formats valid for -d/--date.
  1882     """
  1882     """
  1883     patches = (patch1,) + patches
  1883     patches = (patch1,) + patches
  1884 
  1884 
  1885     date = opts.get('date')
  1885     date = opts.get('date')
  1886     if date:
  1886     if date:
  2079     directory does not exist, it will be created.
  2079     directory does not exist, it will be created.
  2080 
  2080 
  2081     If no directory is given, the current directory is used.
  2081     If no directory is given, the current directory is used.
  2082 
  2082 
  2083     It is possible to specify an ``ssh://`` URL as the destination.
  2083     It is possible to specify an ``ssh://`` URL as the destination.
  2084     See 'hg help urls' for more information.
  2084     See :hg:`help urls` for more information.
  2085     """
  2085     """
  2086     hg.repository(cmdutil.remoteui(ui, opts), dest, create=1)
  2086     hg.repository(cmdutil.remoteui(ui, opts), dest, create=1)
  2087 
  2087 
  2088 def locate(ui, repo, *pats, **opts):
  2088 def locate(ui, repo, *pats, **opts):
  2089     """locate files matching specific patterns
  2089     """locate files matching specific patterns
  2134 
  2134 
  2135     If no revision range is specified, the default is tip:0 unless
  2135     If no revision range is specified, the default is tip:0 unless
  2136     --follow is set, in which case the working directory parent is
  2136     --follow is set, in which case the working directory parent is
  2137     used as the starting revision.
  2137     used as the starting revision.
  2138 
  2138 
  2139     See 'hg help dates' for a list of formats valid for -d/--date.
  2139     See :hg:`help dates` for a list of formats valid for -d/--date.
  2140 
  2140 
  2141     By default this command prints revision number and changeset id,
  2141     By default this command prints revision number and changeset id,
  2142     tags, non-trivial parents, user, date and time, and a summary for
  2142     tags, non-trivial parents, user, date and time, and a summary for
  2143     each commit. When the -v/--verbose switch is used, the list of
  2143     each commit. When the -v/--verbose switch is used, the list of
  2144     changed files and full commit message are shown.
  2144     changed files and full commit message are shown.
  2385     The names 'default' and 'default-push' have a special meaning.
  2385     The names 'default' and 'default-push' have a special meaning.
  2386     They are the locations used when pulling and pushing respectively
  2386     They are the locations used when pulling and pushing respectively
  2387     unless a location is specified. When cloning a repository, the
  2387     unless a location is specified. When cloning a repository, the
  2388     clone source is written as 'default' in .hg/hgrc.
  2388     clone source is written as 'default' in .hg/hgrc.
  2389 
  2389 
  2390     See 'hg help urls' for more information.
  2390     See :hg:`help urls` for more information.
  2391     """
  2391     """
  2392     if search:
  2392     if search:
  2393         for name, path in ui.configitems("paths"):
  2393         for name, path in ui.configitems("paths"):
  2394             if name == search:
  2394             if name == search:
  2395                 ui.write("%s\n" % url.hidepassword(path))
  2395                 ui.write("%s\n" % url.hidepassword(path))
  2427     pull at the time you issued this command. If you then decide to
  2427     pull at the time you issued this command. If you then decide to
  2428     added those changes to the repository, you should use pull -r X
  2428     added those changes to the repository, you should use pull -r X
  2429     where X is the last changeset listed by hg incoming.
  2429     where X is the last changeset listed by hg incoming.
  2430 
  2430 
  2431     If SOURCE is omitted, the 'default' path will be used.
  2431     If SOURCE is omitted, the 'default' path will be used.
  2432     See 'hg help urls' for more information.
  2432     See :hg:`help urls` for more information.
  2433     """
  2433     """
  2434     source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
  2434     source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
  2435     other = hg.repository(cmdutil.remoteui(repo, opts), source)
  2435     other = hg.repository(cmdutil.remoteui(repo, opts), source)
  2436     ui.status(_('pulling from %s\n') % url.hidepassword(source))
  2436     ui.status(_('pulling from %s\n') % url.hidepassword(source))
  2437     revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
  2437     revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
  2463     user forgot to pull and merge before pushing.
  2463     user forgot to pull and merge before pushing.
  2464 
  2464 
  2465     If -r/--rev is used, the named revision and all its ancestors will
  2465     If -r/--rev is used, the named revision and all its ancestors will
  2466     be pushed to the remote repository.
  2466     be pushed to the remote repository.
  2467 
  2467 
  2468     Please see 'hg help urls' for important details about ``ssh://``
  2468     Please see :hg:`help urls` for important details about ``ssh://``
  2469     URLs. If DESTINATION is omitted, a default path will be used.
  2469     URLs. If DESTINATION is omitted, a default path will be used.
  2470     """
  2470     """
  2471     dest = ui.expandpath(dest or 'default-push', dest or 'default')
  2471     dest = ui.expandpath(dest or 'default-push', dest or 'default')
  2472     dest, branches = hg.parseurl(dest, opts.get('branch'))
  2472     dest, branches = hg.parseurl(dest, opts.get('branch'))
  2473     revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
  2473     revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
  2661     working directory has two parents, you must explicitly specify a
  2661     working directory has two parents, you must explicitly specify a
  2662     revision.
  2662     revision.
  2663 
  2663 
  2664     Using the -r/--rev option, revert the given files or directories
  2664     Using the -r/--rev option, revert the given files or directories
  2665     to their contents as of a specific revision. This can be helpful
  2665     to their contents as of a specific revision. This can be helpful
  2666     to "roll back" some or all of an earlier change. See 'hg help
  2666     to "roll back" some or all of an earlier change. See :hg:`help
  2667     dates' for a list of formats valid for -d/--date.
  2667     dates` for a list of formats valid for -d/--date.
  2668 
  2668 
  2669     Revert modifies the working directory. It does not commit any
  2669     Revert modifies the working directory. It does not commit any
  2670     changes, or change the parent of the working directory. If you
  2670     changes, or change the parent of the working directory. If you
  2671     revert to a revision other than the parent of the working
  2671     revert to a revision other than the parent of the working
  2672     directory, the reverted files will thus appear modified
  2672     directory, the reverted files will thus appear modified
  3211     they are stored as a file named ".hgtags" which is managed
  3211     they are stored as a file named ".hgtags" which is managed
  3212     similarly to other project files and can be hand-edited if
  3212     similarly to other project files and can be hand-edited if
  3213     necessary. The file '.hg/localtags' is used for local tags (not
  3213     necessary. The file '.hg/localtags' is used for local tags (not
  3214     shared among repositories).
  3214     shared among repositories).
  3215 
  3215 
  3216     See 'hg help dates' for a list of formats valid for -d/--date.
  3216     See :hg:`help dates` for a list of formats valid for -d/--date.
  3217     """
  3217     """
  3218 
  3218 
  3219     rev_ = "."
  3219     rev_ = "."
  3220     names = (name1,) + names
  3220     names = (name1,) + names
  3221     if len(names) != len(set(names)):
  3221     if len(names) != len(set(names)):
  3353        uncommitted changes are preserved.
  3353        uncommitted changes are preserved.
  3354 
  3354 
  3355     3. With the -C/--clean option, uncommitted changes are discarded and
  3355     3. With the -C/--clean option, uncommitted changes are discarded and
  3356        the working directory is updated to the requested changeset.
  3356        the working directory is updated to the requested changeset.
  3357 
  3357 
  3358     Use null as the changeset to remove the working directory (like 'hg
  3358     Use null as the changeset to remove the working directory (like
  3359     clone -U').
  3359     :hg:`clone -U`).
  3360 
  3360 
  3361     If you want to update just one file to an older changeset, use 'hg revert'.
  3361     If you want to update just one file to an older changeset, use :hg:`revert`.
  3362 
  3362 
  3363     See 'hg help dates' for a list of formats valid for -d/--date.
  3363     See :hg:`help dates` for a list of formats valid for -d/--date.
  3364     """
  3364     """
  3365     if rev and node:
  3365     if rev and node:
  3366         raise util.Abort(_("please specify just one revision"))
  3366         raise util.Abort(_("please specify just one revision"))
  3367 
  3367 
  3368     if not rev:
  3368     if not rev: