mercurial/commands.py
changeset 9249 16f4cfc69e4f
parent 9219 3f650f6aa130
child 9280 b694531a5aa7
equal deleted inserted replaced
9241:d98cef25b5af 9249:16f4cfc69e4f
    19 # Commands start here, listed alphabetically
    19 # Commands start here, listed alphabetically
    20 
    20 
    21 def add(ui, repo, *pats, **opts):
    21 def add(ui, repo, *pats, **opts):
    22     """add the specified files on the next commit
    22     """add the specified files on the next commit
    23 
    23 
    24     Schedule files to be version controlled and added to the repository.
    24     Schedule files to be version controlled and added to the
    25 
    25     repository.
    26     The files will be added to the repository at the next commit. To undo an
    26 
    27     add before that, see hg forget.
    27     The files will be added to the repository at the next commit. To
       
    28     undo an add before that, see hg forget.
    28 
    29 
    29     If no names are given, add all files to the repository.
    30     If no names are given, add all files to the repository.
    30     """
    31     """
    31 
    32 
    32     bad = []
    33     bad = []
    47     return bad and 1 or 0
    48     return bad and 1 or 0
    48 
    49 
    49 def addremove(ui, repo, *pats, **opts):
    50 def addremove(ui, repo, *pats, **opts):
    50     """add all new files, delete all missing files
    51     """add all new files, delete all missing files
    51 
    52 
    52     Add all new files and remove all missing files from the repository.
    53     Add all new files and remove all missing files from the
    53 
    54     repository.
    54     New files are ignored if they match any of the patterns in .hgignore. As
    55 
    55     with add, these changes take effect at the next commit.
    56     New files are ignored if they match any of the patterns in
    56 
    57     .hgignore. As with add, these changes take effect at the next
    57     Use the -s/--similarity option to detect renamed files. With a parameter
    58     commit.
    58     greater than 0, this compares every removed file with every added file and
    59 
    59     records those similar enough as renames. This option takes a percentage
    60     Use the -s/--similarity option to detect renamed files. With a
    60     between 0 (disabled) and 100 (files must be identical) as its parameter.
    61     parameter greater than 0, this compares every removed file with
    61     Detecting renamed files this way can be expensive.
    62     every added file and records those similar enough as renames. This
       
    63     option takes a percentage between 0 (disabled) and 100 (files must
       
    64     be identical) as its parameter. Detecting renamed files this way
       
    65     can be expensive.
    62     """
    66     """
    63     try:
    67     try:
    64         sim = float(opts.get('similarity') or 0)
    68         sim = float(opts.get('similarity') or 0)
    65     except ValueError:
    69     except ValueError:
    66         raise util.Abort(_('similarity must be a number'))
    70         raise util.Abort(_('similarity must be a number'))
    69     return cmdutil.addremove(repo, pats, opts, similarity=sim/100.)
    73     return cmdutil.addremove(repo, pats, opts, similarity=sim/100.)
    70 
    74 
    71 def annotate(ui, repo, *pats, **opts):
    75 def annotate(ui, repo, *pats, **opts):
    72     """show changeset information by line for each file
    76     """show changeset information by line for each file
    73 
    77 
    74     List changes in files, showing the revision id responsible for each line
    78     List changes in files, showing the revision id responsible for
    75 
    79     each line
    76     This command is useful for discovering when a change was made and by whom.
    80 
    77 
    81     This command is useful for discovering when a change was made and
    78     Without the -a/--text option, annotate will avoid processing files it
    82     by whom.
    79     detects as binary. With -a, annotate will annotate the file anyway,
    83 
    80     although the results will probably be neither useful nor desirable.
    84     Without the -a/--text option, annotate will avoid processing files
       
    85     it detects as binary. With -a, annotate will annotate the file
       
    86     anyway, although the results will probably be neither useful
       
    87     nor desirable.
    81     """
    88     """
    82     datefunc = ui.quiet and util.shortdate or util.datestr
    89     datefunc = ui.quiet and util.shortdate or util.datestr
    83     getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
    90     getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
    84 
    91 
    85     if not pats:
    92     if not pats:
   129                 ui.write("%s: %s" % (" ".join(p), l[1]))
   136                 ui.write("%s: %s" % (" ".join(p), l[1]))
   130 
   137 
   131 def archive(ui, repo, dest, **opts):
   138 def archive(ui, repo, dest, **opts):
   132     '''create an unversioned archive of a repository revision
   139     '''create an unversioned archive of a repository revision
   133 
   140 
   134     By default, the revision used is the parent of the working directory; use
   141     By default, the revision used is the parent of the working
   135     -r/--rev to specify a different revision.
   142     directory; use -r/--rev to specify a different revision.
   136 
   143 
   137     To specify the type of archive to create, use -t/--type. Valid types are::
   144     To specify the type of archive to create, use -t/--type. Valid
       
   145     types are::
   138 
   146 
   139       "files" (default): a directory full of files
   147       "files" (default): a directory full of files
   140       "tar": tar archive, uncompressed
   148       "tar": tar archive, uncompressed
   141       "tbz2": tar archive, compressed using bzip2
   149       "tbz2": tar archive, compressed using bzip2
   142       "tgz": tar archive, compressed using gzip
   150       "tgz": tar archive, compressed using gzip
   143       "uzip": zip archive, uncompressed
   151       "uzip": zip archive, uncompressed
   144       "zip": zip archive, compressed using deflate
   152       "zip": zip archive, compressed using deflate
   145 
   153 
   146     The exact name of the destination archive or directory is given using a
   154     The exact name of the destination archive or directory is given
   147     format string; see 'hg help export' for details.
   155     using a format string; see 'hg help export' for details.
   148 
   156 
   149     Each member added to an archive file has a directory prefix prepended. Use
   157     Each member added to an archive file has a directory prefix
   150     -p/--prefix to specify a format string for the prefix. The default is the
   158     prepended. Use -p/--prefix to specify a format string for the
   151     basename of the archive, with suffixes removed.
   159     prefix. The default is the basename of the archive, with suffixes
       
   160     removed.
   152     '''
   161     '''
   153 
   162 
   154     ctx = repo[opts.get('rev')]
   163     ctx = repo[opts.get('rev')]
   155     if not ctx:
   164     if not ctx:
   156         raise util.Abort(_('no working directory: please specify a revision'))
   165         raise util.Abort(_('no working directory: please specify a revision'))
   171                      matchfn, prefix)
   180                      matchfn, prefix)
   172 
   181 
   173 def backout(ui, repo, node=None, rev=None, **opts):
   182 def backout(ui, repo, node=None, rev=None, **opts):
   174     '''reverse effect of earlier changeset
   183     '''reverse effect of earlier changeset
   175 
   184 
   176     Commit the backed out changes as a new changeset. The new changeset is a
   185     Commit the backed out changes as a new changeset. The new
   177     child of the backed out changeset.
   186     changeset is a child of the backed out changeset.
   178 
   187 
   179     If you backout a changeset other than the tip, a new head is created. This
   188     If you backout a changeset other than the tip, a new head is
   180     head will be the new tip and you should merge this backout changeset with
   189     created. This head will be the new tip and you should merge this
   181     another head.
   190     backout changeset with another head.
   182 
   191 
   183     The --merge option remembers the parent of the working directory before
   192     The --merge option remembers the parent of the working directory
   184     starting the backout, then merges the new head with that changeset
   193     before starting the backout, then merges the new head with that
   185     afterwards. This saves you from doing the merge by hand. The result of
   194     changeset afterwards. This saves you from doing the merge by hand.
   186     this merge is not committed, as with a normal merge.
   195     The result of this merge is not committed, as with a normal merge.
   187 
   196 
   188     See 'hg help dates' for a list of formats valid for -d/--date.
   197     See 'hg help dates' for a list of formats valid for -d/--date.
   189     '''
   198     '''
   190     if rev and node:
   199     if rev and node:
   191         raise util.Abort(_("please specify just one revision"))
   200         raise util.Abort(_("please specify just one revision"))
   259 
   268 
   260 def bisect(ui, repo, rev=None, extra=None, command=None,
   269 def bisect(ui, repo, rev=None, extra=None, command=None,
   261                reset=None, good=None, bad=None, skip=None, noupdate=None):
   270                reset=None, good=None, bad=None, skip=None, noupdate=None):
   262     """subdivision search of changesets
   271     """subdivision search of changesets
   263 
   272 
   264     This command helps to find changesets which introduce problems. To use,
   273     This command helps to find changesets which introduce problems. To
   265     mark the earliest changeset you know exhibits the problem as bad, then
   274     use, mark the earliest changeset you know exhibits the problem as
   266     mark the latest changeset which is free from the problem as good. Bisect
   275     bad, then mark the latest changeset which is free from the problem
   267     will update your working directory to a revision for testing (unless the
   276     as good. Bisect will update your working directory to a revision
   268     -U/--noupdate option is specified). Once you have performed tests, mark
   277     for testing (unless the -U/--noupdate option is specified). Once
   269     the working directory as good or bad, and bisect will either update to
   278     you have performed tests, mark the working directory as good or
   270     another candidate changeset or announce that it has found the bad
   279     bad, and bisect will either update to another candidate changeset
   271     revision.
   280     or announce that it has found the bad revision.
   272 
   281 
   273     As a shortcut, you can also use the revision argument to mark a revision
   282     As a shortcut, you can also use the revision argument to mark a
   274     as good or bad without checking it out first.
   283     revision as good or bad without checking it out first.
   275 
   284 
   276     If you supply a command, it will be used for automatic bisection. Its exit
   285     If you supply a command, it will be used for automatic bisection.
   277     status will be used to mark revisions as good or bad: status 0 means good,
   286     Its exit status will be used to mark revisions as good or bad:
   278     125 means to skip the revision, 127 (command not found) will abort the
   287     status 0 means good, 125 means to skip the revision, 127
   279     bisection, and any other non-zero exit status means the revision is bad.
   288     (command not found) will abort the bisection, and any other
       
   289     non-zero exit status means the revision is bad.
   280     """
   290     """
   281     def print_result(nodes, good):
   291     def print_result(nodes, good):
   282         displayer = cmdutil.show_changeset(ui, repo, {})
   292         displayer = cmdutil.show_changeset(ui, repo, {})
   283         if len(nodes) == 1:
   293         if len(nodes) == 1:
   284             # narrowed it down to a single revision
   294             # narrowed it down to a single revision
   396             return hg.clean(repo, node)
   406             return hg.clean(repo, node)
   397 
   407 
   398 def branch(ui, repo, label=None, **opts):
   408 def branch(ui, repo, label=None, **opts):
   399     """set or show the current branch name
   409     """set or show the current branch name
   400 
   410 
   401     With no argument, show the current branch name. With one argument, set the
   411     With no argument, show the current branch name. With one argument,
   402     working directory branch name (the branch will not exist in the repository
   412     set the working directory branch name (the branch will not exist
   403     until the next commit). Standard practice recommends that primary
   413     in the repository until the next commit). Standard practice
   404     development take place on the 'default' branch.
   414     recommends that primary development take place on the 'default'
   405 
   415     branch.
   406     Unless -f/--force is specified, branch will not let you set a branch name
   416 
   407     that already exists, even if it's inactive.
   417     Unless -f/--force is specified, branch will not let you set a
   408 
   418     branch name that already exists, even if it's inactive.
   409     Use -C/--clean to reset the working directory branch to that of the parent
   419 
   410     of the working directory, negating a previous branch change.
   420     Use -C/--clean to reset the working directory branch to that of
   411 
   421     the parent of the working directory, negating a previous branch
   412     Use the command 'hg update' to switch to an existing branch. Use 'hg
   422     change.
   413     commit --close-branch' to mark this branch as closed.
   423 
       
   424     Use the command 'hg update' to switch to an existing branch. Use
       
   425     'hg commit --close-branch' to mark this branch as closed.
   414     """
   426     """
   415 
   427 
   416     if opts.get('clean'):
   428     if opts.get('clean'):
   417         label = repo[None].parents()[0].branch()
   429         label = repo[None].parents()[0].branch()
   418         repo.dirstate.setbranch(label)
   430         repo.dirstate.setbranch(label)
   428         ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch()))
   440         ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch()))
   429 
   441 
   430 def branches(ui, repo, active=False, closed=False):
   442 def branches(ui, repo, active=False, closed=False):
   431     """list repository named branches
   443     """list repository named branches
   432 
   444 
   433     List the repository's named branches, indicating which ones are inactive.
   445     List the repository's named branches, indicating which ones are
   434     If -c/--closed is specified, also list branches which have been marked
   446     inactive. If -c/--closed is specified, also list branches which have
   435     closed (see hg commit --close-branch).
   447     been marked closed (see hg commit --close-branch).
   436 
   448 
   437     If -a/--active is specified, only show active branches. A branch is
   449     If -a/--active is specified, only show active branches. A branch
   438     considered active if it contains repository heads.
   450     is considered active if it contains repository heads.
   439 
   451 
   440     Use the command 'hg update' to switch to an existing branch.
   452     Use the command 'hg update' to switch to an existing branch.
   441     """
   453     """
   442 
   454 
   443     hexfunc = ui.debugflag and hex or short
   455     hexfunc = ui.debugflag and hex or short
   470                 ui.write("%s %s:%s%s\n" % data)
   482                 ui.write("%s %s:%s%s\n" % data)
   471 
   483 
   472 def bundle(ui, repo, fname, dest=None, **opts):
   484 def bundle(ui, repo, fname, dest=None, **opts):
   473     """create a changegroup file
   485     """create a changegroup file
   474 
   486 
   475     Generate a compressed changegroup file collecting changesets not known to
   487     Generate a compressed changegroup file collecting changesets not
   476     be in another repository.
   488     known to be in another repository.
   477 
   489 
   478     If no destination repository is specified the destination is assumed to
   490     If no destination repository is specified the destination is
   479     have all the nodes specified by one or more --base parameters. To create a
   491     assumed to have all the nodes specified by one or more --base
   480     bundle containing all changesets, use -a/--all (or --base null).
   492     parameters. To create a bundle containing all changesets, use
   481 
   493     -a/--all (or --base null).
   482     You can change compression method with the -t/--type option. The available
   494 
   483     compression methods are: none, bzip2, and gzip (by default, bundles are
   495     You can change compression method with the -t/--type option.
   484     compressed using bzip2).
   496     The available compression methods are: none, bzip2, and
   485 
   497     gzip (by default, bundles are compressed using bzip2).
   486     The bundle file can then be transferred using conventional means and
   498 
   487     applied to another repository with the unbundle or pull command. This is
   499     The bundle file can then be transferred using conventional means
   488     useful when direct push and pull are not available or when exporting an
   500     and applied to another repository with the unbundle or pull
   489     entire repository is undesirable.
   501     command. This is useful when direct push and pull are not
   490 
   502     available or when exporting an entire repository is undesirable.
   491     Applying bundles preserves all changeset contents including permissions,
   503 
   492     copy/rename information, and revision history.
   504     Applying bundles preserves all changeset contents including
       
   505     permissions, copy/rename information, and revision history.
   493     """
   506     """
   494     revs = opts.get('rev') or None
   507     revs = opts.get('rev') or None
   495     if revs:
   508     if revs:
   496         revs = [repo.lookup(rev) for rev in revs]
   509         revs = [repo.lookup(rev) for rev in revs]
   497     if opts.get('all'):
   510     if opts.get('all'):
   544     changegroup.writebundle(cg, fname, bundletype)
   557     changegroup.writebundle(cg, fname, bundletype)
   545 
   558 
   546 def cat(ui, repo, file1, *pats, **opts):
   559 def cat(ui, repo, file1, *pats, **opts):
   547     """output the current or given revision of files
   560     """output the current or given revision of files
   548 
   561 
   549     Print the specified files as they were at the given revision. If no
   562     Print the specified files as they were at the given revision. If
   550     revision is given, the parent of the working directory is used, or tip if
   563     no revision is given, the parent of the working directory is used,
   551     no revision is checked out.
   564     or tip if no revision is checked out.
   552 
   565 
   553     Output may be to a file, in which case the name of the file is given using
   566     Output may be to a file, in which case the name of the file is
   554     a format string. The formatting rules are the same as for the export
   567     given using a format string. The formatting rules are the same as
   555     command, with the following additions::
   568     for the export command, with the following additions::
   556 
   569 
   557       %s   basename of file being printed
   570       %s   basename of file being printed
   558       %d   dirname of file being printed, or '.' if in repository root
   571       %d   dirname of file being printed, or '.' if in repository root
   559       %p   root-relative path name of file being printed
   572       %p   root-relative path name of file being printed
   560     """
   573     """
   573 def clone(ui, source, dest=None, **opts):
   586 def clone(ui, source, dest=None, **opts):
   574     """make a copy of an existing repository
   587     """make a copy of an existing repository
   575 
   588 
   576     Create a copy of an existing repository in a new directory.
   589     Create a copy of an existing repository in a new directory.
   577 
   590 
   578     If no destination directory name is specified, it defaults to the basename
   591     If no destination directory name is specified, it defaults to the
   579     of the source.
   592     basename of the source.
   580 
   593 
   581     The location of the source is added to the new repository's .hg/hgrc file,
   594     The location of the source is added to the new repository's
   582     as the default to be used for future pulls.
   595     .hg/hgrc file, as the default to be used for future pulls.
   583 
   596 
   584     If you use the -r/--rev option to clone up to a specific revision, no
   597     If you use the -r/--rev option to clone up to a specific revision,
   585     subsequent revisions (including subsequent tags) will be present in the
   598     no subsequent revisions (including subsequent tags) will be
   586     cloned repository. This option implies --pull, even on local repositories.
   599     present in the cloned repository. This option implies --pull, even
   587 
   600     on local repositories.
   588     By default, clone will check out the head of the 'default' branch. If the
   601 
   589     -U/--noupdate option is used, the new clone will contain only a repository
   602     By default, clone will check out the head of the 'default' branch.
   590     (.hg) and no working copy (the working copy parent is the null revision).
   603     If the -U/--noupdate option is used, the new clone will contain
       
   604     only a repository (.hg) and no working copy (the working copy
       
   605     parent is the null revision).
   591 
   606 
   592     See 'hg help urls' for valid source format details.
   607     See 'hg help urls' for valid source format details.
   593 
   608 
   594     It is possible to specify an ssh:// URL as the destination, but no
   609     It is possible to specify an ssh:// URL as the destination, but no
   595     .hg/hgrc and working directory will be created on the remote side. Please
   610     .hg/hgrc and working directory will be created on the remote side.
   596     see 'hg help urls' for important details about ssh:// URLs.
   611     Please see 'hg help urls' for important details about ssh:// URLs.
   597 
   612 
   598     For efficiency, hardlinks are used for cloning whenever the source and
   613     For efficiency, hardlinks are used for cloning whenever the source
   599     destination are on the same filesystem (note this applies only to the
   614     and destination are on the same filesystem (note this applies only
   600     repository data, not to the checked out files). Some filesystems, such as
   615     to the repository data, not to the checked out files). Some
   601     AFS, implement hardlinking incorrectly, but do not report errors. In these
   616     filesystems, such as AFS, implement hardlinking incorrectly, but
   602     cases, use the --pull option to avoid hardlinking.
   617     do not report errors. In these cases, use the --pull option to
   603 
   618     avoid hardlinking.
   604     In some cases, you can clone repositories and checked out files using full
   619 
   605     hardlinks with ::
   620     In some cases, you can clone repositories and checked out files
       
   621     using full hardlinks with ::
   606 
   622 
   607       $ cp -al REPO REPOCLONE
   623       $ cp -al REPO REPOCLONE
   608 
   624 
   609     This is the fastest way to clone, but it is not always safe. The operation
   625     This is the fastest way to clone, but it is not always safe. The
   610     is not atomic (making sure REPO is not modified during the operation is up
   626     operation is not atomic (making sure REPO is not modified during
   611     to you) and you have to make sure your editor breaks hardlinks (Emacs and
   627     the operation is up to you) and you have to make sure your editor
   612     most Linux Kernel tools do so). Also, this is not compatible with certain
   628     breaks hardlinks (Emacs and most Linux Kernel tools do so). Also,
   613     extensions that place their metadata under the .hg directory, such as mq.
   629     this is not compatible with certain extensions that place their
       
   630     metadata under the .hg directory, such as mq.
   614     """
   631     """
   615     hg.clone(cmdutil.remoteui(ui, opts), source, dest,
   632     hg.clone(cmdutil.remoteui(ui, opts), source, dest,
   616              pull=opts.get('pull'),
   633              pull=opts.get('pull'),
   617              stream=opts.get('uncompressed'),
   634              stream=opts.get('uncompressed'),
   618              rev=opts.get('rev'),
   635              rev=opts.get('rev'),
   620 
   637 
   621 def commit(ui, repo, *pats, **opts):
   638 def commit(ui, repo, *pats, **opts):
   622     """commit the specified files or all outstanding changes
   639     """commit the specified files or all outstanding changes
   623 
   640 
   624     Commit changes to the given files into the repository. Unlike a
   641     Commit changes to the given files into the repository. Unlike a
   625     centralized RCS, this operation is a local operation. See hg push for a
   642     centralized RCS, this operation is a local operation. See hg push
   626     way to actively distribute your changes.
   643     for a way to actively distribute your changes.
   627 
   644 
   628     If a list of files is omitted, all changes reported by "hg status" will be
   645     If a list of files is omitted, all changes reported by "hg status"
   629     committed.
   646     will be committed.
   630 
   647 
   631     If you are committing the result of a merge, do not provide any filenames
   648     If you are committing the result of a merge, do not provide any
   632     or -I/-X filters.
   649     filenames or -I/-X filters.
   633 
   650 
   634     If no commit message is specified, the configured editor is started to
   651     If no commit message is specified, the configured editor is
   635     prompt you for a message.
   652     started to prompt you for a message.
   636 
   653 
   637     See 'hg help dates' for a list of formats valid for -d/--date.
   654     See 'hg help dates' for a list of formats valid for -d/--date.
   638     """
   655     """
   639     extra = {}
   656     extra = {}
   640     if opts.get('close_branch'):
   657     if opts.get('close_branch'):
   668         ui.write(_('committed changeset %d:%s\n') % (rev, short(node)))
   685         ui.write(_('committed changeset %d:%s\n') % (rev, short(node)))
   669 
   686 
   670 def copy(ui, repo, *pats, **opts):
   687 def copy(ui, repo, *pats, **opts):
   671     """mark files as copied for the next commit
   688     """mark files as copied for the next commit
   672 
   689 
   673     Mark dest as having copies of source files. If dest is a directory, copies
   690     Mark dest as having copies of source files. If dest is a
   674     are put in that directory. If dest is a file, the source must be a single
   691     directory, copies are put in that directory. If dest is a file,
   675     file.
   692     the source must be a single file.
   676 
   693 
   677     By default, this command copies the contents of files as they exist in the
   694     By default, this command copies the contents of files as they
   678     working directory. If invoked with -A/--after, the operation is recorded,
   695     exist in the working directory. If invoked with -A/--after, the
   679     but no copying is performed.
   696     operation is recorded, but no copying is performed.
   680 
   697 
   681     This command takes effect with the next commit. To undo a copy before
   698     This command takes effect with the next commit. To undo a copy
   682     that, see hg revert.
   699     before that, see hg revert.
   683     """
   700     """
   684     wlock = repo.wlock(False)
   701     wlock = repo.wlock(False)
   685     try:
   702     try:
   686         return cmdutil.copy(ui, repo, pats, opts)
   703         return cmdutil.copy(ui, repo, pats, opts)
   687     finally:
   704     finally:
   780 def showconfig(ui, repo, *values, **opts):
   797 def showconfig(ui, repo, *values, **opts):
   781     """show combined config settings from all hgrc files
   798     """show combined config settings from all hgrc files
   782 
   799 
   783     With no arguments, print names and values of all config items.
   800     With no arguments, print names and values of all config items.
   784 
   801 
   785     With one argument of the form section.name, print just the value of that
   802     With one argument of the form section.name, print just the value
   786     config item.
   803     of that config item.
   787 
   804 
   788     With multiple arguments, print names and values of all config items with
   805     With multiple arguments, print names and values of all config
   789     matching section names.
   806     items with matching section names.
   790 
   807 
   791     With --debug, the source (filename and line number) is printed for each
   808     With --debug, the source (filename and line number) is printed
   792     config item.
   809     for each config item.
   793     """
   810     """
   794 
   811 
   795     untrusted = bool(opts.get('untrusted'))
   812     untrusted = bool(opts.get('untrusted'))
   796     if values:
   813     if values:
   797         if len([v for v in values if '.' in v]) > 1:
   814         if len([v for v in values if '.' in v]) > 1:
   814             ui.write('%s=%s\n' % (sectname, value))
   831             ui.write('%s=%s\n' % (sectname, value))
   815 
   832 
   816 def debugsetparents(ui, repo, rev1, rev2=None):
   833 def debugsetparents(ui, repo, rev1, rev2=None):
   817     """manually set the parents of the current working directory
   834     """manually set the parents of the current working directory
   818 
   835 
   819     This is useful for writing repository conversion tools, but should be used
   836     This is useful for writing repository conversion tools, but should
   820     with care.
   837     be used with care.
   821     """
   838     """
   822 
   839 
   823     if not rev2:
   840     if not rev2:
   824         rev2 = hex(nullid)
   841         rev2 = hex(nullid)
   825 
   842 
  1049 
  1066 
  1050     Show differences between revisions for the specified files.
  1067     Show differences between revisions for the specified files.
  1051 
  1068 
  1052     Differences between files are shown using the unified diff format.
  1069     Differences between files are shown using the unified diff format.
  1053 
  1070 
  1054     NOTE: diff may generate unexpected results for merges, as it will default
  1071     NOTE: diff may generate unexpected results for merges, as it will
  1055     to comparing against the working directory's first parent changeset if no
  1072     default to comparing against the working directory's first parent
  1056     revisions are specified.
  1073     changeset if no revisions are specified.
  1057 
  1074 
  1058     When two revision arguments are given, then changes are shown between
  1075     When two revision arguments are given, then changes are shown
  1059     those revisions. If only one revision is specified then that revision is
  1076     between those revisions. If only one revision is specified then
  1060     compared to the working directory, and, when no revisions are specified,
  1077     that revision is compared to the working directory, and, when no
  1061     the working directory files are compared to its parent.
  1078     revisions are specified, the working directory files are compared
  1062 
  1079     to its parent.
  1063     Without the -a/--text option, diff will avoid generating diffs of files it
  1080 
  1064     detects as binary. With -a, diff will generate a diff anyway, probably
  1081     Without the -a/--text option, diff will avoid generating diffs of
  1065     with undesirable results.
  1082     files it detects as binary. With -a, diff will generate a diff
  1066 
  1083     anyway, probably with undesirable results.
  1067     Use the -g/--git option to generate diffs in the git extended diff format.
  1084 
  1068     For more information, read 'hg help diffs'.
  1085     Use the -g/--git option to generate diffs in the git extended diff
       
  1086     format. For more information, read 'hg help diffs'.
  1069     """
  1087     """
  1070 
  1088 
  1071     revs = opts.get('rev')
  1089     revs = opts.get('rev')
  1072     change = opts.get('change')
  1090     change = opts.get('change')
  1073 
  1091 
  1088 def export(ui, repo, *changesets, **opts):
  1106 def export(ui, repo, *changesets, **opts):
  1089     """dump the header and diffs for one or more changesets
  1107     """dump the header and diffs for one or more changesets
  1090 
  1108 
  1091     Print the changeset header and diffs for one or more revisions.
  1109     Print the changeset header and diffs for one or more revisions.
  1092 
  1110 
  1093     The information shown in the changeset header is: author, changeset hash,
  1111     The information shown in the changeset header is: author,
  1094     parent(s) and commit comment.
  1112     changeset hash, parent(s) and commit comment.
  1095 
  1113 
  1096     NOTE: export may generate unexpected diff output for merge changesets, as
  1114     NOTE: export may generate unexpected diff output for merge
  1097     it will compare the merge changeset against its first parent only.
  1115     changesets, as it will compare the merge changeset against its
  1098 
  1116     first parent only.
  1099     Output may be to a file, in which case the name of the file is given using
  1117 
  1100     a format string. The formatting rules are as follows::
  1118     Output may be to a file, in which case the name of the file is
       
  1119     given using a format string. The formatting rules are as follows::
  1101 
  1120 
  1102       %%   literal "%" character
  1121       %%   literal "%" character
  1103       %H   changeset hash (40 bytes of hexadecimal)
  1122       %H   changeset hash (40 bytes of hexadecimal)
  1104       %N   number of patches being generated
  1123       %N   number of patches being generated
  1105       %R   changeset revision number
  1124       %R   changeset revision number
  1106       %b   basename of the exporting repository
  1125       %b   basename of the exporting repository
  1107       %h   short-form changeset hash (12 bytes of hexadecimal)
  1126       %h   short-form changeset hash (12 bytes of hexadecimal)
  1108       %n   zero-padded sequence number, starting at 1
  1127       %n   zero-padded sequence number, starting at 1
  1109       %r   zero-padded changeset revision number
  1128       %r   zero-padded changeset revision number
  1110 
  1129 
  1111     Without the -a/--text option, export will avoid generating diffs of files
  1130     Without the -a/--text option, export will avoid generating diffs
  1112     it detects as binary. With -a, export will generate a diff anyway,
  1131     of files it detects as binary. With -a, export will generate a
  1113     probably with undesirable results.
  1132     diff anyway, probably with undesirable results.
  1114 
  1133 
  1115     Use the -g/--git option to generate diffs in the git extended diff format.
  1134     Use the -g/--git option to generate diffs in the git extended diff
  1116     See 'hg help diffs' for more information.
  1135     format. See 'hg help diffs' for more information.
  1117 
  1136 
  1118     With the --switch-parent option, the diff will be against the second
  1137     With the --switch-parent option, the diff will be against the
  1119     parent. It can be useful to review a merge.
  1138     second parent. It can be useful to review a merge.
  1120     """
  1139     """
  1121     if not changesets:
  1140     if not changesets:
  1122         raise util.Abort(_("export requires at least one changeset"))
  1141         raise util.Abort(_("export requires at least one changeset"))
  1123     revs = cmdutil.revrange(repo, changesets)
  1142     revs = cmdutil.revrange(repo, changesets)
  1124     if len(revs) > 1:
  1143     if len(revs) > 1:
  1130                  opts=patch.diffopts(ui, opts))
  1149                  opts=patch.diffopts(ui, opts))
  1131 
  1150 
  1132 def forget(ui, repo, *pats, **opts):
  1151 def forget(ui, repo, *pats, **opts):
  1133     """forget the specified files on the next commit
  1152     """forget the specified files on the next commit
  1134 
  1153 
  1135     Mark the specified files so they will no longer be tracked after the next
  1154     Mark the specified files so they will no longer be tracked
  1136     commit.
  1155     after the next commit.
  1137 
  1156 
  1138     This only removes files from the current branch, not from the entire
  1157     This only removes files from the current branch, not from the
  1139     project history, and it does not delete them from the working directory.
  1158     entire project history, and it does not delete them from the
       
  1159     working directory.
  1140 
  1160 
  1141     To undo a forget before the next commit, see hg add.
  1161     To undo a forget before the next commit, see hg add.
  1142     """
  1162     """
  1143 
  1163 
  1144     if not pats:
  1164     if not pats:
  1163     """search for a pattern in specified files and revisions
  1183     """search for a pattern in specified files and revisions
  1164 
  1184 
  1165     Search revisions of files for a regular expression.
  1185     Search revisions of files for a regular expression.
  1166 
  1186 
  1167     This command behaves differently than Unix grep. It only accepts
  1187     This command behaves differently than Unix grep. It only accepts
  1168     Python/Perl regexps. It searches repository history, not the working
  1188     Python/Perl regexps. It searches repository history, not the
  1169     directory. It always prints the revision number in which a match appears.
  1189     working directory. It always prints the revision number in which a
  1170 
  1190     match appears.
  1171     By default, grep only prints output for the first revision of a file in
  1191 
  1172     which it finds a match. To get it to print every revision that contains a
  1192     By default, grep only prints output for the first revision of a
  1173     change in match status ("-" for a match that becomes a non-match, or "+"
  1193     file in which it finds a match. To get it to print every revision
  1174     for a non-match that becomes a match), use the --all flag.
  1194     that contains a change in match status ("-" for a match that
       
  1195     becomes a non-match, or "+" for a non-match that becomes a match),
       
  1196     use the --all flag.
  1175     """
  1197     """
  1176     reflags = 0
  1198     reflags = 0
  1177     if opts.get('ignore_case'):
  1199     if opts.get('ignore_case'):
  1178         reflags |= re.I
  1200         reflags |= re.I
  1179     try:
  1201     try:
  1332 def heads(ui, repo, *branchrevs, **opts):
  1354 def heads(ui, repo, *branchrevs, **opts):
  1333     """show current repository heads or show branch heads
  1355     """show current repository heads or show branch heads
  1334 
  1356 
  1335     With no arguments, show all repository head changesets.
  1357     With no arguments, show all repository head changesets.
  1336 
  1358 
  1337     Repository "heads" are changesets that don't have child changesets. They
  1359     Repository "heads" are changesets that don't have child
  1338     are where development generally takes place and are the usual targets for
  1360     changesets. They are where development generally takes place and
  1339     update and merge operations.
  1361     are the usual targets for update and merge operations.
  1340 
  1362 
  1341     If one or more REV is given, the "branch heads" will be shown for the
  1363     If one or more REV is given, the "branch heads" will be shown for
  1342     named branch associated with that revision. The name of the branch is
  1364     the named branch associated with that revision. The name of the
  1343     called the revision's branch tag.
  1365     branch is called the revision's branch tag.
  1344 
  1366 
  1345     Branch heads are revisions on a given named branch that do not have any
  1367     Branch heads are revisions on a given named branch that do not have
  1346     descendants on the same branch. A branch head could be a true head or it
  1368     any descendants on the same branch. A branch head could be a true head
  1347     could be the last changeset on a branch before a new branch was created.
  1369     or it could be the last changeset on a branch before a new branch
  1348     If none of the branch heads are true heads, the branch is considered
  1370     was created. If none of the branch heads are true heads, the branch
  1349     inactive. If -c/--closed is specified, also show branch heads marked
  1371     is considered inactive. If -c/--closed is specified, also show branch
  1350     closed (see hg commit --close-branch).
  1372     heads marked closed (see hg commit --close-branch).
  1351 
  1373 
  1352     If STARTREV is specified only those heads (or branch heads) that are
  1374     If STARTREV is specified only those heads (or branch heads) that
  1353     descendants of STARTREV will be displayed.
  1375     are descendants of STARTREV will be displayed.
  1354     """
  1376     """
  1355     if opts.get('rev'):
  1377     if opts.get('rev'):
  1356         start = repo.lookup(opts['rev'])
  1378         start = repo.lookup(opts['rev'])
  1357     else:
  1379     else:
  1358         start = None
  1380         start = None
  1396 def help_(ui, name=None, with_version=False):
  1418 def help_(ui, name=None, with_version=False):
  1397     """show help for a given topic or a help overview
  1419     """show help for a given topic or a help overview
  1398 
  1420 
  1399     With no arguments, print a list of commands with short help messages.
  1421     With no arguments, print a list of commands with short help messages.
  1400 
  1422 
  1401     Given a topic, extension, or command name, print help for that topic.
  1423     Given a topic, extension, or command name, print help for that
  1402     """
  1424     topic."""
  1403     option_lists = []
  1425     option_lists = []
  1404     textwidth = util.termwidth() - 2
  1426     textwidth = util.termwidth() - 2
  1405 
  1427 
  1406     def addglobalopts(aliases):
  1428     def addglobalopts(aliases):
  1407         if ui.verbose:
  1429         if ui.verbose:
  1610 
  1632 
  1611 def identify(ui, repo, source=None,
  1633 def identify(ui, repo, source=None,
  1612              rev=None, num=None, id=None, branch=None, tags=None):
  1634              rev=None, num=None, id=None, branch=None, tags=None):
  1613     """identify the working copy or specified revision
  1635     """identify the working copy or specified revision
  1614 
  1636 
  1615     With no revision, print a summary of the current state of the repository.
  1637     With no revision, print a summary of the current state of the
  1616 
  1638     repository.
  1617     Specifying a path to a repository root or Mercurial bundle will cause
  1639 
  1618     lookup to operate on that repository/bundle.
  1640     Specifying a path to a repository root or Mercurial bundle will
  1619 
  1641     cause lookup to operate on that repository/bundle.
  1620     This summary identifies the repository state using one or two parent hash
  1642 
  1621     identifiers, followed by a "+" if there are uncommitted changes in the
  1643     This summary identifies the repository state using one or two
  1622     working directory, a list of tags for this revision and a branch name for
  1644     parent hash identifiers, followed by a "+" if there are
  1623     non-default branches.
  1645     uncommitted changes in the working directory, a list of tags for
       
  1646     this revision and a branch name for non-default branches.
  1624     """
  1647     """
  1625 
  1648 
  1626     if not repo and not source:
  1649     if not repo and not source:
  1627         raise util.Abort(_("There is no Mercurial repository here "
  1650         raise util.Abort(_("There is no Mercurial repository here "
  1628                            "(.hg not found)"))
  1651                            "(.hg not found)"))
  1685 def import_(ui, repo, patch1, *patches, **opts):
  1708 def import_(ui, repo, patch1, *patches, **opts):
  1686     """import an ordered set of patches
  1709     """import an ordered set of patches
  1687 
  1710 
  1688     Import a list of patches and commit them individually.
  1711     Import a list of patches and commit them individually.
  1689 
  1712 
  1690     If there are outstanding changes in the working directory, import will
  1713     If there are outstanding changes in the working directory, import
  1691     abort unless given the -f/--force flag.
  1714     will abort unless given the -f/--force flag.
  1692 
  1715 
  1693     You can import a patch straight from a mail message. Even patches as
  1716     You can import a patch straight from a mail message. Even patches
  1694     attachments work (to use the body part, it must have type text/plain or
  1717     as attachments work (to use the body part, it must have type
  1695     text/x-patch). From and Subject headers of email message are used as
  1718     text/plain or text/x-patch). From and Subject headers of email
  1696     default committer and commit message. All text/plain body parts before
  1719     message are used as default committer and commit message. All
  1697     first diff are added to commit message.
  1720     text/plain body parts before first diff are added to commit
  1698 
  1721     message.
  1699     If the imported patch was generated by hg export, user and description
  1722 
  1700     from patch override values from message headers and body. Values given on
  1723     If the imported patch was generated by hg export, user and
  1701     command line with -m/--message and -u/--user override these.
  1724     description from patch override values from message headers and
  1702 
  1725     body. Values given on command line with -m/--message and -u/--user
  1703     If --exact is specified, import will set the working directory to the
  1726     override these.
  1704     parent of each patch before applying it, and will abort if the resulting
  1727 
  1705     changeset has a different ID than the one recorded in the patch. This may
  1728     If --exact is specified, import will set the working directory to
  1706     happen due to character set problems or other deficiencies in the text
  1729     the parent of each patch before applying it, and will abort if the
  1707     patch format.
  1730     resulting changeset has a different ID than the one recorded in
  1708 
  1731     the patch. This may happen due to character set problems or other
  1709     With -s/--similarity, hg will attempt to discover renames and copies in
  1732     deficiencies in the text patch format.
  1710     the patch in the same way as 'addremove'.
  1733 
  1711 
  1734     With -s/--similarity, hg will attempt to discover renames and
  1712     To read a patch from standard input, use "-" as the patch name. If a URL
  1735     copies in the patch in the same way as 'addremove'.
  1713     is specified, the patch will be downloaded from it. See 'hg help dates'
  1736 
  1714     for a list of formats valid for -d/--date.
  1737     To read a patch from standard input, use "-" as the patch name. If
       
  1738     a URL is specified, the patch will be downloaded from it.
       
  1739     See 'hg help dates' for a list of formats valid for -d/--date.
  1715     """
  1740     """
  1716     patches = (patch1,) + patches
  1741     patches = (patch1,) + patches
  1717 
  1742 
  1718     date = opts.get('date')
  1743     date = opts.get('date')
  1719     if date:
  1744     if date:
  1809         release(lock, wlock)
  1834         release(lock, wlock)
  1810 
  1835 
  1811 def incoming(ui, repo, source="default", **opts):
  1836 def incoming(ui, repo, source="default", **opts):
  1812     """show new changesets found in source
  1837     """show new changesets found in source
  1813 
  1838 
  1814     Show new changesets found in the specified path/URL or the default pull
  1839     Show new changesets found in the specified path/URL or the default
  1815     location. These are the changesets that would have been pulled if a pull
  1840     pull location. These are the changesets that would have been pulled
  1816     at the time you issued this command.
  1841     if a pull at the time you issued this command.
  1817 
  1842 
  1818     For remote repository, using --bundle avoids downloading the changesets
  1843     For remote repository, using --bundle avoids downloading the
  1819     twice if the incoming is followed by a pull.
  1844     changesets twice if the incoming is followed by a pull.
  1820 
  1845 
  1821     See pull for valid source format details.
  1846     See pull for valid source format details.
  1822     """
  1847     """
  1823     limit = cmdutil.loglimit(opts)
  1848     limit = cmdutil.loglimit(opts)
  1824     source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
  1849     source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
  1878             os.unlink(cleanup)
  1903             os.unlink(cleanup)
  1879 
  1904 
  1880 def init(ui, dest=".", **opts):
  1905 def init(ui, dest=".", **opts):
  1881     """create a new repository in the given directory
  1906     """create a new repository in the given directory
  1882 
  1907 
  1883     Initialize a new repository in the given directory. If the given directory
  1908     Initialize a new repository in the given directory. If the given
  1884     does not exist, it will be created.
  1909     directory does not exist, it will be created.
  1885 
  1910 
  1886     If no directory is given, the current directory is used.
  1911     If no directory is given, the current directory is used.
  1887 
  1912 
  1888     It is possible to specify an ssh:// URL as the destination. See 'hg help
  1913     It is possible to specify an ssh:// URL as the destination.
  1889     urls' for more information.
  1914     See 'hg help urls' for more information.
  1890     """
  1915     """
  1891     hg.repository(cmdutil.remoteui(ui, opts), dest, create=1)
  1916     hg.repository(cmdutil.remoteui(ui, opts), dest, create=1)
  1892 
  1917 
  1893 def locate(ui, repo, *pats, **opts):
  1918 def locate(ui, repo, *pats, **opts):
  1894     """locate files matching specific patterns
  1919     """locate files matching specific patterns
  1895 
  1920 
  1896     Print files under Mercurial control in the working directory whose names
  1921     Print files under Mercurial control in the working directory whose
  1897     match the given patterns.
  1922     names match the given patterns.
  1898 
  1923 
  1899     By default, this command searches all directories in the working
  1924     By default, this command searches all directories in the working
  1900     directory. To search just the current directory and its subdirectories,
  1925     directory. To search just the current directory and its
  1901     use "--include .".
  1926     subdirectories, use "--include .".
  1902 
  1927 
  1903     If no patterns are given to match, this command prints the names of all
  1928     If no patterns are given to match, this command prints the names
  1904     files under Mercurial control in the working directory.
  1929     of all files under Mercurial control in the working directory.
  1905 
  1930 
  1906     If you want to feed the output of this command into the "xargs" command,
  1931     If you want to feed the output of this command into the "xargs"
  1907     use the -0 option to both this command and "xargs". This will avoid the
  1932     command, use the -0 option to both this command and "xargs". This
  1908     problem of "xargs" treating single filenames that contain whitespace as
  1933     will avoid the problem of "xargs" treating single filenames that
  1909     multiple filenames.
  1934     contain whitespace as multiple filenames.
  1910     """
  1935     """
  1911     end = opts.get('print0') and '\0' or '\n'
  1936     end = opts.get('print0') and '\0' or '\n'
  1912     rev = opts.get('rev') or None
  1937     rev = opts.get('rev') or None
  1913 
  1938 
  1914     ret = 1
  1939     ret = 1
  1926     return ret
  1951     return ret
  1927 
  1952 
  1928 def log(ui, repo, *pats, **opts):
  1953 def log(ui, repo, *pats, **opts):
  1929     """show revision history of entire repository or files
  1954     """show revision history of entire repository or files
  1930 
  1955 
  1931     Print the revision history of the specified files or the entire project.
  1956     Print the revision history of the specified files or the entire
  1932 
  1957     project.
  1933     File history is shown without following rename or copy history of files.
  1958 
  1934     Use -f/--follow with a filename to follow history across renames and
  1959     File history is shown without following rename or copy history of
  1935     copies. --follow without a filename will only show ancestors or
  1960     files. Use -f/--follow with a filename to follow history across
  1936     descendants of the starting revision. --follow-first only follows the
  1961     renames and copies. --follow without a filename will only show
  1937     first parent of merge revisions.
  1962     ancestors or descendants of the starting revision. --follow-first
  1938 
  1963     only follows the first parent of merge revisions.
  1939     If no revision range is specified, the default is tip:0 unless --follow is
  1964 
  1940     set, in which case the working directory parent is used as the starting
  1965     If no revision range is specified, the default is tip:0 unless
  1941     revision.
  1966     --follow is set, in which case the working directory parent is
       
  1967     used as the starting revision.
  1942 
  1968 
  1943     See 'hg help dates' for a list of formats valid for -d/--date.
  1969     See 'hg help dates' for a list of formats valid for -d/--date.
  1944 
  1970 
  1945     By default this command prints revision number and changeset id, tags,
  1971     By default this command prints revision number and changeset id,
  1946     non-trivial parents, user, date and time, and a summary for each commit.
  1972     tags, non-trivial parents, user, date and time, and a summary for
  1947     When the -v/--verbose switch is used, the list of changed files and full
  1973     each commit. When the -v/--verbose switch is used, the list of
  1948     commit message are shown.
  1974     changed files and full commit message are shown.
  1949 
  1975 
  1950     NOTE: log -p/--patch may generate unexpected diff output for merge
  1976     NOTE: log -p/--patch may generate unexpected diff output for merge
  1951     changesets, as it will only compare the merge changeset against its first
  1977     changesets, as it will only compare the merge changeset against
  1952     parent. Also, only files different from BOTH parents will appear in
  1978     its first parent. Also, only files different from BOTH parents
  1953     files:.
  1979     will appear in files:.
  1954     """
  1980     """
  1955 
  1981 
  1956     get = util.cachefunc(lambda r: repo[r].changeset())
  1982     get = util.cachefunc(lambda r: repo[r].changeset())
  1957     changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
  1983     changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
  1958 
  1984 
  2051                 count += 1
  2077                 count += 1
  2052 
  2078 
  2053 def manifest(ui, repo, node=None, rev=None):
  2079 def manifest(ui, repo, node=None, rev=None):
  2054     """output the current or given revision of the project manifest
  2080     """output the current or given revision of the project manifest
  2055 
  2081 
  2056     Print a list of version controlled files for the given revision. If no
  2082     Print a list of version controlled files for the given revision.
  2057     revision is given, the first parent of the working directory is used, or
  2083     If no revision is given, the first parent of the working directory
  2058     the null revision if no revision is checked out.
  2084     is used, or the null revision if no revision is checked out.
  2059 
  2085 
  2060     With -v, print file permissions, symlink and executable bits.
  2086     With -v, print file permissions, symlink and executable bits.
  2061     With --debug, print file revision hashes.
  2087     With --debug, print file revision hashes.
  2062     """
  2088     """
  2063 
  2089 
  2077         ui.write("%s\n" % f)
  2103         ui.write("%s\n" % f)
  2078 
  2104 
  2079 def merge(ui, repo, node=None, **opts):
  2105 def merge(ui, repo, node=None, **opts):
  2080     """merge working directory with another revision
  2106     """merge working directory with another revision
  2081 
  2107 
  2082     The current working directory is updated with all changes made in the
  2108     The current working directory is updated with all changes made in
  2083     requested revision since the last common predecessor revision.
  2109     the requested revision since the last common predecessor revision.
  2084 
  2110 
  2085     Files that changed between either parent are marked as changed for the
  2111     Files that changed between either parent are marked as changed for
  2086     next commit and a commit must be performed before any further updates to
  2112     the next commit and a commit must be performed before any further
  2087     the repository are allowed. The next commit will have two parents.
  2113     updates to the repository are allowed. The next commit will have
  2088 
  2114     two parents.
  2089     If no revision is specified, the working directory's parent is a head
  2115 
  2090     revision, and the current branch contains exactly one other head, the
  2116     If no revision is specified, the working directory's parent is a
  2091     other head is merged with by default. Otherwise, an explicit revision with
  2117     head revision, and the current branch contains exactly one other
  2092     which to merge with must be provided.
  2118     head, the other head is merged with by default. Otherwise, an
       
  2119     explicit revision with which to merge with must be provided.
  2093     """
  2120     """
  2094 
  2121 
  2095     if opts.get('rev') and node:
  2122     if opts.get('rev') and node:
  2096         raise util.Abort(_("please specify just one revision"))
  2123         raise util.Abort(_("please specify just one revision"))
  2097     if not node:
  2124     if not node:
  2134     return hg.merge(repo, node, force=opts.get('force'))
  2161     return hg.merge(repo, node, force=opts.get('force'))
  2135 
  2162 
  2136 def outgoing(ui, repo, dest=None, **opts):
  2163 def outgoing(ui, repo, dest=None, **opts):
  2137     """show changesets not found in destination
  2164     """show changesets not found in destination
  2138 
  2165 
  2139     Show changesets not found in the specified destination repository or the
  2166     Show changesets not found in the specified destination repository
  2140     default push location. These are the changesets that would be pushed if a
  2167     or the default push location. These are the changesets that would
  2141     push was requested.
  2168     be pushed if a push was requested.
  2142 
  2169 
  2143     See pull for valid destination format details.
  2170     See pull for valid destination format details.
  2144     """
  2171     """
  2145     limit = cmdutil.loglimit(opts)
  2172     limit = cmdutil.loglimit(opts)
  2146     dest, revs, checkout = hg.parseurl(
  2173     dest, revs, checkout = hg.parseurl(
  2169         displayer.show(repo[n])
  2196         displayer.show(repo[n])
  2170 
  2197 
  2171 def parents(ui, repo, file_=None, **opts):
  2198 def parents(ui, repo, file_=None, **opts):
  2172     """show the parents of the working directory or revision
  2199     """show the parents of the working directory or revision
  2173 
  2200 
  2174     Print the working directory's parent revisions. If a revision is given via
  2201     Print the working directory's parent revisions. If a revision is
  2175     -r/--rev, the parent of that revision will be printed. If a file argument
  2202     given via -r/--rev, the parent of that revision will be printed.
  2176     is given, the revision in which the file was last changed (before the
  2203     If a file argument is given, the revision in which the file was
  2177     working directory revision or the argument to --rev if given) is printed.
  2204     last changed (before the working directory revision or the
       
  2205     argument to --rev if given) is printed.
  2178     """
  2206     """
  2179     rev = opts.get('rev')
  2207     rev = opts.get('rev')
  2180     if rev:
  2208     if rev:
  2181         ctx = repo[rev]
  2209         ctx = repo[rev]
  2182     else:
  2210     else:
  2208             displayer.show(repo[n])
  2236             displayer.show(repo[n])
  2209 
  2237 
  2210 def paths(ui, repo, search=None):
  2238 def paths(ui, repo, search=None):
  2211     """show aliases for remote repositories
  2239     """show aliases for remote repositories
  2212 
  2240 
  2213     Show definition of symbolic path name NAME. If no name is given, show
  2241     Show definition of symbolic path name NAME. If no name is given,
  2214     definition of all available names.
  2242     show definition of all available names.
  2215 
  2243 
  2216     Path names are defined in the [paths] section of /etc/mercurial/hgrc and
  2244     Path names are defined in the [paths] section of /etc/mercurial/hgrc
  2217     $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
  2245     and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
  2218 
  2246 
  2219     See 'hg help urls' for more information.
  2247     See 'hg help urls' for more information.
  2220     """
  2248     """
  2221     if search:
  2249     if search:
  2222         for name, path in ui.configitems("paths"):
  2250         for name, path in ui.configitems("paths"):
  2245 def pull(ui, repo, source="default", **opts):
  2273 def pull(ui, repo, source="default", **opts):
  2246     """pull changes from the specified source
  2274     """pull changes from the specified source
  2247 
  2275 
  2248     Pull changes from a remote repository to a local one.
  2276     Pull changes from a remote repository to a local one.
  2249 
  2277 
  2250     This finds all changes from the repository at the specified path or URL
  2278     This finds all changes from the repository at the specified path
  2251     and adds them to a local repository (the current one unless -R is
  2279     or URL and adds them to a local repository (the current one unless
  2252     specified). By default, this does not update the copy of the project in
  2280     -R is specified). By default, this does not update the copy of the
  2253     the working directory.
  2281     project in the working directory.
  2254 
  2282 
  2255     Use hg incoming if you want to see what would have been added by a pull at
  2283     Use hg incoming if you want to see what would have been added by a
  2256     the time you issued this command. If you then decide to added those
  2284     pull at the time you issued this command. If you then decide to
  2257     changes to the repository, you should use pull -r X where X is the last
  2285     added those changes to the repository, you should use pull -r X
  2258     changeset listed by hg incoming.
  2286     where X is the last changeset listed by hg incoming.
  2259 
  2287 
  2260     If SOURCE is omitted, the 'default' path will be used. See 'hg help urls'
  2288     If SOURCE is omitted, the 'default' path will be used.
  2261     for more information.
  2289     See 'hg help urls' for more information.
  2262     """
  2290     """
  2263     source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
  2291     source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
  2264     other = hg.repository(cmdutil.remoteui(repo, opts), source)
  2292     other = hg.repository(cmdutil.remoteui(repo, opts), source)
  2265     ui.status(_('pulling from %s\n') % url.hidepassword(source))
  2293     ui.status(_('pulling from %s\n') % url.hidepassword(source))
  2266     if revs:
  2294     if revs:
  2277 def push(ui, repo, dest=None, **opts):
  2305 def push(ui, repo, dest=None, **opts):
  2278     """push changes to the specified destination
  2306     """push changes to the specified destination
  2279 
  2307 
  2280     Push changes from the local repository to the given destination.
  2308     Push changes from the local repository to the given destination.
  2281 
  2309 
  2282     This is the symmetrical operation for pull. It moves changes from the
  2310     This is the symmetrical operation for pull. It moves changes from
  2283     current repository to a different one. If the destination is local this is
  2311     the current repository to a different one. If the destination is
  2284     identical to a pull in that directory from the current one.
  2312     local this is identical to a pull in that directory from the
       
  2313     current one.
  2285 
  2314 
  2286     By default, push will refuse to run if it detects the result would
  2315     By default, push will refuse to run if it detects the result would
  2287     increase the number of remote heads. This generally indicates the user
  2316     increase the number of remote heads. This generally indicates the
  2288     forgot to pull and merge before pushing.
  2317     user forgot to pull and merge before pushing.
  2289 
  2318 
  2290     If -r/--rev is used, the named revision and all its ancestors will be
  2319     If -r/--rev is used, the named revision and all its ancestors will
  2291     pushed to the remote repository.
  2320     be pushed to the remote repository.
  2292 
  2321 
  2293     Please see 'hg help urls' for important details about ssh:// URLs. If
  2322     Please see 'hg help urls' for important details about ssh://
  2294     DESTINATION is omitted, a default path will be used.
  2323     URLs. If DESTINATION is omitted, a default path will be used.
  2295     """
  2324     """
  2296     dest, revs, checkout = hg.parseurl(
  2325     dest, revs, checkout = hg.parseurl(
  2297         ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev'))
  2326         ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev'))
  2298     other = hg.repository(cmdutil.remoteui(repo, opts), dest)
  2327     other = hg.repository(cmdutil.remoteui(repo, opts), dest)
  2299     ui.status(_('pushing to %s\n') % url.hidepassword(dest))
  2328     ui.status(_('pushing to %s\n') % url.hidepassword(dest))
  2312 def recover(ui, repo):
  2341 def recover(ui, repo):
  2313     """roll back an interrupted transaction
  2342     """roll back an interrupted transaction
  2314 
  2343 
  2315     Recover from an interrupted commit or pull.
  2344     Recover from an interrupted commit or pull.
  2316 
  2345 
  2317     This command tries to fix the repository status after an interrupted
  2346     This command tries to fix the repository status after an
  2318     operation. It should only be necessary when Mercurial suggests it.
  2347     interrupted operation. It should only be necessary when Mercurial
       
  2348     suggests it.
  2319     """
  2349     """
  2320     if repo.recover():
  2350     if repo.recover():
  2321         return hg.verify(repo)
  2351         return hg.verify(repo)
  2322     return 1
  2352     return 1
  2323 
  2353 
  2324 def remove(ui, repo, *pats, **opts):
  2354 def remove(ui, repo, *pats, **opts):
  2325     """remove the specified files on the next commit
  2355     """remove the specified files on the next commit
  2326 
  2356 
  2327     Schedule the indicated files for removal from the repository.
  2357     Schedule the indicated files for removal from the repository.
  2328 
  2358 
  2329     This only removes files from the current branch, not from the entire
  2359     This only removes files from the current branch, not from the
  2330     project history. -A/--after can be used to remove only files that have
  2360     entire project history. -A/--after can be used to remove only
  2331     already been deleted, -f/--force can be used to force deletion, and -Af
  2361     files that have already been deleted, -f/--force can be used to
  2332     can be used to remove files from the next revision without deleting them
  2362     force deletion, and -Af can be used to remove files from the next
  2333     from the working directory.
  2363     revision without deleting them from the working directory.
  2334 
  2364 
  2335     The following table details the behavior of remove for different file
  2365     The following table details the behavior of remove for different
  2336     states (columns) and option combinations (rows). The file states are Added
  2366     file states (columns) and option combinations (rows). The file
  2337     [A], Clean [C], Modified [M] and Missing [!] (as reported by hg status).
  2367     states are Added [A], Clean [C], Modified [M] and Missing [!] (as
  2338     The actions are Warn, Remove (from branch) and Delete (from disk)::
  2368     reported by hg status). The actions are Warn, Remove (from branch)
       
  2369     and Delete (from disk)::
  2339 
  2370 
  2340              A  C  M  !
  2371              A  C  M  !
  2341       none   W  RD W  R
  2372       none   W  RD W  R
  2342       -f     R  RD RD R
  2373       -f     R  RD RD R
  2343       -A     W  W  W  R
  2374       -A     W  W  W  R
  2344       -Af    R  R  R  R
  2375       -Af    R  R  R  R
  2345 
  2376 
  2346     This command schedules the files to be removed at the next commit. To undo
  2377     This command schedules the files to be removed at the next commit.
  2347     a remove before that, see hg revert.
  2378     To undo a remove before that, see hg revert.
  2348     """
  2379     """
  2349 
  2380 
  2350     after, force = opts.get('after'), opts.get('force')
  2381     after, force = opts.get('after'), opts.get('force')
  2351     if not pats and not after:
  2382     if not pats and not after:
  2352         raise util.Abort(_('no files specified'))
  2383         raise util.Abort(_('no files specified'))
  2382     repo.remove(remove, unlink=not after)
  2413     repo.remove(remove, unlink=not after)
  2383 
  2414 
  2384 def rename(ui, repo, *pats, **opts):
  2415 def rename(ui, repo, *pats, **opts):
  2385     """rename files; equivalent of copy + remove
  2416     """rename files; equivalent of copy + remove
  2386 
  2417 
  2387     Mark dest as copies of sources; mark sources for deletion. If dest is a
  2418     Mark dest as copies of sources; mark sources for deletion. If dest
  2388     directory, copies are put in that directory. If dest is a file, there can
  2419     is a directory, copies are put in that directory. If dest is a
  2389     only be one source.
  2420     file, there can only be one source.
  2390 
  2421 
  2391     By default, this command copies the contents of files as they exist in the
  2422     By default, this command copies the contents of files as they
  2392     working directory. If invoked with -A/--after, the operation is recorded,
  2423     exist in the working directory. If invoked with -A/--after, the
  2393     but no copying is performed.
  2424     operation is recorded, but no copying is performed.
  2394 
  2425 
  2395     This command takes effect at the next commit. To undo a rename before
  2426     This command takes effect at the next commit. To undo a rename
  2396     that, see hg revert.
  2427     before that, see hg revert.
  2397     """
  2428     """
  2398     wlock = repo.wlock(False)
  2429     wlock = repo.wlock(False)
  2399     try:
  2430     try:
  2400         return cmdutil.copy(ui, repo, pats, opts, rename=True)
  2431         return cmdutil.copy(ui, repo, pats, opts, rename=True)
  2401     finally:
  2432     finally:
  2403 
  2434 
  2404 def resolve(ui, repo, *pats, **opts):
  2435 def resolve(ui, repo, *pats, **opts):
  2405     """retry file merges from a merge or update
  2436     """retry file merges from a merge or update
  2406 
  2437 
  2407     This command will cleanly retry unresolved file merges using file
  2438     This command will cleanly retry unresolved file merges using file
  2408     revisions preserved from the last update or merge. To attempt to resolve
  2439     revisions preserved from the last update or merge. To attempt to
  2409     all unresolved files, use the -a/--all switch.
  2440     resolve all unresolved files, use the -a/--all switch.
  2410 
  2441 
  2411     If a conflict is resolved manually, please note that the changes will be
  2442     If a conflict is resolved manually, please note that the changes
  2412     overwritten if the merge is retried with resolve. The -m/--mark switch
  2443     will be overwritten if the merge is retried with resolve. The
  2413     should be used to mark the file as resolved.
  2444     -m/--mark switch should be used to mark the file as resolved.
  2414 
  2445 
  2415     This command also allows listing resolved files and manually indicating
  2446     This command also allows listing resolved files and manually
  2416     whether or not files are resolved. All files must be marked as resolved
  2447     indicating whether or not files are resolved. All files must be
  2417     before a commit is permitted.
  2448     marked as resolved before a commit is permitted.
  2418 
  2449 
  2419     The codes used to show the status of files are::
  2450     The codes used to show the status of files are::
  2420 
  2451 
  2421       U = unresolved
  2452       U = unresolved
  2422       R = resolved
  2453       R = resolved
  2458                 util.rename(a + ".resolve", a + ".orig")
  2489                 util.rename(a + ".resolve", a + ".orig")
  2459 
  2490 
  2460 def revert(ui, repo, *pats, **opts):
  2491 def revert(ui, repo, *pats, **opts):
  2461     """restore individual files or directories to an earlier state
  2492     """restore individual files or directories to an earlier state
  2462 
  2493 
  2463     (Use update -r to check out earlier revisions, revert does not change the
  2494     (Use update -r to check out earlier revisions, revert does not
  2464     working directory parents.)
  2495     change the working directory parents.)
  2465 
  2496 
  2466     With no revision specified, revert the named files or directories to the
  2497     With no revision specified, revert the named files or directories
  2467     contents they had in the parent of the working directory. This restores
  2498     to the contents they had in the parent of the working directory.
  2468     the contents of the affected files to an unmodified state and unschedules
  2499     This restores the contents of the affected files to an unmodified
  2469     adds, removes, copies, and renames. If the working directory has two
  2500     state and unschedules adds, removes, copies, and renames. If the
  2470     parents, you must explicitly specify the revision to revert to.
  2501     working directory has two parents, you must explicitly specify the
  2471 
  2502     revision to revert to.
  2472     Using the -r/--rev option, revert the given files or directories to their
  2503 
  2473     contents as of a specific revision. This can be helpful to "roll back"
  2504     Using the -r/--rev option, revert the given files or directories
  2474     some or all of an earlier change. See 'hg help dates' for a list of
  2505     to their contents as of a specific revision. This can be helpful
  2475     formats valid for -d/--date.
  2506     to "roll back" some or all of an earlier change. See 'hg help
  2476 
  2507     dates' for a list of formats valid for -d/--date.
  2477     Revert modifies the working directory. It does not commit any changes, or
  2508 
  2478     change the parent of the working directory. If you revert to a revision
  2509     Revert modifies the working directory. It does not commit any
  2479     other than the parent of the working directory, the reverted files will
  2510     changes, or change the parent of the working directory. If you
  2480     thus appear modified afterwards.
  2511     revert to a revision other than the parent of the working
  2481 
  2512     directory, the reverted files will thus appear modified
  2482     If a file has been deleted, it is restored. If the executable mode of a
  2513     afterwards.
  2483     file was changed, it is reset.
  2514 
  2484 
  2515     If a file has been deleted, it is restored. If the executable mode
  2485     If names are given, all files matching the names are reverted. If no
  2516     of a file was changed, it is reset.
  2486     arguments are given, no files are reverted.
  2517 
  2487 
  2518     If names are given, all files matching the names are reverted.
  2488     Modified files are saved with a .orig suffix before reverting. To disable
  2519     If no arguments are given, no files are reverted.
  2489     these backups, use --no-backup.
  2520 
       
  2521     Modified files are saved with a .orig suffix before reverting.
       
  2522     To disable these backups, use --no-backup.
  2490     """
  2523     """
  2491 
  2524 
  2492     if opts["date"]:
  2525     if opts["date"]:
  2493         if opts["rev"]:
  2526         if opts["rev"]:
  2494             raise util.Abort(_("you can't specify a revision and a date"))
  2527             raise util.Abort(_("you can't specify a revision and a date"))
  2673 
  2706 
  2674 def rollback(ui, repo):
  2707 def rollback(ui, repo):
  2675     """roll back the last transaction
  2708     """roll back the last transaction
  2676 
  2709 
  2677     This command should be used with care. There is only one level of
  2710     This command should be used with care. There is only one level of
  2678     rollback, and there is no way to undo a rollback. It will also restore the
  2711     rollback, and there is no way to undo a rollback. It will also
  2679     dirstate at the time of the last transaction, losing any dirstate changes
  2712     restore the dirstate at the time of the last transaction, losing
  2680     since that time. This command does not alter the working directory.
  2713     any dirstate changes since that time. This command does not alter
  2681 
  2714     the working directory.
  2682     Transactions are used to encapsulate the effects of all commands that
  2715 
  2683     create new changesets or propagate existing changesets into a repository.
  2716     Transactions are used to encapsulate the effects of all commands
  2684     For example, the following commands are transactional, and their effects
  2717     that create new changesets or propagate existing changesets into a
  2685     can be rolled back::
  2718     repository. For example, the following commands are transactional,
       
  2719     and their effects can be rolled back::
  2686 
  2720 
  2687       commit
  2721       commit
  2688       import
  2722       import
  2689       pull
  2723       pull
  2690       push (with this repository as destination)
  2724       push (with this repository as destination)
  2691       unbundle
  2725       unbundle
  2692 
  2726 
  2693     This command is not intended for use on public repositories. Once changes
  2727     This command is not intended for use on public repositories. Once
  2694     are visible for pull by other users, rolling a transaction back locally is
  2728     changes are visible for pull by other users, rolling a transaction
  2695     ineffective (someone else may already have pulled the changes).
  2729     back locally is ineffective (someone else may already have pulled
  2696     Furthermore, a race is possible with readers of the repository; for
  2730     the changes). Furthermore, a race is possible with readers of the
  2697     example an in-progress pull from the repository may fail if a rollback is
  2731     repository; for example an in-progress pull from the repository
  2698     performed.
  2732     may fail if a rollback is performed.
  2699     """
  2733     """
  2700     repo.rollback()
  2734     repo.rollback()
  2701 
  2735 
  2702 def root(ui, repo):
  2736 def root(ui, repo):
  2703     """print the root (top) of the current working directory
  2737     """print the root (top) of the current working directory
  2709 def serve(ui, repo, **opts):
  2743 def serve(ui, repo, **opts):
  2710     """export the repository via HTTP
  2744     """export the repository via HTTP
  2711 
  2745 
  2712     Start a local HTTP repository browser and pull server.
  2746     Start a local HTTP repository browser and pull server.
  2713 
  2747 
  2714     By default, the server logs accesses to stdout and errors to stderr. Use
  2748     By default, the server logs accesses to stdout and errors to
  2715     the -A/--accesslog and -E/--errorlog options to log to files.
  2749     stderr. Use the -A/--accesslog and -E/--errorlog options to log to
       
  2750     files.
  2716     """
  2751     """
  2717 
  2752 
  2718     if opts["stdio"]:
  2753     if opts["stdio"]:
  2719         if repo is None:
  2754         if repo is None:
  2720             raise error.RepoError(_("There is no Mercurial repository here"
  2755             raise error.RepoError(_("There is no Mercurial repository here"
  2771     cmdutil.service(opts, initfn=service.init, runfn=service.run)
  2806     cmdutil.service(opts, initfn=service.init, runfn=service.run)
  2772 
  2807 
  2773 def status(ui, repo, *pats, **opts):
  2808 def status(ui, repo, *pats, **opts):
  2774     """show changed files in the working directory
  2809     """show changed files in the working directory
  2775 
  2810 
  2776     Show status of files in the repository. If names are given, only files
  2811     Show status of files in the repository. If names are given, only
  2777     that match are shown. Files that are clean or ignored or the source of a
  2812     files that match are shown. Files that are clean or ignored or
  2778     copy/move operation, are not listed unless -c/--clean, -i/--ignored,
  2813     the source of a copy/move operation, are not listed unless
  2779     -C/--copies or -A/--all are given. Unless options described with "show
  2814     -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
  2780     only ..." are given, the options -mardu are used.
  2815     Unless options described with "show only ..." are given, the
  2781 
  2816     options -mardu are used.
  2782     Option -q/--quiet hides untracked (unknown and ignored) files unless
  2817 
  2783     explicitly requested with -u/--unknown or -i/--ignored.
  2818     Option -q/--quiet hides untracked (unknown and ignored) files
  2784 
  2819     unless explicitly requested with -u/--unknown or -i/--ignored.
  2785     NOTE: status may appear to disagree with diff if permissions have changed
  2820 
  2786     or a merge has occurred. The standard diff format does not report
  2821     NOTE: status may appear to disagree with diff if permissions have
  2787     permission changes and diff only reports changes relative to one merge
  2822     changed or a merge has occurred. The standard diff format does not
  2788     parent.
  2823     report permission changes and diff only reports changes relative
  2789 
  2824     to one merge parent.
  2790     If one revision is given, it is used as the base revision. If two
  2825 
  2791     revisions are given, the differences between them are shown.
  2826     If one revision is given, it is used as the base revision.
       
  2827     If two revisions are given, the differences between them are
       
  2828     shown.
  2792 
  2829 
  2793     The codes used to show the status of files are::
  2830     The codes used to show the status of files are::
  2794 
  2831 
  2795       M = modified
  2832       M = modified
  2796       A = added
  2833       A = added
  2845 def tag(ui, repo, name1, *names, **opts):
  2882 def tag(ui, repo, name1, *names, **opts):
  2846     """add one or more tags for the current or given revision
  2883     """add one or more tags for the current or given revision
  2847 
  2884 
  2848     Name a particular revision using <name>.
  2885     Name a particular revision using <name>.
  2849 
  2886 
  2850     Tags are used to name particular revisions of the repository and are very
  2887     Tags are used to name particular revisions of the repository and are
  2851     useful to compare different revisions, to go back to significant earlier
  2888     very useful to compare different revisions, to go back to significant
  2852     versions or to mark branch points as releases, etc.
  2889     earlier versions or to mark branch points as releases, etc.
  2853 
  2890 
  2854     If no revision is given, the parent of the working directory is used, or
  2891     If no revision is given, the parent of the working directory is
  2855     tip if no revision is checked out.
  2892     used, or tip if no revision is checked out.
  2856 
  2893 
  2857     To facilitate version control, distribution, and merging of tags, they are
  2894     To facilitate version control, distribution, and merging of tags,
  2858     stored as a file named ".hgtags" which is managed similarly to other
  2895     they are stored as a file named ".hgtags" which is managed
  2859     project files and can be hand-edited if necessary. The file
  2896     similarly to other project files and can be hand-edited if
  2860     '.hg/localtags' is used for local tags (not shared among repositories).
  2897     necessary. The file '.hg/localtags' is used for local tags (not
       
  2898     shared among repositories).
  2861 
  2899 
  2862     See 'hg help dates' for a list of formats valid for -d/--date.
  2900     See 'hg help dates' for a list of formats valid for -d/--date.
  2863     """
  2901     """
  2864 
  2902 
  2865     rev_ = "."
  2903     rev_ = "."
  2910     repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
  2948     repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
  2911 
  2949 
  2912 def tags(ui, repo):
  2950 def tags(ui, repo):
  2913     """list repository tags
  2951     """list repository tags
  2914 
  2952 
  2915     This lists both regular and local tags. When the -v/--verbose switch is
  2953     This lists both regular and local tags. When the -v/--verbose
  2916     used, a third column "local" is printed for local tags.
  2954     switch is used, a third column "local" is printed for local tags.
  2917     """
  2955     """
  2918 
  2956 
  2919     hexfunc = ui.debugflag and hex or short
  2957     hexfunc = ui.debugflag and hex or short
  2920     tagtype = ""
  2958     tagtype = ""
  2921 
  2959 
  2939             ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype))
  2977             ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype))
  2940 
  2978 
  2941 def tip(ui, repo, **opts):
  2979 def tip(ui, repo, **opts):
  2942     """show the tip revision
  2980     """show the tip revision
  2943 
  2981 
  2944     The tip revision (usually just called the tip) is the changeset most
  2982     The tip revision (usually just called the tip) is the changeset
  2945     recently added to the repository (and therefore the most recently changed
  2983     most recently added to the repository (and therefore the most
  2946     head).
  2984     recently changed head).
  2947 
  2985 
  2948     If you have just made a commit, that commit will be the tip. If you have
  2986     If you have just made a commit, that commit will be the tip. If
  2949     just pulled changes from another repository, the tip of that repository
  2987     you have just pulled changes from another repository, the tip of
  2950     becomes the current tip. The "tip" tag is special and cannot be renamed or
  2988     that repository becomes the current tip. The "tip" tag is special
  2951     assigned to a different changeset.
  2989     and cannot be renamed or assigned to a different changeset.
  2952     """
  2990     """
  2953     cmdutil.show_changeset(ui, repo, opts).show(repo[len(repo) - 1])
  2991     cmdutil.show_changeset(ui, repo, opts).show(repo[len(repo) - 1])
  2954 
  2992 
  2955 def unbundle(ui, repo, fname1, *fnames, **opts):
  2993 def unbundle(ui, repo, fname1, *fnames, **opts):
  2956     """apply one or more changegroup files
  2994     """apply one or more changegroup files
  2957 
  2995 
  2958     Apply one or more compressed changegroup files generated by the bundle
  2996     Apply one or more compressed changegroup files generated by the
  2959     command.
  2997     bundle command.
  2960     """
  2998     """
  2961     fnames = (fname1,) + fnames
  2999     fnames = (fname1,) + fnames
  2962 
  3000 
  2963     lock = repo.lock()
  3001     lock = repo.lock()
  2964     try:
  3002     try:
  2972     return postincoming(ui, repo, modheads, opts.get('update'), None)
  3010     return postincoming(ui, repo, modheads, opts.get('update'), None)
  2973 
  3011 
  2974 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
  3012 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
  2975     """update working directory
  3013     """update working directory
  2976 
  3014 
  2977     Update the repository's working directory to the specified revision, or
  3015     Update the repository's working directory to the specified
  2978     the tip of the current branch if none is specified. Use null as the
  3016     revision, or the tip of the current branch if none is specified.
  2979     revision to remove the working copy (like 'hg clone -U').
  3017     Use null as the revision to remove the working copy (like 'hg
  2980 
  3018     clone -U').
  2981     When the working directory contains no uncommitted changes, it will be
  3019 
  2982     replaced by the state of the requested revision from the repository. When
  3020     When the working directory contains no uncommitted changes, it
  2983     the requested revision is on a different branch, the working directory
  3021     will be replaced by the state of the requested revision from the
  2984     will additionally be switched to that branch.
  3022     repository. When the requested revision is on a different branch,
  2985 
  3023     the working directory will additionally be switched to that
  2986     When there are uncommitted changes, use option -C/--clean to discard them,
  3024     branch.
  2987     forcibly replacing the state of the working directory with the requested
  3025 
  2988     revision. Alternately, use -c/--check to abort.
  3026     When there are uncommitted changes, use option -C/--clean to
  2989 
  3027     discard them, forcibly replacing the state of the working
  2990     When there are uncommitted changes and option -C/--clean is not used, and
  3028     directory with the requested revision. Alternately, use -c/--check
  2991     the parent revision and requested revision are on the same branch, and one
  3029     to abort.
  2992     of them is an ancestor of the other, then the new working directory will
  3030 
  2993     contain the requested revision merged with the uncommitted changes.
  3031     When there are uncommitted changes and option -C/--clean is not
  2994     Otherwise, the update will fail with a suggestion to use 'merge' or
  3032     used, and the parent revision and requested revision are on the
  2995     'update -C' instead.
  3033     same branch, and one of them is an ancestor of the other, then the
  2996 
  3034     new working directory will contain the requested revision merged
  2997     If you want to update just one file to an older revision, use revert.
  3035     with the uncommitted changes. Otherwise, the update will fail with
       
  3036     a suggestion to use 'merge' or 'update -C' instead.
       
  3037 
       
  3038     If you want to update just one file to an older revision, use
       
  3039     revert.
  2998 
  3040 
  2999     See 'hg help dates' for a list of formats valid for -d/--date.
  3041     See 'hg help dates' for a list of formats valid for -d/--date.
  3000     """
  3042     """
  3001     if rev and node:
  3043     if rev and node:
  3002         raise util.Abort(_("please specify just one revision"))
  3044         raise util.Abort(_("please specify just one revision"))
  3023 def verify(ui, repo):
  3065 def verify(ui, repo):
  3024     """verify the integrity of the repository
  3066     """verify the integrity of the repository
  3025 
  3067 
  3026     Verify the integrity of the current repository.
  3068     Verify the integrity of the current repository.
  3027 
  3069 
  3028     This will perform an extensive check of the repository's integrity,
  3070     This will perform an extensive check of the repository's
  3029     validating the hashes and checksums of each entry in the changelog,
  3071     integrity, validating the hashes and checksums of each entry in
  3030     manifest, and tracked files, as well as the integrity of their crosslinks
  3072     the changelog, manifest, and tracked files, as well as the
  3031     and indices.
  3073     integrity of their crosslinks and indices.
  3032     """
  3074     """
  3033     return hg.verify(repo)
  3075     return hg.verify(repo)
  3034 
  3076 
  3035 def version_(ui):
  3077 def version_(ui):
  3036     """output version and copyright information"""
  3078     """output version and copyright information"""