Differences between revisions 4 and 5
Revision 4 as of 2008-03-20 22:25:42
Size: 2671
Editor: abuehl
Comment: af3f26b6bba: dirstate: ignore stat data for files that were updated too recently
Revision 5 as of 2008-04-07 22:29:21
Size: 2696
Editor: abuehl
Comment: +cat
Deletions are marked like this. Additions are marked like this.
Line 58: Line 58:
----
CategoryInternals

Working Directory State

Mercurial tracks various information about the [:WorkingDirectory:working directory] (the dirstate):

  • what revision(s) are currently checked out
  • what files have been copied or renamed
  • what files are controlled by Mercurial

For each file that Mercurial controls, we record the following information:

  • its size
  • its mode
  • its modification time
  • its "state"

The states that are tracked are:

  • n - normal
  • a - added
  • r - removed
  • m - 3-way merged

With this information, we can quickly determine what files in the working directory have changed.

Here's an example of the dirstate:

$ hg parents -q
1224:cc61d366bc3b
$ hg debugstate
n 644        168 08/19/05 17:42:17 .hgignore
n 644        412 08/20/05 01:46:57 .hgtags
n 644       1328 08/26/05 23:22:20 CONTRIBUTORS
n 644      17992 06/30/05 10:19:51 COPYING
n 644        459 08/24/05 00:38:20 MANIFEST.in
n 644        512 08/24/05 00:35:02 Makefile
n 644        232 06/30/05 10:19:51 PKG-INFO
n 644       2736 08/20/05 00:48:33 README
n 644       1676 06/30/05 10:19:51 comparison.txt
n 644       3711 12/31/69 15:59:59 contrib/bash_completion
n 711       1305 07/01/05 15:04:52 contrib/buildrpm
n 755       8300 08/16/05 16:03:59 contrib/convert-repo
n 644         69 06/30/05 10:19:51 contrib/git-viz/git-cat-file
n 644         69 06/30/05 10:19:51 contrib/git-viz/git-diff-tree
n 644         69 06/30/05 10:19:51 contrib/git-viz/git-rev-list
n 644         69 06/30/05 10:19:51 contrib/git-viz/git-rev-tree
n 644        457 06/30/05 10:19:51 contrib/git-viz/hg-viz
n 755       8039 08/16/05 16:03:59 contrib/hgit
n 755      40043 06/30/05 10:19:51 contrib/hgk
...

For files having state "n" in the dirstate, Mercurial compares the file modification time and the size in the dirstate with the modification time and the size of the file in the working directory. If both the modification time and the size are the same, Mercurial will not include it in the next [:Commit:commit].

From this follows, that if a file F has been first included in a [:ChangeSet:changeset] C as changed and then quickly been modfied again within the same second of the commit of C (with respect to the local system time), Mercurial will only include the file in the next commit, if F changed its size during the new modification. This aspect must be considered when doing fast scripted serial commits.


CategoryInternals

DirState (last edited 2021-11-04 11:32:34 by RaphaelGomes)