Wednesday, March 11, 2015

Mercurial HG. How to restore corrupted repository: unknown format 114

Working with Eclipse and installed MercurialEclipse faced with error "unknown format 114". My repository contained committed, inactive and not pushed revision in bookmark. Problem occurred in the middle of revision history, don't know how.


C:\U\DL\workspace\broken> hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
 src/com/projectname/rfp/web/helpers/ProjectReplicationSettings.java@2660: broken revlog! (index data/src/com/projectname/rfp/web/helpers/ProjectReplicationSettings.java.i unknown format 114)
warning: orphan revlog 'data/src/com/projectname/rfp/web/helpers/ProjectReplicationSettings.java.i'
5599 files, 3098 changesets, 19303 total revisions
1 warnings encountered!
1 integrity errors encountered!
(first damaged changeset appears to be 2660)


Here we have broken revision #2660. Total number of revisions is 3098.

According to Mercurial Repository Corruption wiki found out how to solve it.
Save repository backup before modifying it.
  1. Clone current (broken) repository up to untouched revision #2659 to a new one (fixed):
    C:\U\DL\workspace> hg clone -r 2659 broken fixed
    adding changesets
    adding manifests
    adding file changes
    added 2660 changesets with 16958 changes to 5163 files
    updating to branch default
    3910 files updated, 0 files merged, 0 files removed, 0 files unresolved
    

  2. Pull other changes from remote repository:
    C:\U\DL\workspace\> cd fixed
    C:\U\DL\workspace\fixed> hg pull  http://hg.host.example/project/
    pulling from http://hg.host.example/project/
    searching for changes
    adding changesets
    adding manifests
    adding file changes
    added 439 changesets with 2335 changes to 1062 files
    (run 'hg update' to get a working copy)
    

  3. Now we have working copy from remote repository with local bookmarks. Next step pull from broken local repository unpushed commit. In my case it was revision #3096:
    C:\U\DL\workspace\fixed> hg pull  http://hg.host.example/project/
    pulling from C:\Users\DanilLopatin\workspace\broken
    searching for changes
    adding changesets
    adding manifests
    adding file changes
    added 1 changesets with 17 changes to 17 files (+1 heads)
    adding remote bookmark TAReport
    (run 'hg heads' to see heads, 'hg merge' to merge)
    

  4. Check repository status and heads to ensure everything has been moved.
    C:\U\DL\workspace\fixed> hg head
    changeset:   3099:4a2c6e365e37
    bookmark:    TAReport
    tag:         tip
    parent:      3095:eb47f5a393fb
    user:        Danil Lopatin
    date:        Mon Mar 09 13:45:35 2015
    summary:     Task (Maintenance) #13148: 2015 Questionnaire changes - Methodology up
    
    changeset:   3098:239ca417382b
    user:        Your Teammate
    date:        Tue Mar 10 18:58:46 2015
    summary:     Bug (Maintenance) #13243: Drag and drop not working in IE 9
    
    
    C:\U\DL\workspace\fixed> hg verify
    checking changesets
    checking manifests
    crosschecking files in changesets and manifests
    checking files
    5599 files, 3100 changesets, 19310 total revisions
    

  5. Two options to restore eclipse project: 
    1. Use merge tools (MeldKDiff3) and move files from broken repository to a new one.
    2. Copy hg folder to broken and restore files from hg:
      1. Open fixed repository ./fixed/.hg and copy all files except hgrc file to ./broken/.hg
      2. Run hg revert -a on broken repository to revert all files to active revision. Note, if there are some uncommitted files, copy them before!
      3. Update to required revision: hg update -r 3098. Check all files was updated and there are no uncommitted. 

No comments :

Post a Comment