Differences between revisions 24 and 26 (spanning 2 versions)
Revision 24 as of 2008-12-31 16:23:56
Size: 4324
Editor: abuehl
Comment: +link
Revision 26 as of 2009-05-19 21:56:55
Size: 4358
Editor: BenoitAllard
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
''(for a short intro of the basic concepts of Mercurial, see [:UnderstandingMercurial])''
''(for a short intro of the basic concepts of Mercurial, see [[UnderstandingMercurial]])''
Line 8: Line 9:
All of the files and directories that coexist with the `.hg` directory in the repository root are said to live in the [:WorkingDirectory:working directory]. All of the files and directories that coexist with the `.hg` directory in the repository root are said to live in the [[WorkingDirectory|working directory]].
Line 12: Line 13:
Local Mercurial repositores are adressed by specifying the path to the repository root (global option `-R` for commands). Local Mercurial repositories are adressed by specifying the path to the repository root (global option `-R` for commands).
Line 16: Line 17:
[[TableOfContents]] <<TableOfContents>>
Line 21: Line 22:
Repositories can be [:Clone:cloned] with {{{hg clone}}}, which creates a copy of an existing repository. Repositories can be [[Clone|cloned]] with {{{hg clone}}}, which creates a copy of an existing repository.
Line 28: Line 29:
A file in the working directory that shall be tracked by Mercurial must be added with {{{hg add}}}. [:LocalModifications:Local modifications] to tracked files in the working directory can be [:Commit:committed] with {{{hg commit}}}, which adds a new [:ChangeSet:changeset] to the repository by recording it in the {{{.hg}}} directory. A file in the working directory that shall be tracked by Mercurial must be added with {{{hg add}}}. [[LocalModifications|Local modifications]] to tracked files in the working directory can be [[Commit|committed]] with {{{hg commit}}}, which adds a new [[ChangeSet|changeset]] to the repository by recording it in the {{{.hg}}} directory.
Line 30: Line 31:
The working directory can be restored with {{{hg update}}} to any previously committed state by specifying the requested changeset with its [:ChangeSetID:changeset ID] (see [:Update]). Use {{{hg parents}}} to see the currently checked
out revision (see [:Parent]).
The working directory can be restored with {{{hg update}}} to any previously committed state by specifying the requested changeset with its [[ChangeSetID|changeset ID]] (see [[Update]]). Use {{{hg parents}}} to see the currently checked
out revision (see [[Parent]]).
Line 33: Line 34:
The last commit in a repository can be undone with {{{hg rollback}}} (see [:Rollback]). The last commit in a repository can be undone with {{{hg rollback}}} (see [[Rollback]]).
Line 38: Line 39:
Changesets can be transferred from one repository to another with {{{hg pull}}}, {{{hg push}}}, {{{hg export}}} and {{{hg import}}} (see [:Pull], [:Push], [:Export], [:Import], [:CommunicatingChanges]). Changesets can be transferred from one repository to another with {{{hg pull}}}, {{{hg push}}}, {{{hg export}}} and {{{hg import}}} (see [[Pull]], [[Push]], [[Export]], [[Import]], [[CommunicatingChanges]]).
Line 50: Line 51:
 * The [:Manifest:manifest] &mdash; Files {{{.hg/store/00manifest.i}}} and {{{.hg/store/00manifest.d}}}
    Describes the file contents of the repository at a particular changeset ID. Stored in [:Revlog:revlog] format.
 * The [:Changelog:changelog] &mdash; Files {{{.hg/store/00changelog.i}}} and {{{.hg/store/00changelog.d}}}
 * The [[Manifest|manifest]] &mdash; Files {{{.hg/store/00manifest.i}}} and {{{.hg/store/00manifest.d}}}
    Describes the file contents of the repository at a particular changeset ID. Stored in [[Revlog|revlog]] format.
 * The [[Changelog|changelog]] &mdash; Files {{{.hg/store/00changelog.i}}} and {{{.hg/store/00changelog.d}}}
Line 55: Line 56:
    {{{<encoded path>}}} is the path of the tracked file in the working directory, encoded according to [:CaseFoldingPlan].
 * The [:DirState:dirstate] &mdash; File {{{.hg/dirstate}}}
    {{{<encoded path>}}} is the path of the tracked file in the working directory, encoded according to [[CaseFoldingPlan]].
 * The [[DirState|dirstate]] &mdash; File {{{.hg/dirstate}}}
Line 59: Line 60:
Note that for small revlogs, the revlog data file ({{{*.d}}}) may be missing, because its content may be interleaved into the corresponding index file ({{{*.i}}}) (see also [:RevlogNG]). Note that for small revlogs, the revlog data file ({{{*.d}}}) may be missing, because its content may be interleaved into the corresponding index file ({{{*.i}}}) (see also [[RevlogNG]]).
Line 64: Line 65:
Backing up a repository can be done by using push/pull/clone to a backup repository. A repository which is not actively written to (by other processes concurrently running on the computer) can be backed-up by backing-up the repo directory using normal directory/file backup procedures (like tar, zip, etc). The {{{.hg}}} directory is [:CaseFolding:case folding] tolerant, which means, it can for example be copied onto a FAT filesystem (see also [:BackUp], [:CaseFoldingPlan]). Backing up a repository can be done by using push/pull/clone to a backup repository. A repository which is not actively written to (by other processes concurrently running on the computer) can be backed-up by backing-up the repo directory using normal directory/file backup procedures (like tar, zip, etc). The {{{.hg}}} directory is [[CaseFolding|case folding]] tolerant, which means, it can for example be copied onto a FAT filesystem (see also [[BackUp]], [[CaseFoldingPlan]]).
Line 69: Line 70:
 * [:ManPages]
 * [:RepositoryNaming]
 * [:PublishingRepositories]
 * [:RepositoryConversion]
 * [:DeveloperRepos]
 * [:RepoSamples]
 * [:SharedRepository]
 * [[ManPages]]
 * [[RepositoryNaming]]
 * [[PublishingRepositories]]
 * [[RepositoryConversion]]
 * [[DeveloperRepos]]
 * [[RepoSamples]]
 * [[SharedRepository]]

Repository

(for a short intro of the basic concepts of Mercurial, see UnderstandingMercurial)

Strictly speaking, the term repository refers to the directory named .hg (dot hg) in the repository root directory. The repository root directory is the parent directory of the .hg directory. Mercurial stores its internal data structures – the metadata – inside that .hg directory.

All of the files and directories that coexist with the .hg directory in the repository root are said to live in the working directory.

An easy way to remember the distinction is that the repository contains the history of your project, while the working directory contains a snapshot of your project at a particular point in history.

Local Mercurial repositories are adressed by specifying the path to the repository root (global option -R for commands).

Sometimes Mercurial users and developers also use the term "repository" when referring to the repository root. But strictly speaking, the .hg directory is the "real" repository.

Creation

Repositories can be cloned with hg clone, which creates a copy of an existing repository.

An existing, already populated but yet untracked directory can be transformed into a repository with hg init, which creates and initializes the .hg subdirectory.

Tracking Files

A file in the working directory that shall be tracked by Mercurial must be added with hg add. Local modifications to tracked files in the working directory can be committed with hg commit, which adds a new changeset to the repository by recording it in the .hg directory.

The working directory can be restored with hg update to any previously committed state by specifying the requested changeset with its changeset ID (see Update). Use hg parents to see the currently checked out revision (see Parent).

The last commit in a repository can be undone with hg rollback (see Rollback).

Transferring Changesets

Changesets can be transferred from one repository to another with hg pull, hg push, hg export and hg import (see Pull, Push, Export, Import, CommunicatingChanges).

Checking Integrity

Checking the internal integrity of a repository (the contents of .hg) can be done with hg verify.

Structure

The .hg directory of a repository contains (incomplete listing):

  • The manifest — Files .hg/store/00manifest.i and .hg/store/00manifest.d

    • Describes the file contents of the repository at a particular changeset ID. Stored in revlog format.

  • The changelog — Files .hg/store/00changelog.i and .hg/store/00changelog.d

    • Contains all changesets. Stored in revlog format.
  • A revlog per tracked file — Files .hg/store/data/<encoded path>.i and .hg/store/data/<encoded path>.d

    • <encoded path> is the path of the tracked file in the working directory, encoded according to CaseFoldingPlan.

  • The dirstate — File .hg/dirstate

    • Tracks various information about the working directory.

Note that for small revlogs, the revlog data file (*.d) may be missing, because its content may be interleaved into the corresponding index file (*.i) (see also RevlogNG).

Backup

Backing up a repository can be done by using push/pull/clone to a backup repository. A repository which is not actively written to (by other processes concurrently running on the computer) can be backed-up by backing-up the repo directory using normal directory/file backup procedures (like tar, zip, etc). The .hg directory is case folding tolerant, which means, it can for example be copied onto a FAT filesystem (see also BackUp, CaseFoldingPlan).

See also


CategoryGlossary

Repository (last edited 2013-03-25 18:30:23 by 208)