Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Merge like it's 2099:

Merge like it's 2099:

Every developer working in a team of more than 2 person has experienced conflicts when merging, rebasing or cherry picking a commit. Resolving those conflicts is a tedious task and it's time for a change. This talk will propose a solution to merge smarter and not harder.

Xavier F. Gouchet

October 27, 2017
Tweet

More Decks by Xavier F. Gouchet

Other Decks in Programming

Transcript

  1. ABOUT… XAVIER F. GOUCHET ANDROID ARCHITECT AT DEEZER FLUENT IN

    ANDROID SINCE CUPCAKE ON ALL SOCIAL NETWORKS @XGOUCHET 2
  2. 3

  3. 4

  4. 5

  5. OUR FIRST COMMIT commit 1e7dfd3e0c6715f3e611975892d8618afb7c33a6 Author: _alex <_alex@...> Date: Tue

    Jan 6 14:56:57 2009 +0000 Created folder git-svn-id: file:///opt/svn-android/trunk@2 966f65aa-2a5b-49e2-8ec6-7a0f9cdf547d 6
  6. SINCE THEN… 8 years 12’000+ commits 4 main repositories 30+

    different committers 750’000+ lines of code 100’000+ lines of comments 10’000+ source files 7
  7. TEXT BASED VERSIONNING Diff / Merge is based on a

    stream of characters Easy (and fast-ish) to compute Recognizes newlines / whitespace Doesn’t understand any syntax¹ 9
  8. COMMON CONFLICTS The `imports` section Same change on both sides

    Additions at the same place Changes in different lines in same block Unrelated changes on same line … ? 10
  9. BASIC PRINCIPLE Integrate with Integrate with 3rd party tools Many

    simple automatic solvers Language agnostic Manual solving as a “last resort” solution 13
  10. EXAMPLE 1 : EASY CASE [AMT] ✗ abc didn’t solve

    all conflicts [AMT] → Trying merge with jkl 16
  11. EXAMPLE 1 : EASY CASE [AMT] ✗ jkl didn’t solve

    all conflicts [AMT] → Trying merge with xyz 17
  12. EXAMPLE 2 : HARDER CASE [AMT] ✗ abc didn’t solve

    all conflicts [AMT] → Trying merge with jkl 21
  13. EXAMPLE 2 : HARDER CASE [AMT] ✗ jkl didn’t solve

    all conflicts [AMT] → Trying merge with xyz 22
  14. EXAMPLE 2 : HARDER CASE [AMT] ✗ xyz didn’t solve

    all conflicts [AMT] → Trying merge with manualToolX 23
  15. [merge] tool = amt conflictstyle = diff3 [mergetool "amt"] cmd

    = amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED 26
  16. [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool

    "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml 27
  17. LANGUAGE AGNOSTIC Addition at the same line Deleting the same

    block Woven conflicts Conflict simplification … 29
  18. FIRST TRY : REBASED A HUUUGE COMMIT (+1537/-3250) Number of

    conflicted files : 37 Number of conflicts : 62 Number of conflicts solved manually : 3 Time spent : 2 minutes plus time to write AutoMergeTool 32
  19. WHERE CAN I GET IT ? Github : Pip /

    Easyinstall github.com/xgouchet/AutoMergeTool $ pip install automergetool 34
  20. ¹ GOING EVEN FURTHER ($6.90/month) (XML only) Semantic Merge Delta

    XML Why doesn’t this exist yet: Syntax-aware merge 38
  21. F.A.Q. Does it work with `.xyz` files ? Even with

    binary formats ? Can I write a custom solver? Can it break my code ? How to write a solver ? Template 39