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

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.

Xavier Gouchet

April 10, 2017
Tweet

More Decks by Xavier Gouchet

Other Decks in Programming

Transcript

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

    View Slide

  2. About...
    Xavier F. Gouchet
    Android Architect
    Jenkins/Sonar Admin
    Bash/Python dev tools
    Bad Puns Advocate
    @xgouchet on Github,
    StackOverflow, Twitter, …

    View Slide


  3. “Put your hands in the air”
    Placebo
    @xgouchet

    View Slide

  4. Git
    @xgouchet

    View Slide

  5. Git Merge
    @xgouchet

    View Slide

  6. Conflicts
    @xgouchet

    View Slide


  7. “Let’s start at the very begining
    (a very good place to start)”
    Julie Andrews
    @xgouchet

    View Slide

  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

    View Slide

  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

    View Slide


  10. “Too many problems,
    oh why am I here?”
    Megadeth
    @xgouchet

    View Slide

  11. CVS is
    text based
    @xgouchet

    View Slide

  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

    View Slide

  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

    View Slide


  14. “Most of those are easy,
    but tedious to solve”
    @xgouchet

    View Slide


  15. “There must be a better way to
    make the things we want…”
    Paul Mc Cartney
    @xgouchet

    View Slide

  16. Smarter
    merge tool
    @xgouchet

    View Slide

  17. Basic principle
    ◎ Many simple automatic solvers
    ◎ Language agnostic
    ◎ Manual solving as a “last resort” solution
    ◎ Integrate with git / 3rd party tools
    @xgouchet

    View Slide

  18. $ git rebase develop
    $ git mergetool
    Auto Merge Tool Process
    auto auto auto
    @xgouchet

    View Slide

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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  26. Automatic conflict solvers
    ◎ Language agnostic
    ○ Addition at the same line
    ○ Deleting the same block
    ○ Woven conflicts
    ○ …
    ◎ Language specific
    ○ Java Imports
    ○ …
    @xgouchet

    View Slide

  27. Early
    results
    @xgouchet

    View Slide

  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

    View Slide

  29. Globally
    ◎ Used since december 2016
    ◎ Number of manual conflicts down by 75%
    ◎ Mood increased by 100%
    @xgouchet

    View Slide

  30. http://www.github.com/xgouchet/AutoMergeTool
    Going further
    @xgouchet

    View Slide

  31. ◎ Semantic Merge ($6.90/month)
    ◎ DeltaXML (XML only)
    ◎ Why doesn’t this exist yet: Syntax-aware merge
    ¹ Going even further
    @xgouchet

    View Slide

  32. Thanks!
    Any questions?
    http://www.github.com/xgouchet/AutoMergeTool
    @xgouchet

    View Slide