CN113535206B - Multi-version code upgrading method and system - Google Patents

Multi-version code upgrading method and system Download PDF

Info

Publication number
CN113535206B
CN113535206B CN202110836701.9A CN202110836701A CN113535206B CN 113535206 B CN113535206 B CN 113535206B CN 202110836701 A CN202110836701 A CN 202110836701A CN 113535206 B CN113535206 B CN 113535206B
Authority
CN
China
Prior art keywords
code
version
modification
file
modified
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110836701.9A
Other languages
Chinese (zh)
Other versions
CN113535206A (en
Inventor
王斌
鄢彪
李昊峰
丁文杰
华达
余晨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Hode Information Technology Co Ltd
Original Assignee
Shanghai Hode Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Hode Information Technology Co Ltd filed Critical Shanghai Hode Information Technology Co Ltd
Priority to CN202110836701.9A priority Critical patent/CN113535206B/en
Publication of CN113535206A publication Critical patent/CN113535206A/en
Application granted granted Critical
Publication of CN113535206B publication Critical patent/CN113535206B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The application discloses a multi-version code upgrading method, which comprises the following steps: setting a path and an initial priority of each version code file; setting modification priorities corresponding to various modification types; comparing each code line in the code file of each modified version with each code line in the code file of the oldest original version to obtain specific modification content and modification type of each code line of each modified version; and determining an optimal modification result of each code line according to the initial priority corresponding to each code file of the modification version and the modification priority corresponding to each modification type to obtain the code file of the final optimization version. The application also discloses a multi-version code upgrading system, an electronic device and a computer readable storage medium. Therefore, the burden of manually auditing codes in the code version iteration process can be effectively reduced, and the time cost and the error probability of upgrading the code files of a plurality of versions can be reduced.

Description

Multi-version code upgrading method and system
Technical Field
The present disclosure relates to the field of code upgrade technologies, and in particular, to a method, a system, an electronic device, and a computer readable storage medium for upgrading a multi-version code.
Background
With the popularization and development of computer technology, users often need to upgrade multi-version codes on electronic devices, and input methods have become important tools for users to interact with electronic devices, so that users with different professional fields, different interests and using habits have higher and higher intelligent requirements on input modes.
Currently, the mainstream code version management tools in the market are Git, svn and the like, and the version management tools provide simple management content synchronization functions, such as local modification conflict and server modification conflict prompt conflict when comparing local version and server version, and automatic merging is achieved without conflict.
However, a drawback of such version management tools is that only merging or synchronization between two versions is possible, and that efficient synchronization is not possible for multi-version codes that are larger than two.
It should be noted that the foregoing is not intended to limit the scope of the application.
Disclosure of Invention
The main objective of the present application is to provide a method, a system, an electronic device and a computer readable storage medium for upgrading multi-version codes, which aim to solve the problem of how to quickly and effectively merge and upgrade when the code versions are more.
In order to achieve the above object, an embodiment of the present application provides a multi-version code upgrade method, including:
Setting a path and an initial priority of each version code file;
setting modification priorities corresponding to various modification types;
comparing each code line in the code file of each modified version with each code line in the code file of the oldest original version to obtain specific modification content and modification type of each code line of each modified version; and
And determining an optimal modification result of each code line according to the initial priority corresponding to each code file of the modification version and the modification priority corresponding to each modification type to obtain the code file of the final optimization version.
Optionally, after setting the modification priorities corresponding to the various modification types, the method further includes:
setting an additional priority for the modified content meeting the preset condition;
and when the optimal modification result of each code line is determined, comprehensively judging according to the initial priority corresponding to each version of code file, the modification priority corresponding to each modification type and the additional priority.
Optionally, the modification types include an addition modification, a content modification, and a deletion modification.
Optionally, comparing each code line in the code file of each modified version with each code line in the code file of the oldest original version, and obtaining the specific modification content and modification type of each code line of each modified version of the code file includes:
Traversing all files in the code file of the oldest original version, opening the file and obtaining code line content;
comparing the code files of each modified version with the same name files under the same path of the code files of the oldest original version, and calculating the similarity between each code line in the two files through a longest common subsequence algorithm to obtain the specific modified content and the modified type of the code files of the modified version aiming at the code lines.
Optionally, the determining the optimal modification result of each code line according to the initial priority corresponding to each modified version of the code file and the modification priority corresponding to each modified type includes:
judging whether each code file of the modified version modifies the current code line or not;
when only one code file with a modified version is modified on the current code line, using the specific modified content of the code file with the modified version on the current code line as the optimal modification result of the current code line;
when a plurality of code files with modified versions modify the current code line, respectively calculating the priority of each modified version, wherein the priority comprises the initial priority plus the modified priority, and using the code file with the modified version with the highest priority to specifically modify the current code line as the optimal modification result of the current code line.
Optionally, the determining the optimal modification result of each code line according to the initial priority corresponding to each modified version of the code file and the modification priority corresponding to each modified type further includes:
when a plurality of code files with modified versions are modified on the current code line and have the same priority, prompting a user to manually process conflict contents, and obtaining an optimal modification result of the current code line according to a processing result of the user.
Optionally, the method further comprises, before comparing each modified version of the code file with each code line in the oldest original version of the code file:
setting a file type needing content synchronization through a suffix name;
executing a step of comparing each code line for the file of the file type in each modified version of the code file with the oldest original version of the code file;
and judging a modification result by comparing MD5 codes of the files aiming at the files which are not of the file types, and determining an optimal modification result of the files according to the initial priority corresponding to each modified version of code file.
In addition, to achieve the above object, an embodiment of the present application further provides a multi-version code upgrade system, where the system includes:
The setting module is used for setting the path and the initial priority of each version code file and setting the modification priority corresponding to various modification types;
the comparison module is used for comparing each code line in the code file of each modified version with each code line in the code file of the oldest original version to obtain the specific modification content and modification type of each code line of each modified version;
and the optimization module is used for determining an optimal modification result of each code line according to the initial priority corresponding to each code file of the modification version and the modification priority corresponding to each modification type to obtain the code file of the final optimization version.
To achieve the above object, an embodiment of the present application further provides an electronic device, including: the system comprises a memory, a processor and a multi-version code upgrading program which is stored in the memory and can run on the processor, wherein the multi-version code upgrading program realizes the multi-version code upgrading method when being executed by the processor.
To achieve the above object, an embodiment of the present application further provides a computer readable storage medium, where a multi-version code upgrade program is stored, where the multi-version code upgrade program, when executed by a processor, implements the multi-version code upgrade method as described above.
The multi-version code upgrading method, the system, the electronic device and the computer readable storage medium can analyze the modification type and the priority of each code row between versions according to a preset synchronization strategy by increasing the comparison between the code files of the versions, give an optimal modification result, and automatically combine and upgrade to obtain a final optimized code file. The method can effectively reduce the burden of manually auditing codes in the code version iteration process, and reduce the time cost and error probability when upgrading the code files of a plurality of versions.
Drawings
FIG. 1 is a diagram of an application environment architecture for implementing various embodiments of the present application;
FIG. 2 is a flowchart of a multi-version code upgrade method according to a first embodiment of the present application;
FIG. 3 is a schematic diagram of an operator interface for setting paths for code files of various versions;
FIG. 4 is a schematic diagram of an operator interface for prioritizing;
FIG. 5 is a schematic diagram of a refinement process of step S204 in FIG. 2;
FIG. 6 is a schematic diagram of a refinement flow chart of step S206 in FIG. 2;
FIG. 7 is a schematic diagram of a conflict handling interface;
FIG. 8 is a flowchart of a multi-version code upgrade method according to a second embodiment of the present application;
Fig. 9 is a schematic hardware architecture of an electronic device according to a third embodiment of the present application;
fig. 10 is a schematic block diagram of a multi-version code upgrade system according to a fourth embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
It should be noted that the descriptions of "first," "second," etc. in the embodiments of the present application are for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In addition, the technical solutions of the embodiments may be combined with each other, but it is necessary to base that the technical solutions can be realized by those skilled in the art, and when the technical solutions are contradictory or cannot be realized, the combination of the technical solutions should be regarded as not exist and not within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a schematic diagram of an application environment for implementing various embodiments of the present application. The present application is applicable in application environments including, but not limited to, client 2, server 4, network 6.
The client 2 is configured to display an operation interface to a user and receive an operation of the user, for example, when a conflict occurs in automatic upgrade (a plurality of code files with modified versions modify a current code line and have the same priority), prompt the user to manually process the conflict content and receive a processing result of the user. The client 2 may be a terminal device such as a PC (Personal Computer ), a mobile phone, a tablet computer, a portable computer, etc.
The server 4 is used for realizing automatic merging and upgrading of a plurality of version code files.
The existing version management tool has the defect that only two versions are merged or synchronized, and effective synchronization cannot be achieved for multi-version codes larger than two. Particularly when the code provider gives different version codes in batches and the code receiver has own modification optimization for each version code, the last version optimization code needs to be inherited in the received new version code, and the existing version management tool cannot realize the inheritance. For example, in the game localization process, the code needs to be modified in the optimization process from the first version of the day side to the first version of the my side, and then when the second version of the day side is localized to the second version of the my side, the problem of the original first version still exists in the second version, and repeated optimization is needed. When the versions are more, the modified content is too much and too miscellaneous, and the comparison and optimization are required to be repeated every time from the first version to the Nth version.
If the multi-version codes are combined by manual operation, a great deal of time is required to compare the differences of the codes at the same positions of all versions, then the combination scheme is determined again according to the comparison result, and the error probability is extremely high for long-time visual observation. In addition, the version conflict rules of existing version management tools are generally given, and the user cannot customize the rules.
In each embodiment of the present application, the server 4 analyzes the modification type and priority of each code line between each version according to a preset synchronization policy (policies such as various priorities may be custom designed) by increasing the comparison between the code files of each version, and gives an optimal modification result, and automatically merges and upgrades to obtain the finally optimized code file.
The server 4 may be a rack server, a blade server, a tower server, a cabinet server, or other computing devices, and may be an independent server or a server cluster formed by a plurality of servers.
The network 6 may be a wireless or wired network such as an Intranet (Intranet), the Internet (Internet), a global system for mobile communications (Global System of Mobile communication, GSM), wideband code division multiple access (Wideband Code Division Multiple Access, WCDMA), a 4G network, a 5G network, bluetooth (Bluetooth), wi-Fi, etc. The server 4 and one or more of the clients 2 are communicatively connected via the network 6 for data transmission and interaction.
Example 1
Fig. 2 is a flowchart of a multi-version code upgrading method according to a first embodiment of the present application. It will be appreciated that the flow charts in the method embodiments are not intended to limit the order in which the steps are performed. Some of the steps in the flow chart may be added or subtracted as desired. The method will be described below with the server 4 as the execution subject.
The method comprises the following steps:
s200, setting paths and initial priorities of the code files of each version.
For example, a path of an oldest original version code file (original version old) provided by a code provider, a path of a latest original version code file (original version new) provided by a code provider, a path of each optimized version code file (optimized version N, for example, a game original version is a japanese version, and an optimized version may include a table service version, a korean version, a state service version, etc.) obtained by optimizing the code file of the oldest original version, a path of a final optimized version code file (optimized version new, initial content is original version new, and optimized content in each optimized version is provided) (initial path content is null) may be set.
Fig. 3 is a schematic diagram of an operation interface for setting paths of code files of each version in the present embodiment. Wherein, the "optimized version path" may correspond to the optimized version N, and N paths are set. The paths can be added by clicking the plus sign in the interface, one path can be added at a time, meanwhile, the paths can also be directly edited, and a plurality of paths are separated by the division sign, for example: xxxxx1; xxxxx2; xxxx3. It is noted that the content under the "optimized version new path" needs to be empty for use at this time.
The initial priority of each version code file is mainly the initial priority corresponding to each code file in the two types of the new original version and the optimized version N. Wherein, each code file of the optimized version in the optimized version N corresponds to an own initial priority.
Fig. 4 is a schematic diagram of an operation interface for setting priority in the present embodiment. In fig. 4, original_base_priority represents a new initial priority of the Original version, and optimized_base_priority (or optimized_base_priority_n) represents an initial priority of the Optimized version N. The initial priority of the optimized version N can be filled in by clicking a plus sign in the interface, and can be directly edited and separated by a semicolon, such as: 0;0;0. if there is some optimized version that does not set the corresponding priority, the default is the priority set in the old of the original version (if all are not set, the default is 0).
S202, setting modification priorities corresponding to various modification types.
The modification types include a newly added modification (a code line newly added with respect to the original version), a content modification (a code line modified with respect to the original version of the old content), and a deletion modification (a code line deleted with respect to the original version of the old content). Thus, the modification priority includes a priority of newly added modification, a priority of content modification, and a priority of deleted modification.
In addition, the embodiment may set an additional priority for the modified content that meets the preset condition. The additional priority is used for special content usage, for example for code content that is either of a certain or a certain not, by means of which the content usage sequence can be controlled. The use mode of the additional priority is to judge whether the modified content of the current code line meets the preset condition, if so, the corresponding additional priority is a preset value, and the preset value is usually infinity or infinity; and if not, the additional priority is 0.
For example, in fig. 4, content_modification_priority represents the priority of Content modification, content_add_priority represents the priority of newly added modification, and content_del_priority represents the priority of deleted modification. In addition, the application_priority represents an additional priority, and a plus button corresponding to the application_priority in the interface can be clicked to fill in specific content in the popped setting frame.
The significance of the priority is that when two versions of code files conflict with each other on the modified content of the same code line, the modified content with high priority is taken as an optimal modified result, and the modified content with low priority is abandoned in the finally obtained code file with the final optimized version. The size of each priority may be determined according to the code synchronization requirement, for example, the newer the version, the higher the initial priority corresponding to the version. For another example, assuming that deletion modifications need to be preferentially used, the priority of the deletion modifications is set to be larger than the priority of the content modifications.
In a preferred embodiment, the priority is set to ensure that the absolute value of the priority of the optimized version N minus the new priority of the original version is smaller than any one of the priority value of the new modification, the priority of the content modification, and the priority of the deletion modification.
S204, comparing each code line in the code file of each modified version with each code line in the code file of the oldest original version to obtain specific modification content and modification type of each code line of each modified version.
After the setting is completed, in order to obtain the code file of the final optimized version, the code file of each modified version (the new original version and the optimized version N) needs to be compared with the code file of the oldest original version (the old original version) to find the modified content of the code file of each modified version. And the comparison is to find out the corresponding code lines of the same file in the same path in the code file of each modified version for each code line in all the files in the code file of the oldest original version, and compare the contents line by line.
Specifically, referring further to fig. 5, a schematic diagram of the refinement process of step S204 is shown. It will be appreciated that the flowchart is not intended to limit the order in which the steps are performed. Some of the steps in the flow chart may be added or subtracted as desired. In this embodiment, the step S204 specifically includes:
s2040, traversing all files in the code file of the oldest original version, opening the file and obtaining code line content.
S2042, comparing the code files of each modified version with the same-name files under the same path of the code files of the oldest original version, and calculating the similarity between each code line in the two files through an LCS (Longest Common Subsequence ) algorithm to obtain the specific modified content and the modified type of the code files of the modified version aiming at the code line.
In this embodiment, the content similarity of the code lines is not a letter-based contrast unit, but a word-based contrast unit is used, for example, the two code lines of int temp=100 and ptrTemp- > Func () are similar to 0 in the word-based contrast unit because the word temp and the word ptrTemp are not identical. The LCS algorithm calculates the similarity of two code lines by calculating the maximum common substring length in the two code lines divided by the maximum length in the two code lines, e.g. the similarity of code lines abcde1 and abcdef2 is 5/7.
By adopting the LCS algorithm, the specific modification content can be obtained by comparing words of two code lines, and the modification type can be obtained by the similarity. Wherein the similarity is 100% of the new modifications, the similarity is more than 0 and less than 100% of the content modifications, and the similarity is 0 of the deletion modifications.
S206, determining an optimal modification result of each code line according to the initial priority corresponding to each code file of the modification version and the modification priority corresponding to each modification type, and obtaining the code file of the final optimization version.
Specifically, referring further to fig. 6, a schematic diagram of the refinement process of step S206 is shown. It will be appreciated that the flowchart is not intended to limit the order in which the steps are performed. Some of the steps in the flow chart may be added or subtracted as desired. In this embodiment, the step S206 specifically includes:
s2060, determine whether each modified version of the code file has a modification to the current code line.
S2062, when only one code file of the modified version has a modification to the current code line, using the specific modification content of the code file of the modified version to the current code line as the optimal modification result of the current code line.
That is, if only one version of the code file in the original version new and optimized version N is modified with respect to the old current code line of the original code, the specific modification content of that version is directly used as the optimal modification result of the current code line.
S2064, when a plurality of code files with modified versions modify the current code line, respectively calculating the priority of each modified version, and using the specific modified content of the code file with the highest priority to the current code line as the optimal modification result of the current code line.
If the code files of multiple versions in the new and optimized versions N of the original version are modified relative to the old current code line of the original code, the specific modification content of which version is used at all needs to be selected by priority as the optimal modification result of the current code line.
In this embodiment, the priority includes the initial priority plus the modified priority. For example, when the original version is newly modified for the current code line of which the original version is old, the priority is the original priority of the original version new plus the modification priority corresponding to the modification type of the modification.
In addition, when an additional priority is set, comprehensive judgment is required according to the initial priority corresponding to each version of code file, the modification priority corresponding to each modification type and the additional priority, that is, the priority includes the initial priority plus the modification priority plus the additional priority.
It should be noted that, in a preferred embodiment, when multiple modified code files are generated and the current code line is modified by multiple modified code files and the priority is the same (conflict occurs), the user may be prompted to manually process the conflict content, and an optimal modification result is obtained according to the processing result of the user.
For example, fig. 7 is a schematic diagram of a conflict-handling interface in this embodiment. In fig. 7, a plurality of display areas, mainly including a modified version area and an original version old area, respectively display the modified contents of the code files of the plurality of modified versions that collide to the current code line and the original contents of the current code line in the original version old. When the modified version area is clicked, the details of each modified version are respectively presented below.
In this embodiment, after the automatic merging and upgrading are completed by adopting the steps for the code line (the portion without conflict), the user is prompted to manually process the portion with conflict. The user may be presented with the original exception content (the code line content in the old of the original version), the original modification content (the code line content in the new of the original version) and the optimization modification content (the code line content in the respective optimization version N) for each conflicting code line, prompting the user to select a final optimal modification result or to make a manual modification. After the user finishes processing one code line, marking the processing, and processing the next exception record (the next code line with conflict) until all exception record processing is finished. And after all the exception processing is completed, generating a code file of a final optimized version.
According to the multi-version code upgrading method, comparison among the code files of all versions can be increased, the modification type and the priority of each code row among all versions can be analyzed according to a preset synchronization strategy (strategies such as various priorities can be custom designed), an optimal modification result is given, and finally the optimized code files are obtained through automatic merging and upgrading. The method can effectively reduce the burden of manually auditing codes in the code version iteration process, and reduce the time cost and error probability when upgrading the code files of a plurality of versions.
Example two
Fig. 8 is a flowchart of a multi-version code upgrade method according to a second embodiment of the present application. In the second embodiment, the multi-version code upgrade method further includes steps S304-S306 and S312-S314 on the basis of the above-described first embodiment. It will be appreciated that the flow charts in the method embodiments are not intended to limit the order in which the steps are performed. Some of the steps in the flow chart may be added or subtracted as desired.
The method comprises the following steps:
s300, setting paths and initial priorities of the code files of each version.
For example, a path of an oldest original version code file (original version old) provided by a code provider, a path of a latest original version code file (original version new) provided by a code provider, a path of each optimized version code file (optimized version N, for example, a game original version is a japanese version, and an optimized version may include a table service version, a korean version, a state service version, etc.) obtained by optimizing the code file of the oldest original version, a path of a final optimized version code file (optimized version new, initial content is original version new, and optimized content in each optimized version is provided) (initial path content is null) may be set.
The initial priority of each version code file is mainly the initial priority corresponding to each code file in the two types of the new original version and the optimized version N. Wherein, each code file of the optimized version in the optimized version N corresponds to an own initial priority.
S302, setting modification priorities corresponding to various modification types.
The modification types include a newly added modification (a code line newly added with respect to the original version), a content modification (a code line modified with respect to the original version of the old content), and a deletion modification (a code line deleted with respect to the original version of the old content). Thus, the modification priority includes a priority of newly added modification, a priority of content modification, and a priority of deleted modification.
In addition, the embodiment may set an additional priority for the modified content that meets the preset condition. The additional priority is used for special content usage, for example for code content that is either of a certain or a certain not, by means of which the content usage sequence can be controlled. The use mode of the additional priority is to judge whether the modified content of the current code line meets the preset condition, if so, the corresponding additional priority is a preset value, and the preset value is usually infinity or infinity; and if not, the additional priority is 0.
The significance of the priority is that when two versions of code files conflict with each other on the modified content of the same code line, the modified content with high priority is taken as an optimal modified result, and the modified content with low priority is abandoned in the finally obtained code file with the final optimized version. The size of each priority may be determined according to the code synchronization requirement, for example, the newer the version, the higher the initial priority corresponding to the version. For another example, assuming that deletion modifications need to be preferentially used, the priority of the deletion modifications is set to be larger than the priority of the content modifications.
In a preferred embodiment, the priority is set to ensure that the absolute value of the priority of the optimized version N minus the new priority of the original version is smaller than any one of the priority value of the new modification, the priority of the content modification, and the priority of the deletion modification.
S304, setting the file type requiring content synchronization through the suffix name.
In this embodiment, the subsequent synchronization process will synchronize using a progressive content comparison (i.e., comparing each code line) for the set file type, while the remaining files will synchronize in a resource file comparison (i.e., comparing the MD5 codes of the entire file).
For example, these file types with suffix names of cpp, css, html, java, and mm may be set for content synchronization.
S306, each file in the code file of the oldest original version is obtained, and whether the file belongs to the set file type is judged. When the file belongs to the set file type, steps S308 to S310 are performed. When the file does not belong to the set file type, steps S312 to S314 are performed.
And when the comparison and synchronization are performed, the code files of the oldest original version are based, so that each file in the code files of the oldest original version is traversed, and whether the file belongs to the set file type is judged according to the current file. If the file belongs to the set file type, synchronizing by using a progressive content comparison mode, otherwise, synchronizing by using a resource file comparison mode.
S308, comparing each code line of the file in the code file of each modified version with each code line of the file in the code file of the oldest original version to obtain specific modification content and modification type of each code line of each modified version.
In order to obtain the code file of the final optimized version, the code file of each modified version (the new original version and the optimized version N) needs to be compared with the code file of the oldest original version (the old original version) to find the modified content of the code file of each modified version. And the comparison is to find out the corresponding code lines of the same file in the same path in the code file of each modified version for each code line in all the files in the code file of the oldest original version, and compare the contents line by line.
The specific details of this step are referred to the description in the first embodiment, and will not be described here again.
And S310, determining an optimal modification result of each code line according to the initial priority corresponding to each modified version code file and the modification priority corresponding to each modification type, and obtaining a final optimized version of the file.
After the specific modification content and modification type of each code line of each modification version code file are obtained according to the progressive content comparison of the last step, judging whether each modification version code file modifies the current code line. When only one code file with a modified version is modified on the current code line, the specific modified content of the code file with the modified version on the current code line is used as the optimal modification result of the current code line. When a plurality of code files with modified versions modify the current code line, respectively calculating the priority of each modified version, and using the code file with the highest priority to specifically modify the current code line as the optimal modification result of the current code line.
The specific details of this step are referred to the description in the first embodiment, and will not be described here again.
S312, comparing the MD5 code of the file in each modified version code file with the MD5 code of the file in the oldest original version code file, and judging the modification result of the modified version code file on the oldest original version code file.
For files not belonging to the set file type, whether the file is modified or not is judged by comparing MD5 codes of the whole file. The judging conditions are as follows: and respectively reading the contents of the two files to obtain corresponding MD5 codes, comparing whether the MD5 codes of the two files are identical, indicating that modification occurs when the MD5 codes are identical, and indicating that no modification occurs when the MD5 codes are not identical.
And S314, determining the optimal modification result of the file according to the initial priority corresponding to the code file of each modification version, and obtaining the final optimized version of the file.
Specifically, in the present embodiment, the mode of non-modified automatic synchronization and newly added automatic synchronization is adopted. The non-modified automatic synchronization refers to comparing the file which is judged to be non-modified after the original version is new and the original version is old, and directly using the same file with the highest priority in the optimized version N as the final optimized version of the file. The automatic new synchronization refers to that when the optimized version N has new files relative to the original version, the new file with the highest priority in the optimized version N is used as the final optimized version of the file. At this time, the priority is the initial priority corresponding to the file.
For example, assuming that the resource file a in the old original version does not belong to the set file type, it is determined whether the resource file a exists in the new original version. If the resource file A exists in the new original version, further judging whether the resource file A exists in the optimized version N. If the resource file A exists in the optimized version N, the first MD5 code of the resource file A in the old of the original version and the second MD5 code of the resource file A in the new of the original version are obtained for comparison, and when the two codes are identical, the resource file A with the highest priority in the optimized version N is used as a final optimized version. If the resource file A does not exist in the new original version, the resource file A with the highest priority in the optimized version N is directly used as a final optimized version.
According to the multi-version code upgrading method, comparison among the code files of all versions can be increased, the modification type and the priority of each code row among all versions can be analyzed according to a preset synchronization strategy (strategies such as various priorities can be custom designed), an optimal modification result is given, and finally the optimized code files are obtained through automatic merging and upgrading. The method can effectively reduce the burden of manually auditing codes in the code version iteration process, and reduce the time cost and error probability when upgrading the code files of a plurality of versions. Moreover, the file types which need to be subjected to content synchronization can be preset, and the mode of progressive content comparison and MD code comparison of the whole file is adopted for different file types, so that the applicability of the method can be improved, and the efficiency of comparison and synchronization is improved.
Example III
As shown in fig. 9, a hardware architecture diagram of an electronic device 20 according to a third embodiment of the present application is provided. In this embodiment, the electronic device 20 may include, but is not limited to, a memory 21, a processor 22, and a network interface 23, which may be communicatively connected to each other through a system bus. It should be noted that fig. 9 only shows an electronic device 20 having components 21-23, but it should be understood that not all of the illustrated components are required to be implemented and that more or fewer components may alternatively be implemented. In this embodiment, the electronic device 20 may be the server 4.
The memory 21 includes at least one type of readable storage medium including flash memory, hard disk, multimedia card, card memory (e.g., SD or DX memory, etc.), random Access Memory (RAM), static Random Access Memory (SRAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), programmable Read Only Memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the storage 21 may be an internal storage unit of the electronic device 20, such as a hard disk or a memory of the electronic device 20. In other embodiments, the memory 21 may also be an external storage device of the electronic apparatus 20, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the electronic apparatus 20. Of course, the memory 21 may also include both an internal memory unit and an external memory device of the electronic apparatus 20. In this embodiment, the memory 21 is generally used for storing an operating system and various application software installed on the electronic device 20, such as program codes of the multi-version code upgrade system 60. Further, the memory 21 may be used to temporarily store various types of data that have been output or are to be output.
The processor 22 may be a central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments. The processor 22 is generally used to control the overall operation of the electronic device 20. In this embodiment, the processor 22 is configured to execute the program code or process data stored in the memory 21, for example, to execute the multi-version code upgrade system 60.
The network interface 23 may comprise a wireless network interface or a wired network interface, which network interface 23 is typically used for establishing a communication connection between the electronic apparatus 20 and other electronic devices.
Example IV
As shown in fig. 10, a block diagram of a multi-version code upgrade system 60 according to a fourth embodiment of the present application is provided. The multi-version code upgrade system 60 may be partitioned into one or more program modules that are stored in a storage medium and executed by one or more processors to complete the embodiments of the present application. Program modules in the embodiments of the present application refer to a series of computer program instruction segments capable of implementing specific functions, and the following description specifically describes the functions of each program module in the embodiments.
In this embodiment, the multi-version code upgrade system 60 includes:
the setting module 600 is configured to set a path and an initial priority of each version code file.
For example, a path of an oldest original version code file (original version old) provided by a code provider, a path of a latest original version code file (original version new) provided by a code provider, a path of each optimized version code file (optimized version N, for example, a game original version is a japanese version, and an optimized version may include a table service version, a korean version, a state service version, etc.) obtained by optimizing the code file of the oldest original version, a path of a final optimized version code file (optimized version new, initial content is original version new, and optimized content in each optimized version is provided) (initial path content is null) may be set.
The initial priority of each version code file is mainly the initial priority corresponding to each code file in the two types of the new original version and the optimized version N. Wherein, each code file of the optimized version in the optimized version N corresponds to an own initial priority.
The setting module 600 is further configured to set modification priorities corresponding to the various modification types.
The modification types include a newly added modification (a code line newly added with respect to the original version), a content modification (a code line modified with respect to the original version of the old content), and a deletion modification (a code line deleted with respect to the original version of the old content). Thus, the modification priority includes a priority of newly added modification, a priority of content modification, and a priority of deleted modification.
In addition, the embodiment may set an additional priority for the modified content that meets the preset condition. The additional priority is used for special content usage, for example for code content that is either of a certain or a certain not, by means of which the content usage sequence can be controlled. The use mode of the additional priority is to judge whether the modified content of the current code line meets the preset condition, if so, the corresponding additional priority is a preset value, and the preset value is usually infinity or infinity; and if not, the additional priority is 0.
The significance of the priority is that when two versions of code files conflict with each other on the modified content of the same code line, the modified content with high priority is taken as an optimal modified result, and the modified content with low priority is abandoned in the finally obtained code file with the final optimized version. The size of each priority may be determined according to the code synchronization requirement, for example, the newer the version, the higher the initial priority corresponding to the version. For another example, assuming that deletion modifications need to be preferentially used, the priority of the deletion modifications is set to be larger than the priority of the content modifications.
In a preferred embodiment, the priority is set to ensure that the absolute value of the priority of the optimized version N minus the new priority of the original version is smaller than any one of the priority value of the new modification, the priority of the content modification, and the priority of the deletion modification.
The comparison module 602 is configured to compare each code line in the code file of each modified version with each code line in the code file of the oldest original version, so as to obtain specific modification content and modification type of each code line of each modified version.
After the setting is completed, in order to obtain the code file of the final optimized version, the code file of each modified version (the new original version and the optimized version N) needs to be compared with the code file of the oldest original version (the old original version) to find the modified content of the code file of each modified version. And the comparison is to find out the corresponding code lines of the same file in the same path in the code file of each modified version for each code line in all the files in the code file of the oldest original version, and compare the contents line by line.
The specific process of comparing by the comparing module 602 is described in the first embodiment, and will not be described herein.
And the optimizing module 604 is configured to determine an optimal modification result of each code line according to the initial priority corresponding to each code file of the modified version and the modification priority corresponding to each modification type, so as to obtain a code file of a final optimized version.
After the comparing module 602 obtains the specific modification content and modification type of each modified version of the code file for each code line, the optimizing module 604 determines whether each modified version of the code file has a modification to the current code line. When only one code file with a modified version is modified on the current code line, the specific modified content of the code file with the modified version on the current code line is used as the optimal modification result of the current code line. When a plurality of code files with modified versions modify the current code line, respectively calculating the priority of each modified version, and using the code file with the highest priority to specifically modify the current code line as the optimal modification result of the current code line. And the optimal modification results of all the code lines form the code file of the final optimized version.
The specific process of the optimizing module 604 to obtain the code file of the final optimized version is referred to the description in the first embodiment, and will not be described herein.
The multi-version code upgrading system provided by the embodiment can analyze the modification type and the priority of each code row between versions according to a preset synchronization strategy (strategies such as various priorities can be custom designed) by increasing the comparison among the code files of each version, give an optimal modification result, and automatically combine and upgrade to obtain a finally optimized code file. The method can effectively reduce the burden of manually auditing codes in the code version iteration process, and reduce the time cost and error probability when upgrading the code files of a plurality of versions.
Example five
The present application also provides another embodiment, namely, a computer-readable storage medium storing a multi-version code upgrade program executable by at least one processor to cause the at least one processor to perform the steps of the multi-version code upgrade method as described above.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing embodiment numbers of the present application are merely for describing, and do not represent advantages or disadvantages of the embodiments.
It will be apparent to those skilled in the art that the modules or steps of the embodiments of the application described above may be implemented in a general purpose computing device, they may be concentrated on a single computing device, or distributed across a network of computing devices, they may alternatively be implemented in program code executable by computing devices, so that they may be stored in a storage device for execution by computing devices, and in some cases, the steps shown or described may be performed in a different order than what is shown or described, or they may be separately fabricated into individual integrated circuit modules, or multiple modules or steps of them may be fabricated into a single integrated circuit module. Thus, embodiments of the present application are not limited to any specific combination of hardware and software.
The foregoing is only the preferred embodiments of the present application, and is not intended to limit the scope of the embodiments of the present application, and all equivalent structures or equivalent processes using the descriptions of the embodiments of the present application and the contents of the drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the embodiments of the present application.

Claims (10)

1. A method for upgrading a multi-version code, the method comprising:
setting a path and an initial priority of each version code file;
setting modification priorities corresponding to various modification types;
comparing each code line in the code file of each modified version with each code line in the code file of the oldest original version to obtain specific modification content and modification type of each code line of each modified version; and
Determining an optimal modification result of each code line according to the initial priority corresponding to each code file of the modification version and the modification priority corresponding to each modification type to obtain a code file of a final optimization version, wherein the method comprises the following steps:
judging whether each code file of the modified version modifies the current code line or not;
when a plurality of code files with modified versions modify the current code line, respectively calculating the priority of each modified version, wherein the priority comprises the initial priority plus the modified priority, and using the code file with the modified version with the highest priority to specifically modify the current code line as the optimal modification result of the current code line.
2. The multi-version code upgrade method according to claim 1, further comprising, after setting the modification priorities corresponding to the various modification types:
setting an additional priority for the modified content meeting the preset condition;
and when the optimal modification result of each code line is determined, comprehensively judging according to the initial priority corresponding to each version of code file, the modification priority corresponding to each modification type and the additional priority.
3. The multi-version code upgrade method according to claim 1 or 2, wherein the modification type includes an addition modification, a content modification, and a deletion modification.
4. The multi-version code upgrade method according to claim 1, wherein comparing each code line in the code file of each modified version with each code line in the code file of the oldest original version, and obtaining specific modification contents and modification types of each code line for each code file of each modified version comprises:
traversing all files in the code file of the oldest original version, opening the file and obtaining code line content;
comparing the code files of each modified version with the same name files under the same path of the code files of the oldest original version, and calculating the similarity between each code line in the two files through a longest common subsequence algorithm to obtain the specific modified content and the modified type of the code files of the modified version aiming at the code lines.
5. The multi-version code upgrade method according to claim 1, wherein the determining the optimal modification result of each code line according to the initial priority level corresponding to each modified version code file and the modification priority level corresponding to each modification type further comprises:
when only one code file with a modified version is modified on the current code line, the specific modified content of the code file with the modified version on the current code line is used as the optimal modification result of the current code line.
6. The multi-version code upgrade method according to claim 5, wherein the determining the optimal modification result of each code line according to the initial priority level corresponding to each modified version code file and the modification priority level corresponding to each modification type further comprises:
when a plurality of code files with modified versions are modified on the current code line and have the same priority, prompting a user to manually process conflict contents, and obtaining an optimal modification result of the current code line according to a processing result of the user.
7. The multi-version code upgrade method according to claim 1, further comprising, before comparing each modified version code file with each code line in the oldest original version code file:
Setting a file type needing content synchronization through a suffix name;
executing a step of comparing each code line for the file of the file type in each modified version of the code file with the oldest original version of the code file;
and judging a modification result by comparing MD5 codes of the files aiming at the files which are not of the file types, and determining an optimal modification result of the files according to the initial priority corresponding to each modified version of code file.
8. A multi-version code upgrade system, said system comprising:
the setting module is used for setting the path and the initial priority of each version code file and setting the modification priority corresponding to various modification types;
the comparison module is used for comparing each code line in the code file of each modified version with each code line in the code file of the oldest original version to obtain the specific modification content and modification type of each code line of each modified version;
the optimizing module is configured to determine an optimal modification result of each code line according to the initial priority corresponding to each modified version of the code file and the modification priority corresponding to each modified type, and obtain a code file of a final optimized version, where the optimizing module includes:
Judging whether each code file of the modified version modifies the current code line or not;
when a plurality of code files with modified versions modify the current code line, respectively calculating the priority of each modified version, wherein the priority comprises the initial priority plus the modified priority, and using the code file with the modified version with the highest priority to specifically modify the current code line as the optimal modification result of the current code line.
9. An electronic device, the electronic device comprising: memory, a processor and a multi-version code upgrade program stored on the memory and executable on the processor, which when executed by the processor implements the multi-version code upgrade method according to any one of claims 1 to 7.
10. A computer readable storage medium, wherein a multi-version code upgrade program is stored on the computer readable storage medium, which when executed by a processor implements the multi-version code upgrade method according to any one of claims 1 to 7.
CN202110836701.9A 2021-07-23 2021-07-23 Multi-version code upgrading method and system Active CN113535206B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110836701.9A CN113535206B (en) 2021-07-23 2021-07-23 Multi-version code upgrading method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110836701.9A CN113535206B (en) 2021-07-23 2021-07-23 Multi-version code upgrading method and system

Publications (2)

Publication Number Publication Date
CN113535206A CN113535206A (en) 2021-10-22
CN113535206B true CN113535206B (en) 2024-02-20

Family

ID=78088838

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110836701.9A Active CN113535206B (en) 2021-07-23 2021-07-23 Multi-version code upgrading method and system

Country Status (1)

Country Link
CN (1) CN113535206B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116302078B (en) * 2023-05-19 2023-08-01 深圳前海环融联易信息科技服务有限公司 Code file merging method and device, storage medium and computer equipment

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106126410A (en) * 2016-05-26 2016-11-16 华为技术有限公司 The reminding method of code conflicts and device
CN106484606A (en) * 2015-09-01 2017-03-08 阿里巴巴集团控股有限公司 Method and apparatus submitted to by a kind of code
CN106569844A (en) * 2016-09-23 2017-04-19 北京五八信息技术有限公司 Processing method, processing device and equipment for program code update
CN107832062A (en) * 2017-09-08 2018-03-23 上海壹账通金融科技有限公司 A kind of method for updating program and terminal device
CN109446492A (en) * 2018-10-17 2019-03-08 南京垂宇网络科技有限公司 Method for maintaining consistency of document editing data
CN111176983A (en) * 2019-10-18 2020-05-19 华为技术有限公司 Code conflict resolution system, method, device, equipment and medium
CN111221566A (en) * 2019-12-28 2020-06-02 华为技术有限公司 Method and device for combining multiple and changeable versions of software code
CN112148329A (en) * 2020-09-18 2020-12-29 湖南联盛网络科技股份有限公司 Code version automatic updating method and device, computer equipment and storage medium
CN112612716A (en) * 2020-12-28 2021-04-06 上海品顺信息科技有限公司 Method, system, equipment and storage medium for enhancing marking of coverage rate of difference line codes
CN112947986A (en) * 2020-09-29 2021-06-11 深圳市明源云科技有限公司 Multi-version code sign-in control method and device, client and storage medium
CN113110871A (en) * 2021-04-27 2021-07-13 东南大学 Multi-version software evolution history static analysis method and system based on text comparison

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8719786B2 (en) * 2005-03-30 2014-05-06 Alcatel Lucent Method for performing conditionalized N-way merging of source code
CN102314411B (en) * 2010-06-30 2015-02-18 百度在线网络技术(北京)有限公司 Method for processing vocabulary entry editing and creating conflict and system
US20150220331A1 (en) * 2014-02-05 2015-08-06 International Business Machines Corporation Resolving merge conflicts that prevent blocks of program code from properly being merged
CN106406918B (en) * 2016-11-25 2020-02-28 华胜信泰信息产业发展有限公司 Automatic source code merging method and automatic source code merging device
US10877746B2 (en) * 2018-05-06 2020-12-29 Methodics, Inc. Component dependency tree normalization through contextual dependency

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106484606A (en) * 2015-09-01 2017-03-08 阿里巴巴集团控股有限公司 Method and apparatus submitted to by a kind of code
CN106126410A (en) * 2016-05-26 2016-11-16 华为技术有限公司 The reminding method of code conflicts and device
CN106569844A (en) * 2016-09-23 2017-04-19 北京五八信息技术有限公司 Processing method, processing device and equipment for program code update
CN107832062A (en) * 2017-09-08 2018-03-23 上海壹账通金融科技有限公司 A kind of method for updating program and terminal device
CN109446492A (en) * 2018-10-17 2019-03-08 南京垂宇网络科技有限公司 Method for maintaining consistency of document editing data
CN111176983A (en) * 2019-10-18 2020-05-19 华为技术有限公司 Code conflict resolution system, method, device, equipment and medium
CN111221566A (en) * 2019-12-28 2020-06-02 华为技术有限公司 Method and device for combining multiple and changeable versions of software code
CN112148329A (en) * 2020-09-18 2020-12-29 湖南联盛网络科技股份有限公司 Code version automatic updating method and device, computer equipment and storage medium
CN112947986A (en) * 2020-09-29 2021-06-11 深圳市明源云科技有限公司 Multi-version code sign-in control method and device, client and storage medium
CN112612716A (en) * 2020-12-28 2021-04-06 上海品顺信息科技有限公司 Method, system, equipment and storage medium for enhancing marking of coverage rate of difference line codes
CN113110871A (en) * 2021-04-27 2021-07-13 东南大学 Multi-version software evolution history static analysis method and system based on text comparison

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Automatic Software Merging using Automated Program Repair;X. Xing等;《2019 IEEE 1st International Workshop on Intelligent Bug Fixing (IBF)》;pp. 11-16 *
机场旅客智能服务系统Android客户端的设计与实现;于晓杰;《中国优秀硕士学位论文全文数据库信息科技辑》(第08期);I138-273 *

Also Published As

Publication number Publication date
CN113535206A (en) 2021-10-22

Similar Documents

Publication Publication Date Title
WO2019056540A1 (en) Test case automation management method and apparatus, device, and storage medium
CN111158715B (en) Gray release control method and system
CN108920691B (en) Front-end static resource management method and device, computer equipment and storage medium
CN108874426B (en) Application program updating method and device and readable storage medium
CN103559065A (en) Method and system for OTA (Over-the-Air Technology) upgrade
CN108415998B (en) Application dependency relationship updating method, terminal, device and storage medium
CN113672224A (en) Method and device for generating small program page code and computer equipment
CN113535206B (en) Multi-version code upgrading method and system
CN106293790B (en) application program upgrading method and device based on Firefox operating system
CN111488483B (en) Method, device, terminal and non-transitory computer readable storage medium for updating a library
CN112416384A (en) Software upgrading method and device and computer equipment
CN111125721A (en) Control method for process starting, computer equipment and readable storage medium
CN111046316A (en) Application on-shelf state monitoring method, intelligent terminal and storage medium
CN103220336B (en) The implementation method of vector clock and system in a kind of file synchronization
CN115543429A (en) Project environment building method, electronic equipment and computer readable storage medium
CN111125744B (en) Code branch merging method, system, computer device and readable storage medium
CN115004667B (en) Information pushing method, device, electronic equipment and computer readable medium
KR100558394B1 (en) electronic apparatus and program update method of thereof
CN112416383A (en) Hot updating method and device for golang program and computer equipment
CN114610366A (en) Difference package upgrading method and system, intelligent electronic equipment and storage medium
CN112947991A (en) Method and device for acquiring version difference code file, computer equipment and medium
CN112328295A (en) Software updating method and device
CN112417324A (en) Chrome-based URL (Uniform resource locator) interception method and device and computer equipment
CN110825406A (en) Software upgrading method and related equipment
US20140013195A1 (en) Content reference in extensible markup language documents

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant