Pergunta

Using https://github.com/AndreyNikiforov/vault2git I was able to convert a Vault repo to Git and then used Mercurial's hg convert to get a hg repo. The only issues is that after running hg convert the dates on the change set commit dates are incorrect.

The dates show the time the change set was converted from got to mercurial instead of the commit date.

Is there something else I need to do to preserve the dates?

Foi útil?

Solução

I got this working by removing the code that checks the committer information in the hg convert git extension in the file https://www.mercurial-scm.org/repo/hg-stable/file/09b200396384/hgext/convert/git.py lines 125 to 130:

        if n == "committer":
            p = v.split()
            tm, tz = p[-2:]
            committer = " ".join(p[:-2])
            if committer[0] == "<": committer = committer[1:-1]
            committer = self.recode(committer)

Once you remove this, hg convert will use the author information for the date. You'll need to copy over the convert extension from the repo link, modify it and then add it to TortoiseHg.

Why this needs to be done:

When committing with git, there are two records in the changeset metadata: committer and author.

  • Author is the person responsible for the code.

  • Committer is the person who actually committed the changes to the repository.

This distinction is important in an open-source project where the person who authored the code isn't necessarily the person that commits it to the repository: usually there are maintainers (committers) of the project that accept pull requests from a contributor (author) and commit it to the repository.

Vault2Git uses the Vault checkin info (committer and date of commit) as the git changeset author info. The git committer info uses the git user's info and the actual date of commit (your default user for the repository). You can see this difference by doing git cat-file <rev hash> on a changeset that Vault2Git does.

This works fine for git, but when you run hg convert, Mercurial uses the author name and the committer date to create the Mercruial changeset metadata.

Outras dicas

You could try hg-git rather than the convert extension. It's a bi-directional bridge between the two that is meant to be lossless. That must include dates otherwise the hashes would change each time you pulled.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top