O modelo de desenvolvimento descentralizado do Mercurial pode confundir os novos usuários. Esta página tenta ilustrar alguns conceitos básicos. Veja o ["Tutorial"] para instruções passo a passo.

TableOfContents

O que é um Repositório

Os [:Repository:repositórios] do Mercurial contém um [:WorkingDirectory:diretório de trabalho] acoplado com um store:

O store contém o histórico completo do projeto. Diferente dos [:SCM:SCMs] tradicionais, onde há apenas uma cópia central deste histórico, todo diretório de trabalho é acompanhado de uma cópia privada do histórico. Isto permite que o desenvolvimento ocorra em paralelo.

O diretório de trabalho contém uma cópia dos arquivos do projeto em um determinado ponto do tempo pronta para edição (por exemplo, rev 2). Devido as [:Tag:tags] e os arquivos ignorados serem serem controlados pela revisão, eles também são incluídos.

Salvando (Committing) Modificações

Quando você submete suas modificações ([:Commit:commit]), o estado do diretório de trabalho em relação aos seus [:Parent:pais] é gravado como uma nova [:Revision:revisão]:

Note here that revision 4 is a branch of revision 2, which was the revision in the working directory. Now revision 4 is the working directory's parent.

Revisões, Changesets, Heads, and Tip

O Mercurial agrupa as modificações relacionadas a múltiplos arquivos um único conjunto atômicio de modificações ([:ChangeSet:changesets]), os quais são as revisões para o prpjeto como um todo. Cada uma destas modificações recebe um [:RevisionNumber:número de revisão] seqüencial. Because Mercurial allows distributed parallel development, these revision numbers may disagree between users. So Mercurial also assigns each revision a global [:ChangeSetID:changeset ID]. Changeset IDs are 40-digit hexadecimal numbers, but they can be abbreviated to any unambiguous prefix, like "e38487".

Branches and [:Merge:merges] in the revision history can occur at any point. Each unmerged branch creates a new [:Head:head] of the revision history. Here, revisions 5 and 6 are heads. Mercurial considers revision 6 to be the [:Tip:tip] of the repository, the head with the highest revision number.

Cloning, Making Changes, Merging, and Pulling

Let's start with a user Alice, who has a store that looks like:

Bob [:Clone:clones] this repo, and ends up with a complete copy of Alice's store (though his working directory is independent!):

Bob then [:Commit:commits] a couple changes:

Alice then makes her own change in parallel:

Bob then [:Pull:pulls] Alice's repo to synchronize. This copies all of Alice's changes into Bob's repo:

Because Alice's g is the newest head in Bob's repository, it's now the tip. Bob then does a [:Merge:merge] which combines the last change he was working on (f) with the tip, commits the result, and ends up with:

Now if Alice pulls from Bob, she will get Bob's changes e, f, and h, and they will be fully synchronized:

A Decentralized System

Mercurial is a completely decentralized system, and thus has no internal notion of a central repository. Thus users are free to define their own topologies for sharing changes (see CommunicatingChanges):

For a hands-on introduction to using Mercurial, see the ["Tutorial"].