Mercurial > hg > hg-git
view CONTRIBUTING @ 867:a3b12aa1bcd6
git_handler: don't store rename source if branch info is stored
Consider a Mercurial commit with hash 'h1'. Originally, if the only Mercurial
field stored is the branch info (which is stored in the commit message rather
than as an extra field), we'd store the rename source explicitly as a Git extra
field -- let's call the original exported hash 'g1'.
In Git, some operations throw all extra fields away. (One such example is a
rebase.) If such an operation happens, we'll be left with a frankencommit with
the branch info but without the rename source. Let's call this hash 'g2'. For a
setup where Git is the source of truth, let's say that this 'g2' frankencommit
is what gets pushed to the server.
When 'g2' is subsequently imported into Mercurial, we'd look at the fact that
it contains a Mercurial field in the commit message and believe that it was a
legacy commit from the olden days when all info was stored in the commit
message. In that case, in an attempt to preserve the hash, we wouldn't store
any extra rename source info, resulting in 'h1'. Then, when the commit is
re-exported to Git, we'd add the rename source again and produce 'g1' -- and
thus break bidirectionality.
Prevent this situation by not storing the rename source if we're adding branch
info to the commit message. Then for 'h1' we export as 'g2' directly and never
produce 'g1'.
What happens if we not only need to store branch info but also other extra
info, like renames? For 'h1' we'd produce 'g1', then it'd be rewritten on the
Git side to 'g2' throwing away all that extra information. 'g2' being
subsequently imported into Mercurial would produce a new hash, say 'h2'. That's
fine because the commit did get rewritten in Git. We unfortunately wouldn't
perform rename detection thinking that the commit is from Mercurial and had no
renames recorded there, but when the commit is re-exported to Git we'd export
it to 'g2' again. This at least preserves bidirectionality.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Thu, 26 Feb 2015 22:14:44 -0800 |
parents | 427f26764fab |
children | 66336cb849b4 |
line wrap: on
line source
The short version: * Patches should have a good summary line for first line of commit message * Patches should be sent to the Google Group[0] * Patch needs to do exactly one thing * testsuite passes The longer version: We use a variant of Mercurial's own contribution system. http://mercurial.selenic.com/wiki/ContributingChanges contains their full guidelines. Key differences are (by rule number): 1. For hg-git, I'm not strict about the "topic: a few words" format for the first line, but I do insist on a sensible summary as the first line of your commit 2. We don't require use of issueNNN for bug fixes (we have no robot) 3. Use the hg-git google group 10. We use mostly pep8 style. The current codebase is a mess, but new code should be basically pep8. 0: Pull requests are generally not noticed more than once every few months. If you do a pull request, I'm still going to expect you to have a clean history, and to be willing to rework history so it's clean before I push the "merge" button.