U
U
UZER20062013-05-24 12:39:32
JavaScript
UZER2006, 2013-05-24 12:39:32

Compare and merge code?

There is some functionality in the project that was implemented through copy-paste. Depending on the specific ID, the functionality is slightly different, but generally similar. Why those who developed it before me did it through copies - I don’t know. This is from the indocode area. Decided to refactor.
Accordingly, after combining, the unique code will be enclosed in ifs and executed depending on the ID.
So. There are 20 files with JS code. The structure is generally the same, many files are identical, some differ only slightly, some to the point of missing some functionality. Accordingly, to combine them into one, you need to go through each and see if there are certain functions or even lines in each of the files. By the way, it is possible that later you will also have to compare the server code.
While I started to do everything manually, but I was not very enthusiastic.
Question. Is it possible to somehow simplify and automate this task? And if so, by what means and methods?
A simple comparison is not suitable, since only two files are compared, in some lines or entire functions may be rearranged. And in general, you need to keep in mind all the files at once, and not just two with each other.
A negative answer is also an answer, if you are sure of it.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
U
UZER2006, 2013-06-07
@UZER2006

As a result, I did everything manually, using the usual tool for comparing texts, because otherwise it is unrealistic.
Thanks to everyone for the answers, incl. for Araxis Merge.

A
AgentSIB, 2013-05-24
@AgentSIB

In general, almost any IDE can compare files (NetBeans, WebStorm definitely can). You can also use third party diff tools .

Z
zednight, 2013-05-24
@zednight

diff,
vim -d

D
Dmitry Guketlev, 2013-05-24
@Yavanosta

Araxis Merge has a three-file comparison mode. Source, and two edits, and you can merge edits into one. Very handy for merging.

1
1x1, 2013-05-24
@1x1

Solved a similar problem, found a perl module using the n-way diff keywords. As a result, it turned out that
1) it is much more convenient to run a diff in pairs and
2) the number of ifs and cases went off scale, so in the end I did everything with classes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question