I was trying to undo my last commit and enabled the mq extension, but the hg strip command failed and now I can't commit:
basin#BASIN /cygdrive/c/progs/maven/nb/releases-modresource_cache_root/lib.cvsclient
$ hg strip -r . --keep
saved backup bundle to /cygdrive/c/progs/maven/nb/releases-modresource_cache_root/.hg/strip-backup/ac19a716fbf9-6b28e0c3-backup.hg
transaction abort!
failed to truncate 00manifest.d
rollback failed - please run hg recover
strip failed, backup bundle stored in '/cygdrive/c/progs/maven/nb/releases-modresource_cache_root/.hg/strip-backup/ac19a716fbf9-6b28e0c3-backup.hg'
abort: Invalid argument
basin#BASIN /cygdrive/c/progs/maven/nb/releases-modresource_cache_root/lib.cvsclient
$ hg recover
rolling back interrupted transaction
failed to truncate 00manifest.d
abort: Invalid argument
$ hg --version
Mercurial Distributed SCM (version 4.3.2)
(see https://mercurial-scm.org for more information)
Copyright (C) 2005-2017 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Is it possible to manually cleanup the failed transaction?
Upd:
$ hg verify
abandoned transaction found - run hg recover
checking changesets
checking manifests
manifest#?: data length off by -1958844 bytes
manifest#?: rev 310321 points to nonexistent changeset 316448
manifest#?: 14b8e332323c not in changesets
crosschecking files in changesets and manifests
checking files
applemenu/src/org/netbeans/modules/applemenu/layer.xml#?: rev 12 points to unexpected changeset 149753
(expected 149755)
defaults/src/org/netbeans/modules/defaults/Eclipse-keybindings-mac.xml#?: rev 0 points to unexpected changeset 149753
(expected 149755)
defaults/src/org/netbeans/modules/defaults/Eclipse-keybindings.xml#?: rev 25 points to unexpected changeset 149753
(expected 149755)
defaults/src/org/netbeans/modules/defaults/mf-layer.xml#?: rev 74 points to unexpected changeset 149753
(expected 149755)
lib.cvsclient/src/org/netbeans/lib/cvsclient/util/LoggedDataInputStream.java#?: rev 5 points to nonexistent changeset 316448
(expected )
lib.cvsclient/src/org/netbeans/lib/cvsclient/util/LoggedDataInputStream.java#?: 7ad471280c10 not in manifests
warning: orphan revlog 'data/lib.cvsclient/src/org/netbeans/lib/cvsclient/util/InterruptibleInputStream.java.i'
194663 files, 316448 changesets, 1130994 total revisions
6 warnings encountered!
9 integrity errors encountered!
Option 1: Don't work on a shared drive. Shared drives have complicated permissions issues.
Option 2: If you must work on a shared drive, dig into "how to set and change permissions". Make sure that you have all permissions on the shared-drive files in question.
Related
We discovered that our Hg repository got corrupted several weeks ago. This corruption seems to have propagated: all clones (the central repo and the user repos) are corrupted, pretty badly, in the same way. I think we could have prevented it if we did verification at that time.
Is there some Hg setting that would cause verification on each push, and prevent push in case of verification failure? I know I could implement it as a hook in Python, but is there maybe a simpler solution?
Is it also possible to do the opposite: make sure the remote repository is verified before pulling?
FWIW, I am on Windows 10 and we are using TortoiseHg.
Update: I've tried creating hooks as suggested by Jordi. Hg now hangs waiting for locks. Here is what I see:
c:\Users\username\test-hook>hg init
c:\Users\username\test-hook>cd ..
c:\Users\username>hg clone test-hook test-hook-clone
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
# At this point I edited clone repository settings to include
# [hooks]
# preoutgoing = hg verify
#
# Then I created a test.txt file and "added" it via TortoiseHg context menu.
c:\Users\username\test-hook-clone>hg commit
c:\Users\username\test-hook-clone>hg status
c:\Users\username\test-hook-clone>hg outgoing
comparing with c:\Users\username\test-hook
searching for changes
changeset: 0:a61d33af6cdb
tag: tip
user: username
date: Mon May 06 20:32:54 2019 +0200
summary: test file added
c:\Users\username\test-hook-clone>hg push -verbose
pushing to c:\Users\username\test-hook
searching for changes
running hook preoutgoing: hg verify
waiting for lock on repository c:\Users\username\test-hook-clone held by process '16840' on host 'LT407233'
To answer your question, the hook does not have to be written in Python. In the appropriate server's hgrc (either at the repository level or the system level), simply set
[hooks]
preoutgoing = hg verify
preincoming = hg verify
This may significantly slow down all pull and push operations, but perhaps you are willing to sacrifice speed for correctness.
This will result in output like this when a client tries to pull from a corrupt repo:
$ hg clone http://localhost:9000 sample-repo
requesting all changes
remote: abort: preoutgoing hook exited with status 1
and in your server logs, you should see output similar to
127.0.0.1 - - [18/Apr/2019 12:41:09] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=lheads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 partial-pull
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
a#0: broken revlog! (index data/a.i is corrupted)
warning: orphan data file 'data/a.i'
checked 2 changesets with 1 changes to 2 files
1 warnings encountered!
1 integrity errors encountered!
(first damaged changeset appears to be 0)
You can enable a server side option to perform more validation all incoming content, just set the server.validate=yes option on your server.
The simplest way is to enable it in your server global hgrc or in the repository .hg/hgrc file by adding the following two lines:
[server]
validate = yes
This is a server option but you can also use it on the client. It should validate pull too.
(By the way, what kind of corruption are you seeing?)
We have too large Mercurial repo's in which following error has occured few times during a year when trying to clone:
$ hg clone --rev develop --noupdate http://url.to.repository
adding changesets
adding manifests
adding file changes
transaction abort!
rollback completed
abort: data/.../Result.Database.nuspec.i#03b180f4076b: unknown parent!
All goes well if I don't specify a revision in clone command.
Hg verify doesn't show any error:
$ hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
3427 files, 913 changesets, 5406 total revisions
How can I fix this error?
What is causing this error? I would like to fix the root cause to prevent this happening anymore in future.
When checking hg verify
portfolio/600x600/72.jpg#8: unpacking 346174023f35: revlog decompress error: Error -3 while decompressing data: incorrect data check
And I need update another files except this. Have any command in hg for do this?
for example from version 49 to 50
like this
hg update 50 -ignore portfolio/600x600/72.jpg
Updating to a revision does not support this. However you can revert selected files to a certain revision:
hg revert -rXXX FILENAME
it also supports the --exclude and --include flags, so you could try:
hg revert -r50 --all --exclude portfolio/600x600/72.jpg
Mind: the repository will be a modified state after this, should you commit, the parent will be your currently checked-out revision.
I was doing an hg pull today when my connection dropped and I had to Ctrl+C out of it. Mercurial exited by aborting the pull and rolling back. When I tried hg pull again, it pulled everything from scratch and then told me that the repo failed the integrity check, and hg verify says every single one of my 50k revisions are corrupt:
48697: unpacking changeset a61b3e37d87e: integrity check failed on 00changelog.i:48697
48698: unpacking changeset 5121ebcb6aa0: integrity check failed on 00changelog.i:48698
changelog#?: rev 48699 points to nonexistent changeset -1
(expected 48699)
changelog#?: rev 48700 points to nonexistent changeset -1
(expected 48700)
changelog#?: duplicate revision 48700 (48699)
changelog#?: rev 48701 points to nonexistent changeset -1
(expected 48701)
changelog#?: duplicate revision 48701 (48700)
changelog#?: rev 48702 points to nonexistent changeset -1
(expected 48702)
changelog#?: duplicate revision 48702 (48701)
changelog#?: rev 48703 points to nonexistent changeset -1
(expected 48703)
changelog#?: duplicate revision 48703 (48702)
checking manifests
manifest#?: data length off by 2190024704 bytes
manifest#?: rev 0 points to unexpected changeset 0
manifest#?: 41fcd28f8ff6 not in changesets
manifest#?: rev 1 points to unexpected changeset 1
manifest#?: fdf33d9f9be1 not in changesets
manifest#?: rev 2 points to unexpected changeset 2
manifest#?: 4dd93d3b7258 not in changesets
manifest#?: rev 3 points to unexpected changeset 3
Can anyone tell me what's going on? Is it possible to fix my repo at all without doing a full hg clone? How do I avoid this in the future?
Use Mercurial's recover command:
hg recover
If that doens't work, you'll have to clone.
When you Ctrl+C a Mercurial operation, you're rolling the dice on the result. Sometimes it cancels fine, other times you get repository corruption. Usually best to let it complete what it needs to do. Investigate why your connection dropped and try to make the connection more resiliant.
Fortunately, you're working directory is probably fine, so if/when you clone a new working copy, you should be able to copy over any files that you committed in the old/corrupted repository.
I'm receiving a "missing revlog" error when using Mercurial (via TortoiseHg). Does anybody know how to fix this repo?
% hg --repository C:\Source\Project verify --verbose
repository uses revlog format 1
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
data/MyProject.Class.Library.Tests/Part/FileName.cs.orig.i#1: missing revlog!
1: empty or missing MyProject.Class.Library.Tests/Part/FileName.cs.orig
MyProject.Class.Library.Tests/Part/FileName.cs.orig#1: fb25dd9d5f41 in manifests not found
4384 files, 1354 changesets, 12803 total revisions
3 integrity errors encountered!
(first damaged changeset appears to be 1)
[command returned code 1 Wed May 11 13:31:14 2011]
You can try to use convert extension with convert.hg.ignoreerrors set to True, as described on the wiki. Keep in mind that this will modify the hashes, and damaged files will probably be lost completely.
The Mercurial wiki has a page on Repository Corruption. If the solution suggested by #Cat Plus Plus does not work for you, then you may attempt to reconstruct the revlog.
There is a section with step-by-step instructions for reconstructing missing revlogs. However, you must have a copy o the problem file as it existed in the "bad" revision.
In your case, you would need an exact copy of data/MyProject.Class.Library.Tests/Part/FileName.cs.orig as it existed in revision 1 of the repo.