Differences between revisions 14 and 38 (spanning 24 versions)
Revision 14 as of 2008-01-16 10:11:01
Size: 3227
Editor: abuehl
Comment:
Revision 38 as of 2013-03-25 18:30:23
Size: 4662
Editor: 208
Comment: Fixed typo
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Repository == #pragma section-numbers 2
Line 3: Line 3:
''(for a short intro of the basic concepts of Mercurial, see UnderstandingMercurial)'' = Repository =
Line 5: Line 5:
A '''repository''' is a directory (the repository directory or "repo" directory) which contains a subdirectory named {{{.hg}}} (dot hg) where Mercurial stores its internal data structures. Everything else (files and other subdirectories) in the repo directory is conceptually part of the [:WorkingDirectory:working directory], which is tracked by Mercurial (some files and subdirectories may be ignored. See [".hgignore"]). ''(for a short intro of the basic concepts of Mercurial, see [[UnderstandingMercurial]])''
Line 7: Line 7:
[[TableOfContents]] 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.
Line 9: Line 9:
=== Creation === 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]].

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 addressed 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.

<<TableOfContents>>


== Creation ==

Repositories can be [[Cmd:clone|cloned]] with {{{hg clone}}}, which creates a copy of an existing repository. If possible,
Mercurial uses hardlinks to save space and speedup the cloning (see HardlinkedClones).
Line 14: Line 28:
=== Tracking Files === == Tracking files ==
Line 16: Line 30:
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 [[Cmd:commit|committed]] with {{{hg commit}}}, which adds a new [[ChangeSet|changeset]] to the repository by recording it in the {{{.hg}}} directory.
Line 18: Line 32:
The working directory can be restored with {{{hg update}}} to any previously committed state by specifying the requested changeset with its [:ChangeSetID:changeset ID]. 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 [[Cmd:update|update]]). Use {{{hg parents}}} to see the currently checked
out revision (see [[Cmd:parents|parents]]).
Line 20: Line 35:
The last transaction in a repository can be undone with {{{hg rollback}}} (see ["Rollback"]). The last commit in a repository can be undone with {{{hg rollback}}} (see [[Cmd:rollback|rollback]]).
Line 23: Line 38:
=== Transferring Changesets and Cloning === == Transferring changesets ==
Line 25: Line 40:
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"]).

Repositories can be [:Clone:cloned] with {{{hg clone}}}.
Changesets can be transferred from one repository to another with {{{hg pull}}}, {{{hg push}}}, {{{hg export}}} and {{{hg import}}} (see [[Cmd:pull]], [[Cmd:push]], [[Cmd:export]], [[Cmd:import]], [[CommunicatingChanges]]).
Line 30: Line 43:
=== Checking Integrity === == Checking integrity ==
Line 35: Line 48:
=== Structure === == Structure ==
Line 39: Line 52:
 * 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 &mdash; Files {{{.hg/store/00changelog.i}}} and {{{.hg/store/00changelog.d}}}
Line 44: Line 57:
    {{{<encoded path>}}} is the path of the tracked file in the working directory, encoded according to [:CaseFoldingPlan].     {{{<encoded path>}}} is the path of the tracked file in the working directory, encoded according to [[CaseFoldingPlan]].
 * The [[DirState|dirstate]] &mdash; File {{{.hg/dirstate}}}
    Tracks various information about the working directory.
 * The [[RequiresFile|requires file]] &mdash; File {{{.hg/requires}}}
    Specifies the capabilities needed by a client to access this repository

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 47: Line 66:
=== Backup === == Backup ==
Line 49: Line 68:
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 52: Line 71:
=== See also === == See also ==
Line 54: Line 73:
 * ManPages
 *
RepositoryNaming
 * PublishingRepositories
 * RepositoryConversion
 * [[RepositoryNaming]]
 * [[PublishingRepositories]]
 * [[SharedRepository]]
 * [[Subrepository]]
 * [[
RepositoryCorruption]]
 * [[UpgradingMercurial]]
Line 61: Line 82:

[[FrenchRepository|Français]]

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 addressed 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.

1. Creation

Repositories can be cloned with hg clone, which creates a copy of an existing repository. If possible, Mercurial uses hardlinks to save space and speedup the cloning (see HardlinkedClones).

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

2. 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 parents).

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

3. 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).

4. Checking integrity

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

5. 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.
  • The requires file — File .hg/requires

    • Specifies the capabilities needed by a client to access this repository

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).

6. 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).

7. See also


CategoryGlossary

Français

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