doc/FAQ.txt
author mpm@selenic.com
Thu, 23 Jun 2005 13:48:44 -0800
changeset 446 8cc0ee3f18fb
child 449 df83b2c306ac
permissions -rw-r--r--
The beginnings of a FAQ file -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The beginnings of a FAQ file manifest hash: 234ee7d9fb5cd3b0bd794e615a74f96a4cc234e0 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCuy48ywK+sNU5EO8RAmdYAJ923bFC/a6q28nVYumWsaQ+axlKawCfS7IC kh1xVlj5OYOloicyaHDhLU4= =7CJ2 -----END PGP SIGNATURE-----
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
446
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
     1
Mercurial Frequently Asked Questions
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
     2
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
     3
Section 1: General Usage
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
     4
------------------------
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
     5
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
     6
Q. I did an 'hg pull' and my working directory is empty!
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
     7
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
     8
There are two parts to Mercurial: the repository and the working
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
     9
directory. 'hg pull' pulls all new changes from a remote repository
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    10
into the local one but doesn't alter the working directory.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    11
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    12
This keeps you from upsetting your work in progress, which may not be
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    13
ready to merge with the new changes you've pulled and also allows you
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    14
to manage merging more easily (see below about best practices).
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    15
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    16
To update your working directory, run 'hg update'. If you're sure you
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    17
want to update your working directory on a pull, you can also use 'hg
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    18
pull -u'. This will refuse to merge or overwrite local changes.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    19
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    20
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    21
Q. What is the difference between revision numbers, changeset IDs,
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    22
and tags?
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    23
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    24
Mercurial will generally allow you to refer to a revision in three
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    25
ways: by revision number, by changeset ID, and by tag.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    26
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    27
A revision number is a simple decimal number that corresponds with the
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    28
ordering of commits in the local repository. It is important to
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    29
understand that this ordering can change from machine to machine due
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    30
to Mercurial's distributed, decentralized architecture.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    31
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    32
This is where changeset IDs come in. A changeset ID is a 160-bit
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    33
identifier that uniquely describes a changeset and its position in the
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    34
change history, regardless of which machine it's on. This is
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    35
represented to the user as a 40 digit hexadecimal number. As that
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    36
tends to be unwieldy, Mercurial will accept any unambiguous substring
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    37
of that number when specifying versions. It will also generally print
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    38
these numbers in "short form", which is the first 12 digits.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    39
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    40
You should always use some form of changeset ID rather than the local
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    41
revision number when discussing revisions with other Mercurial users
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    42
as they may have different revision numbering on their system.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    43
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    44
Finally, a tag is an arbitrary string that has been assigned a
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    45
correspondence to a changeset ID. This lets you refer to revisions
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    46
symbolically.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    47
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    48
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    49
Q. What are branches, heads, and the tip?
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    50
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    51
The central concept of Mercurial is branching. A 'branch' is simply
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    52
an independent line of development. In most other version control
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    53
systems, all users generally commit to the same line of development
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    54
called 'the trunk' or 'the main branch'. In Mercurial, every developer
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    55
effectively works on a private branch and there is no internal concept
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    56
of 'the main branch'.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    57
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    58
Thus Mercurial works hard to make repeated merging between branches
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    59
easy. Simply run 'hg pull' and 'hg update -m' and commit the result.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    60
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    61
'Heads' are simply the most recent commits on a branch. Technically,
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    62
they are changesets which have no children. Merging is the process of
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    63
joining points on two branches into one, usually at their current
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    64
heads. Use 'hg heads' to find the heads in the current repository.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    65
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    66
The 'tip' is the most recently changed head, and also the highest
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    67
numbered revision. If you have just made a commit, that commit will be
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    68
the head. Alternately, if you have just pulled from another
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    69
repository, the tip of that repository becomes the current tip.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    70
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    71
The 'tip' is the default revision for many commands such as update,
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    72
and also functions as a special symbolic tag.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    73
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    74
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    75
Q. How does merging work?
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    76
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    77
The merge process is simple. Usually you will want to merge the tip
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    78
into your working directory. Thus you run 'hg update -m' and Mercurial
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    79
will incorporate the changes from tip into your local changes.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    80
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    81
The first step of this process is tracing back through the history of
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    82
changesets and finding the 'common ancestor' of the two versions that
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    83
are being merged. This is done on a project-wide and a file by file
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    84
basis.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    85
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    86
For files that have been changed in both projects, a three-way merge
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    87
is attempted to add the changes made remotely into the changes made
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    88
locally. If there are conflicts between these changes, the user is
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    89
prompted to interactively resolve them.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    90
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    91
Mercurial uses a helper tool for this, which is usually found by the
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    92
hgmerge script. Example tools include tkdiff, kdiff3, and the classic
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    93
RCS merge.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    94
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    95
After you've completed the merge and you're satisfied that the results
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    96
are correct, it's a good idea to commit your changes. Mercurial won't
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    97
allow you to perform another merge until you've done this commit as
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    98
that would lose important history that will be needed for future
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
    99
merges.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   100
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   101
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   102
Q. How do tags work in Mercurial?
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   103
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   104
Tags work slightly differently in Mercurial than most revision
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   105
systems. The design attempts to meet the following requirements:
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   106
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   107
- be version controlled and mergeable just like any other file
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   108
- allow signing of tags
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   109
- allow adding a tag to an already committed changeset
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   110
- allow changing tags in the future
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   111
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   112
Thus Mercurial stores tags as a file in the working dir. This file is
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   113
called .hgtags and consists of a list of changeset IDs and their
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   114
corresponding tags. To add a tag to the system, simply add a line to
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   115
this file and then commit it for it to take effect. The 'hg tag'
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   116
command will do this for you and 'hg tags' will show the currently
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   117
effective tags.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   118
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   119
Note that because tags refer to changeset IDs and the changeset ID is
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   120
effectively the sum of all the contents of the repository for that
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   121
change, it is impossible in Mercurial to simultaneously commit and add
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   122
a tag. Thus tagging a revision must be done as a second step.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   123
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   124
Q. How do tags work with multiple heads?
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   125
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   126
The tags that are in effect at any given time are the tags specified
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   127
in each head, with heads closer to the tip taking precedence.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   128
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   129
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   130
Q. What are some best practices for distributed development with Mercurial?
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   131
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   132
First, merge often! This makes merging easier for everyone and you
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   133
find out about conflicts (which are often rooted in incompatible
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   134
design decisions) earlier.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   135
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   136
Second, don't hesitate to use multiple trees locally. Mercurial makes
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   137
this fast and light-weight. Typical usage is to have an incoming tree,
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   138
an outgoing tree, and a separate tree for each area being worked on.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   139
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   140
The incoming tree is best maintained as a pristine copy of the
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   141
upstream repository. This works as a cache so that you don't have to
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   142
pull multiple copies over the network. No need to check files out here
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   143
as you won't be changing them.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   144
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   145
The outgoing tree contains all the changes you intend for merger into
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   146
upsteam. Publish this tree with 'hg serve' or hgweb.cgi or use 'hg
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   147
push' to push it to another publicly availabe repository.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   148
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   149
Then, for each feature you work on, create a new tree. Commit early
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   150
and commit often, merge with incoming regularly, and once you're
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   151
satisfied with your feature, pull the changes into your outgoing tree.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   152
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   153
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   154
Q. How do I import from a repository created in a different SCM?
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   155
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   156
Take a look at contrib/convert-repo. This is an extensible
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   157
framework for converting between repository types.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   158
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   159
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   160
Q. What about Windows support?
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   161
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   162
Patches to support Windows are being actively integrated, a fully
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   163
working Windows version is probably not far off
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   164
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   165
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   166
Section 2: Technical
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   167
--------------------
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   168
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   169
Q. What limits does Mercurial have?
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   170
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   171
Mercurial currently assumes that single files, indices, and manifests
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   172
can fit in memory for efficiency.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   173
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   174
Offsets in revlogs are currently tracked with 32 bits, so a revlog for
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   175
a single file can currently not grow beyond 4G.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   176
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   177
There should otherwise be no limits on file name length, file size,
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   178
file contents, number of files, or number of revisions.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   179
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   180
The network protocol is big-endian.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   181
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   182
File names cannot contain the null character. Committer addresses
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   183
cannot contain newlines.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   184
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   185
Mercurial is primarily developed for UNIX systems, so some UNIXisms
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   186
may be present in ports.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   187
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   188
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   189
Q. How does signing work?
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   190
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   191
Take a look at the hgeditor script for an example. The basic idea
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   192
is to sign the manifest ID inside that changelog entry. The manifest
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   193
ID is a recursive hash of all of the files in the system and their
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   194
complete history, and thus signing the manifest hash signs the entire
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   195
project to that point.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   196
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   197
More precisely: each file hash is an SHA1 hash of the contents of that
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   198
file and the hashes of its parent revisions. The manifest contains a
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   199
list of each file in the project along with its current file hash.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   200
This manifest is hashed similarly to the file hashes, incorporating
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   201
the hashes of the parent revisions.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   202
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   203
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   204
Q. What about hash collisions? What about weaknesses in SHA1?
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   205
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   206
The SHA1 hashes are large enough that the odds of accidental hash collision
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   207
are negligible for projects that could be handled by the human race.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   208
The known weaknesses in SHA1 are currently still not practical to
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   209
attack, and Mercurial will switch to SHA256 hashing before that
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   210
becomes a realistic concern.
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   211
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   212
Collisions with the "short hashes" are not a concern as they're always
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   213
checked for ambiguity and are still long enough that they're not
8cc0ee3f18fb The beginnings of a FAQ file
mpm@selenic.com
parents:
diff changeset
   214
likely to happen for reasonably-sized projects (< 1M changes).