doc/hg.1.txt
changeset 438 b38deaf7873e
parent 330 27d08c0c2a7e
child 478 f1804f2e7f35
child 484 934279f3ca53
equal deleted inserted replaced
437:5b38a5af4019 438:b38deaf7873e
     1 HG(1)
     1 HG(1)
     2 =====
     2 =====
     3 Matt Mackall <mpm@selenic.com>
     3 Matt Mackall <mpm@selenic.com>
     4 v0.5, 27 May 2005
     4 v0.6, 27 May 2005
     5 
     5 
     6 NAME
     6 NAME
     7 ----
     7 ----
     8 hg - command line interface to the Mercurial source code management system
     8 hg - Mercurial source code management system
     9 
     9 
    10 SYNOPSIS
    10 SYNOPSIS
    11 --------
    11 --------
    12 'hg' [-v -d -q -y] <command> [command options] [files]
    12 'hg' [-v -d -q -y] <command> [command options] [files]
    13 
    13 
    14 DESCRIPTION
    14 DESCRIPTION
    15 -----------
    15 -----------
    16 The hg(1) command provides a command line interface to the Mercurial system.
    16 The hg(1) command provides a command line interface to the Mercurial system.
    17 
    17 
    18 NOTE
       
    19 ----
       
    20 Many of the hg commands are not yet subdirectory and/or working directory
       
    21 aware.  This means that some commands will only work in the top level 
       
    22 repository directory or will only accept paths and filenames relative to the
       
    23 top level.  Merges and commits, in particular, should be done in the
       
    24 top-level directory.
       
    25 
       
    26 OPTIONS
    18 OPTIONS
    27 -------
    19 -------
       
    20 
    28 --debug, -d::
    21 --debug, -d::
    29     enable debugging output
    22     enable debugging output
    30 
    23 
    31 --quiet, -q::
    24 --quiet, -q::
    32     suppress output
    25     suppress output
    44     indicates one or more filename or relative path filenames
    37     indicates one or more filename or relative path filenames
    45 
    38 
    46 path::
    39 path::
    47     indicates a path on the local machine
    40     indicates a path on the local machine
    48 
    41 
    49 revision::
    42 revision:: 
    50     indicates a changeset which can be specified as a changeset id (int),
    43     indicates a changeset which can be specified as a changeset revision
    51     a tag, or a unique substring of the changeset hash value
    44     number, a tag, or a unique substring of the changeset hash value
    52 
    45 
    53 repository path::
    46 repository path::
    54     is either the pathname of a local repository of the URI of a remote
    47     is either the pathname of a local repository of the URI of a remote
    55     repository.  There are two available URI protocols, http:// which is
    48     repository.  There are two available URI protocols, http:// which is
    56     fast and the old-http:// protocol which is much slower but does not 
    49     fast and the old-http:// protocol which is much slower but does not 
    57     require python on the web host.
    50     require a special server on the web host.
    58 
    51 
    59 COMMANDS
    52 COMMANDS
    60 --------
    53 --------
       
    54 
    61 add [files ...]::
    55 add [files ...]::
    62     add the given files to the repository.  Note that this just schedules the
    56     Add the given files to the repository.  Note that this just schedules the
    63     files for addition at the next hg commit time.
    57     files for addition at the next hg commit time.
    64 
    58 
    65 addremove::
    59 addremove::
    66     add all new files and remove all missing files from the repository.  new
    60     Add all new files and remove all missing files from the repository.  New
    67     files are ignored if they match any of the patterns in .hgignore
    61     files are ignored if they match any of the patterns in .hgignore
    68 
    62 
    69 annotate [-r revision -u -n -c] [files ...]::
    63 annotate [-r <rev> -u -n -c] [files ...]::
    70     list the files with each line showing the revision id responsible 
    64     List the files with each line showing the revision id responsible 
    71     for that line.  -u will add the author to the revision id, -c will
    65     for that line. 
    72     print the changeset hash, and -n will ...
    66 
    73 
    67     options:
    74 branch <path>::
    68     -r, --revision <rev>  annotate the specified revision
    75     create a new branch of the repository indicated by path in the current
    69     -u, --user            list the author
    76     directory.  Note that there should not be a repository already initialized
    70     -c, --changeset       list the changeset
    77     in the current directory
    71     -n, --number          list the revision number (default)
    78 
    72 
    79 checkout [revision]::
    73 cat <file> [revision]::
    80     check out the indicated version of the repository into the working
    74     Output the given revision or tip of the specified file to stdout.
    81     directory.  Note that currently no merge occurs with changed files 
    75 
    82     in the working dir.
    76 commit [-A -t -l <file> -t <text> -u <user> -d <datecode>] [files...]::
    83 
       
    84 commit::
       
    85     commit all changed files in the working dir to the repository.  This uses
    77     commit all changed files in the working dir to the repository.  This uses
    86     the EDITOR environment variable to bring up an editor to add a commit
    78     the EDITOR environment variable to bring up an editor to add a commit
    87     comment.
    79     comment.
    88 
    80 
       
    81     Options:
       
    82     
       
    83     -A, --addremove       run addremove during commit
       
    84     -t, --text <text>     use <text> as commit message
       
    85     -l, --logfile <file>  read the commit message from the specified
       
    86                           file
       
    87     -d, --date <datecode> use the specified date code
       
    88     -u, --user <user>     record commit as the specified user
       
    89 
       
    90     aliases: ci
       
    91 
       
    92 copy <source> <dest>::
       
    93     Mark a file as copied or renamed for the next commit.
       
    94 
    89 diff [-r revision] [-r revision] [files ...]::
    95 diff [-r revision] [-r revision] [files ...]::
    90     generate a unified diff of the indicated files.  If there are no 
    96     Generate a unified diff of the indicated files. If there are no 
    91     revisions specified, the working directory file is compared to 
    97     revisions specified, the working directory file is compared to 
    92     the tip, one revision specified indicates a comparison between the 
    98     the tip, one revision specified indicates a comparison between the 
    93     working directory file and the specified revision, two revisions 
    99     working directory file and the specified revision, and two revisions 
    94     compares the two versions specified.
   100     compares the two versions specified.
    95 
   101 
    96 dump <file> [revision]::
   102 export [revision]::
    97     print the indicated revision of the file
   103     Print the changeset header (author, changeset hash, parent, and commit
    98 
   104     comment) and the diffs for a particular revision.
    99 dumpmanifest [revision]::
   105 
   100     print the indicated revision of the manifest (list of version controlled
   106 forget [files]::
       
   107     Undo an 'hg add' scheduled for the next commit.
       
   108 
       
   109 heads::
       
   110     Show all changesets with no children. These are the "heads" of
       
   111     development branches and are the usual targets for updates and merges.
       
   112 
       
   113 history::
       
   114     Print the revision history of the repository. Use the -v switch
       
   115     for more detail.
       
   116 
       
   117 identify::
       
   118     Print a short identifier of the current state of the repo. This
       
   119     includes one or two parent hash identifiers, followed by
       
   120     a "+" if there are uncommitted changes in the working directory,
       
   121     followed by a list of tags for this revision
       
   122 
       
   123     aliases: id
       
   124 
       
   125 import [-p <n> -b <base> -q] <patches>::
       
   126     Import the listed patches and commit them individually.
       
   127 
       
   128     options:
       
   129     -p, --strip <n>   directory strip option for patch
       
   130     -b <path>         base directory to read patches from
       
   131 
       
   132     aliases: patch
       
   133 
       
   134 init [-u] [source]::
       
   135     Initialize a repository in the current directory.
       
   136 
       
   137     If a source is specified, pull that source into the repository.
       
   138     This source is added to .hg/hgrc as the default for future pulls
       
   139     in this repository.
       
   140 
       
   141     If the specified source is on the same filesystem, the repository
       
   142     will be copied via hardlinks. This is the fastest and most
       
   143     space-efficient mode of operation.
       
   144 
       
   145     options:
       
   146     -u, --update   update the working directory to match the tip
       
   147 
       
   148 log <file>::
       
   149     Print the revision history of the specified file.
       
   150 
       
   151 manifest [revision]::
       
   152     Print the indicated revision of the manifest (list of version controlled
   101     files)
   153     files)
   102 
   154 
   103 export [revision]::
   155 parents::
   104     print the changeset header (author, changeset hash, parent, and commit
   156     Print the working directory's parent revisions.
   105     comment) and the diffs for a particular revision.
   157 
   106 
   158 pull <repository path>::
   107 history::
       
   108     print the revision history of the repository
       
   109 
       
   110 init::
       
   111     initialize a repository in the current directory
       
   112 
       
   113 log <file>::
       
   114     print the revision history of the specified file
       
   115 
       
   116 merge <repository path>::
       
   117     pull any changes from the specified repository to the repository in the
   159     pull any changes from the specified repository to the repository in the
   118     current directory.  Use the value of the HGMERGE environment variable
   160     current directory.
   119     as a program to resolve any merge conflicts between the two repositories.
   161 
   120     An implicit commit is done at the end of this process if there were any
   162     options:
   121     merge conflicts.  Note that merge does not yet merge with changed files
   163     -u, --update   update the working directory to tip after pull
   122     in the working dir.
   164 
       
   165 push <destination>::
       
   166     Push changes from the local repository to the specified
       
   167     destination. If the destination is local, this is identical to a
       
   168     a pull in that directory from the current directory.
       
   169 
       
   170     The other currently available push method is SSH. This requires an
       
   171     accessible shell account on the destination machine and a copy of
       
   172     hg in the remote path. Destinations are specified in the following
       
   173     form:
       
   174 
       
   175       ssh://[user@]host[:port]/path
       
   176 
       
   177 rawcommit [-p -d -u -F -t -l]::
       
   178     Primarily useful for importing from other SCMs. 
   123 
   179 
   124 recover::
   180 recover::
   125     rollback an interrupted transaction
   181     Recover from an interrupted commit or pull. This should only be
       
   182     necessary when Mercurial suggests it.
   126 
   183 
   127 remove [files ...]::
   184 remove [files ...]::
   128     schedule the indicated files for removal from the repository at the next
   185     schedule the indicated files for removal from the repository at the next
   129     commit
   186     commit
       
   187  
       
   188     aliases: rm
   130 
   189 
   131 serve [-a addr -n name -p port -t templatedir]::
   190 serve [-a addr -n name -p port -t templatedir]::
   132     this will start an http server, by default on port 8000, that will 
   191     Start a local HTTP repository browser and pull server.
   133     allow browsing the repository using the hgweb interface and will allow 
   192 
   134     merging from the repository.  -a sets the interface address, -p the 
   193     options:
   135     port to listen on, -n the name of the repository and -t sets the 
   194     -a, --address <addr> address to use
   136     location of the template directory.
   195     -p, --port <n>       port to use (default: 8000)
       
   196     -n, --name <name>    name to show in web pages (default: working dir)
       
   197     -t, --templatedir <path> web templates to use
   137 
   198 
   138 status::
   199 status::
   139     list new, changed, and missing files in the working directory
   200     Show changed files in the working directory.
       
   201 
       
   202     C = changed
       
   203     A = added
       
   204     R = removed
       
   205     ? = not tracked
       
   206 
       
   207 tag [-t <text> -d <datecode> -u <user>] <name> [revision]::
       
   208     Add a tag <name> to the specified revision or the tip.
       
   209 
       
   210     options:
       
   211     -t, --text <text>     message for tag commit log entry
       
   212     -d, --date <datecode> datecode for commit
       
   213     -u, --user <user>     user for commit
   140 
   214 
   141 tags::
   215 tags::
   142     list the current tags
   216     List the current tags.
       
   217 
       
   218 tip::
       
   219     Show the tip revision
   143 
   220 
   144 undo::
   221 undo::
   145     undo the last transaction
   222     Undo the last commit or pull transaction.
       
   223 
       
   224 update [-m -C] [revision]::
       
   225     Update or merge the working directory to a specified revision.
       
   226 
       
   227     If there are no outstanding changes in the working directory and
       
   228     there is a linear relationship between the current version and the
       
   229     requested version, the result is the requested version.
       
   230 
       
   231     Otherwise the result is a merge between the contents of the
       
   232     current working directory and the requested version. Files that
       
   233     changed between either parent are marked as changed for the next
       
   234     commit and a commit must be performed before any further updates
       
   235     are allowed. Merging will not be performed without the -m flag.
       
   236 
       
   237     The -C switch will tell Mercurial to forcibly update to the
       
   238     specified version, adding, removing, and overwriting locally
       
   239     changed fils as necessary.
       
   240 
       
   241     options:
       
   242     -m, --merge       allow merging of branches
       
   243     -C, --clean       overwrite locally modified files
       
   244 
       
   245     aliases: up checkout co
       
   246 
       
   247 verify::
       
   248     Verify the integrity of the current repository.
       
   249 
       
   250     This will perform an extensive check of the repository's
       
   251     integrity, validating the hashes and checksums of each entry in
       
   252     the changelog, manifest, and tracked files, as well as the
       
   253     integrity of their crosslinks and indices.
       
   254 
   146 
   255 
   147 ENVIRONMENT VARIABLES
   256 ENVIRONMENT VARIABLES
   148 ---------------------
   257 ---------------------
       
   258 
   149 HGMERGE::
   259 HGMERGE::
   150     points to an executable to use for resolving merge conflicts, the
   260     An executable to use for resolving merge conflicts. The program ,
   151     program will be executed with four arguments: local file, remote
   261     will be executed with three arguments: local file, remote file,
   152     file, ancestor file, and original filename.
   262     ancestor file.
       
   263 
       
   264     The default program is "hgmerge", which is a shell script provided
       
   265     by Mercurial with some sensible defaults.
   153 
   266 
   154 HGUSER::
   267 HGUSER::
   155     this is the string used for the author value of a commit
   268     This is the string used for the author of a commit.
   156 
       
   157 HG_OPTS::
       
   158     this string is used for default arguments to hg
       
   159 
       
   160 PYTHONPATH::
       
   161     this is used by Python to find imported modules and needs to be set
       
   162     appropriately based on where mercurial is installed
       
   163 
   269 
   164 EMAIL::
   270 EMAIL::
   165     if HGUSER is not set, this will be used next as the author value for
   271     If HGUSER is not set, this will be used as the author for a commit.
   166     a commit
       
   167 
   272 
   168 LOGNAME::
   273 LOGNAME::
   169     if neither HGUSER nor EMAIL is set, LOGNAME will be used (with
   274     if neither HGUSER nor EMAIL is set, LOGNAME will be used (with
   170     '@hostname' appended) as the author value for a commit
   275     '@hostname' appended) as the author value for a commit.
   171 
   276 
   172 EDITOR::
   277 EDITOR::
   173     this is the name of the editor to use when committing
   278     This is the name of the editor to use when committing. Defaults to 'vi'.
       
   279 
       
   280 PYTHONPATH::
       
   281     This is used by Python to find imported modules and may need to be set
       
   282     appropriately if Mercurial is not installed system-wide.
   174 
   283 
   175 FILES
   284 FILES
   176 -----
   285 -----
   177  .hgignore::
   286  .hgignore::
   178     this file contains regular expressions (one per line) that describe file
   287     This file contains regular expressions (one per line) that describe file
   179     names that should be ignored by hg
   288     names that should be ignored by hg
   180 
   289 
   181  .hgtags::
   290  .hgtags::
   182     this file contains changeset hash values and text tag names (one of each
   291     This file contains changeset hash values and text tag names (one of each
   183     seperated by spaces) that correspond to tagged versions of the repository
   292     seperated by spaces) that correspond to tagged versions of the repository
   184     contents.
   293     contents.
   185 
   294 
   186  $HOME/.hgpaths::
   295  $HOME/.hgrc, .hg/hgrc::
   187     this file contains a mapping from a symbolic name to a repository path
   296     This file contains defaults and configuration. Values in .hg/hgrc
   188     (which could be a local path or a remote URI), the format is 
   297     override those in .hgrc.
   189     <symbolic name> <repository path> with each mapping on a seperate line
   298 
       
   299 NAMED REPOSITORIES
       
   300 ------------------
       
   301 
       
   302     To give symbolic names to a repository, create a section in .hgrc
       
   303     or .hg/hgrc containing assignments of names to paths.
       
   304 
       
   305     Example:
       
   306 
       
   307 [paths]
       
   308 hg = http://selenic.com/hg
   190 
   309 
   191 NON_TRANSPARENT PROXY SUPPORT
   310 NON_TRANSPARENT PROXY SUPPORT
   192 -----
   311 -----------------------------
   193 
   312 
   194     To access a mercurial repository through a proxy,
   313     To access a Mercurial repository through a proxy,
   195     create a file $HOME/.hgrc in the following format:
   314     create a file $HOME/.hgrc in the following format:
   196 
   315 
   197 [http_proxy]
   316 [http_proxy]
   198 host=myproxy:8080
   317 host=myproxy:8080
   199 user=<username>
   318 user=<username>