feature request: export with bug fixes in commit message

Bug #1606973 reported by Scott Moser
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Bazaar Fast Import
Confirmed
Undecided
Unassigned

Bug Description

I am in the process of moving cloud-init from bzr to git.
Like many people I've used 'bzr commit --fixes lp:'.

It would be nice if exporting to git could retain the bug information.
ie:
 bzr fast-export --git-branch=master --plain | git fast-import

This should be somewhat easily done at least for '--fixes lp:'.
I suggest that those should just be converted into LP: #XXX[, #XXX] strings and appended to the commit message.

Other people have gone looking for such solutions such as http://stackoverflow.com/questions/14518594/migrate-bazaar-to-git-with-commit-properties-to-link-bugs-fixed

Revision history for this message
Scott Moser (smoser) wrote :

I'm attaching a local fix, not really useful generally, but sufficient for my need.

description: updated
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

This is a good idea.

Ideally, this should go via the bug tracker registry in bzrlib, rather than something ad-hoc in bzr-fastimport.

Scott Moser (smoser)
Changed in bzr-fastimport:
status: New → Confirmed
Revision history for this message
Alex Rousskov (rousskov) wrote :

I am attaching another proof-of-concept patch that preserves more bzr metadata (e.g., multiple commit authors, bzr branch nicks, and revnos). Preserving revnos is a good idea if your bzr commit comments and various external sources (e.g., bug reports) refer to bzr revisions by revnos. While it is technically possible to reconstruct at least some revnos after git import (by counting commits on a git branch), that approach results in terrible UX.

This patch has at least two serious flaws:

1. The whole idea of appending metadata to commit messages when exporting to git is flawed IMO. We should be using git notes[1] instead of modifying old commit messages.

2. I failed to find a way to compute bzr revnos for unsquashed merged commits. The patch currently uses self.branch.revision_id_to_revno(revid) to compute revnos for the current branch, but I do not know how to do something like that for those merged commits that still belong to another branch (bzr log shows dotted revnos and a [merge] heading for those commits).

I suspect that a better overall approach would be to leave bzr fast-export "as is" and use "bzr log -n0 --show-ids" output combined with the "marks" file created by "bzr fast-export --export-marks" to create a second export dump file that, when imported by git fast-import, will create appropriate git notes[1].

[1] http://alblue.bandlem.com/2011/11/git-tip-of-week-git-notes.html

Revision history for this message
Alex Rousskov (rousskov) wrote :

> I suspect that a better overall approach would be to leave bzr fast-export "as is" and [do X].

Unless, of course, it is possible to do X from within exporter.py itself -- that would be even better, but it may require more development work than parsing "bzr log" output, and it will require addressing the second flaw documented in the above comment.

Revision history for this message
Patrick Storz (ede123) wrote :

> 2. I failed to find a way to compute bzr revnos for unsquashed merged commits.

I think you were looking for the function "revision_id_to_dotted_revno()"? It creates the dotted revision numbers for merged branches just fine with the downside that the lookup is not that fast (i.e. performance suffers).

Revision history for this message
Patrick Storz (ede123) wrote :

Or even a bit more convenient:
- _compute_revno_str from bzrlib.log

Revision history for this message
Alex Rousskov (rousskov) wrote :

IIRC, I failed to feed revision_id_to_dotted_revno() with the information it needed to compute those dotted revision numbers. I am not implying that exporter.py cannot get the right information to feed that function properly. I just could not figure it out within the time I could spend on that problem.

FWIW, we have built a yet another bzr conversion tool; it exports metadata to git notes:

* tool: https://github.com/measurement-factory/bzr2git4notes
* use case: https://github.com/squid-cache/squid/issues/20

Revision history for this message
Patrick Storz (ede123) wrote :

> IIRC, I failed to feed revision_id_to_dotted_revno() with the
> information it needed to compute those dotted revision numbers.

Well, it's working fine for me (maybe something was changed internally?) with the simple patch in bug #1695103 [1] (similar to what you proposed in comment #3).

> FWIW, we have built a yet another bzr conversion tool;
> it exports metadata to git notes:

Nice! I was considering that option, but seeing that
a) they are not fetched by default
b) very few GUI frontends for git support git notes (notably neither GitHub nor GitLab, but also SourceTree and others)
I ruled it out as it would result in almost zero visibility of that information.

[1] https://bugs.launchpad.net/inkscape/+bug/1695103/+attachment/4887502/+files/fast-export.patch

Revision history for this message
Balint Reczey (rbalint) wrote :

@jelmer I uploaded a package including the patch with minor tweaks ppa:rbalint/bzr-to-git

The encoded metadata looks like that:

commit b35d0353ee30ef8d72d14b25fff8662264e6c2a6
Author: Foo <>
Date: Mon Nov 26 19:00:07 2018 +0100

    Have a nice day!

    LP: #12345
    LP: #444444
    Co-Authored-By: Bar
    Bzr-Rev: 864.3

Revision history for this message
Balint Reczey (rbalint) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.