Mercurial > hg
annotate hgext/graphlog.py @ 25759:ff11c1565c04
cmdutil: apply dirstate.normallookup on (maybe partially) committed files
To detect change of a file without redundant comparison of file
content, dirstate recognizes a file as certainly clean, if:
(1) it is already known as "normal",
(2) dirstate entry for it has valid (= not "-1") timestamp, and
(3) mode, size and timestamp of it on the filesystem are as same as
ones expected in dirstate
This works as expected in many cases, but doesn't in the corner case
that changing a file keeps mode, size and timestamp of it on the
filesystem.
The timetable below shows steps in one of typical such situations:
---- ----------------------------------- ----------------
timestamp of "f"
----------------
dirstate file-
time action mem file system
---- ----------------------------------- ---- ----- -----
N *** ***
- change "f" N
- execute 'hg commit -i'
- backup "f" with timestamp N
- revert "f" by 'merge.update()' N
with 'partially'
- apply selected hunks N
by 'patch.patch()'
- 'repo.commit()'
- 'dirstate.normal("f")' N
N+1
- 'dirstate.write()' N N
- restore "f" N+1
- restore timestamp of "f" N
- 'hg status' shows "f" as "clean" N N N
---- ----------------------------------- ---- ----- -----
The most important point is that 'dirstate.write()' is executed at N+1
or later. This causes writing dirstate timestamp N of "f" out
successfully. If it is executed at N, 'parsers.pack_dirstate()'
replaces timestamp N with "-1" before actual writing dirstate out.
This issue can occur when 'hg commit -i' satisfies conditions below:
- the file is committed partially, and
- mode and size of the file aren't changed before and after committing
The root cause of this issue is that (maybe partially changed) files
are restored with original timestamp but dirstate isn't updated for
them.
To detect changes of files correctly, this patch applies
'dirstate.normallookup()' on restored files. Status check is needed
before 'dirstate.normallookup()', because status other than "n(ormal)"
should be kept at failure of committing.
This patch doesn't examine whether each files are committed fully or
partially, because interactive hunk selection makes it difficult.
After this change, timetable is changed as below:
---- ----------------------------------- ----------------
timestamp of "f"
----------------
dirstate file-
time action mem file system
---- ----------------------------------- ---- ----- -----
N *** ***
- change "f" N
- execute 'hg commit -i'
- backup "f" with timestamp N
- revert "f" by 'merge.update()' N
with 'partially'
- apply selected hunks N
by 'patch.internalpatch()'
- 'repo.commit()'
- 'dirstate.normal("f")' N
N+1
- 'dirstate.write()' N N
- restore "f" N+1
- restore timestamp of "f" N
----------------------------------- ---- ----- -----
- normallookup("f") -1
- release wlock
- 'dirstate.write()' -1 -1 N
----------------------------------- ---- ----- -----
- 'hg status' shows "f" as "clean" -1 -1 N
---- ----------------------------------- ---- ----- -----
To reproduce this issue in tests certainly, this patch emulates some
timing critical actions as below:
- change "f" at N
'touch -t 200001010000' before command invocation changes mtime of
"f" to "2000-01-01 00:00" (= N).
- apply selected hunks at N
'patch.internalpatch()' with 'fakepatchtime.py' explicitly changes
mtime of patched files to "2000-01-01 00:00" (= N).
- 'dirstate.write()' at N+1 (or "not at N")
'pack_dirstate()' uses actual timestamp at runtime as "now", and
it should be different from the "2000-01-01 00:00" of "f".
BTW, in 'test-commit-interactive.t', files are sometimes treated as
modified , even though they are just committed fully via 'hg commit
-i' and 'hg diff' shows nothing for them.
Enabling win32text causes EOL style mismatching below:
- files are changed in LF style EOL
=> files restored after committing uses LF style EOL (1)
- 'merge.update()' reverts files in CRLF style EOL
- 'patch.internalpatch()' changes files in CRLF style EOL
=> 'dirstate.normal()' via 'repo.commit()' uses the size of files
in CRLF style EOL (2)
Therefore, fully committed files are treated as "modified", because
'lstat()' returns size of (1) restored files in LF style EOL, but
dirstate expects size of (2) committed files in CRLF style EOL.
After this patch, 'dirstate.normallookup()' on committed files forces
subsequent 'hg status' to examine changes exactly, and fully committed
files are treated as clean as expected.
This is reason why this patch also does:
- add some 'hg status' checking status of fully committed files
- clear win32text configuration before size/timestamp sensitive examination
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 08 Jul 2015 17:07:45 +0900 |
parents | 80c5b2666a96 |
children | 2f804a38351e |
rev | line source |
---|---|
4344 | 1 # ASCII graph log extension for Mercurial |
2 # | |
3 # Copyright 2007 Joel Rosdahl <joel@rosdahl.net> | |
4516
96d8a56d4ef9
Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4509
diff
changeset
|
4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8210
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
8228
eee2319c5895
add blank line after copyright notices and after header
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
7 |
20118
6ed9141151bf
graphlog: mark as deprecated
Martin Geisler <martin@geisler.net>
parents:
18267
diff
changeset
|
8 '''command to view revision graphs from a shell (DEPRECATED) |
6ed9141151bf
graphlog: mark as deprecated
Martin Geisler <martin@geisler.net>
parents:
18267
diff
changeset
|
9 |
6ed9141151bf
graphlog: mark as deprecated
Martin Geisler <martin@geisler.net>
parents:
18267
diff
changeset
|
10 The functionality of this extension has been include in core Mercurial |
6ed9141151bf
graphlog: mark as deprecated
Martin Geisler <martin@geisler.net>
parents:
18267
diff
changeset
|
11 since version 2.3. |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
12 |
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
13 This extension adds a --graph option to the incoming, outgoing and log |
9259
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
14 commands. When this options is given, an ASCII representation of the |
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
15 revision graph is also shown. |
7426
df0962f6c54e
Graphlog extension adds a --graph option to log/in/out
Alpar Juttner <alpar@cs.elte.hu>
parents:
7383
diff
changeset
|
16 ''' |
4344 | 17 |
18 from mercurial.i18n import _ | |
17182
cdf1532d89c6
incoming/outgoing: handle --graph in core
Patrick Mezard <patrick@mezard.eu>
parents:
17181
diff
changeset
|
19 from mercurial import cmdutil, commands |
5938
9ed100559851
graphlog: add filelog revision grapher
Steve Borho <steve@borho.org>
parents:
4735
diff
changeset
|
20 |
14311
9bbac962f4dd
graphlog: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents:
14139
diff
changeset
|
21 cmdtable = {} |
9bbac962f4dd
graphlog: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents:
14139
diff
changeset
|
22 command = cmdutil.command(cmdtable) |
25186
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24200
diff
changeset
|
23 # Note for extension authors: ONLY specify testedwith = 'internal' for |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24200
diff
changeset
|
24 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24200
diff
changeset
|
25 # be specifying the version(s) of Mercurial they are tested with, or |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24200
diff
changeset
|
26 # leave the attribute unspecified. |
16743
38caf405d010
hgext: mark all first-party extensions as such
Augie Fackler <raf@durin42.com>
parents:
16434
diff
changeset
|
27 testedwith = 'internal' |
14311
9bbac962f4dd
graphlog: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents:
14139
diff
changeset
|
28 |
9bbac962f4dd
graphlog: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents:
14139
diff
changeset
|
29 @command('glog', |
16432
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
30 [('f', 'follow', None, |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
31 _('follow changeset history, or file history across copies and renames')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
32 ('', 'follow-first', None, |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
33 _('only follow the first parent of merge changesets (DEPRECATED)')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
34 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
35 ('C', 'copies', None, _('show copied files')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
36 ('k', 'keyword', [], |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
37 _('do case-insensitive search for a given text'), _('TEXT')), |
23091
8d43c6bb38c0
doc: change 'revision or range' to 'revision or revset'
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
21782
diff
changeset
|
38 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')), |
16432
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
39 ('', 'removed', None, _('include revisions where files were removed')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
40 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
41 ('u', 'user', [], _('revisions committed by user'), _('USER')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
42 ('', 'only-branch', [], |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
43 _('show only changesets within the given named branch (DEPRECATED)'), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
44 _('BRANCH')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
45 ('b', 'branch', [], |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
46 _('show changesets within the given named branch'), _('BRANCH')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
47 ('P', 'prune', [], |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
48 _('do not display revision or any of its ancestors'), _('REV')), |
365bb0fa73a4
graphlog: add all log options to glog command
Patrick Mezard <patrick@mezard.eu>
parents:
16431
diff
changeset
|
49 ] + commands.logopts + commands.walkopts, |
21782
404eca1ce4f9
graphlog: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
20118
diff
changeset
|
50 _('[OPTION]... [FILE]'), |
404eca1ce4f9
graphlog: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
20118
diff
changeset
|
51 inferrepo=True) |
14043
1c1e1232abdc
graphlog: make use of graphmod's revset support
Alexander Solovyov <alexander@solovyov.net>
parents:
14042
diff
changeset
|
52 def graphlog(ui, repo, *pats, **opts): |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
53 """show revision history alongside an ASCII revision graph |
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
54 |
9259
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
55 Print a revision history alongside a revision graph drawn with |
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
56 ASCII characters. |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
57 |
9259
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
58 Nodes printed as an @ character are parents of the working |
19a4b8fd5c48
graphlog: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9198
diff
changeset
|
59 directory. |
7325
f9985108d4e4
graphlog: split the actual DAG grapher out into a separate method
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7324
diff
changeset
|
60 """ |
24200
8e1f1673aa9a
graphlog: do not bypass commands.log so that -fr works
Yuya Nishihara <yuya@tcha.org>
parents:
23091
diff
changeset
|
61 opts['graph'] = True |
8e1f1673aa9a
graphlog: do not bypass commands.log so that -fr works
Yuya Nishihara <yuya@tcha.org>
parents:
23091
diff
changeset
|
62 return commands.log(ui, repo, *pats, **opts) |