News for hackers. Stuff that matters.
Re:Version Control Before Git with CVS by yitchelle on Sunday July 08, 2018 @02:13PM (#17485225)
If someone can come up with an error free merging for all situations, it would be the "killer app" for configuration management. I would especially look forward to merging for XML files as well.
Re:Version Control Before Git with CVS by nradov on Sunday July 08, 2018 @02:50PM (#17485416)
You're never going to avoid all errors, but with additional tools SVN merging seems no more error prone than Git.

I do agree that source code control needs to move beyond lines to deal directly with nodes in a tree structure. That could be XML, JSON, a C++ parsed abstract syntax tree, etc.

Re:Version Control Before Git with CVS by lmitchell on Sunday July 08, 2018 @05:17PM (#17486243)
So I've actually thought about this a fair bit recently, since I'm making some changes to C++ code that touch a lot of files in reasonably straightforward ways. The changes should be possible to merge conflict-free in basically 100% of cases, but since so many lines are touched, no VCS merge tool can manage it. Most of my changes are just typenames, so I figured, you could do some sort of AST-based merge to allow those changes to merge with semantic changes to the surrounding code.

But this has a lot of problems. Namely - most of the time, when two people change the same line, the changes really do conflict, and someone really does need to manually merge them. In fact, sometimes even when your VCS merges things happily, it still gets them wrong because two changes conflict semantically but don't touch the same lines.

So I guess I would say, I think merging is an impossible problem to 'solve', and going to a more granular merge strategy is actually a move in the wrong direction. You could maybe fix my particular case by 'whitelisting' those typename changes, and saying 'these are allowed to merge with anything else', but at that point... the effort required to specify that unambiguously and make it work properly is probably higher than just merging the changes.

Re:Version Control Before Git with CVS by cpeterso on Sunday July 08, 2018 @02:45PM (#17485381)
Do any source control systems have filetype-aware merge algorithms? We can do something smarter when merging XML than textual line diffs.
Re:Version Control Before Git with CVS by WorldMaker on Monday July 09, 2018 @11:08AM (#17490740)
My experiments showed that you can get good character-based diffs from using a syntax highlighting tokenizer. [1] It was faster than a pure character diff algorithm, but the resulting diffs/patches are interoperable, and provided quite reasonably semantic diffs on the examples I tested. Most tokenizers are great too because they tend to operate very well with work-in-progress code or broken/edge-case code (because they are the same sorts of tools we use in our editors).

I've not seen someone actually use it for source control, but the core idea is simple enough for the taking.

[1] https://github.com/WorldMaker/tokdiff

Re:Version Control Before Git with CVS by jpeloquin on Sunday July 08, 2018 @05:54PM (#17486425)
Git can be told to use custom diff and merge drivers for particular file extensions via .gitattributes: https://git-scm.com/docs/gitattributes

For example, I have used .gitattributes to make git use MS Word to merge docx files, and LabView to merge .vi files. TortoiseGit (for Windows) includes diff/merge driver scripts for use with MS Word files.

Re:Version Control Before Git with CVS by jharger on Sunday July 08, 2018 @08:36PM (#17487149)
While not a source control system, the JetBrains IDEs have a very good merge tool that is filetype aware. For example, WebStorm/IntelliJ Ultimate, when merging JavaScript, often has a "magic wand" option that can detect when merge conflicts are actually resolvable if you parse both sides first, and merge the AST.

It doesn't always work quite right, but it's good enough that I use it quite often.

Re:Version Control Before Git with CVS by fowl2 on Sunday July 08, 2018 @11:40PM (#17487836)
Plastic SCM claims to have C#, Java, C and VB.net semantic diff. Looks pretty impressive - sad that it's proprietary!

https://www.plasticscm.com/features/semantic-version-control...

Re:Version Control Before Git with CVS by yitchelle on Sunday July 08, 2018 @04:11PM (#17485928)
Totally agree. Could AI or machine learning be used for this type of application? I don't know much about machine learning, but I could imagine that it could be used to learn the programming habits of a development team and, perhaps, use it as a context for determining its merging strategies.
Re:Version Control Before Git with CVS by makapuf on Sunday July 08, 2018 @04:27PM (#17486016)
Or any language grammar, in fact.