Mercurial > hg
annotate tests/test-dispatch.py @ 24787:9d5c27890790
largefiles: for update -C, only update largefiles when necessary
Before, a --clean update with largefiles would use the "optimization" that it
didn't read hashes from standin files before and after the update. Instead of
trusting the content of the standin files, it would rehash all the actual
largefiles that lfdirstate reported clean and update the standins that didn't
have the expected content. It could thus in some "impossible" situations
automatically recover from some "largefile got out sync with its standin"
issues (even there apparently still were weird corner cases where it could
fail). This extra checking is similar to what core --clean intentionally do
not do, and it made update --clean unbearable slow.
Usually in core Mercurial, --clean will rely on the dirstate to find the files
it should update. (It is thus intentionally possible (when trying to trick the
system or if there should be bugs) to end up in situations where --clean not
will restore the working directory content correctly.) Checking every file when
we "know" it is ok is however not an option - that would be too slow.
Instead, trust the content of the standin files. Use the same logic for --clean
as for linear updates and trust the dirstate and that our "logic" will keep
them in sync. It is much cheaper to just rehash the largefiles reported dirty
by a status walk and read all standins than to hash largefiles.
Most of the changes are just a change of indentation now when the different
kinds of updates no longer are handled that differently. Standins for added
files are however only written when doing a normal update, while deleted and
removed files only will be updated for --clean updates.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 15 Apr 2015 15:22:16 -0400 |
parents | 08bfec2ef031 |
children | 06245740b408 |
rev | line source |
---|---|
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
1 import os |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
2 from mercurial import dispatch |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
3 |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
4 def testdispatch(cmd): |
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
5 """Simple wrapper around dispatch.dispatch() |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
6 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
7 Prints command and result value, but does not handle quoting. |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
8 """ |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
9 print "running: %s" % (cmd,) |
14438
08bfec2ef031
dispatch: wrap dispatch related information in a request class
Idan Kamara <idankk86@gmail.com>
parents:
9031
diff
changeset
|
10 req = dispatch.request(cmd.split()) |
08bfec2ef031
dispatch: wrap dispatch related information in a request class
Idan Kamara <idankk86@gmail.com>
parents:
9031
diff
changeset
|
11 result = dispatch.dispatch(req) |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
12 print "result: %r" % (result,) |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
13 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
14 |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
15 testdispatch("init test1") |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
16 os.chdir('test1') |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
17 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
18 # create file 'foo', add and commit |
9031
3b76321aa0de
compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents:
5178
diff
changeset
|
19 f = open('foo', 'wb') |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
20 f.write('foo\n') |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
21 f.close() |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
22 testdispatch("add foo") |
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
23 testdispatch("commit -m commit1 -d 2000-01-01 foo") |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
24 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
25 # append to file 'foo' and commit |
9031
3b76321aa0de
compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents:
5178
diff
changeset
|
26 f = open('foo', 'ab') |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
27 f.write('bar\n') |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
28 f.close() |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
29 testdispatch("commit -m commit2 -d 2000-01-02 foo") |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
30 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
31 # check 88803a69b24 (fancyopts modified command table) |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
32 testdispatch("log -r 0") |
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
33 testdispatch("log -r tip") |