RosettaCommons / tools

Tools for parsing Rosetta source code and scripts for running specific Rosetta applications.
Other
3 stars 1 forks source link

Add diff5.py, a tool for helping deduce merge conflicts. #86

Closed roccomoretti closed 4 years ago

roccomoretti commented 4 years ago

For significant merge conflicts, I've found it helpful to see what has changed in each side of the merge.

Turning on merge.conflictstyle=diff3 in git helps, in that it gives you most recent common ancestor version in the diff, but for large, complex diffs it's sometimes hard to parse (especially if there's a small change in a section of code which was moved/deleted in the other leg of the merge.)

This diff5 tool takes a diff3 merge result and then uses some python diff tools to do add a line-by-line annotation of the two legs of the diff, showing what has changed in each since their common merge base.

I've had this tool kicking around for a bit, but I figure others may get some use out of it as well.

roccomoretti commented 4 years ago

Example output:

<<<<<<< HEAD
  std::list<std::string> compose_metadata(core::conformation::Residue const & residue);
  std::list<std::string> compose_ctab(core::conformation::Residue const & residue);
  std::list<std::string> compose_atoms(core::conformation::Residue const & residue);
  std::list<std::string> compose_bonds(core::conformation::Residue const & residue);
  std::list<std::string> compose_properties(core::conformation::Residue const & residue);
  std::list<std::string> compose_atomnames(core::conformation::Residue const & residue);
  std::list<std::string> compose_typeinfo(core::conformation::Residue const & residue);
  std::list<std::string> compose_nbr_atom(core::conformation::Residue const & residue);
  std::list<std::string> compose_naming(core::conformation::Residue const & residue);
  std::list<std::string> compose_rosetta_properties(core::conformation::Residue const &  residue);
*******
    std::list<std::string> compose_metadata(core::conformation::Residue const & residue);
    std::list<std::string> compose_ctab(core::conformation::Residue const & residue);
    std::list<std::string> compose_atoms(core::conformation::Residue const & residue);
    std::list<std::string> compose_bonds(core::conformation::Residue const & residue);
    std::list<std::string> compose_properties(core::conformation::Residue const & residue);
+   std::list<std::string> compose_atomnames(core::conformation::Residue const & residue);
    std::list<std::string> compose_typeinfo(core::conformation::Residue const & residue);
    std::list<std::string> compose_nbr_atom(core::conformation::Residue const & residue);
    std::list<std::string> compose_naming(core::conformation::Residue const & residue);
    std::list<std::string> compose_rosetta_properties(core::conformation::Residue const &  residue);
||||||| merged common ancestors
  std::list<std::string> compose_metadata(core::conformation::Residue const & residue);
  std::list<std::string> compose_ctab(core::conformation::Residue const & residue);
  std::list<std::string> compose_atoms(core::conformation::Residue const & residue);
  std::list<std::string> compose_bonds(core::conformation::Residue const & residue);
  std::list<std::string> compose_properties(core::conformation::Residue const & residue);
  std::list<std::string> compose_typeinfo(core::conformation::Residue const & residue);
  std::list<std::string> compose_nbr_atom(core::conformation::Residue const & residue);
  std::list<std::string> compose_naming(core::conformation::Residue const & residue);
  std::list<std::string> compose_rosetta_properties(core::conformation::Residue const &  residue);
=======
-   std::list<std::string> compose_metadata(core::conformation::Residue const & residue);
?                                                  ^^^^^  ^^^^
+   std::list<std::string> compose_metadata(core::chemical::MutableResidueType const & residue);
?                                                  ^^ ++ ^  +++++++       ++++
-   std::list<std::string> compose_ctab(core::conformation::Residue const & residue);
-   std::list<std::string> compose_atoms(core::conformation::Residue const & residue);
+   std::list<std::string> compose_ctab(core::chemical::MutableResidueType const & residue, std::map< std::string, core::Vector > const & coords);
+   std::list<std::string> compose_atoms(core::chemical::MutableResidueType const & residue, std::map< std::string, core::Vector > const & coords);
-   std::list<std::string> compose_bonds(core::conformation::Residue const & residue);
?                                               ^^^^^  ^^^^
+   std::list<std::string> compose_bonds(core::chemical::MutableResidueType const & residue);
?                                               ^^ ++ ^  +++++++       ++++
-   std::list<std::string> compose_properties(core::conformation::Residue const & residue);
?                                                    ^^^^^  ^^^^
+   std::list<std::string> compose_properties(core::chemical::MutableResidueType const & residue);
?                                                    ^^ ++ ^  +++++++       ++++
-   std::list<std::string> compose_typeinfo(core::conformation::Residue const & residue);
?                                                  ^^^^^  ^^^^
+   std::list<std::string> compose_typeinfo(core::chemical::MutableResidueType const & residue);
?                                                  ^^ ++ ^  +++++++       ++++
-   std::list<std::string> compose_nbr_atom(core::conformation::Residue const & residue);
?                                                  ^^^^^  ^^^^
+   std::list<std::string> compose_nbr_atom(core::chemical::MutableResidueType const & residue);
?                                                  ^^ ++ ^  +++++++       ++++
-   std::list<std::string> compose_naming(core::conformation::Residue const & residue);
?                                                ^^^^^  ^^^^
+   std::list<std::string> compose_naming(core::chemical::MutableResidueType const & residue);
?                                                ^^ ++ ^  +++++++       ++++
-   std::list<std::string> compose_rosetta_properties(core::conformation::Residue const &  residue);
?                                                            ^^^^^  ^^^^
+   std::list<std::string> compose_rosetta_properties(core::chemical::MutableResidueType const &  residue);
?                                                            ^^ ++ ^  +++++++       ++++
*******
  std::list<std::string> compose_metadata(core::chemical::MutableResidueType const & residue);
  std::list<std::string> compose_ctab(core::chemical::MutableResidueType const & residue, std::map< std::string, core::Vector > const & coords);
  std::list<std::string> compose_atoms(core::chemical::MutableResidueType const & residue, std::map< std::string, core::Vector > const & coords);
  std::list<std::string> compose_bonds(core::chemical::MutableResidueType const & residue);
  std::list<std::string> compose_properties(core::chemical::MutableResidueType const & residue);
  std::list<std::string> compose_typeinfo(core::chemical::MutableResidueType const & residue);
  std::list<std::string> compose_nbr_atom(core::chemical::MutableResidueType const & residue);
  std::list<std::string> compose_naming(core::chemical::MutableResidueType const & residue);
  std::list<std::string> compose_rosetta_properties(core::chemical::MutableResidueType const &  residue);
>>>>>>> origin/master

With just a diff2 or diff3 format, it might have been easy to see the core::conformation::Residue -> core::chemical::MutableResidueType change, but the addition of the compose_atomnames line (the reason why the merge didn't go cleanly) might have been difficult to pick out. (This is particularly useful when there's a small change in a section of code which got deleted/moved - you can pick it out more easily and then figure out if you need to do anything with it.)