Mercurial adding new file gives no match found error - mercurial

I have a strange problem with updating Mercurial. Everytime when I add a file to my repository and then update another location of the repository (for example with in CI process), the error "no match found" occures. Then when I remove to whole folder and clone it again there are no problems and the new added file(s) are there. Updating and removing doesnt give problems
When I do "a" Verify the following is shown:
data/test.txt.i#54: missing revlog!
54: empty or missing test.txt
test.txt#54: b80de5d13875 in manifests
not found 3 integrity errors
encountered! (first damaged changeset
appears to be 54)
Any idea what could be causing this?
EDIT
The complete trace:
ThoughtWorks.CruiseControl.Core.CruiseControlException:
Source control operation failed:
abort: data/test.txt.i#b80de5d13875:
no match found! . Process command: hg
update --noninteractive at
ThoughtWorks.CruiseControl.Core.Sourcecontrol.ProcessSourceControl.Execute(ProcessInfo
processInfo) at
ThoughtWorks.CruiseControl.Core.Sourcecontrol.Mercurial.Mercurial.GetSource(IIntegrationResult
result) at
ThoughtWorks.CruiseControl.Core.IntegrationRunner.Build(IIntegrationResult
result) at
ThoughtWorks.CruiseControl.Core.IntegrationRunner.Integrate(IntegrationRequest
request)

The "repository corruption" is not patent here, since you can clone again, and retrieve the all content (old and newly added).
So the different points to check are:
1/ process conflict of some kind (something preventing data/test.txt.i#b80de5d13875 to be written, even so the file content is recorded)
2/ hg revlog and hg debugindex, to check out the versions actually recorded in your repo.
3/ hg verify to rule out any repo corruption.
4/ check the integrity of your repo

Related

How to recover repository when hg recover aborts?

Due to unknown reasons an HG command failed with the message:
abort: abandoned transaction found - run hg recover!
But when I tried to use recover to get rid of the abandoned transaction, I got a different error:
$ hg recover
rolling back interrupted transaction
attempted to truncate path/to/file to 12345 bytes, but it was already 456 bytes
and it aborted. The actual file was named like:
_some_filename.cs.i
which is an internal HG data file. So it seems like the HG data records for some_filename.cs are badly clobbered. And indeed running hg verify shows errors like this:
# hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
warning: revlog 'data/project/folder/some_filename.cs.i' not in fncache!
13691: empty or missing project/folder/some_filename.cs
project/folder/some_filename.cs#13691: manifest refers to unknown revision b269f6036278
project/folder/some_filename.cs#13741: manifest refers to unknown revision 651b96abf6da
...
(goes on for a long time)
which corroborates that the file is damaged but doesn't do anything useful to fix it.
hg recover --help doesn't show anything else that I can do...
And aside from the apparent damage to this one file, no ordinary HG commands work at this point. All of them report the repository is damaged. How can I recover from this?
I concluded that this was just a situation that HG was not designed to deal with. For whatever reason HG's internal data file (the .i file) was destroyed.
It was helpful to review the HG source code which produced the key error:
if fp.tell() < o:
raise error.Abort(
_(
b"attempted to truncate %s to %d bytes, but it was "
b"already %d bytes\n"
)
% (f, o, fp.tell())
)
(https://fossies.org/linux/mercurial/mercurial/transaction.py)
I'm not especially familiar with HG internals but this seemed to make it clear enough that HG was not able to handle the situation (understandably - arbitrary destruction of one of its data files leaves few options!).
The best workaround I could come up with was to manually copy the damaged .i file from another copy of the repository (on another PC). I didn't actually have local changes to that source file, so this seemed reasonable.
I copied the file (replacing the damaged original having made a backup first).
Then ran hg recover. This was now able to resolve the original "abandoned transaction" issue. Other HG commands work as well.
Worth noting that running hg verify still reports some errors (though many fewer). Perhaps the history of this single file is still not right; ultimately I think I will need to re-clone this repository but at least I can complete my immediate tasks without losing any work.

Mercurial abort: error: getaddrinfo failed AFTER clone/updating

I've looked up the general error message, but it always seems to come immediately after an attempt to clone the repository. I'm using hg serve if that helps shed any light on this.
C:\workspace\Project>hg clone --pull http://host:8001 client
requesting all changes
adding changesets
adding manifests
adding file changes
added 1556 changesets with 6734 changes to 2367 files (+1 heads)
updating to branch trunk
abort: error: getaddrinfo failed
As the comments you've received allude to, I think the repository you're cloning contain sub-repositories.
The error message is saying that Mercurial can't find the IP address for something (i.e. a DNS lookup has failed), but you've obviously managed to connect to the server with the initial repository on it. Sub-repositories are cloned during the update process of the parent. The fact that you're getting the error just after the updating to branch trunk message leads to the conclusion that this is your problem.
Look at the contents of .hgsub in the original repository. If it has anything in it, it will have the URLs of any sub-repositories. I suspect these URLs have been written in a way that means they aren't accessible from the machine you're trying to clone to. If possible, fix these to make them general enough to work anywhere.
That error message should really say what it was looking up and why.

Fixing a failed integrity check in Mercurial?

I just did hg pull on a repository and brought in some changesets. It said to run hg update, so I did. Unfortunately, when I did that, it failed with the following error message:
abort: integrity check failed on 00manifest.i:173!
When I run hg verify, it tells me there are a number of issues with things not in the manifest (with some slight path obscuring):
>hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
somewhere1/file1.aspx#172: in changeset but not in manifest
somewhere2/file1.pdf#170: in changeset but not in manifest checking files
file3.csproj#172: ee005cae8058 not in manifests
somewhere2/file1.pdf#171: 00371c8b9d95 not in manifests
somewhere3/file1.ascx#170: 5c921d9bf620 not in manifests
somewhere4/file1.ascx#172: 23acbd0efd3a not in manifests
somewhere5/file1.aspx#170: ce48ed795067 not in manifests
somewhere5/file2.aspx#171: 15d13df4206f not in manifests
1328 files, 174 changesets, 3182 total revisions
8 integrity errors encountered!
(first damaged changeset appears to be 170)
The source repository passes hg verify just fine.
Is there any way to recover from an integrity check failure or do I need to re-clone the repository completely from the source (not a huge issue in this case)? What could I have done to cause this, so I don't do it again?
Well, since the first damaged changeset is 170, you could clone your local repository to 169 and then pull from the source. That means only pulling 5 changesets.
hg clone -r 169 damagedrepo fixedrepo
cd fixedreop
hg verify
And then:
hg pull originalsource
As for manual recovery of repository corruption, this page expounds on that better than I can. See section 4:
I have found corruption once in a while before, and although the above
documentation says it is usually from user error, my instances were on
removable USB drives with empty working directories. Sometimes things
just don't get written correctly or are interfered with somehow: it's
not always user error. But I always have multiple copies I can reclone
from so I've been able to get away with basic fixing.
If the simple fix of a partial local clone and pulling from the server doesn't fix it, you're down to 2 options after backing up your changes (if any) to a bundle or patches:
Manually hacking at Mercurial's files.
Doing a new full clone from the server. Usually the easier and faster of the two.
Beware: This method will change all hashes.
Actually there is another way to recover the repository when it is corrupted like this -
You can do a complete rebuild of the repository by using the convert extension. See Section 4.5 on https://www.mercurial-scm.org/wiki/RepositoryCorruption#Recovery_using_convert_extension
First enable the convert extension by adding the following to your ~/.hgrc file
[extensions]
convert=
Then convert the bad repo to create a fixed repo:
$ hg convert --config convert.hg.ignoreerrors=True REPO REPOFIX
This worked for me when I had the experience of suddenly finding that there were missing files in the manifests - "error 255".
Try remove your file 00manifest.i from repo and next use hg remove 00manifest.i and hg commit commands. Worked for me.
What we ended up doing was making a new copy of our 'central' repository, deleting the .hg folder in this copy, creating a new repository there (hg init), and then working with this as the central repository.
Be aware however this is only an appropriate solution if you don't need your changeset history other than as a reference (which we don't). You can still use your old central repository for this purpose.

Mercurial Missing Revlog

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.

Mercurial HG Update Exited With Status 255

When remotely updating a Mercurial Repository, I am getting the following error from the hg update command that is being run on the remote server after the push. I looked around online for some help for this however was unsuccessful in finding anything useful. At this point, I am hoping for some ideas and / or insight as to what would be causing this problem.
The error is just below. It occurred when pushing two changesets. One changeset included an unrelated index.html file change. The other changeset was a merge, which included the index.html change as well as the renaming of the two image files.
levinaris#server01:/home/web/repository$ hg push
pushing to ssh://10.10.1.12//home/web/repository
searching for changes`remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 2 changesets with 1 changes to 1 files
remote: abort: Operation not permitted: /home/web/repository/html/images/image.gif
remote: warning: changegroup hook exited with status 255
Additional details:
Both images are 10385 bytes in size. (yes, this error occurs on two images I have)
The two images had their names changed in changesets that were already pushed and hg updated due to case-folding collisions when attempting to pull the repositories down to Windows PCs.
The target server has the following hook in /etc/mercurial/hgrc:
[hooks]
changegroup = hg update
As a work-around, I did the following:
Deleted image.gif.
Deleted another image file that produced the error.
Ran hg update - success!
Ran hg revert html/image/image.gif
Ran hg revert html/image/otherimage.gif
At this point, I am trying to better understand the cause of this problem, so that I can ensure a solid, easy-to-use implementation in my environment. I really appreciate your help!!
After using hg --debug update in the hook, I received this output:
levinaris#server01:/home/web/repository$ hg push
pushing to /home/web/staging/repository
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 1 changes to 1 files
resolving manifests
overwrite False partial False
ancestor 58a5edb95c9a local 58a5edb95c9a+ remote 3aafb97b148c
searching for copies back to rev 6
html/index.php: remote is newer -> g
html/images/otherimage.gif.casefolding: update permissions -> e
html/images/image.gif: update permissions -> e
abort: Operation not permitted: /home/web/staging/repository/html/images/image.gif
warning: changegroup hook exited with status 255
Additional Permission Information:
All 3 files in the 2 changesets have 775 permission with the webuser:dev user:group.
My Global hgrc file has the webuser trusted
[trusted]
users = webuser
Is it possible that the permissions that file on the server were such that it couldn't be overwitten by the person doing the push?
If, for example, two different people have done that push (and thus update) the second person isn't going to be able to overwrite the files created by the first person's push triggered update.
Maybe try changing the hook to this for a test (you don't actually have those single quotes on your hook, right?):
[hooks]
changegroup = hg --debug update
If it is a permissions issue the usual fix is to put everyone who will be pushing and updating into the same group (I call mine 'hg') and then using the sticky group bit on all the directories in the repo to make sure new files have that group.