Skip to content

Instantly share code, notes, and snippets.

@hlian
Created December 3, 2012 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlian/4196022 to your computer and use it in GitHub Desktop.
Save hlian/4196022 to your computer and use it in GitHub Desktop.
[PATCH STABLE] localrepo: clear filecache correctly on destroyed()
* Run like this: `rm -r /tmp/foo; hg init /tmp/foo; python test.py`
* 2be2a is the parent of http://selenic.com/hg/rev/9f94358
* f94ea is the tip of stable as of writing
* Running hg verify after running the test script yields the output seen in verify.f94ea.output
(kiln29) PS C:\code> rm C:\code\fever -R; hg init \code\fever; python .\test.py
iteration: 0
len(changelog): 0
repository tip rolled back to revision -1 (undo commit)
tip: 0000000000000000000000000000000000000000
iteration: 1
len(changelog): 0
repository tip rolled back to revision -1 (undo commit)
tip: 0000000000000000000000000000000000000000
iteration: 2
len(changelog): 0
repository tip rolled back to revision -1 (undo commit)
tip: 0000000000000000000000000000000000000000
iteration: 3
len(changelog): 0
repository tip rolled back to revision -1 (undo commit)
tip: 0000000000000000000000000000000000000000
iteration: 4
len(changelog): 0
repository tip rolled back to revision -1 (undo commit)
tip: 0000000000000000000000000000000000000000
iteration: 5
len(changelog): 0
repository tip rolled back to revision -1 (undo commit)
tip: 0000000000000000000000000000000000000000
iteration: 6
len(changelog): 0
repository tip rolled back to revision -1 (undo commit)
tip: 0000000000000000000000000000000000000000
iteration: 7
len(changelog): 0
repository tip rolled back to revision -1 (undo commit)
tip: 0000000000000000000000000000000000000000
iteration: 8
len(changelog): 0
repository tip rolled back to revision -1 (undo commit)
tip: 0000000000000000000000000000000000000000
iteration: 9
len(changelog): 0
repository tip rolled back to revision -1 (undo commit)
tip: 0000000000000000000000000000000000000000
iteration: 0
len(changelog): 0
repository tip rolled back to revision -1 (undo commit)
tip: 0000000000000000000000000000000000000000
iteration: 1
len(changelog): 0
repository tip rolled back to revision -1 (undo commit)
tip: 0675f683061e7fbfd2129913b10437bfd557ebaa
iteration: 2
len(changelog): 1
repository tip rolled back to revision 0 (undo commit)
tip: 6d7301c32e2f21cb1ba312836cbbb56b3b42c585
iteration: 3
len(changelog): 2
repository tip rolled back to revision 1 (undo commit)
tip: c6c58c87dfabb373898cea6bec9031f8c5c3746c
iteration: 4
len(changelog): 3
repository tip rolled back to revision 2 (undo commit)
tip: a088739f0a7e52b2b0dfb4a3954011b1aef57b70
iteration: 5
len(changelog): 4
repository tip rolled back to revision 3 (undo commit)
tip: d66ac62bf086e1d71c4ca579244da21ee97832a1
iteration: 6
len(changelog): 5
repository tip rolled back to revision 4 (undo commit)
tip: 3b8bfea7b6f0f20569986aad9032e1d033834992
iteration: 7
len(changelog): 6
repository tip rolled back to revision 5 (undo commit)
tip: 2bab4e92764cb05c6a92fd0a397bdb681777a1d7
iteration: 8
len(changelog): 7
repository tip rolled back to revision 6 (undo commit)
tip: ac82ee2655581efd2efd89b3f9615d5d43b59078
iteration: 9
len(changelog): 8
repository tip rolled back to revision 7 (undo commit)
tip: 2a96c955ed34d0da81e823661a0ac739c6ff80ca
from mercurial import context, hg, util
from mercurial.node import hex, nullid
@apply
def ui():
from mercurial import ui as _ui
return _ui.ui()
counter = 0
repo = hg.repository(ui, '/tmp/foo/')
files = ['foo.txt']
author = 'foo@example.com'
def make_file_context(repo, mctx, path):
return context.memfilectx(path, 'revision %d' % counter)
def make_context(parent):
ctx = context.memctx(
repo,
(parent, nullid),
'revision %d' % counter,
files,
make_file_context,
author,
util.makedate(),
extra={})
return ctx
def main():
global counter
parent = nullid
for i in range(0, 10):
print 'iteration: %d' % i
print 'len(changelog): %d' % len(repo.changelog)
counter = i
ctx = make_context(parent)
repo.commitctx(ctx)
repo.rollback(force=True)
print 'tip: %s' % hex(repo.changelog.tip())
if __name__ == '__main__':
main()
repository uses revlog format 0
checking changesets
changelog@?: index contains 26 extra bytes
changelog@?: rev 0 points to nonexistent changeset 93
(expected 0)
0: unpacking changeset 000000000000: [Errno 2] C:\code\fever\.hg/store\00changelog.d: The system cannot find the file s
pecified
changelog@?: rev 1 points to nonexistent changeset 1211512118
(expected 1)
1: unpacking changeset 000a010f4700: [Errno 2] C:\code\fever\.hg/store\00changelog.d: The system cannot find the file s
pecified
changelog@?: rev 2 points to nonexistent changeset 23296
(expected 2)
2: unpacking changeset 000000000000: [Errno 2] C:\code\fever\.hg/store\00changelog.d: The system cannot find the file s
pecified
changelog@?: rev 3 points to nonexistent changeset -1736621624
(expected 3)
3: unpacking changeset 6cc589b038a7: size must be zero or positive
changelog@?: rev 4 points to nonexistent changeset -1
(expected 4)
4: unpacking changeset 00034d10b648: [Errno 2] C:\code\fever\.hg/store\00changelog.d: The system cannot find the file s
pecified
changelog@?: rev 5 points to nonexistent changeset 858993845
(expected 5)
5: unpacking changeset 000000000000: size must be zero or positive
changelog@?: rev 6 points to nonexistent changeset 1279
(expected 6)
6: unpacking changeset 9c15ca410a80: [Errno 2] C:\code\fever\.hg/store\00changelog.d: The system cannot find the file s
pecified
changelog@?: rev 7 points to nonexistent changeset -1048952857
(expected 7)
7: unpacking changeset 000000000049: [Errno 2] C:\code\fever\.hg/store\00changelog.d: The system cannot find the file s
pecified
changelog@?: rev 8 points to nonexistent changeset -234526312
(expected 8)
8: unpacking changeset 334f31b5344b: size must be zero or positive
changelog@?: rev 9 points to nonexistent changeset 705562338
(expected 9)
9: unpacking changeset 0001ea000000: [Errno 2] C:\code\fever\.hg/store\00changelog.d: The system cannot find the file s
pecified
changelog@?: rev 10 points to nonexistent changeset -1837740880
(expected 10)
10: unpacking changeset a19452bcb90a: [Errno 2] C:\code\fever\.hg/store\00changelog.d: The system cannot find the file
specified
changelog@?: rev 11 points to nonexistent changeset 107950427
(expected 11)
11: unpacking changeset 000600000007: [Errno 2] C:\code\fever\.hg/store\00changelog.d: The system cannot find the file
specified
changelog@?: rev 12 points to nonexistent changeset -1871183872
(expected 12)
12: unpacking changeset 4a4c010a271a: size must be zero or positive
changelog@?: rev 13 points to nonexistent changeset -421058216
(expected 13)
13: unpacking changeset 005d00000008: [Errno 2] C:\code\fever\.hg/store\00changelog.d: The system cannot find the file
specified
changelog@?: rev 14 points to nonexistent changeset -952514817
(expected 14)
14: unpacking changeset 4a0ce3abffbb: size must be zero or positive
checking manifests
0: empty or missing manifest
crosschecking files in changesets and manifests
checking files
0 files, 15 changesets, 0 total revisions
15 warnings encountered!
32 integrity errors encountered!
(first damaged changeset appears to be 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment