mercurial/commands.py
changeset 8004 d5b1b846f277
parent 7983 7b813bdbd5d0
child 8007 a4defdc4f5dc
equal deleted inserted replaced
8003:14f27921932a 8004:d5b1b846f277
    16 # Commands start here, listed alphabetically
    16 # Commands start here, listed alphabetically
    17 
    17 
    18 def add(ui, repo, *pats, **opts):
    18 def add(ui, repo, *pats, **opts):
    19     """add the specified files on the next commit
    19     """add the specified files on the next commit
    20 
    20 
    21     Schedule files to be version controlled and added to the repository.
    21     Schedule files to be version controlled and added to the
       
    22     repository.
    22 
    23 
    23     The files will be added to the repository at the next commit. To
    24     The files will be added to the repository at the next commit. To
    24     undo an add before that, see hg revert.
    25     undo an add before that, see hg revert.
    25 
    26 
    26     If no names are given, add all files to the repository.
    27     If no names are given, add all files to the repository.
    46     return rejected and 1 or 0
    47     return rejected and 1 or 0
    47 
    48 
    48 def addremove(ui, repo, *pats, **opts):
    49 def addremove(ui, repo, *pats, **opts):
    49     """add all new files, delete all missing files
    50     """add all new files, delete all missing files
    50 
    51 
    51     Add all new files and remove all missing files from the repository.
    52     Add all new files and remove all missing files from the
    52 
    53     repository.
    53     New files are ignored if they match any of the patterns in .hgignore. As
    54 
    54     with add, these changes take effect at the next commit.
    55     New files are ignored if they match any of the patterns in
       
    56     .hgignore. As with add, these changes take effect at the next
       
    57     commit.
    55 
    58 
    56     Use the -s option to detect renamed files. With a parameter > 0,
    59     Use the -s option to detect renamed files. With a parameter > 0,
    57     this compares every removed file with every added file and records
    60     this compares every removed file with every added file and records
    58     those similar enough as renames. This option takes a percentage
    61     those similar enough as renames. This option takes a percentage
    59     between 0 (disabled) and 100 (files must be identical) as its
    62     between 0 (disabled) and 100 (files must be identical) as its
    68     return cmdutil.addremove(repo, pats, opts, similarity=sim/100.)
    71     return cmdutil.addremove(repo, pats, opts, similarity=sim/100.)
    69 
    72 
    70 def annotate(ui, repo, *pats, **opts):
    73 def annotate(ui, repo, *pats, **opts):
    71     """show changeset information per file line
    74     """show changeset information per file line
    72 
    75 
    73     List changes in files, showing the revision id responsible for each line
    76     List changes in files, showing the revision id responsible for
    74 
    77     each line
    75     This command is useful to discover who did a change or when a change took
    78 
    76     place.
    79     This command is useful to discover who did a change or when a
       
    80     change took place.
    77 
    81 
    78     Without the -a option, annotate will avoid processing files it
    82     Without the -a option, annotate will avoid processing files it
    79     detects as binary. With -a, annotate will generate an annotation
    83     detects as binary. With -a, annotate will generate an annotation
    80     anyway, probably with undesirable results.
    84     anyway, probably with undesirable results.
    81     """
    85     """
   132     '''create unversioned archive of a repository revision
   136     '''create unversioned archive of a repository revision
   133 
   137 
   134     By default, the revision used is the parent of the working
   138     By default, the revision used is the parent of the working
   135     directory; use "-r" to specify a different revision.
   139     directory; use "-r" to specify a different revision.
   136 
   140 
   137     To specify the type of archive to create, use "-t". Valid
   141     To specify the type of archive to create, use "-t". Valid types
   138     types are:
   142     are:
   139 
   143 
   140     "files" (default): a directory full of files
   144     "files" (default): a directory full of files
   141     "tar": tar archive, uncompressed
   145     "tar": tar archive, uncompressed
   142     "tbz2": tar archive, compressed using bzip2
   146     "tbz2": tar archive, compressed using bzip2
   143     "tgz": tar archive, compressed using gzip
   147     "tgz": tar archive, compressed using gzip
   146 
   150 
   147     The exact name of the destination archive or directory is given
   151     The exact name of the destination archive or directory is given
   148     using a format string; see 'hg help export' for details.
   152     using a format string; see 'hg help export' for details.
   149 
   153 
   150     Each member added to an archive file has a directory prefix
   154     Each member added to an archive file has a directory prefix
   151     prepended. Use "-p" to specify a format string for the prefix.
   155     prepended. Use "-p" to specify a format string for the prefix. The
   152     The default is the basename of the archive, with suffixes removed.
   156     default is the basename of the archive, with suffixes removed.
   153     '''
   157     '''
   154 
   158 
   155     ctx = repo[opts.get('rev')]
   159     ctx = repo[opts.get('rev')]
   156     if not ctx:
   160     if not ctx:
   157         raise util.Abort(_('no working directory: please specify a revision'))
   161         raise util.Abort(_('no working directory: please specify a revision'))
   181     created. This head will be the new tip and you should merge this
   185     created. This head will be the new tip and you should merge this
   182     backout changeset with another head (current one by default).
   186     backout changeset with another head (current one by default).
   183 
   187 
   184     The --merge option remembers the parent of the working directory
   188     The --merge option remembers the parent of the working directory
   185     before starting the backout, then merges the new head with that
   189     before starting the backout, then merges the new head with that
   186     changeset afterwards. This saves you from doing the merge by
   190     changeset afterwards. This saves you from doing the merge by hand.
   187     hand. The result of this merge is not committed, as with a normal
   191     The result of this merge is not committed, as with a normal merge.
   188     merge.
       
   189 
   192 
   190     See \'hg help dates\' for a list of formats valid for -d/--date.
   193     See \'hg help dates\' for a list of formats valid for -d/--date.
   191     '''
   194     '''
   192     if rev and node:
   195     if rev and node:
   193         raise util.Abort(_("please specify just one revision"))
   196         raise util.Abort(_("please specify just one revision"))
   260 
   263 
   261 def bisect(ui, repo, rev=None, extra=None, command=None,
   264 def bisect(ui, repo, rev=None, extra=None, command=None,
   262                reset=None, good=None, bad=None, skip=None, noupdate=None):
   265                reset=None, good=None, bad=None, skip=None, noupdate=None):
   263     """subdivision search of changesets
   266     """subdivision search of changesets
   264 
   267 
   265     This command helps to find changesets which introduce problems.
   268     This command helps to find changesets which introduce problems. To
   266     To use, mark the earliest changeset you know exhibits the problem
   269     use, mark the earliest changeset you know exhibits the problem as
   267     as bad, then mark the latest changeset which is free from the
   270     bad, then mark the latest changeset which is free from the problem
   268     problem as good. Bisect will update your working directory to a
   271     as good. Bisect will update your working directory to a revision
   269     revision for testing (unless the --noupdate option is specified).
   272     for testing (unless the --noupdate option is specified). Once you
   270     Once you have performed tests, mark the working directory as bad
   273     have performed tests, mark the working directory as bad or good
   271     or good and bisect will either update to another candidate changeset
   274     and bisect will either update to another candidate changeset or
   272     or announce that it has found the bad revision.
   275     announce that it has found the bad revision.
   273 
   276 
   274     As a shortcut, you can also use the revision argument to mark a
   277     As a shortcut, you can also use the revision argument to mark a
   275     revision as good or bad without checking it out first.
   278     revision as good or bad without checking it out first.
   276 
   279 
   277     If you supply a command it will be used for automatic bisection. Its exit
   280     If you supply a command it will be used for automatic bisection.
   278     status will be used as flag to mark revision as bad or good. In case exit
   281     Its exit status will be used as flag to mark revision as bad or
   279     status is 0 the revision is marked as good, 125 - skipped, 127 (command not
   282     good. In case exit status is 0 the revision is marked as good, 125
   280     found) - bisection will be aborted; any other status bigger than 0 will
   283     - skipped, 127 (command not found) - bisection will be aborted;
   281     mark revision as bad.
   284     any other status bigger than 0 will mark revision as bad.
   282     """
   285     """
   283     def print_result(nodes, good):
   286     def print_result(nodes, good):
   284         displayer = cmdutil.show_changeset(ui, repo, {})
   287         displayer = cmdutil.show_changeset(ui, repo, {})
   285         transition = (good and "good" or "bad")
   288         transition = (good and "good" or "bad")
   286         if len(nodes) == 1:
   289         if len(nodes) == 1:
   395     With no argument, show the current branch name. With one argument,
   398     With no argument, show the current branch name. With one argument,
   396     set the working directory branch name (the branch does not exist
   399     set the working directory branch name (the branch does not exist
   397     in the repository until the next commit). It is recommended to use
   400     in the repository until the next commit). It is recommended to use
   398     the 'default' branch as your primary development branch.
   401     the 'default' branch as your primary development branch.
   399 
   402 
   400     Unless --force is specified, branch will not let you set a
   403     Unless --force is specified, branch will not let you set a branch
   401     branch name that shadows an existing branch.
   404     name that shadows an existing branch.
   402 
   405 
   403     Use --clean to reset the working directory branch to that of the
   406     Use --clean to reset the working directory branch to that of the
   404     parent of the working directory, negating a previous branch change.
   407     parent of the working directory, negating a previous branch
       
   408     change.
   405 
   409 
   406     Use the command 'hg update' to switch to an existing branch.
   410     Use the command 'hg update' to switch to an existing branch.
   407     """
   411     """
   408 
   412 
   409     if opts.get('clean'):
   413     if opts.get('clean'):
   463     assumed to have all the nodes specified by one or more --base
   467     assumed to have all the nodes specified by one or more --base
   464     parameters. To create a bundle containing all changesets, use
   468     parameters. To create a bundle containing all changesets, use
   465     --all (or --base null). To change the compression method applied,
   469     --all (or --base null). To change the compression method applied,
   466     use the -t option (by default, bundles are compressed using bz2).
   470     use the -t option (by default, bundles are compressed using bz2).
   467 
   471 
   468     The bundle file can then be transferred using conventional means and
   472     The bundle file can then be transferred using conventional means
   469     applied to another repository with the unbundle or pull command.
   473     and applied to another repository with the unbundle or pull
   470     This is useful when direct push and pull are not available or when
   474     command. This is useful when direct push and pull are not
   471     exporting an entire repository is undesirable.
   475     available or when exporting an entire repository is undesirable.
   472 
   476 
   473     Applying bundles preserves all changeset contents including
   477     Applying bundles preserves all changeset contents including
   474     permissions, copy/rename information, and revision history.
   478     permissions, copy/rename information, and revision history.
   475     """
   479     """
   476     revs = opts.get('rev') or None
   480     revs = opts.get('rev') or None
   527     changegroup.writebundle(cg, fname, bundletype)
   531     changegroup.writebundle(cg, fname, bundletype)
   528 
   532 
   529 def cat(ui, repo, file1, *pats, **opts):
   533 def cat(ui, repo, file1, *pats, **opts):
   530     """output the current or given revision of files
   534     """output the current or given revision of files
   531 
   535 
   532     Print the specified files as they were at the given revision.
   536     Print the specified files as they were at the given revision. If
   533     If no revision is given, the parent of the working directory is used,
   537     no revision is given, the parent of the working directory is used,
   534     or tip if no revision is checked out.
   538     or tip if no revision is checked out.
   535 
   539 
   536     Output may be to a file, in which case the name of the file is
   540     Output may be to a file, in which case the name of the file is
   537     given using a format string. The formatting rules are the same as
   541     given using a format string. The formatting rules are the same as
   538     for the export command, with the following additions:
   542     for the export command, with the following additions:
   568     subsequent revisions (including subsequent tags) will be present
   572     subsequent revisions (including subsequent tags) will be present
   569     in the cloned repository. This option implies --pull, even on
   573     in the cloned repository. This option implies --pull, even on
   570     local repositories.
   574     local repositories.
   571 
   575 
   572     By default, clone will check out the head of the 'default' branch.
   576     By default, clone will check out the head of the 'default' branch.
   573     If the -U option is used, the new clone will contain only a repository
   577     If the -U option is used, the new clone will contain only a
   574     (.hg) and no working copy (the working copy parent is the null revision).
   578     repository (.hg) and no working copy (the working copy parent is
       
   579     the null revision).
   575 
   580 
   576     See 'hg help urls' for valid source format details.
   581     See 'hg help urls' for valid source format details.
   577 
   582 
   578     It is possible to specify an ssh:// URL as the destination, but no
   583     It is possible to specify an ssh:// URL as the destination, but no
   579     .hg/hgrc and working directory will be created on the remote side.
   584     .hg/hgrc and working directory will be created on the remote side.
   580     Look at the help text for URLs for important details about ssh:// URLs.
   585     Look at the help text for URLs for important details about ssh://
       
   586     URLs.
   581 
   587 
   582     For efficiency, hardlinks are used for cloning whenever the source
   588     For efficiency, hardlinks are used for cloning whenever the source
   583     and destination are on the same filesystem (note this applies only
   589     and destination are on the same filesystem (note this applies only
   584     to the repository data, not to the checked out files). Some
   590     to the repository data, not to the checked out files). Some
   585     filesystems, such as AFS, implement hardlinking incorrectly, but
   591     filesystems, such as AFS, implement hardlinking incorrectly, but
   617     will be committed.
   623     will be committed.
   618 
   624 
   619     If you are committing the result of a merge, do not provide any
   625     If you are committing the result of a merge, do not provide any
   620     file names or -I/-X filters.
   626     file names or -I/-X filters.
   621 
   627 
   622     If no commit message is specified, the configured editor is started to
   628     If no commit message is specified, the configured editor is
   623     prompt you for a message.
   629     started to prompt you for a message.
   624 
   630 
   625     See 'hg help dates' for a list of formats valid for -d/--date.
   631     See 'hg help dates' for a list of formats valid for -d/--date.
   626     """
   632     """
   627     extra = {}
   633     extra = {}
   628     if opts.get('close_branch'):
   634     if opts.get('close_branch'):
  1058     Print the changeset header and diffs for one or more revisions.
  1064     Print the changeset header and diffs for one or more revisions.
  1059 
  1065 
  1060     The information shown in the changeset header is: author,
  1066     The information shown in the changeset header is: author,
  1061     changeset hash, parent(s) and commit comment.
  1067     changeset hash, parent(s) and commit comment.
  1062 
  1068 
  1063     NOTE: export may generate unexpected diff output for merge changesets,
  1069     NOTE: export may generate unexpected diff output for merge
  1064     as it will compare the merge changeset against its first parent only.
  1070     changesets, as it will compare the merge changeset against its
       
  1071     first parent only.
  1065 
  1072 
  1066     Output may be to a file, in which case the name of the file is
  1073     Output may be to a file, in which case the name of the file is
  1067     given using a format string. The formatting rules are as follows:
  1074     given using a format string. The formatting rules are as follows:
  1068 
  1075 
  1069     %%   literal "%" character
  1076     %%   literal "%" character
  1080     probably with undesirable results.
  1087     probably with undesirable results.
  1081 
  1088 
  1082     Use the --git option to generate diffs in the git extended diff
  1089     Use the --git option to generate diffs in the git extended diff
  1083     format. Read the diffs help topic for more information.
  1090     format. Read the diffs help topic for more information.
  1084 
  1091 
  1085     With the --switch-parent option, the diff will be against the second
  1092     With the --switch-parent option, the diff will be against the
  1086     parent. It can be useful to review a merge.
  1093     second parent. It can be useful to review a merge.
  1087     """
  1094     """
  1088     if not changesets:
  1095     if not changesets:
  1089         raise util.Abort(_("export requires at least one changeset"))
  1096         raise util.Abort(_("export requires at least one changeset"))
  1090     revs = cmdutil.revrange(repo, changesets)
  1097     revs = cmdutil.revrange(repo, changesets)
  1091     if len(revs) > 1:
  1098     if len(revs) > 1:
  1101 
  1108 
  1102     Search revisions of files for a regular expression.
  1109     Search revisions of files for a regular expression.
  1103 
  1110 
  1104     This command behaves differently than Unix grep. It only accepts
  1111     This command behaves differently than Unix grep. It only accepts
  1105     Python/Perl regexps. It searches repository history, not the
  1112     Python/Perl regexps. It searches repository history, not the
  1106     working directory. It always prints the revision number in which
  1113     working directory. It always prints the revision number in which a
  1107     a match appears.
  1114     match appears.
  1108 
  1115 
  1109     By default, grep only prints output for the first revision of a
  1116     By default, grep only prints output for the first revision of a
  1110     file in which it finds a match. To get it to print every revision
  1117     file in which it finds a match. To get it to print every revision
  1111     that contains a change in match status ("-" for a match that
  1118     that contains a change in match status ("-" for a match that
  1112     becomes a non-match, or "+" for a non-match that becomes a match),
  1119     becomes a non-match, or "+" for a non-match that becomes a match),
  1314 def help_(ui, name=None, with_version=False):
  1321 def help_(ui, name=None, with_version=False):
  1315     """show help for a given topic or a help overview
  1322     """show help for a given topic or a help overview
  1316 
  1323 
  1317     With no arguments, print a list of commands and short help.
  1324     With no arguments, print a list of commands and short help.
  1318 
  1325 
  1319     Given a topic, extension, or command name, print help for that topic."""
  1326     Given a topic, extension, or command name, print help for that
       
  1327     topic."""
  1320     option_lists = []
  1328     option_lists = []
  1321 
  1329 
  1322     def addglobalopts(aliases):
  1330     def addglobalopts(aliases):
  1323         if ui.verbose:
  1331         if ui.verbose:
  1324             option_lists.append((_("global options:"), globalopts))
  1332             option_lists.append((_("global options:"), globalopts))
  1527 
  1535 
  1528 def identify(ui, repo, source=None,
  1536 def identify(ui, repo, source=None,
  1529              rev=None, num=None, id=None, branch=None, tags=None):
  1537              rev=None, num=None, id=None, branch=None, tags=None):
  1530     """identify the working copy or specified revision
  1538     """identify the working copy or specified revision
  1531 
  1539 
  1532     With no revision, print a summary of the current state of the repo.
  1540     With no revision, print a summary of the current state of the
       
  1541     repo.
  1533 
  1542 
  1534     With a path, do a lookup in another repository.
  1543     With a path, do a lookup in another repository.
  1535 
  1544 
  1536     This summary identifies the repository state using one or two parent
  1545     This summary identifies the repository state using one or two
  1537     hash identifiers, followed by a "+" if there are uncommitted changes
  1546     parent hash identifiers, followed by a "+" if there are
  1538     in the working directory, a list of tags for this revision and a branch
  1547     uncommitted changes in the working directory, a list of tags for
  1539     name for non-default branches.
  1548     this revision and a branch name for non-default branches.
  1540     """
  1549     """
  1541 
  1550 
  1542     if not repo and not source:
  1551     if not repo and not source:
  1543         raise util.Abort(_("There is no Mercurial repository here "
  1552         raise util.Abort(_("There is no Mercurial repository here "
  1544                            "(.hg not found)"))
  1553                            "(.hg not found)"))
  1611     text/x-patch to be used). From and Subject headers of email
  1620     text/x-patch to be used). From and Subject headers of email
  1612     message are used as default committer and commit message. All
  1621     message are used as default committer and commit message. All
  1613     text/plain body parts before first diff are added to commit
  1622     text/plain body parts before first diff are added to commit
  1614     message.
  1623     message.
  1615 
  1624 
  1616     If the imported patch was generated by hg export, user and description
  1625     If the imported patch was generated by hg export, user and
  1617     from patch override values from message headers and body. Values
  1626     description from patch override values from message headers and
  1618     given on command line with -m and -u override these.
  1627     body. Values given on command line with -m and -u override these.
  1619 
  1628 
  1620     If --exact is specified, import will set the working directory
  1629     If --exact is specified, import will set the working directory to
  1621     to the parent of each patch before applying it, and will abort
  1630     the parent of each patch before applying it, and will abort if the
  1622     if the resulting changeset has a different ID than the one
  1631     resulting changeset has a different ID than the one recorded in
  1623     recorded in the patch. This may happen due to character set
  1632     the patch. This may happen due to character set problems or other
  1624     problems or other deficiencies in the text patch format.
  1633     deficiencies in the text patch format.
  1625 
  1634 
  1626     With --similarity, hg will attempt to discover renames and copies
  1635     With --similarity, hg will attempt to discover renames and copies
  1627     in the patch in the same way as 'addremove'.
  1636     in the patch in the same way as 'addremove'.
  1628 
  1637 
  1629     To read a patch from standard input, use patch name "-".
  1638     To read a patch from standard input, use patch name "-". See 'hg
  1630     See 'hg help dates' for a list of formats valid for -d/--date.
  1639     help dates' for a list of formats valid for -d/--date.
  1631     """
  1640     """
  1632     patches = (patch1,) + patches
  1641     patches = (patch1,) + patches
  1633 
  1642 
  1634     date = opts.get('date')
  1643     date = opts.get('date')
  1635     if date:
  1644     if date:
  1724 
  1733 
  1725 def incoming(ui, repo, source="default", **opts):
  1734 def incoming(ui, repo, source="default", **opts):
  1726     """show new changesets found in source
  1735     """show new changesets found in source
  1727 
  1736 
  1728     Show new changesets found in the specified path/URL or the default
  1737     Show new changesets found in the specified path/URL or the default
  1729     pull location. These are the changesets that would be pulled if a pull
  1738     pull location. These are the changesets that would be pulled if a
  1730     was requested.
  1739     pull was requested.
  1731 
  1740 
  1732     For remote repository, using --bundle avoids downloading the changesets
  1741     For remote repository, using --bundle avoids downloading the
  1733     twice if the incoming is followed by a pull.
  1742     changesets twice if the incoming is followed by a pull.
  1734 
  1743 
  1735     See pull for valid source format details.
  1744     See pull for valid source format details.
  1736     """
  1745     """
  1737     limit = cmdutil.loglimit(opts)
  1746     limit = cmdutil.loglimit(opts)
  1738     source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
  1747     source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
  1979 
  1988 
  1980     Print a list of version controlled files for the given revision.
  1989     Print a list of version controlled files for the given revision.
  1981     If no revision is given, the first parent of the working directory
  1990     If no revision is given, the first parent of the working directory
  1982     is used, or tip if no revision is checked out.
  1991     is used, or tip if no revision is checked out.
  1983 
  1992 
  1984     With -v flag, print file permissions, symlink and executable bits. With
  1993     With -v flag, print file permissions, symlink and executable bits.
  1985     --debug flag, print file revision hashes.
  1994     With --debug flag, print file revision hashes.
  1986     """
  1995     """
  1987 
  1996 
  1988     if rev and node:
  1997     if rev and node:
  1989         raise util.Abort(_("please specify just one revision"))
  1998         raise util.Abort(_("please specify just one revision"))
  1990 
  1999 
  2010     Files that changed between either parent are marked as changed for
  2019     Files that changed between either parent are marked as changed for
  2011     the next commit and a commit must be performed before any further
  2020     the next commit and a commit must be performed before any further
  2012     updates are allowed. The next commit has two parents.
  2021     updates are allowed. The next commit has two parents.
  2013 
  2022 
  2014     If no revision is specified, the working directory's parent is a
  2023     If no revision is specified, the working directory's parent is a
  2015     head revision, and the current branch contains exactly one other head,
  2024     head revision, and the current branch contains exactly one other
  2016     the other head is merged with by default. Otherwise, an explicit
  2025     head, the other head is merged with by default. Otherwise, an
  2017     revision to merge with must be provided.
  2026     explicit revision to merge with must be provided.
  2018     """
  2027     """
  2019 
  2028 
  2020     if rev and node:
  2029     if rev and node:
  2021         raise util.Abort(_("please specify just one revision"))
  2030         raise util.Abort(_("please specify just one revision"))
  2022     if not node:
  2031     if not node:
  2048     return hg.merge(repo, node, force=force)
  2057     return hg.merge(repo, node, force=force)
  2049 
  2058 
  2050 def outgoing(ui, repo, dest=None, **opts):
  2059 def outgoing(ui, repo, dest=None, **opts):
  2051     """show changesets not found in destination
  2060     """show changesets not found in destination
  2052 
  2061 
  2053     Show changesets not found in the specified destination repository or
  2062     Show changesets not found in the specified destination repository
  2054     the default push location. These are the changesets that would be pushed
  2063     or the default push location. These are the changesets that would
  2055     if a push was requested.
  2064     be pushed if a push was requested.
  2056 
  2065 
  2057     See pull for valid destination format details.
  2066     See pull for valid destination format details.
  2058     """
  2067     """
  2059     limit = cmdutil.loglimit(opts)
  2068     limit = cmdutil.loglimit(opts)
  2060     dest, revs, checkout = hg.parseurl(
  2069     dest, revs, checkout = hg.parseurl(
  2084         displayer.show(repo[n])
  2093         displayer.show(repo[n])
  2085 
  2094 
  2086 def parents(ui, repo, file_=None, **opts):
  2095 def parents(ui, repo, file_=None, **opts):
  2087     """show the parents of the working dir or revision
  2096     """show the parents of the working dir or revision
  2088 
  2097 
  2089     Print the working directory's parent revisions. If a
  2098     Print the working directory's parent revisions. If a revision is
  2090     revision is given via --rev, the parent of that revision
  2099     given via --rev, the parent of that revision will be printed. If a
  2091     will be printed. If a file argument is given, revision in
  2100     file argument is given, revision in which the file was last
  2092     which the file was last changed (before the working directory
  2101     changed (before the working directory revision or the argument to
  2093     revision or the argument to --rev if given) is printed.
  2102     --rev if given) is printed.
  2094     """
  2103     """
  2095     rev = opts.get('rev')
  2104     rev = opts.get('rev')
  2096     if rev:
  2105     if rev:
  2097         ctx = repo[rev]
  2106         ctx = repo[rev]
  2098     else:
  2107     else:
  2124             displayer.show(repo[n])
  2133             displayer.show(repo[n])
  2125 
  2134 
  2126 def paths(ui, repo, search=None):
  2135 def paths(ui, repo, search=None):
  2127     """show aliases for remote repositories
  2136     """show aliases for remote repositories
  2128 
  2137 
  2129     Show definition of symbolic path name NAME. If no name is given, show
  2138     Show definition of symbolic path name NAME. If no name is given,
  2130     definition of available names.
  2139     show definition of available names.
  2131 
  2140 
  2132     Path names are defined in the [paths] section of /etc/mercurial/hgrc
  2141     Path names are defined in the [paths] section of /etc/mercurial/hgrc
  2133     and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
  2142     and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
  2134 
  2143 
  2135     See 'hg help urls' for more information.
  2144     See 'hg help urls' for more information.
  2204     the client has forgotten to pull and merge before pushing.
  2213     the client has forgotten to pull and merge before pushing.
  2205 
  2214 
  2206     If -r is used, the named revision and all its ancestors will be
  2215     If -r is used, the named revision and all its ancestors will be
  2207     pushed to the remote repository.
  2216     pushed to the remote repository.
  2208 
  2217 
  2209     Look at the help text for URLs for important details about ssh:// URLs.
  2218     Look at the help text for URLs for important details about ssh://
  2210     If DESTINATION is omitted, a default path will be used.
  2219     URLs. If DESTINATION is omitted, a default path will be used.
  2211     See 'hg help urls' for more information.
  2220     See 'hg help urls' for more information.
  2212     """
  2221     """
  2213     dest, revs, checkout = hg.parseurl(
  2222     dest, revs, checkout = hg.parseurl(
  2214         ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev'))
  2223         ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev'))
  2215     cmdutil.setremoteconfig(ui, opts)
  2224     cmdutil.setremoteconfig(ui, opts)
  2252 def recover(ui, repo):
  2261 def recover(ui, repo):
  2253     """roll back an interrupted transaction
  2262     """roll back an interrupted transaction
  2254 
  2263 
  2255     Recover from an interrupted commit or pull.
  2264     Recover from an interrupted commit or pull.
  2256 
  2265 
  2257     This command tries to fix the repository status after an interrupted
  2266     This command tries to fix the repository status after an
  2258     operation. It should only be necessary when Mercurial suggests it.
  2267     interrupted operation. It should only be necessary when Mercurial
       
  2268     suggests it.
  2259     """
  2269     """
  2260     if repo.recover():
  2270     if repo.recover():
  2261         return hg.verify(repo)
  2271         return hg.verify(repo)
  2262     return 1
  2272     return 1
  2263 
  2273 
  2264 def remove(ui, repo, *pats, **opts):
  2274 def remove(ui, repo, *pats, **opts):
  2265     """remove the specified files on the next commit
  2275     """remove the specified files on the next commit
  2266 
  2276 
  2267     Schedule the indicated files for removal from the repository.
  2277     Schedule the indicated files for removal from the repository.
  2268 
  2278 
  2269     This only removes files from the current branch, not from the entire
  2279     This only removes files from the current branch, not from the
  2270     project history. -A can be used to remove only files that have already
  2280     entire project history. -A can be used to remove only files that
  2271     been deleted, -f can be used to force deletion, and -Af can be used
  2281     have already been deleted, -f can be used to force deletion, and
  2272     to remove files from the next revision without deleting them.
  2282     -Af can be used to remove files from the next revision without
  2273 
  2283     deleting them.
  2274     The following table details the behavior of remove for different file
  2284 
  2275     states (columns) and option combinations (rows). The file states are
  2285     The following table details the behavior of remove for different
  2276     Added, Clean, Modified and Missing (as reported by hg status). The
  2286     file states (columns) and option combinations (rows). The file
  2277     actions are Warn, Remove (from branch) and Delete (from disk).
  2287     states are Added, Clean, Modified and Missing (as reported by hg
       
  2288     status). The actions are Warn, Remove (from branch) and Delete
       
  2289     (from disk).
  2278 
  2290 
  2279            A  C  M  !
  2291            A  C  M  !
  2280     none   W  RD W  R
  2292     none   W  RD W  R
  2281     -f     R  RD RD R
  2293     -f     R  RD RD R
  2282     -A     W  W  W  R
  2294     -A     W  W  W  R
  2317     repo.remove(remove, unlink=not after)
  2329     repo.remove(remove, unlink=not after)
  2318 
  2330 
  2319 def rename(ui, repo, *pats, **opts):
  2331 def rename(ui, repo, *pats, **opts):
  2320     """rename files; equivalent of copy + remove
  2332     """rename files; equivalent of copy + remove
  2321 
  2333 
  2322     Mark dest as copies of sources; mark sources for deletion. If
  2334     Mark dest as copies of sources; mark sources for deletion. If dest
  2323     dest is a directory, copies are put in that directory. If dest is
  2335     is a directory, copies are put in that directory. If dest is a
  2324     a file, there can only be one source.
  2336     file, there can only be one source.
  2325 
  2337 
  2326     By default, this command copies the contents of files as they
  2338     By default, this command copies the contents of files as they
  2327     exist in the working directory. If invoked with --after, the
  2339     exist in the working directory. If invoked with --after, the
  2328     operation is recorded, but no copying is performed.
  2340     operation is recorded, but no copying is performed.
  2329 
  2341 
  2402     This restores the contents of the affected files to an unmodified
  2414     This restores the contents of the affected files to an unmodified
  2403     state and unschedules adds, removes, copies, and renames. If the
  2415     state and unschedules adds, removes, copies, and renames. If the
  2404     working directory has two parents, you must explicitly specify the
  2416     working directory has two parents, you must explicitly specify the
  2405     revision to revert to.
  2417     revision to revert to.
  2406 
  2418 
  2407     Using the -r option, revert the given files or directories to their
  2419     Using the -r option, revert the given files or directories to
  2408     contents as of a specific revision. This can be helpful to "roll
  2420     their contents as of a specific revision. This can be helpful to
  2409     back" some or all of an earlier change.
  2421     "roll back" some or all of an earlier change. See 'hg help dates'
  2410     See 'hg help dates' for a list of formats valid for -d/--date.
  2422     for a list of formats valid for -d/--date.
  2411 
  2423 
  2412     Revert modifies the working directory. It does not commit any
  2424     Revert modifies the working directory. It does not commit any
  2413     changes, or change the parent of the working directory. If you
  2425     changes, or change the parent of the working directory. If you
  2414     revert to a revision other than the parent of the working
  2426     revert to a revision other than the parent of the working
  2415     directory, the reverted files will thus appear modified
  2427     directory, the reverted files will thus appear modified
  2416     afterwards.
  2428     afterwards.
  2417 
  2429 
  2418     If a file has been deleted, it is restored. If the executable
  2430     If a file has been deleted, it is restored. If the executable mode
  2419     mode of a file was changed, it is reset.
  2431     of a file was changed, it is reset.
  2420 
  2432 
  2421     If names are given, all files matching the names are reverted.
  2433     If names are given, all files matching the names are reverted.
  2422     If no arguments are given, no files are reverted.
  2434     If no arguments are given, no files are reverted.
  2423 
  2435 
  2424     Modified files are saved with a .orig suffix before reverting.
  2436     Modified files are saved with a .orig suffix before reverting.
  2785 
  2797 
  2786     Tags are used to name particular revisions of the repository and are
  2798     Tags are used to name particular revisions of the repository and are
  2787     very useful to compare different revisions, to go back to significant
  2799     very useful to compare different revisions, to go back to significant
  2788     earlier versions or to mark branch points as releases, etc.
  2800     earlier versions or to mark branch points as releases, etc.
  2789 
  2801 
  2790     If no revision is given, the parent of the working directory is used,
  2802     If no revision is given, the parent of the working directory is
  2791     or tip if no revision is checked out.
  2803     used, or tip if no revision is checked out.
  2792 
  2804 
  2793     To facilitate version control, distribution, and merging of tags,
  2805     To facilitate version control, distribution, and merging of tags,
  2794     they are stored as a file named ".hgtags" which is managed
  2806     they are stored as a file named ".hgtags" which is managed
  2795     similarly to other project files and can be hand-edited if
  2807     similarly to other project files and can be hand-edited if
  2796     necessary. The file '.hg/localtags' is used for local tags (not
  2808     necessary. The file '.hg/localtags' is used for local tags (not
  2843     repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
  2855     repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
  2844 
  2856 
  2845 def tags(ui, repo):
  2857 def tags(ui, repo):
  2846     """list repository tags
  2858     """list repository tags
  2847 
  2859 
  2848     This lists both regular and local tags. When the -v/--verbose switch
  2860     This lists both regular and local tags. When the -v/--verbose
  2849     is used, a third column "local" is printed for local tags.
  2861     switch is used, a third column "local" is printed for local tags.
  2850     """
  2862     """
  2851 
  2863 
  2852     l = repo.tagslist()
  2864     l = repo.tagslist()
  2853     l.reverse()
  2865     l.reverse()
  2854     hexfunc = ui.debugflag and hex or short
  2866     hexfunc = ui.debugflag and hex or short
  2908     return postincoming(ui, repo, modheads, opts.get('update'), None)
  2920     return postincoming(ui, repo, modheads, opts.get('update'), None)
  2909 
  2921 
  2910 def update(ui, repo, node=None, rev=None, clean=False, date=None):
  2922 def update(ui, repo, node=None, rev=None, clean=False, date=None):
  2911     """update working directory
  2923     """update working directory
  2912 
  2924 
  2913     Update the repository's working directory to the specified revision,
  2925     Update the repository's working directory to the specified
  2914     or the tip of the current branch if none is specified. Use null as
  2926     revision, or the tip of the current branch if none is specified.
  2915     the revision to remove the working copy (like 'hg clone -U').
  2927     Use null as the revision to remove the working copy (like 'hg
       
  2928     clone -U').
  2916 
  2929 
  2917     When the working dir contains no uncommitted changes, it will be
  2930     When the working dir contains no uncommitted changes, it will be
  2918     replaced by the state of the requested revision from the repo. When
  2931     replaced by the state of the requested revision from the repo.
  2919     the requested revision is on a different branch, the working dir
  2932     When the requested revision is on a different branch, the working
  2920     will additionally be switched to that branch.
  2933     dir will additionally be switched to that branch.
  2921 
  2934 
  2922     When there are uncommitted changes, use option -C to discard them,
  2935     When there are uncommitted changes, use option -C to discard them,
  2923     forcibly replacing the state of the working dir with the requested
  2936     forcibly replacing the state of the working dir with the requested
  2924     revision.
  2937     revision.
  2925 
  2938 
  2928     and one of them is an ancestor of the other, then the new working
  2941     and one of them is an ancestor of the other, then the new working
  2929     directory will contain the requested revision merged with the
  2942     directory will contain the requested revision merged with the
  2930     uncommitted changes. Otherwise, the update will fail with a
  2943     uncommitted changes. Otherwise, the update will fail with a
  2931     suggestion to use 'merge' or 'update -C' instead.
  2944     suggestion to use 'merge' or 'update -C' instead.
  2932 
  2945 
  2933     If you want to update just one file to an older revision, use revert.
  2946     If you want to update just one file to an older revision, use
       
  2947     revert.
  2934 
  2948 
  2935     See 'hg help dates' for a list of formats valid for --date.
  2949     See 'hg help dates' for a list of formats valid for --date.
  2936     """
  2950     """
  2937     if rev and node:
  2951     if rev and node:
  2938         raise util.Abort(_("please specify just one revision"))
  2952         raise util.Abort(_("please specify just one revision"))