Mercurial > hg > hg-git
changeset 918:3246f2fab625
import_git_commit: skip hgsubstate logic if file was deleted
Previously, there was an edge case for Git repositories that started as
Mercurial repositories and had used subrepos where a deleted .hgsubstate would
be ignored and therefore reintroduced.
This patch fixes that behavior by checking for the deleted .hgsubstate file
first.
A test has been added to verify behavior.
author | Sean Farley <sean@farley.io> |
---|---|
date | Sat, 13 Jun 2015 18:03:34 -0700 |
parents | 6aa31a3b0506 |
children | f5dc1730e4d3 |
files | hggit/git_handler.py tests/test-clone.t |
diffstat | 2 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -770,8 +770,11 @@ else: hgsubstate[path] = sha # in case .hgsubstate wasn't among changed files - # force its inclusion - if not hgsubstate and parentsubdata: + # force its inclusion if it wasn't already deleted + hgsubdeleted = files.get('.hgsubstate') + if hgsubdeleted: + hgsubdeleted = hgsubdeleted[0] + if hgsubdeleted or (not hgsubstate and parentsubdata): files['.hgsubstate'] = True, None, None elif util.serialize_hgsubstate(hgsubstate) != parentsubdata: files['.hgsubstate'] = False, 0100644, None
--- a/tests/test-clone.t +++ b/tests/test-clone.t @@ -60,6 +60,22 @@ saving mapfile saving mapfile +Make sure that a deleted .hgsubstate does not confuse hg-git + + $ cd gitrepo + $ echo 'HASH random' > .hgsubstate + $ git add .hgsubstate + $ fn_git_commit -m 'add bogus .hgsubstate' + $ git rm -q .hgsubstate + $ fn_git_commit -m 'remove bogus .hgsubstate' + $ cd .. + + $ hg clone -r beta gitrepo hgrepo-c + importing git objects into hg + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --cwd hgrepo-c status + clone empty repo $ git init empty Initialized empty Git repository in $TESTTMP/empty/.git/