commit --amend leaves old entry in git-mapfile
Created originally on Bitbucket by sr105
Amending a branch head after (g)exporting (& pushing) to git doesn't remove the old revision mapping from git-mapfile. This prevents pushing the amended head with an error like "abort: unknown revision [HG hash for previous head commit which matches the current GIT hash for the head on the server".
Easy fix is to remove the offending line in the mapfile and pull.
Actually, the more I think about it, I'm not sure what hg-git should do about it other than to force an immediate gexport during the amend because it will never again know what it knows at that point, i.e. that one hash is replacing another.
To reproduce:
#!shell
# I created a local git repo with one file, "file," in one commit.
$ hg clone git-repo hg-repo
importing git objects into hg
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd hg-repo
$ cat .hg/git-mapfile
1353f990a0f6b857d022c38b40eae535084794e8 fcc7a2fcfdd47bbb778d5a9f1e6407d6fea9f57d
$ hg gl
@ 0:fcc7a2fcfdd4 default/master tip master hchapman
initial
# Add a commit from mercurial
$ seq 11 15 >> file
$ hg ci -m "add 11-20 to file"
$ hg gexport
$ cat .hg/git-mapfile
1353f990a0f6b857d022c38b40eae535084794e8 fcc7a2fcfdd47bbb778d5a9f1e6407d6fea9f57d
b459b53655238c06ef755dc1f3cadce81b2f59bb 75e0b715fa0d4b3cf1d42f67243b0a93fd50475b
$ hg gl
@ 1:75e0b715fa0d tip master hchapman
| add 11-20 to file
o 0:fcc7a2fcfdd4 default/master hchapman
initial
# Whoops, we made a mistake. Fix and amend.
$ seq 16 20 >> file
$ hg ci --amend -m "add 11-20 to file"
saved backup bundle to /Users/hchapman/Desktop/hg-repo/.hg/strip-backup/75e0b715fa0d-f8cdecfc-amend-backup.hg
$ hg gexport
$ cat .hg/git-mapfile
1353f990a0f6b857d022c38b40eae535084794e8 fcc7a2fcfdd47bbb778d5a9f1e6407d6fea9f57d
8d42dfb6b5dc8ee3d6f16dc7cd74819e01e23d56 f616d6949969b0273af6c96178f6c1aeb08acca2
b459b53655238c06ef755dc1f3cadce81b2f59bb 75e0b715fa0d4b3cf1d42f67243b0a93fd50475b
$ hg gl
@ 1:f616d6949969 tip master hchapman
| add 11-20 to file
o 0:fcc7a2fcfdd4 default/master hchapman
initial
$