A
A
Alexander Melikhov2017-02-17 20:59:04
Algorithms
Alexander Melikhov, 2017-02-17 20:59:04

Find which lines in the text have changed?

Situation: there is a project for code review. You can leave comments for each line of the downloaded piece of code. The piece of code can be updated.
When updating a piece of code, you must also move comments to the corresponding lines.
Examples (comments conditionally indicated starting with <<<):

01 <?php
     <<< comment1
     <<< comment2
02 echo 'Hello, world!';

For example, let's add a php comment to this file in the first line and after the update it should look like this:
01 // Some comment
02 <?php
     <<< comment1
     <<< comment2
03 echo 'Hello, world!';

If the line of code to which comments were left is gone after the update, then the comments must also be deleted.
What algorithm should be used? Is there already something ready?
In principle, you need almost the same thing as github, or bitbucket, or phpstorm shows when viewing diff.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dark Hole, 2017-02-17
@abyrkov

It is unlikely that there is something ready, comments are a delicate matter. But there are a bunch of ready-made diff solutions on GitHub

R
RuWeb, 2019-04-13
@RuWeb

Text comparison https://texttools.ru/difference-checker

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question