Mercurial > hg
annotate tests/test-lrucachedict.py @ 20275:2123d27ff75d
backout: avoid update on simple case.
Before the changeset the backout process was:
1) go to <target>
2) revert to <target> parent
3) update back to changeset we came from
The two update steps can takes a very long time to move back and forth unrelated
file change between <target> and current working directory.
The new process is just merging current working directory with the parent of
<target> using <target> as ancestor. This give the very same result but skip
the two updates. On big repo with a lot of files and changes that save a lots of
time (x20 for one week window).
The "merge" version (hg backout --merge) is still done with upgrades. We could
imagine using in memory commit to speed it up but this is another fish.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 08 Jan 2014 14:53:46 -0800 |
parents | 887ffa22fd0d |
children | 45d996a566d7 |
rev | line source |
---|---|
18603 | 1 from mercurial import util |
2 | |
3 def printifpresent(d, xs): | |
4 for x in xs: | |
5 present = x in d | |
6 print "'%s' in d: %s" % (x, present) | |
7 if present: | |
8 print "d['%s']: %s" % (x, d[x]) | |
9 | |
10 def test_lrucachedict(): | |
11 d = util.lrucachedict(4) | |
12 d['a'] = 'va' | |
13 d['b'] = 'vb' | |
14 d['c'] = 'vc' | |
15 d['d'] = 'vd' | |
16 | |
17 # all of these should be present | |
18 printifpresent(d, ['a', 'b', 'c', 'd']) | |
19 | |
20 # 'a' should be dropped because it was least recently used | |
21 d['e'] = 've' | |
22 printifpresent(d, ['a', 'b', 'c', 'd', 'e']) | |
23 | |
24 # touch entries in some order (get or set). | |
25 d['e'] | |
26 d['c'] = 'vc2' | |
27 d['d'] | |
28 d['b'] = 'vb2' | |
29 | |
30 # 'e' should be dropped now | |
31 d['f'] = 'vf' | |
32 printifpresent(d, ['b', 'c', 'd', 'e', 'f']) | |
33 | |
19710
887ffa22fd0d
lrucachedict: implement clear()
Siddharth Agarwal <sid0@fb.com>
parents:
18603
diff
changeset
|
34 d.clear() |
887ffa22fd0d
lrucachedict: implement clear()
Siddharth Agarwal <sid0@fb.com>
parents:
18603
diff
changeset
|
35 printifpresent(d, ['b', 'c', 'd', 'e', 'f']) |
887ffa22fd0d
lrucachedict: implement clear()
Siddharth Agarwal <sid0@fb.com>
parents:
18603
diff
changeset
|
36 |
18603 | 37 if __name__ == '__main__': |
38 test_lrucachedict() |