att / rcloud

Collaborative data analysis and visualization
http://rcloud.social
MIT License
430 stars 142 forks source link

consider cell renumbering when merging #2668

Open gordonwoodhull opened 5 years ago

gordonwoodhull commented 5 years ago

If a cell is inserted in the middle of a notebook, then all the cells now have different names/numbers, and merge only works cell by cell.

I can think of three ways to improve this:

  1. Diff the whole notebooks, ignoring cell divisions. Merge is a lot easier this way (both to program and in UI). The problem is how to restore cell divisions, splitting the result similar to the source notebooks.
  2. Detect renamed cells, e.g. by hashing each cell content and seeing if any cells have moved without changing content. This could deal with drag-and-drop reordering as well as cell insertions. It doesn't answer which cells really have changed versus which happen to be in the same place, which cells have moved and changed... and this is all very hand-wavy.
  3. If the notebooks have a common ancestor (commit in a common fork-parent), do a three-way merge. This is probably only for advanced users, and although the algorithms are well-known from git, I think they are pretty complicated. Also it's a complete rewrite of the UI, because we found we were not able to interact with a two-pane view using Monaco - only static diffs were possible. So three panels is right out.

Someday someone is going to create some reusable diff and merge tools for the web which will make this stuff a lot easier. We thought that's what Microsoft did in VS Code, but we found it wasn't all that reusable. So any of these are a significant development effort.