Lupius
Lupius

Reputation: 178

Connection dropped during hg pull. Now my repo is corrupted?

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?

Upvotes: 2

Views: 361

Answers (1)

Aaron Jensen
Aaron Jensen

Reputation: 26789

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.

Upvotes: 1

Related Questions