Pro Yearly is on sale from $80 to $50! »

Merge like it's 2099 (AndroidMakers 2017)

Merge like it's 2099 (AndroidMakers 2017)

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.

Cf95f93e78f6d6dd0630049396f723c6?s=128

Xavier Gouchet

April 10, 2017
Tweet

Transcript

  1. Merging like it’s 2099 ! Introducing the AutoMergeTool Android Makers

    2017 - Paris
  2. About... Xavier F. Gouchet Android Architect Jenkins/Sonar Admin Bash/Python dev

    tools Bad Puns Advocate @xgouchet on Github, StackOverflow, Twitter, …
  3. “ “Put your hands in the air” Placebo @xgouchet

  4. Git @xgouchet

  5. Git Merge @xgouchet

  6. Conflicts @xgouchet

  7. “ “Let’s start at the very begining (a very good

    place to start)” Julie Andrews @xgouchet
  8. @xgouchet 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
  9. Our code base ◎ 8 years ◎ 12’000+ commits ◎

    30+ different committers ◎ 750’000+ lines of code* ◎ 200’000+ lines of comments* ◎ 7’500+ source files* * Java, XML, python, gradle, shell @xgouchet
  10. “ “Too many problems, oh why am I here?” Megadeth

    @xgouchet
  11. CVS is text based @xgouchet

  12. Text based ? ◎ Diff / Merge is based on

    a stream of characters. ◎ Easy (and fast-ish) to compute ◎ Recognizes newlines / whitespace ◎ Doesn’t understand any syntax¹ @xgouchet
  13. 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 ◎ … ? @xgouchet
  14. “ “Most of those are easy, but tedious to solve”

    @xgouchet
  15. “ “There must be a better way to make the

    things we want…” Paul Mc Cartney @xgouchet
  16. Smarter merge tool @xgouchet

  17. Basic principle ◎ Many simple automatic solvers ◎ Language agnostic

    ◎ Manual solving as a “last resort” solution ◎ Integrate with git / 3rd party tools @xgouchet
  18. $ git rebase develop $ git mergetool Auto Merge Tool

    Process auto auto auto @xgouchet
  19. $ git merge feature/foo $ git mergetool auto auto auto

    Auto Merge Tool Process @xgouchet
  20. Configuration (~/.gitconfig) [merge] tool = amt [mergetool "amt"] cmd =

    amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml @xgouchet
  21. Configuration (~/.gitconfig) [merge] tool = amt [mergetool "amt"] cmd =

    amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml @xgouchet
  22. Configuration (~/.gitconfig) [merge] tool = amt [mergetool "amt"] cmd =

    amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml @xgouchet
  23. Configuration (~/.gitconfig) [merge] tool = amt [mergetool "amt"] cmd =

    amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml @xgouchet
  24. Configuration (~/.gitconfig) [merge] tool = amt [mergetool "amt"] cmd =

    amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml @xgouchet
  25. Configuration (~/.gitconfig) [merge] tool = amt [mergetool "amt"] cmd =

    amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml @xgouchet
  26. Automatic conflict solvers ◎ Language agnostic ◦ Addition at the

    same line ◦ Deleting the same block ◦ Woven conflicts ◦ … ◎ Language specific ◦ Java Imports ◦ … @xgouchet
  27. Early results @xgouchet

  28. Specific Case ◎ Rebased a huuuuge 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 @xgouchet
  29. Globally ◎ Used since december 2016 ◎ Number of manual

    conflicts down by 75% ◎ Mood increased by 100% @xgouchet
  30. http://www.github.com/xgouchet/AutoMergeTool Going further @xgouchet

  31. ◎ Semantic Merge ($6.90/month) ◎ DeltaXML (XML only) ◎ Why

    doesn’t this exist yet: Syntax-aware merge ¹ Going even further @xgouchet
  32. Thanks! Any questions? http://www.github.com/xgouchet/AutoMergeTool @xgouchet