annotate tests/svn-safe-append.py @ 46846:2819df466cae

tests: add test-remotefilelog-strip.t to demonstrate an issue with linknodes ### Background Every time a commit is modified, remotefilelog updates the metadata for the file object to point to the new commit (I believe that this is different from non-remotefilelog hg, which leaves the linkrevs pointing to the obsolete commits; doing otherwise would involve changing data in the middle of revlogs). With `hg strip` (or other things that use repair.strip()), when you strip a commit that's not the tip of the revlog, there may be commits after it in revnum order that aren't descended from it and don't need to be (and shouldn't be) stripped. These are "saved" by strip in a bundle, and that bundle is reapplied after truncating the relevant revlogs. ### The problem Remotefilelog generally avoids being involved at all in strip. Currently, that includes even providing file contents to this backup bundle. This can cause the linknode to point to a changeset that is no longer in the repository. Example: ``` @ 3 df91f74b871e | | x 2 70494d7ec5ef |/ | x 1 1e423846dde0 |/ o 0 b292c1e3311f ``` Commits 1, 2, and 3 are related via obsolescence, and are description-only changes. The linknode for the file in these commits changed each time we updated the description, so it's currently df91f7. If I strip commits 1 and 3, however, the linknode *remains* df91f7, which no longer exists in the repository. Commit 70494d was "saved", stripped, and then reapplied, so it is in the repository (as revision 1 instead of 2 now), and was unobsoleted since the obsmarker was stripped as well. The linknode for the file should point to 70494d, the most recent commit that is in the repository that modified the file. Remotefilelog has some logic to handle broken linknodes, but it can be slow. We have actually disabled it internally because it's too slow for our purposes. Differential Revision: https://phab.mercurial-scm.org/D10319
author Kyle Lippincott <spectral@google.com>
date Tue, 06 Apr 2021 15:38:33 -0700
parents c102b704edb5
children 6000f5b25c9b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45830
c102b704edb5 global: use python3 in shebangs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39724
diff changeset
1 #!/usr/bin/env python3
6439
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
2
29195
bdba6a2015d0 py3: make tests/svn-safe-append.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 6439
diff changeset
3 from __future__ import absolute_import
bdba6a2015d0 py3: make tests/svn-safe-append.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 6439
diff changeset
4
6439
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
5 __doc__ = """Same as `echo a >> b`, but ensures a changed mtime of b.
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
6 Without this svn will not detect workspace changes."""
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
7
29195
bdba6a2015d0 py3: make tests/svn-safe-append.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 6439
diff changeset
8 import os
36781
ffa3026d4196 cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents: 29195
diff changeset
9 import stat
29195
bdba6a2015d0 py3: make tests/svn-safe-append.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 6439
diff changeset
10 import sys
6439
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
11
39724
e1e10cbb5568 py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 36781
diff changeset
12 if sys.version_info[0] >= 3:
e1e10cbb5568 py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 36781
diff changeset
13 text = os.fsencode(sys.argv[1])
e1e10cbb5568 py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 36781
diff changeset
14 fname = os.fsencode(sys.argv[2])
e1e10cbb5568 py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 36781
diff changeset
15 else:
e1e10cbb5568 py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 36781
diff changeset
16 text = sys.argv[1]
e1e10cbb5568 py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 36781
diff changeset
17 fname = sys.argv[2]
6439
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
18
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
19 f = open(fname, "ab")
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
20 try:
36781
ffa3026d4196 cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents: 29195
diff changeset
21 before = os.fstat(f.fileno())[stat.ST_MTIME]
6439
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
22 f.write(text)
39724
e1e10cbb5568 py3: make tests/svn-safe-append.py compatible with python 3
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 36781
diff changeset
23 f.write(b"\n")
6439
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
24 finally:
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
25 f.close()
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
26 inc = 1
36781
ffa3026d4196 cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents: 29195
diff changeset
27 now = os.stat(fname)[stat.ST_MTIME]
6439
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
28 while now == before:
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
29 t = now + inc
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
30 inc += 1
c1b47c0fd2b6 convert: fix test-convert-svn-* problems with mtime not changing
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff changeset
31 os.utime(fname, (t, t))
36781
ffa3026d4196 cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents: 29195
diff changeset
32 now = os.stat(fname)[stat.ST_MTIME]