Differences between revisions 14 and 16 (spanning 2 versions)
Revision 14 as of 2008-03-31 23:16:36
Size: 1907
Editor: abuehl
Comment:
Revision 16 as of 2008-09-11 23:30:24
Size: 2355
Editor: abuehl
Comment: add a bit about when we have two or one parent revision
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
It’s useful to think of the working directory as "the changeset I’m about to commit". It’s useful to think of the working directory as "the changeset I’m about to commit". If the working directory has no [:LocalModifications:local modifications] it is said to be ''clean''.

Use {{{hg revert}}} to discard all local modifications (see [:Revert]).
Line 20: Line 22:
A working directory has one or two [:Parent:parent] revisions. The parent revision or revisions will become the parent revisions of the new revision which will eventually be created by a commit of the [:LocalModifications:local modifications]. A working directory has one or two [:Parent:parent] revisions. The parent revision (or revisions) will become the parent revisions of the new revision which will eventually be created by a commit of the local modifications.
Line 22: Line 24:
An update will change the parent revision, whereas a [:Revert:revert] will only modify the content of the working directory. An {{{hg update}}} will change the parent revision, whereas {{{hg revert}}} will only modify the content of the working directory.
Line 24: Line 26:
A working directory will only have two parent revisions as the result of a [:Merge:merge]. A working directory will only have two parent revisions as the result of a [:Merge:merge],
but only until that merge has been committed.

Immediately after a commit (or after an update -C), the working directory has exactly ''one'' parent revision,
namely the newly committed (or updated-to) changeset. This is even the case if the newly committed
changeset was a merge.

Working directory

The working directory is the top-level directory in a [:Repository:repository], in which the plain versions of files are available to read, edit and build. Files in the working directory are usually from the [:Tip:tip], but may be from older [:Revision:revisions], or modified and not yet [:Commit:committed].

It’s useful to think of the working directory as "the changeset I’m about to commit". If the working directory has no [:LocalModifications:local modifications] it is said to be clean.

Use hg revert to discard all local modifications (see [:Revert]).

Use hg update to bring the working directory into sync with a particular [:ChangeSet:changeset] (see [:Update]).

To remove all files from the working directory (not the repository!), you can do

hg update null

A [:NamedBranches:branch name] can be set for the working directory.

Mercurial tracks various information about the working directory (see DirState).

1. Parent(s)

A working directory has one or two [:Parent:parent] revisions. The parent revision (or revisions) will become the parent revisions of the new revision which will eventually be created by a commit of the local modifications.

An hg update will change the parent revision, whereas hg revert will only modify the content of the working directory.

A working directory will only have two parent revisions as the result of a [:Merge:merge], but only until that merge has been committed.

Immediately after a commit (or after an update -C), the working directory has exactly one parent revision, namely the newly committed (or updated-to) changeset. This is even the case if the newly committed changeset was a merge.

2. When an update is needed

There are several ways to see if an update of your working directory is needed (see related [http://www.selenic.com/pipermail/mercurial/2006-September/010951.html mailing list thread]):

To see the delta between the working directory and the tip, do:

hg diff -r tip

To see what patches would be applied to the working directory on an update do:

hg log -r tip:.

If the working directory is at the tip (that is, no update needed)

hg id

will write "tip" after the changeset id.


CategoryGlossary

WorkingDirectory (last edited 2012-11-06 16:23:25 by abuehl)