mercurial/commands.py
changeset 6448 cd3d49ffc6f6
parent 6442 fa5454a451c6
child 6468 af2edc9c5bb9
equal deleted inserted replaced
6447:9d2ce19bdacd 6448:cd3d49ffc6f6
    51     Add all new files and remove all missing files from the repository.
    51     Add all new files and remove all missing files from the repository.
    52 
    52 
    53     New files are ignored if they match any of the patterns in .hgignore. As
    53     New files are ignored if they match any of the patterns in .hgignore. As
    54     with add, these changes take effect at the next commit.
    54     with add, these changes take effect at the next commit.
    55 
    55 
    56     Use the -s option to detect renamed files.  With a parameter > 0,
    56     Use the -s option to detect renamed files. With a parameter > 0,
    57     this compares every removed file with every added file and records
    57     this compares every removed file with every added file and records
    58     those similar enough as renames.  This option takes a percentage
    58     those similar enough as renames. This option takes a percentage
    59     between 0 (disabled) and 100 (files must be identical) as its
    59     between 0 (disabled) and 100 (files must be identical) as its
    60     parameter.  Detecting renamed files this way can be expensive.
    60     parameter. Detecting renamed files this way can be expensive.
    61     """
    61     """
    62     try:
    62     try:
    63         sim = float(opts.get('similarity') or 0)
    63         sim = float(opts.get('similarity') or 0)
    64     except ValueError:
    64     except ValueError:
    65         raise util.Abort(_('similarity must be a number'))
    65         raise util.Abort(_('similarity must be a number'))
   132     '''create unversioned archive of a repository revision
   132     '''create unversioned archive of a repository revision
   133 
   133 
   134     By default, the revision used is the parent of the working
   134     By default, the revision used is the parent of the working
   135     directory; use "-r" to specify a different revision.
   135     directory; use "-r" to specify a different revision.
   136 
   136 
   137     To specify the type of archive to create, use "-t".  Valid
   137     To specify the type of archive to create, use "-t". Valid
   138     types are:
   138     types are:
   139 
   139 
   140     "files" (default): a directory full of files
   140     "files" (default): a directory full of files
   141     "tar": tar archive, uncompressed
   141     "tar": tar archive, uncompressed
   142     "tbz2": tar archive, compressed using bzip2
   142     "tbz2": tar archive, compressed using bzip2
   146 
   146 
   147     The exact name of the destination archive or directory is given
   147     The exact name of the destination archive or directory is given
   148     using a format string; see "hg help export" for details.
   148     using a format string; see "hg help export" for details.
   149 
   149 
   150     Each member added to an archive file has a directory prefix
   150     Each member added to an archive file has a directory prefix
   151     prepended.  Use "-p" to specify a format string for the prefix.
   151     prepended. Use "-p" to specify a format string for the prefix.
   152     The default is the basename of the archive, with suffixes removed.
   152     The default is the basename of the archive, with suffixes removed.
   153     '''
   153     '''
   154 
   154 
   155     ctx = repo.changectx(opts['rev'])
   155     ctx = repo.changectx(opts['rev'])
   156     if not ctx:
   156     if not ctx:
   172                      matchfn, prefix)
   172                      matchfn, prefix)
   173 
   173 
   174 def backout(ui, repo, node=None, rev=None, **opts):
   174 def backout(ui, repo, node=None, rev=None, **opts):
   175     '''reverse effect of earlier changeset
   175     '''reverse effect of earlier changeset
   176 
   176 
   177     Commit the backed out changes as a new changeset.  The new
   177     Commit the backed out changes as a new changeset. The new
   178     changeset is a child of the backed out changeset.
   178     changeset is a child of the backed out changeset.
   179 
   179 
   180     If you back out a changeset other than the tip, a new head is
   180     If you back out a changeset other than the tip, a new head is
   181     created.  This head will be the new tip and you should merge this
   181     created. This head will be the new tip and you should merge this
   182     backout changeset with another head (current one by default).
   182     backout changeset with another head (current one by default).
   183 
   183 
   184     The --merge option remembers the parent of the working directory
   184     The --merge option remembers the parent of the working directory
   185     before starting the backout, then merges the new head with that
   185     before starting the backout, then merges the new head with that
   186     changeset afterwards.  This saves you from doing the merge by
   186     changeset afterwards. This saves you from doing the merge by
   187     hand.  The result of this merge is not committed, as for a normal
   187     hand. The result of this merge is not committed, as for a normal
   188     merge.
   188     merge.
   189 
   189 
   190     See 'hg help dates' for a list of formats valid for -d/--date.
   190     See 'hg help dates' for a list of formats valid for -d/--date.
   191     '''
   191     '''
   192     if rev and node:
   192     if rev and node:
   367 
   367 
   368 def branches(ui, repo, active=False):
   368 def branches(ui, repo, active=False):
   369     """list repository named branches
   369     """list repository named branches
   370 
   370 
   371     List the repository's named branches, indicating which ones are
   371     List the repository's named branches, indicating which ones are
   372     inactive.  If active is specified, only show active branches.
   372     inactive. If active is specified, only show active branches.
   373 
   373 
   374     A branch is considered active if it contains unmerged heads.
   374     A branch is considered active if it contains unmerged heads.
   375 
   375 
   376     Use the command 'hg update' to switch to an existing branch.
   376     Use the command 'hg update' to switch to an existing branch.
   377     """
   377     """
   402     Generate a compressed changegroup file collecting changesets not
   402     Generate a compressed changegroup file collecting changesets not
   403     found in the other repository.
   403     found in the other repository.
   404 
   404 
   405     If no destination repository is specified the destination is
   405     If no destination repository is specified the destination is
   406     assumed to have all the nodes specified by one or more --base
   406     assumed to have all the nodes specified by one or more --base
   407     parameters.  To create a bundle containing all changesets, use
   407     parameters. To create a bundle containing all changesets, use
   408     --all (or --base null).
   408     --all (or --base null).
   409 
   409 
   410     The bundle file can then be transferred using conventional means and
   410     The bundle file can then be transferred using conventional means and
   411     applied to another repository with the unbundle or pull command.
   411     applied to another repository with the unbundle or pull command.
   412     This is useful when direct push and pull are not available or when
   412     This is useful when direct push and pull are not available or when
   467     Print the specified files as they were at the given revision.
   467     Print the specified files as they were at the given revision.
   468     If no revision is given, the parent of the working directory is used,
   468     If no revision is given, the parent of the working directory is used,
   469     or tip if no revision is checked out.
   469     or tip if no revision is checked out.
   470 
   470 
   471     Output may be to a file, in which case the name of the file is
   471     Output may be to a file, in which case the name of the file is
   472     given using a format string.  The formatting rules are the same as
   472     given using a format string. The formatting rules are the same as
   473     for the export command, with the following additions:
   473     for the export command, with the following additions:
   474 
   474 
   475     %s   basename of file being printed
   475     %s   basename of file being printed
   476     %d   dirname of file being printed, or '.' if in repo root
   476     %d   dirname of file being printed, or '.' if in repo root
   477     %p   root-relative path name of file being printed
   477     %p   root-relative path name of file being printed
   499     The location of the source is added to the new repository's
   499     The location of the source is added to the new repository's
   500     .hg/hgrc file, as the default to be used for future pulls.
   500     .hg/hgrc file, as the default to be used for future pulls.
   501 
   501 
   502     For efficiency, hardlinks are used for cloning whenever the source
   502     For efficiency, hardlinks are used for cloning whenever the source
   503     and destination are on the same filesystem (note this applies only
   503     and destination are on the same filesystem (note this applies only
   504     to the repository data, not to the checked out files).  Some
   504     to the repository data, not to the checked out files). Some
   505     filesystems, such as AFS, implement hardlinking incorrectly, but
   505     filesystems, such as AFS, implement hardlinking incorrectly, but
   506     do not report errors.  In these cases, use the --pull option to
   506     do not report errors. In these cases, use the --pull option to
   507     avoid hardlinking.
   507     avoid hardlinking.
   508 
   508 
   509     You can safely clone repositories and checked out files using full
   509     You can safely clone repositories and checked out files using full
   510     hardlinks with
   510     hardlinks with
   511 
   511 
   569         ui.status(_('created new head\n'))
   569         ui.status(_('created new head\n'))
   570 
   570 
   571 def copy(ui, repo, *pats, **opts):
   571 def copy(ui, repo, *pats, **opts):
   572     """mark files as copied for the next commit
   572     """mark files as copied for the next commit
   573 
   573 
   574     Mark dest as having copies of source files.  If dest is a
   574     Mark dest as having copies of source files. If dest is a
   575     directory, copies are put in that directory.  If dest is a file,
   575     directory, copies are put in that directory. If dest is a file,
   576     there can only be one source.
   576     there can only be one source.
   577 
   577 
   578     By default, this command copies the contents of files as they
   578     By default, this command copies the contents of files as they
   579     stand in the working directory.  If invoked with --after, the
   579     stand in the working directory. If invoked with --after, the
   580     operation is recorded, but no copying is performed.
   580     operation is recorded, but no copying is performed.
   581 
   581 
   582     This command takes effect in the next commit. To undo a copy
   582     This command takes effect in the next commit. To undo a copy
   583     before that, see hg revert.
   583     before that, see hg revert.
   584     """
   584     """
   961 
   961 
   962     NOTE: export may generate unexpected diff output for merge changesets,
   962     NOTE: export may generate unexpected diff output for merge changesets,
   963     as it will compare the merge changeset against its first parent only.
   963     as it will compare the merge changeset against its first parent only.
   964 
   964 
   965     Output may be to a file, in which case the name of the file is
   965     Output may be to a file, in which case the name of the file is
   966     given using a format string.  The formatting rules are as follows:
   966     given using a format string. The formatting rules are as follows:
   967 
   967 
   968     %%   literal "%" character
   968     %%   literal "%" character
   969     %H   changeset hash (40 bytes of hexadecimal)
   969     %H   changeset hash (40 bytes of hexadecimal)
   970     %N   number of patches being generated
   970     %N   number of patches being generated
   971     %R   changeset revision number
   971     %R   changeset revision number
   995 def grep(ui, repo, pattern, *pats, **opts):
   995 def grep(ui, repo, pattern, *pats, **opts):
   996     """search for a pattern in specified files and revisions
   996     """search for a pattern in specified files and revisions
   997 
   997 
   998     Search revisions of files for a regular expression.
   998     Search revisions of files for a regular expression.
   999 
   999 
  1000     This command behaves differently than Unix grep.  It only accepts
  1000     This command behaves differently than Unix grep. It only accepts
  1001     Python/Perl regexps.  It searches repository history, not the
  1001     Python/Perl regexps. It searches repository history, not the
  1002     working directory.  It always prints the revision number in which
  1002     working directory. It always prints the revision number in which
  1003     a match appears.
  1003     a match appears.
  1004 
  1004 
  1005     By default, grep only prints output for the first revision of a
  1005     By default, grep only prints output for the first revision of a
  1006     file in which it finds a match.  To get it to print every revision
  1006     file in which it finds a match. To get it to print every revision
  1007     that contains a change in match status ("-" for a match that
  1007     that contains a change in match status ("-" for a match that
  1008     becomes a non-match, or "+" for a non-match that becomes a match),
  1008     becomes a non-match, or "+" for a non-match that becomes a match),
  1009     use the --all flag.
  1009     use the --all flag.
  1010     """
  1010     """
  1011     reflags = 0
  1011     reflags = 0
  1171     Repository "heads" are changesets that don't have child
  1171     Repository "heads" are changesets that don't have child
  1172     changesets. They are where development generally takes place and
  1172     changesets. They are where development generally takes place and
  1173     are the usual targets for update and merge operations.
  1173     are the usual targets for update and merge operations.
  1174 
  1174 
  1175     Branch heads are changesets that have a given branch tag, but have
  1175     Branch heads are changesets that have a given branch tag, but have
  1176     no child changesets with that tag.  They are usually where
  1176     no child changesets with that tag. They are usually where
  1177     development on the given branch takes place.
  1177     development on the given branch takes place.
  1178     """
  1178     """
  1179     if opts['rev']:
  1179     if opts['rev']:
  1180         start = repo.lookup(opts['rev'])
  1180         start = repo.lookup(opts['rev'])
  1181     else:
  1181     else:
  1464     Import a list of patches and commit them individually.
  1464     Import a list of patches and commit them individually.
  1465 
  1465 
  1466     If there are outstanding changes in the working directory, import
  1466     If there are outstanding changes in the working directory, import
  1467     will abort unless given the -f flag.
  1467     will abort unless given the -f flag.
  1468 
  1468 
  1469     You can import a patch straight from a mail message.  Even patches
  1469     You can import a patch straight from a mail message. Even patches
  1470     as attachments work (body part must be type text/plain or
  1470     as attachments work (body part must be type text/plain or
  1471     text/x-patch to be used).  From and Subject headers of email
  1471     text/x-patch to be used). From and Subject headers of email
  1472     message are used as default committer and commit message.  All
  1472     message are used as default committer and commit message. All
  1473     text/plain body parts before first diff are added to commit
  1473     text/plain body parts before first diff are added to commit
  1474     message.
  1474     message.
  1475 
  1475 
  1476     If the imported patch was generated by hg export, user and description
  1476     If the imported patch was generated by hg export, user and description
  1477     from patch override values from message headers and body.  Values
  1477     from patch override values from message headers and body. Values
  1478     given on command line with -m and -u override these.
  1478     given on command line with -m and -u override these.
  1479 
  1479 
  1480     If --exact is specified, import will set the working directory
  1480     If --exact is specified, import will set the working directory
  1481     to the parent of each patch before applying it, and will abort
  1481     to the parent of each patch before applying it, and will abort
  1482     if the resulting changeset has a different ID than the one
  1482     if the resulting changeset has a different ID than the one
  1641             os.unlink(cleanup)
  1641             os.unlink(cleanup)
  1642 
  1642 
  1643 def init(ui, dest=".", **opts):
  1643 def init(ui, dest=".", **opts):
  1644     """create a new repository in the given directory
  1644     """create a new repository in the given directory
  1645 
  1645 
  1646     Initialize a new repository in the given directory.  If the given
  1646     Initialize a new repository in the given directory. If the given
  1647     directory does not exist, it is created.
  1647     directory does not exist, it is created.
  1648 
  1648 
  1649     If no directory is given, the current directory is used.
  1649     If no directory is given, the current directory is used.
  1650 
  1650 
  1651     It is possible to specify an ssh:// URL as the destination.
  1651     It is possible to specify an ssh:// URL as the destination.
  1659     """locate files matching specific patterns
  1659     """locate files matching specific patterns
  1660 
  1660 
  1661     Print all files under Mercurial control whose names match the
  1661     Print all files under Mercurial control whose names match the
  1662     given patterns.
  1662     given patterns.
  1663 
  1663 
  1664     This command searches the entire repository by default.  To search
  1664     This command searches the entire repository by default. To search
  1665     just the current directory and its subdirectories, use
  1665     just the current directory and its subdirectories, use
  1666     "--include .".
  1666     "--include .".
  1667 
  1667 
  1668     If no patterns are given to match, this command prints all file
  1668     If no patterns are given to match, this command prints all file
  1669     names.
  1669     names.
  1701 
  1701 
  1702     Print the revision history of the specified files or the entire
  1702     Print the revision history of the specified files or the entire
  1703     project.
  1703     project.
  1704 
  1704 
  1705     File history is shown without following rename or copy history of
  1705     File history is shown without following rename or copy history of
  1706     files.  Use -f/--follow with a file name to follow history across
  1706     files. Use -f/--follow with a file name to follow history across
  1707     renames and copies. --follow without a file name will only show
  1707     renames and copies. --follow without a file name will only show
  1708     ancestors or descendants of the starting revision. --follow-first
  1708     ancestors or descendants of the starting revision. --follow-first
  1709     only follows the first parent of merge revisions.
  1709     only follows the first parent of merge revisions.
  1710 
  1710 
  1711     If no revision range is specified, the default is tip:0 unless
  1711     If no revision range is specified, the default is tip:0 unless
  1860     marked as changed for the next commit and a commit must be
  1860     marked as changed for the next commit and a commit must be
  1861     performed before any further updates are allowed.
  1861     performed before any further updates are allowed.
  1862 
  1862 
  1863     If no revision is specified, the working directory's parent is a
  1863     If no revision is specified, the working directory's parent is a
  1864     head revision, and the repository contains exactly one other head,
  1864     head revision, and the repository contains exactly one other head,
  1865     the other head is merged with by default.  Otherwise, an explicit
  1865     the other head is merged with by default. Otherwise, an explicit
  1866     revision to merge with must be provided.
  1866     revision to merge with must be provided.
  1867     """
  1867     """
  1868 
  1868 
  1869     if rev and node:
  1869     if rev and node:
  1870         raise util.Abort(_("please specify just one revision"))
  1870         raise util.Abort(_("please specify just one revision"))
  1971 
  1971 
  1972     Show definition of symbolic path name NAME. If no name is given, show
  1972     Show definition of symbolic path name NAME. If no name is given, show
  1973     definition of available names.
  1973     definition of available names.
  1974 
  1974 
  1975     Path names are defined in the [paths] section of /etc/mercurial/hgrc
  1975     Path names are defined in the [paths] section of /etc/mercurial/hgrc
  1976     and $HOME/.hgrc.  If run inside a repository, .hg/hgrc is used, too.
  1976     and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
  1977     """
  1977     """
  1978     if search:
  1978     if search:
  1979         for name, path in ui.configitems("paths"):
  1979         for name, path in ui.configitems("paths"):
  1980             if name == search:
  1980             if name == search:
  1981                 ui.write("%s\n" % util.hidepassword(path))
  1981                 ui.write("%s\n" % util.hidepassword(path))
  2212     repo.remove(remove, unlink=not after)
  2212     repo.remove(remove, unlink=not after)
  2213 
  2213 
  2214 def rename(ui, repo, *pats, **opts):
  2214 def rename(ui, repo, *pats, **opts):
  2215     """rename files; equivalent of copy + remove
  2215     """rename files; equivalent of copy + remove
  2216 
  2216 
  2217     Mark dest as copies of sources; mark sources for deletion.  If
  2217     Mark dest as copies of sources; mark sources for deletion. If
  2218     dest is a directory, copies are put in that directory.  If dest is
  2218     dest is a directory, copies are put in that directory. If dest is
  2219     a file, there can only be one source.
  2219     a file, there can only be one source.
  2220 
  2220 
  2221     By default, this command copies the contents of files as they
  2221     By default, this command copies the contents of files as they
  2222     stand in the working directory.  If invoked with --after, the
  2222     stand in the working directory. If invoked with --after, the
  2223     operation is recorded, but no copying is performed.
  2223     operation is recorded, but no copying is performed.
  2224 
  2224 
  2225     This command takes effect in the next commit. To undo a rename
  2225     This command takes effect in the next commit. To undo a rename
  2226     before that, see hg revert.
  2226     before that, see hg revert.
  2227     """
  2227     """
  2247     Using the -r option, revert the given files or directories to their
  2247     Using the -r option, revert the given files or directories to their
  2248     contents as of a specific revision. This can be helpful to "roll
  2248     contents as of a specific revision. This can be helpful to "roll
  2249     back" some or all of an earlier change.
  2249     back" some or all of an earlier change.
  2250     See 'hg help dates' for a list of formats valid for -d/--date.
  2250     See 'hg help dates' for a list of formats valid for -d/--date.
  2251 
  2251 
  2252     Revert modifies the working directory.  It does not commit any
  2252     Revert modifies the working directory. It does not commit any
  2253     changes, or change the parent of the working directory.  If you
  2253     changes, or change the parent of the working directory. If you
  2254     revert to a revision other than the parent of the working
  2254     revert to a revision other than the parent of the working
  2255     directory, the reverted files will thus appear modified
  2255     directory, the reverted files will thus appear modified
  2256     afterwards.
  2256     afterwards.
  2257 
  2257 
  2258     If a file has been deleted, it is restored.  If the executable
  2258     If a file has been deleted, it is restored. If the executable
  2259     mode of a file was changed, it is reset.
  2259     mode of a file was changed, it is reset.
  2260 
  2260 
  2261     If names are given, all files matching the names are reverted.
  2261     If names are given, all files matching the names are reverted.
  2262     If no arguments are given, no files are reverted.
  2262     If no arguments are given, no files are reverted.
  2263 
  2263 
  2489     """export the repository via HTTP
  2489     """export the repository via HTTP
  2490 
  2490 
  2491     Start a local HTTP repository browser and pull server.
  2491     Start a local HTTP repository browser and pull server.
  2492 
  2492 
  2493     By default, the server logs accesses to stdout and errors to
  2493     By default, the server logs accesses to stdout and errors to
  2494     stderr.  Use the "-A" and "-E" options to log to files.
  2494     stderr. Use the "-A" and "-E" options to log to files.
  2495     """
  2495     """
  2496 
  2496 
  2497     if opts["stdio"]:
  2497     if opts["stdio"]:
  2498         if repo is None:
  2498         if repo is None:
  2499             raise RepoError(_("There is no Mercurial repository here"
  2499             raise RepoError(_("There is no Mercurial repository here"
  2550     cmdutil.service(opts, initfn=service.init, runfn=service.run)
  2550     cmdutil.service(opts, initfn=service.init, runfn=service.run)
  2551 
  2551 
  2552 def status(ui, repo, *pats, **opts):
  2552 def status(ui, repo, *pats, **opts):
  2553     """show changed files in the working directory
  2553     """show changed files in the working directory
  2554 
  2554 
  2555     Show status of files in the repository.  If names are given, only
  2555     Show status of files in the repository. If names are given, only
  2556     files that match are shown.  Files that are clean or ignored or
  2556     files that match are shown. Files that are clean or ignored or
  2557     source of a copy/move operation, are not listed unless -c (clean),
  2557     source of a copy/move operation, are not listed unless -c (clean),
  2558     -i (ignored), -C (copies) or -A is given.  Unless options described
  2558     -i (ignored), -C (copies) or -A is given. Unless options described
  2559     with "show only ..." are given, the options -mardu are used.
  2559     with "show only ..." are given, the options -mardu are used.
  2560 
  2560 
  2561     Option -q/--quiet hides untracked (unknown and ignored) files
  2561     Option -q/--quiet hides untracked (unknown and ignored) files
  2562     unless explicitly requested with -u/--unknown or -i/-ignored.
  2562     unless explicitly requested with -u/--unknown or -i/-ignored.
  2563 
  2563 
  2653     or tip if no revision is checked out.
  2653     or tip if no revision is checked out.
  2654 
  2654 
  2655     To facilitate version control, distribution, and merging of tags,
  2655     To facilitate version control, distribution, and merging of tags,
  2656     they are stored as a file named ".hgtags" which is managed
  2656     they are stored as a file named ".hgtags" which is managed
  2657     similarly to other project files and can be hand-edited if
  2657     similarly to other project files and can be hand-edited if
  2658     necessary.  The file '.hg/localtags' is used for local tags (not
  2658     necessary. The file '.hg/localtags' is used for local tags (not
  2659     shared among repositories).
  2659     shared among repositories).
  2660 
  2660 
  2661     See 'hg help dates' for a list of formats valid for -d/--date.
  2661     See 'hg help dates' for a list of formats valid for -d/--date.
  2662     """
  2662     """
  2663 
  2663