WO2021128973A1 - 一种软件代码的多变更版本合并方法及装置 - Google Patents
一种软件代码的多变更版本合并方法及装置 Download PDFInfo
- Publication number
- WO2021128973A1 WO2021128973A1 PCT/CN2020/115692 CN2020115692W WO2021128973A1 WO 2021128973 A1 WO2021128973 A1 WO 2021128973A1 CN 2020115692 W CN2020115692 W CN 2020115692W WO 2021128973 A1 WO2021128973 A1 WO 2021128973A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- change
- code
- software code
- conflict
- block
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3604—Analysis of software for verifying properties of programs
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/72—Code refactoring
Definitions
- This application relates to the field of computer technology, and in particular to a method and device for merging multiple versions of software code.
- Git can realize the merging of multiple changed versions of software code and output the merged software code version.
- Git merges multiple versions of software code, it is a text-based software code merging method. That is, the code line or character of the software code is used as the unit, and the change of each software code change version to the same code line or character is detected, and then merged.
- This text-based software code merging method cannot accurately perform semantic analysis on the changed code in the software code change version, and cannot better merge multiple software code change versions.
- the output merged software code version will exist.
- This application provides a method for merging multiple versions of software code to provide accurate elimination of conflicting blocks in the preliminary merged version of software code.
- this application provides a method for merging multiple versions of software code.
- the method can be executed by a merging device.
- the merging device can first merge the software code with the preliminary merged version, the first software code modified version, and the The second software code change version is analyzed.
- the first code area of the conflicting block in the first software code change version in the preliminary merged version of the software code and the second code area of the conflicting block in the second software code change version can be located, and the first code area and the first code area can be analyzed. 2.
- the merging device After determining the change intentions of the first code area and the second code area, the merging device eliminates conflicting blocks based on the conflict elimination rule set based on the change intentions of the first code area and the change intentions of the second code area, that is, eliminates conflicting blocks.
- the output eliminates the initial merged version of the software code of the conflicting block.
- the merging device can display the preliminary merged version of the software code that eliminated the conflicting block for users to view, or send the preliminary merged version of the software code that eliminated the conflicting block to other devices, and the other device may display the initial merged version of the software code that eliminated the conflicting block. A preliminary merged version of the software code.
- the merging device no longer eliminates the conflicting blocks in the preliminary merged version of the software code based on the text, but analyzes the change intentions of different software code change versions, eliminates the conflicting blocks, can ensure the accuracy of the conflict elimination, and further achieves high efficiency Merge multiple changed versions of the software code.
- the merging device can call the prediction model to eliminate the conflicting blocks in the preliminary merged version of the software code, and the prediction module is pre-trained. Yes, the model of the conflict elimination scheme can be output according to the input conflict block.
- the merging device can also eliminate the conflicting blocks in the preliminary merged version of the software code with the help of a predictive model, which can eliminate as many software code as possible
- the conflict block can ensure the accuracy of the merging of multiple changed versions of the software code, and can also improve the merging efficiency of the multiple changed versions of the software code.
- the merging device can analyze the conflicting blocks and unilaterally changed blocks in the preliminary merged version of the software code, and determine whether there is an association between the unilaterally changed blocks and whether there is an association between the unilaterally changed blocks and the conflicting blocks. After there is an association relationship between the unilateral change blocks and/or the association relationship between the unilateral change blocks and the conflicting blocks, the merging device can be based on the association relationship between the unilateral change blocks, and/or the unilateral change blocks and the conflict blocks. Association relationship, prompts that there is an implicit conflict.
- the merging device can also discover some implicit conflicts in the preliminary merged version of the software code, and give an early warning, so that subsequent users can view the implicit conflicts and modify the preliminary merged version of the software code.
- the merging device may first generate a change action set (referred to as the first change action set) of the first code area, and the first change action set includes In the original code area of the original software code (that is, the conflicting block is in the code area corresponding to the original software code), at least one change action of the first code area. After that, the merging device then invokes multiple change analyzers to analyze the first change action set, and determine the change intention of the first code area.
- the first change action set referred to as the first change action set of the first code area
- the first change action set includes In the original code area of the original software code (that is, the conflicting block is in the code area corresponding to the original software code), at least one change action of the first code area.
- the merging device when the merging device determines the intention to change the second code area, it may first generate a change action set (referred to as the second change action set) of the second code area, and the second change action set includes changes to the original software code.
- the original code area at least one change action in the second code area.
- the merging device then invokes multiple change analyzers to analyze the second change action set, and determine the change intention of the second code area.
- the merging device determines the change intention of the code change area (the first code area and the second code area) based on the change action set (the first change action set or the second change action set), and the change intention determined in this way It is more accurate and can better understand the changes that need to be implemented in the code change area.
- association relationship between unilateral change blocks includes at least one of the following:
- the association relationship between the unilateral change block and the conflict block includes at least one of the following:
- the reference relationship of the function between the unilateral change block and the conflict block (also can be understood as the code change area of the different software code change versions involved in the conflict block), the modification relationship of the function between the unilateral change block and the conflict block, the unilateral change block and the conflict.
- the merging device can more accurately locate the implicit conflict in the preliminary merged version of the software code based on the association relationship between the unilateral change blocks and the association relationship between the unilateral change blocks and the conflicting blocks.
- the merging device when generating the first change action set, may first construct the syntax tree of the original software code, the syntax tree of the first software code change version, and the syntax tree of the second software code change version; , And then determine the first change action set according to the syntax tree of the original software code and the syntax tree of the first software code modified version;
- the merging device when the merging device generates the second change action set, it can first construct the syntax tree of the original software code, the syntax tree of the second software code modified version, and the syntax tree of the second software code modified version; The syntax tree of the code and the syntax tree of the second software code change version determine the second change action set.
- the merging device compares the original software code and the syntax tree of the software code change version, can more accurately determine the change action performed in the code change area, and generate a change action set.
- the embodiment of the present application also provides a merging device, and the beneficial effects can be referred to the description of the first aspect and will not be repeated here.
- the device has the function of realizing the behavior in the method example of the first aspect described above.
- the function can be realized by hardware, or by hardware executing corresponding software.
- the hardware or software includes one or more modules corresponding to the above-mentioned functions.
- the structure of the device includes an intention understanding module, an explicit conflict elimination module, and an implicit conflict early warning module. These modules can perform the corresponding functions in the above-mentioned method examples of the first aspect. For details, please refer to the detailed description in the method examples, which will not be repeated here.
- an embodiment of the present application also provides a computing device.
- the computing device includes a processor and a memory, and may also include a communication interface and a display screen.
- the processor executes the program instructions in the memory to execute the foregoing A method provided by one aspect or any possible implementation manner of the first aspect.
- the memory is coupled with the processor, and it stores program instructions and data necessary in the process of determining the traffic flow.
- the communication interface is used to communicate with other devices, such as receiving original software code, a modified version of the first software code, and a modified version of the second software code, and, for example, sending software with conflict-eliminated blocks (and implicit conflicts marked) A preliminary merged version of the code.
- the display screen is used to display to the user the software code that eliminates the explicit conflicts under the trigger of the processor, and can also display the implicit conflicts in the software code.
- the present application provides a computing device cluster, and the computing device cluster includes at least one computing device.
- Each computing device includes a memory and a processor.
- the processor of at least one computing device is configured to access the code in the memory to execute the first aspect or the method provided in any one of the possible implementation manners of the first aspect.
- the present application provides a non-transitory readable storage medium.
- the non-transitory readable storage medium executes the foregoing first aspect or any of the first aspects.
- the storage medium stores the program.
- the storage medium includes, but is not limited to, volatile memory, such as random access memory, non-volatile memory, such as flash memory, hard disk drive (HDD), and solid state drive (SSD).
- this application provides a computing device program product.
- the computing device program product includes computer instructions. When executed by a computing device, the computing device executes the foregoing first aspect or any possible implementation of the first aspect.
- the computer program product may be a software installation package. In the case where the method provided in the foregoing first aspect or any possible implementation of the first aspect needs to be used, the computer program product may be downloaded and executed on a computing device. Program product.
- the present application also provides a computer chip, which is connected to the memory, and the chip is used to read and execute the software program stored in the memory, and execute the aforementioned first aspect or any possible implementation of the first aspect. method.
- Figure 1 is a schematic structural diagram of a merging device provided by this application.
- Figure 2 is a schematic diagram of a merging party of multiple versions of software code provided by this application.
- 3A is a schematic diagram of conflicting blocks in a preliminary merged version of software code provided by this application.
- FIG. 3B is a schematic diagram of a change intention of a code area provided by this application.
- Figure 4 is a schematic diagram of a conflict elimination rule provided by this application.
- Figure 5 is a schematic diagram of the construction of a training sample provided by this application.
- FIG. 6 is a schematic diagram of the correspondence relationship between a label and a merge strategy provided by this application.
- FIG. 7A is a schematic diagram of conflicting blocks in another preliminary merged version of software code provided by this application.
- FIG. 7B is a schematic diagram of the software code after conflict elimination block provided by this application.
- FIG. 8A is a schematic diagram of conflicting blocks in another preliminary merged version of software code provided by this application.
- FIG. 8B is a schematic diagram of another software code after conflict elimination block provided by this application.
- FIG. 9 is a schematic structural diagram of a computer cluster provided by this application.
- FIG. 10 is a schematic structural diagram of a system provided by this application.
- the software code is written by the programmer using the language supported by the development tool.
- the software code is composed of a set of numbers or letters with directional meaning.
- the software code includes multiple lines of code, each line is set with a line number, and the line of code is identified by the line number.
- Original software code refers to the software code that has not been changed.
- the modified version of the software code refers to the software code that has been changed on the basis of the original software code.
- the embodiment of this application does not limit the number of software code modification versions.
- two software code modification versions are used (for easy distinction, they are respectively referred to as the first software code modification version and the second software code modification version) Take an example for illustration.
- the merging method of multiple software code change versions is similar to the merging method of two software code change versions, and will not be repeated in this embodiment of the application.
- the preliminary merged version of the software code refers to the software code generated by initially merging the changed versions of the software code.
- the preliminary merged version of the software code is the software code generated by merging the changed versions of the software code by Git.
- the embodiments of this application do not limit the software code. How the preliminary merged version was produced.
- there are many merge conflicts in the preliminary merged version of the software code that is, there are many conflicting blocks, and there may be some undiscovered merge conflicts.
- conflict blocks in the preliminary merged version of the software code can be eliminated, and merge conflicts that have not been discovered before in the preliminary merged version of the software code can also be found and prompted.
- the software code changed by the training samples in the training set is called the original code.
- the software code needs to meet certain writing specifications during the writing process, such as object-oriented programming (OOP), procedure-oriented programming (POP) and so on.
- object-oriented programming OOP
- procedure-oriented programming POP
- the programming languages for object-oriented programming include C++, Java, C#, etc.
- the programming languages for procedural programming include fortran, C, etc.
- the software code written with a certain writing specification can include code elements such as classes, packages, functions/methods, domains/variables, etc.
- the package can include one or more classes, each class can include internal classes, functions/methods; functions/methods can call domains/variables.
- Inner classes are similar to classes, and functions/methods can also be included in inner classes.
- Class is a construction of object-oriented computer programming language in object-oriented programming, which describes the common methods and domains of the created objects.
- the inner class is the class contained in the class.
- Function/method refers to a kind of subroutine in a class.
- a method usually consists of a series of sentences and can complete a function. It is called method in the writing specification of object-oriented programming, and called function in the writing specification of process-oriented programming.
- Field/variable stores some data, such as integers and characters, strings, hash tables, pointers, etc.
- Package is used to describe the path structure of a certain section of the program.
- a package usually contains multiple classes, and the complete package path needs to be filled in the package import area when the class is referenced.
- the conflict block composed of two different code change areas and the original code area is called a conflict block.
- the conflicting block in the preliminary merged version of the software code can be set with a specific identifier so that the user can view the conflicting block.
- the code change area corresponding to the code area in the first software code change version is called the first code area
- the code change area corresponding to the code area in the second software code change version is called the second code area . That is, the first code area is the area after the code area is changed in the first software code change version, and the second code area is the area after the code area is changed in the second software code change version.
- the initial merged version of the software code did not merge the two software code change versions to merge the changes to the code area.
- the tool that initially merged the software code (such as Git) could not change the two software codes.
- the version merges the changes to this code area.
- the code change areas involved in the training samples in the training set are called the first change area and the second change area.
- the code change area involved in the training sample may be a code area different from the first code area and the second code area.
- the area corresponding to the code area in the preliminary merged version of the software code is a unilateral change block, usually ,
- the unilateral change block is the area after the software code change version changes the code area.
- the merge conflicts existing in the preliminary merged version of the software code are divided into two types, one is an explicit conflict, and the other is an implicit conflict.
- Explicit conflicts are the conflicts shown in the conflicting blocks in the preliminary merged version of the software code, and are the conflicting blocks that have been marked in the preliminary merged version of the software code.
- Implicit conflicts refer to conflicts that are not prompted in the preliminary merged version of the software code, but conflicts that cause compilation errors due to unilateral changes with associated relationships.
- implicit conflicts are divided into two categories, one is the implicit conflict caused by the unilateral change block with the association relationship, and the other is the unilateral change block with the association relationship and the conflict block after the conflict is eliminated.
- the implicit conflict is the implicit conflict caused by the unilateral change block with the association relationship, and the other is the unilateral change block with the association relationship and the conflict block after the conflict is eliminated.
- variable ApK in the code area A in the original code area the variable name of the code area is changed to mloadedApK in the first software code change version, but the code area is not in the second software code change version
- the code area A in the preliminary merged version of the software code will adopt the change of the first software code version.
- the code area B in the preliminary merged version of the software code will adopt the change of the second software code version.
- the area corresponding to the code area B in the preliminary merged version of the software code is another unilateral change block.
- this conflict has not been found in Git, and it belongs to the existence of an association relationship. Implicit conflict caused by unilateral change of block.
- the implicit conflict caused by the unilateral change of the association relationship and the conflict block after the conflict is eliminated is similar to the implicit conflict caused by the unilateral change block of the association relationship.
- variable ApK in the code area A in the original code area the variable name of the code area is changed to mloadedApK in the first software code change version, and the code area is changed to mloadedApK in the second software code change version.
- the variable name is changed to mloadedinfo.
- the code area B in the preliminary merged version of the software code will adopt the change of the second software code version.
- the conflict is eliminated by adopting the change of the code area in the first software code change version, that is, the variable ApK variable name of the area corresponding to the code area A in the preliminary merged version of the software code is changed For mloadedApK.
- the implicit conflict belongs to the implicit conflict caused by the unilateral change of the association relationship and the conflict block after the conflict is eliminated.
- An abstract syntax tree which can also be referred to as a syntax tree for short, is an abstract representation of the grammatical structure of software code.
- the grammar tree expresses the grammatical structure of the programming language in a tree-like form.
- Each node on the tree represents a structure in the software code, such as variables, functions, methods, and so on.
- n represents the number of AST node types.
- the change action set is used to indicate the set of change actions of the code change area in the software code change version to the original code area.
- the change action consists of the change operation and the AST node type.
- the change operation includes but is not limited to: add (add), modify (change), move (move), and delete (delete).
- the change action set of the first code area is called the first change action set
- the change action set of the second code area is called the second change action set.
- the alteration action sets involved in the training samples in the training set are referred to as alteration action set 1 and alteration action set 2. Since the code change area involved in the training sample can be a different code area from the first code area and the second code area, the change action set 1 and the change action set 2 can also be different from the first change action set and the second change action set .
- each change analyzer can analyze the change purpose or intention of the change action set of the code area (such as the first code area and the second code area), such as the change purpose or intention It is the change (such as adding, modifying, moving and deleting) of this type of statement in the code area.
- the change analyzer involved in the embodiments of this application includes but is not limited to: variable analyzer, control flow statement change analyzer, log change statement analyzer, function signature transformation analyzer (function analyzer), function call transform analyzer (function invoke analyzer), class interface analyzer (classor interface analyzer), and expression sentence analyzer (expression analyzer).
- variable analyzer can analyze whether there are variables in the code area based on the change action set, and whether the variable is renamed, and the change intention determined by the variable analyzer is that the code area is renamed.
- the control flow statement change analyzer can determine whether the changes of statements or expressions such as If, While, Do-While, For, Switch, Try-Catch, etc. in the code area occur in the condition or the body of the change based on the change action set, and then determine whether There is a change in the control flow statement.
- the change intent determined by the control flow statement change analyzer is that the control flow statement in the code area changes.
- the log change statement analyzer can analyze whether there are log, trace and other related log-containing statement changes based on the change action set.
- the change intention determined by the log change statement analyzer is that the statement of the log in the code area has changed.
- the function signature transformation analyzer can analyze the modifier change in the function signature, the function parameter type change, and the function parameter name change based on the change action set, and determine whether the function has changed.
- the change intention determined by the function signature transformation analyzer is that the function in the code area changes.
- the function call transformation analyzer can analyze the change of the owner in the function call and the change of the function call parameters based on the change action set.
- the change intention determined by the function call transformation analyzer is that the calling method of the function in the code area changes.
- the class interface analyzer can analyze changes in the class or interface including the name, inherited class, or implementation interface based on the change action set.
- the change intention determined by the class interface analyzer is a change in the class or interface in the code area.
- the expression sentence analyzer can analyze the change of the variable or value of the expression based on the change action set.
- the change intention determined by the expression sentence analyzer is that the expression in the code area changes.
- a merging device 100 provided in this embodiment of the application includes an intention understanding module 110, an explicit conflict elimination module 120 and an implicit conflict early warning module 130.
- the intention understanding module 110 analyzes the conflicting block in the preliminary merged version of the software code, the first code area in the first software code change version and the second code area in the second software code change version; determines the change intention of the first code area And the intention to change the second code area.
- the intention understanding module 110 includes one or more change analyzers, which can analyze the change intent of the first code area and the change intent of the second code area.
- the explicit conflict elimination module 120 includes a set of conflict elimination rules, and may also include a predictive model.
- the explicit conflict elimination module 120 can eliminate conflict blocks in the preliminary merged version based on the conflict elimination rule set according to the change intention of the first code area and the change intention of the second code area.
- the explicit conflict elimination module 120 can also call the predictive model elimination. The conflicting blocks in the preliminary merge version of the software code.
- the implicit conflict warning module 130 analyzes the unilateral change blocks in the conflict blocks in the preliminary merged version of the software code, and determines the relationship between the unilateral change blocks and the relationship between the unilateral change blocks and the conflict blocks, based on the unilateral change blocks The association relationship between and the association relationship between the unilateral change block and the conflict block determines the implicit conflict in the preliminary merged version of the software code, indicating that there is an implicit conflict.
- an embodiment of the present application also provides a training device, which is used to train a prediction model, and sends the trained prediction model to the explicit conflict elimination module 120, so that the explicit conflict elimination is displayed.
- the module 120 calls the predictive model to eliminate conflicting blocks in the preliminary merged version of the software code.
- the method can be divided into two parts, one part is an explicit conflict elimination method (see step 201 to step 202), and the other part is an implicit conflict early warning method (see step 203 to 204). These two parts can be executed independently or jointly (that is, both explicit conflict elimination and implicit conflict warning are executed). In the joint execution, the embodiment of this application does not limit the execution order of the two parts.
- the embodiment of this application It is just an example for the implementation of the implicit conflict early warning method after the explicit conflict elimination method is executed. The method is described below:
- Step 201 The intention understanding module 110 analyzes the first code area in the first software code change version and the second code area in the second software code change version of the conflicting block in the preliminary merged version of the software code, and determines the first code area The change intent of the second code area and the change intent of the second code area.
- conflicting blocks is not limited in the embodiments of the present application, and there may be one or more conflicting blocks.
- the intention understanding module 110 first determines the first code area in the first software code change version and the second code area in the first software code change version of the conflict block.
- Step 1 The intention understanding module 110 first locates the conflicting block in the preliminary merged version of the software code.
- Git the tool for initial software code merging (that is, the tool for outputting the initial merged version of software code is Git) as an example
- conflicting blocks in the initial merged version of software code are usually marked with specific identifiers, including but not Limited to ⁇ ,
- the conflict block marked in the preliminary merged version of the software code output by Git records the first code area in the first software code change version, the original code area of the original software code, and the second code area in the second software code change version.
- " is the first code area.
- Step 2 The intention understanding module 110 constructs the syntax tree of the original software code, the syntax tree of the first software code modified version, and the syntax tree of the second software code modified version.
- Step 3 The intention understanding module 110 determines the first change action set of the first software code according to the syntax tree of the original software code and the syntax tree of the first software code change version.
- the first change action set records the first change action set based on the original software code. A collection of code area change actions.
- the intention understanding module 110 may use the Gumtree code change action recognition algorithm to recognize the first change action set according to the syntax tree of the original software code and the syntax tree of the first software code change version.
- Step 4 The intention understanding module 110 determines a second change action set of the second software code according to the syntax tree of the original software code and the syntax tree of the first software code change version.
- the second change action set records the area based on the original code, 2.
- the execution method of step 4 is similar to that of step 3, and will not be repeated here.
- Step 5 The intention understanding module 110 calls the change analyzer to analyze the first change action set, and determines the change intention of the first code area.
- the intention understanding module 110 includes a plurality of change analyzers, and the intention understanding module 110 can respectively call the plurality of change analyzers to analyze the first change action set.
- variable analyzer uses a variable analyzer as an example to describe the manner in which the change analyzer analyzes the first change action set.
- the variable analyzer can analyze the identifiers involved in each change action in the first change action set, analyze whether the identifier is a variable, and then analyze whether the identifier is subjected to a variable renaming operation to determine whether there is in the first code area Change intent of variable renaming.
- Step 6 The intention understanding module 110 calls the change analyzer to analyze the second change action set, and determines the change intention of the second code area. Step 6 is performed in the same manner as step 5, and will not be repeated here. For details, please refer to the foregoing content.
- the first code area, the original code area, and the second code area corresponding to the conflicting block in the preliminary merged version of the software code are the first block diagram and the second code area corresponding to the conflicting block in the preliminary merged version of the software code.
- the first block diagram is the first code area in the first software code change version
- the second block diagram is the original code area in the original software code
- the second block diagram is the second software code change version. The second code area.
- the linear frame in Figure 3B encircles the change intent of the first code region and the second code region.
- the change intention of the control flow analyzer is called to determine that the change intention of the first code area is a change in the control flow statement, and the expression analyzer is called to determine that the change intention of the first code area is an expression change.
- Step 202 The explicit conflict elimination module 120 eliminates conflicting blocks in the preliminary merged version of the software code according to the change intent of the first code area and the change intent of the second code area.
- the explicit conflict elimination module 120 can eliminate the conflict block.
- the first type, the explicit conflict elimination module 120 is based on the conflict elimination rule set, and eliminates conflicting blocks in the preliminary merged version of the software code according to the change intent of the first code area and the change intent of the second code area.
- the explicit conflict elimination module 120 can store a set of conflict elimination rules.
- the conflict elimination rule set includes one or more conflict elimination rules.
- Each conflict elimination rule records the conflict block and merges the code change areas in different software code changes.
- the conflict elimination rule set may be preset.
- the embodiment of the application does not limit the specific content of the conflict elimination rule record.
- the conflict elimination rule provided by the embodiment of the application where each row of records
- the content is a conflict elimination rule.
- the code area indicates a type of code changed in different software code change versions, and the functional entity is the code changed in different software code change versions.
- A is used to indicate the modified content of the first code area
- B is used to indicate the modified content of the second code area.
- A is used to indicate the added content of the first code area
- B is used to indicate the added content of the second code area .
- the conflict elimination rule records the intention to delete import a in the first code area, and the intention to not delete import a in the second code area, and the conflict resolution finally adopted. Not to delete.
- the conflict elimination rule records the change intention of field a in the first code area as a modification, and the change intention of field a in the first code area is also a modification, and the conflict resolution is finally adopted.
- the plan is as follows:
- field a is modified to A or B.
- Rule 1 Two software code changes are aimed at the same original code area, one is the control flow statement change, and the other is the log statement change.
- the conflict elimination solution is to merge the log statement changes on the basis of the control flow statement change.
- the conflict elimination scheme is to display the code change area corresponding to the original code area in the software code change version (such as the first Software code area and second software code area), for example, the first software code area is displayed on the upper side, and the second software code area is displayed on the lower side.
- the software code change version such as the first Software code area and second software code area
- Rule 7 Two software code change versions are aimed at the same original code area.
- the code change area of one software code change version includes the code change area of the other software code change version.
- the conflict resolution plan is to adopt the code change area that includes the other software code change version.
- the preliminary merged version of the software code may include some conflicting blocks that cannot be eliminated using the set of conflict elimination rules. For the remaining unresolved conflicting blocks, it can be judged whether the conflicting block is a conflicting block that cannot be eliminated. For example, in the conflicting block, the first software code change version and the second software code change version use different change operations for the same line of code . If it is such a conflict block that cannot be eliminated, it can be prompted that the conflict block cannot be eliminated. Otherwise, it is considered that the conflicting block can be eliminated. For such conflicting blocks that are not eliminated by the first method and determined to be eliminated, the second method can be used.
- the second type is that the explicit conflict elimination module 120 calls the predictive model to eliminate conflicting blocks in the preliminary merged version of the software code.
- the prediction model is used to initially merge conflicting blocks in the version based on the software code, and output a conflict elimination plan for the conflicting block.
- the accuracy of the prediction model is related to the training method of the prediction model and the training set.
- the following describes the construction method of the training set of the training device to construct the prediction model:
- the training device first determines a number of initial training samples.
- Each initial training sample includes two different software code change versions, a set of change actions in the code change area in the original code, and the set of changes used when merging the two code change areas.
- Consolidation strategy The merging strategy used when merging the two changed regions in each initial training sample may be pre-collected.
- the change action set used when merging two change areas may be a merge strategy manually used when the manual conflict elimination method is performed. Consolidation strategies can also understand conflict resolution schemes.
- the training device respectively determines two code change areas corresponding to the same area in the original code (to distinguish the original code area, here the code area in the original code is called the original area) (for the convenience of explanation, the first change area is used here)
- change action set for the convenience of explanation, here use change action set 1 to represent the change action set of the first change area and change action set 2 to indicate the change action set of the second change area.
- each change action set can be converted into a 4*n-bit vector.
- Two change action sets can be converted into a 4*n*2 bit vector.
- the training device uses the 4*n*2 bit vector converted from the training initial sample and a label as a training sample, and the label can indicate the merging strategy used when merging the two changed regions.
- the training device uses the same method to convert multiple initial training samples into multiple training samples.
- the flag 1 indicates that the merge strategy is to use the first change area. At this time, both the first change area and the second change area have changed the original area.
- the mark 2 indicates that the merging strategy is to adopt the second change area. At this time, both the first change area and the second change area have changed the original area.
- the mark 3 indicates that the merge strategy is to directly merge the first change area and the second change area. At this time, both the first change area and the second change area have changed the original area.
- the mark 4 indicates that the merge strategy is to use the first change area for the first part and the second change area for the latter part.
- the first change area changes the previous part of the original area
- the second change area changes the latter part of the original area. Part of the changes.
- the mark 5 indicates that the merge strategy uses the second change area for the first part and the first change area for the latter part. At this time, the first change area changes the latter part of the original area, and the second change area changes the former part of the original area. Part of the changes.
- the mark 6 indicates that the merge strategy is that the front and rear parts adopt the first change area, and the middle part adopts the second change area.
- the first change area changes the front and rear parts of the original area
- the second change area changes the original area.
- the middle part of the area is changed.
- the mark 7 indicates that the merge strategy is to use the second change area for the front and back parts, and the first change area for the middle part. At this time, the first change area changes the middle part of the original area, and the second change area changes the original area. Change the front and back parts of the
- the mark 8 indicates that the merge strategy is to use change set 1 and change set 2 to merge. At this time, both the first change area and the second change area have changed the original area.
- the mark 9 indicates that the merge cannot be performed. At this time, both the first change area and the second change area have changed the original area.
- a machine learning method (such as a random forest algorithm) is used for model training to obtain a prediction model.
- the explicit conflict elimination module 120 converts the first change action set and the second change action set into a 4*n*2 bit vector in the same way, and inputs the vector to the prediction model, according to the prediction The output of the model determines the merger strategy.
- the explicit conflict elimination module 120 eliminates conflicting blocks according to the merge strategy.
- the first code area, the original code area, and the second code area corresponding to another conflicting block in the preliminary merged version of the software code are the first block diagram and the second code area corresponding to another conflicting block in the preliminary merged version of the software code.
- the first block diagram is the first code area in the first software code change version
- the second block diagram is the original code area in the original software code
- the third block diagram is the second software code change version. The second code area.
- the middle block diagram is the result of using step 202 to eliminate conflicting blocks.
- step 201 it can be determined that the change intention of the first code area is the change of the If control flow, and the change intention of the second code area is the change of the variable name. , You can change the variable name based on the change of the If control flow.
- the first code area, the original code area, and the second code area corresponding to another conflicting block in the preliminary merged version of the software code are the first block diagram and the second code area corresponding to another conflicting block in the preliminary merged version of the software code.
- the first block diagram is the first code area in the first software code change version
- the second block diagram is the original code area in the original software code
- the third block diagram is the second software code change version. The second code area.
- the middle block diagram is the result of using step 202 to eliminate conflicting blocks.
- step 201 it can be determined that the change intention of the first code area is the increase of function modifiers, and the change intention of the second code area is the increase of function parameters. , You can directly merge the first code area and the second code area, adding function modifiers and function parameters.
- the method provided by the embodiment of this application can better eliminate the conflicts in the conflict block in the preliminary merged version of the software code.
- the method provided by the embodiment of the present application can also eliminate the conflicts in the preliminary merged version of the software code.
- the implicit conflict of the alarm For details, see step 203 and step 204.
- Step 203 The implicit conflict warning module 130 analyzes the unilateral change blocks in the preliminary merged version of the software code, and determines the association relationship between the unilateral change blocks and the association relationship between the unilateral change blocks and the conflict blocks.
- the implicit conflict warning module 130 analyzes the unilateral change blocks in the preliminary merged version of the software code, and analyzes the definition and usage mode of the variables in each unilateral change block, the definition of the function, and the usage mode.
- the implicit conflict early warning module 130 determines the definition and usage mode of the variables in each unilateral change block and the definition and use mode of the function according to the analysis obtained, and determines the association relationship between the unilateral change block and the relationship between the unilateral change block and the conflict block. connection relation.
- the association relationship between the unilaterally changed blocks includes, but is not limited to: the modification or reference relationship of functions between the unilaterally changed blocks, and the modification or reference relationship of variables between the unilaterally changed blocks.
- the association relationship between the unilateral change block and the conflict block includes, but is not limited to: the modification or reference relationship of the function between the unilateral change block and the conflict block, and the modification or reference relationship of the variables between the unilateral change block and the conflict block.
- Step 204 The implicit conflict warning module 130 determines the implicit conflict in the preliminary merged version of the software code based on the association relationship between the unilateral change block and the association relationship between the unilateral change block and the conflict block, and prompts that there is an implicit conflict.
- Implicit conflicts can be divided into two categories, one is the implicit conflict caused by the unilateral change block with the association relationship, and the other is the implicit conflict caused by the unilateral change block with the association relationship and the conflict block after the conflict is eliminated.
- the change method of a unilateral change block is to delete a function or variable, and the other change method of a unilateral change block is to add code, and the added code refers to the deleted function or variable. Then these two unilateral change blocks will cause an implicit conflict.
- an original code area is int a
- the code area corresponding to the original code area in the first software code change version is int a
- the original code area in the second software code change version is null (that is, delete int a)
- the unilateral merging block adopts the area corresponding to the original code area in the second software code modification version, that is, deletes the variable.
- the other original code area is null
- the code area corresponding to the original code area in the second software code change version is null (that is, the original code area is not changed)
- the unilateral merging block adopts the area corresponding to the original code area in the first software code change version, that is, the code is added.
- the change method of one unilateral change block is to modify the function or variable (such as modifying the function name or variable name, or the parameter in the function or variable), and the change method of the other unilateral change block is to add code and add code reference Function or variable before modification. Then these two unilateral change blocks will cause an implicit conflict.
- an original code area is int a
- the code area corresponding to the original code area in the first software code change version is int a
- the code area corresponding to the original code area in the second software code change version is int b (that is, Modify the variable name of variable a)
- the unilateral merging block adopts the code area corresponding to the original code area in the second software code modification version, that is, modify the variable name.
- the other original code area is null
- the code area corresponding to the original code area in the second software code change version is null (that is, the original code area is not changed)
- the unilateral merging block adopts the code area corresponding to the original code area in the first software code change version, that is, the code is added.
- conflict block after the conflict is eliminated refers to the code area after the conflict block is eliminated, that is, the code area after the different changes in the conflict block are merged.
- the method of eliminating the conflict block is not limited here.
- the conflicting block can be eliminated in step 202, or other methods, such as manually eliminating conflicting blocks.
- the change method of a unilateral change block is to delete a function or variable, and the conflict block after eliminating the conflict refers to the deleted function or variable. Then the unilateral change block and the conflict block after eliminating the conflict will cause an implicit conflict.
- an original code area is int a
- the code area corresponding to the original code area in the first software code change version is int a
- the code area corresponding to the original code area in the second software code change version is int b (that is, Modify the variable name of the variable a)
- the unilateral merging block adopts the code area corresponding to the original code area in the second software code modification version, that is, modify the variable.
- the original code area in the second software code change version is The second software code area is null (that is, the code is deleted).
- the change method of a unilateral change block is to modify the function or variable, and the conflict block after eliminating the conflict refers to the modified function or variable. Then the unilateral change block and the conflict block after eliminating the conflict will cause an implicit conflict.
- an original code area is int a
- the code area corresponding to the original code area in the first software code change version is int a
- the code area corresponding to the original code area in the second software code change version is null (that is, delete int a)
- the unilateral merging block adopts the code area corresponding to the original code area in the second software code modification version, that is, deletes the variable.
- the first software code area is selected.
- a software code area is selected.
- an original code area is func1() ⁇ ac; ⁇ , the first software code area of the original code area in the first software code change version is ⁇ func1() ⁇ ab; ⁇ (that is, the modified function), and the second In the modified version of the software code, the second software code area of the original code area is func2(int p), that is, the modified function.
- the first software code area is selected.
- the other original code area is func1()
- the code area corresponding to the original code area in the first software code change version is func1()
- the code area corresponding to the original code area in the second software code change version is func2(3) (That is, the called function is modified)
- the unilateral merging block adopts the code region corresponding to the original code region in the second software code modification version, that is, the called function is modified.
- the first software code area modifies the initial value of the variable
- the second software code area deletes the variable
- the second software code area is used to eliminate the conflict of the conflict block.
- a unilateral change block adds code, and the added code references the variable. Then the unilateral change block and the conflict block after eliminating the conflict will cause an implicit conflict.
- the second software code area of the original code area is null, that is, the initial value of the variable is deleted.
- the conflicting block conflicts, the second software code area is selected.
- the other original code area is null
- the code area corresponding to the original code area in the first software code change version is a++ (the variable is referenced)
- the code area corresponding to the original code area in the second software code change version is null( That is, without modification)
- the unilateral merging block adopts the code area corresponding to the original code area in the first software code modification version, that is, the variable is referenced.
- the first software code area modifies the initial value of the variable, and the second software code area changes the variable name of the variable.
- the second software code area is used to eliminate the conflict of the conflict block.
- a unilateral change block adds code, and the added code references the variable. Then the unilateral change block and the conflict block after eliminating the conflict will cause an implicit conflict.
- the other original code area is null
- the code area corresponding to the original code area in the first software code change version is a++ (the variable is referenced)
- the code area corresponding to the original code area in the second software code change version is null( That is, without modification)
- the unilateral merging block adopts the code area corresponding to the original code area in the first software code modification version, that is, the variable is referenced.
- the merged version of the software code After eliminating the conflicting block in the preliminary merged version of the software code, or discovering the implicit conflict in the conflicting block in the preliminary merged version of the software code, the merged version of the software code can be output, and the merged version of the software code may eliminate the conflicting block
- the preliminary merged version of the software code may also be the preliminary merged version of the software code where the implicit conflict is found, and the merged version of the software code may also be the preliminary merged version of the software code where the conflict block is eliminated and the implicit conflict is found.
- FIG. 9 shows a computer cluster provided by an embodiment of the present application.
- the computer cluster includes a plurality of computing devices 900, and each computing device 900 establishes a communication path through a communication network.
- Each computing device 900 includes a bus 901, a processor 902, a communication interface 903, and a memory 904.
- the computing device 900 may also include a display screen 905.
- the processor 902, the memory 904, and the communication interface 903 communicate through a bus 901.
- the processor 902 may be composed of one or more general-purpose processors, such as a central processing unit (CPU), or a combination of a CPU and a hardware chip.
- the above-mentioned hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof.
- the above-mentioned PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a general array logic (generic array logic, GAL), or any combination thereof.
- the memory 904 may include a volatile memory (volatile memory), such as a random access memory (random access memory, RAM).
- volatile memory such as a random access memory (random access memory, RAM).
- the memory 904 may also include non-volatile memory (NVM), such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (solid-disk drive, HDD). state drive, SSD).
- NVM non-volatile memory
- ROM read-only memory
- HDD hard disk drive
- solid-state drive solid-disk drive
- state drive SSD
- the memory 904 may also include a combination of the above types.
- the memory 904 stores executable codes.
- the processor 902 can read the executable codes in the memory 904 to realize functions. It can also communicate with other computing devices through the communication interface 903.
- the processor 902 can also trigger the display screen 905 to report to the user. Display information, such as the information in Figures 3B, 7B, and 8B in the embodiment of the present application, and also display the merged version of the software code.
- the processor 902 may implement one or more modules of the merging apparatus 100 (such as one or more of the intention understanding module 110, the explicit conflict elimination module 120, and the implicit conflict early warning module 130).
- the memory 904 stores one or more modules of the merging device 100 (such as one or more modules of the intention understanding module 110, the explicit conflict elimination module 120, and the implicit conflict early warning module 130).
- the processors 902 in the multiple computing devices 900 may coordinate work to execute the method for merging multiple versions of software codes provided in the embodiment of the present application.
- a system architecture provided by this embodiment of the application includes a client 200 and a cloud device 300 with a change device deployed.
- the client 200 and the cloud device 300 are connected via a network, and the cloud device 300 is located in a cloud environment and can be a server or a virtual machine deployed in a cloud data center.
- the merging apparatus 100 is deployed on a cloud device 300 as an example.
- the merging The device may be deployed on multiple cloud devices 300 in a distributed manner.
- the client 200 includes a bus 201, a processor 202, a communication interface 203, a memory 204, and a display screen 205.
- the processor 202, the memory 204, and the communication interface 203 communicate through a bus 201.
- the memory 204 stores executable codes, and the processor 202 can read the executable codes in the memory 204 to implement functions.
- the processor 202 may also trigger the display screen 205 to display information to the user, such as the information shown in FIGS. 3B, 7B, and 8B in the embodiment of the present application, and may also display a merged version of the software code.
- the processor 202 may also communicate with the cloud device through the communication interface 203.
- the processor 202 may prompt the user to select the original software code, the preliminary merged version of the software code, the changed version of the first software code, and the changed version of the second software code through the display screen 205, and feedback the architecture information to the cloud device 300 through the communication interface 203. It is also possible to receive through the communication interface 203 the conflict-eliminated block and the merged version of the software code including the hint of implicit conflict, and display the merged version of the software code on the display screen 205.
- the cloud device 300 includes a bus 301, a processor 302, a communication interface 303, and a memory 304.
- the processor 302, the memory 304, and the communication interface 303 communicate through a bus 301.
- the memory 304 stores executable code
- the processor 302 can read the executable code in the memory 304 to implement functions, and can also communicate with the client 200 through the communication interface 303.
- the processor 302 may implement the function of the merging apparatus 100.
- the memory 304 stores one or more of the receiving module 110, the construction module 120, and the display module 130 of the merging apparatus 100. Module.
- the processor 302 After the processor 302 receives the original software code, the preliminary merged version of the software code, the modified version of the first software code, and the modified version of the second software code from the client 200 through the communication interface 303, it can call the modules stored in the memory 304 to implement the application.
- the method for merging multiple versions of software code provided in the example generates a merged version of the software code, and the processor 302 may send the merged version of the software code to the client 200 through the communication interface 303.
- the disclosed system, device, and method can be implemented in other ways.
- the device embodiments described above are merely illustrative, for example, the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components may be combined or It can be integrated into another system, or some features can be ignored or not implemented.
- the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
- the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Stored Programmes (AREA)
Abstract
一种软件代码的多变更版本合并方法及装置,合并装置可以先对软件代码初步合并版本、两个不同的软件代码变更版本中的代码变更区域进行分析。在确定了两个代码变更区域的变更意图之后,合并装置基于冲突消除规则集合,依据两个代码变更区域的变更意图消除件软代码初步合并版本中的冲突块,相较于基于文本消除软件代码初步合并版本中冲突块的方式,通过分析不同代码变更区域的变更意图消除冲突块的方式,能够提高消除冲突块的准确性,进一步,实现高效的软件代码的多变更版本合并。
Description
相关申请的交叉引用
本申请要求在2019年12月28日提交中国专利局、申请号为201911383077.0、申请名称为“一种软件代码的多变更版本合并方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及计算机技术领域,尤其涉及一种软件代码的多变更版本合并方法及装置。
在对软件代码进行变更时,若针对同一软件代码存在多种软件代码变更版本,需要将这多个软件代码变更版本进行合并。
目前,Git作为一种分布式代码控制管理工具,通过Git可以实现软件代码的多变更版本合并,并输出合并后的软件代码版本。
但由于Git进行软件代码的多变更版本合并的方式,是一种基于文本的软件代码合并方式。也就是以软件代码的代码行或字符为单位,检测各个软件代码变更版本针对同一代码行或字符的变更,再进行合并。
这种基于文本的软件代码合并方式,无法精确地对软件代码变更版本中变更的代码进行语义分析,不能对多种软件代码变更版本进行较好的合并,输出的合并后的软件代码版本会存在大量的冲突块,其中,冲突块是指Git无法进行合并的代码区域。
显然,目前软件代码的多变更版本合并的方式准确性较差。
发明内容
本申请提供一种软件代码的多变更版本合并方法,以提供准确的消除软件代码初步合并版本中的冲突块。
第一方面,本申请提供了一种软件代码的多变更版本合并方法,该方法可以由合并装置执行,在该方法中,合并装置可以先对软件代码初步合并版本、第一软件代码变更版本以及第二软件代码变更版本进行分析。例如,可以定位软件代码初步合并版本中冲突块在第一软件代码变更版本中的第一代码区域以及该冲突块在第二软件代码变更版本中的第二代码区域,分析第一代码区域和第二代码区域的变更意图。
在确定了第一代码区域和第二代码区域的变更意图之后,合并装置基于冲突消除规则集合,依据第一代码区域的变更意图和第二代码区域的变更意图消除冲突块,也就是消除冲突块中的冲突,输出消除了该冲突块的软件代码初步合并版本。合并装置可以显示消除了该冲突块的软件代码初步合并版本,以供用户查看,也可以将消除了该冲突块的软件代码初步合并版本发送给其他装置,由其他装置显示消除了该冲突块的软件代码初步合并版本。
通过上述方法,合并装置不再基于文本消除软件代码初步合并版本中的冲突块,而是 分析不同软件代码变更版本的变更意图,消除冲突块,能够保证冲突块消除的准确性,进一步,实现高效的软件代码的多变更版本合并。
在一种可能的实现方式中,若软件代码初步合并版本中还存在一些未消除的冲突块,该合并装置可以调用预测模型消除软件代码初步合并版本中的冲突块,预测模块是预先已训练好的,能够根据输入的冲突块输出该冲突块的冲突消除方案的模型。
通过上述方法,合并装置除了基于冲突消除规则消除软件代码初步合并版本中的冲突块,还能够借助预测模型消除软件代码初步合并版本中的冲突块,可以尽可能多的消除软件代码初步合并版本中的冲突块,能够保证软件代码多变更版本合并的准确性,还可以提高软件代码多变更版本的合并效率。
在一种可能的设计中,软件代码初步合并版本中除一些已标注的冲突块外,还可能存在一些未预警的隐式冲突,也就是一些被忽视的冲突。为了能够发现这些冲突,合并装置可以对软件代码初步合并版本中的冲突块和单方变更块进行分析,确定单方变更块之间是否存在关联,单方变更块与冲突块之间是否存在关联,在确定单方变更块之间存在关联关系、和/或单方变更块与冲突块之间存在关联关系后,合并装置可以基于单方变更块之间的关联关系、和/或单方变更块与冲突块之间的关联关系,提示存在隐式冲突。
通过上述方法,合并装置还能够发现软件代码初步合并版本中的一些隐式冲突,并进行预警,便于后续用户查看隐式冲突,对软件代码初步合并版本进行修改。
在一种可能的设计中,合并装置在确定第一代码区域的变更意图时,可以先生成第一代码区域的变更动作集(简称为第一变更动作集),该第一变更动作集中包括针对原始软件代码中的原始代码区域(也即冲突块在原始软件代码对应的代码区域),第一代码区域的至少一个变更动作。之后,合并装置再调用多个变更分析器对第一变更动作集进行分析,确定第一代码区域的变更意图。
类似的,合并装置在确定第二代码区域的变更意图时,可以先生成第二代码区域的变更动作集(简称为第二变更动作集),该第二变更动作集中包括针对原始软件代码中的原始代码区域,第二代码区域的至少一个变更动作。之后,合并装置再调用多个变更分析器对第二变更动作集进行分析,确定第二代码区域的变更意图。
通过上述方法,合并装置基于变更动作集(第一变更动作集或第二变更动作集)确定代码变更区域(第一代码区域和第二代码区域)的变更意图,采用这种方式确定的变更意图更加准确,能够较好的理解代码变更区域需要实现的变更。
在一种可能的设计中,单方变更块之间的关联关系包括下列至少一项:
单方变更块之间函数的引用关系,单方变更块之间函数的修改关系(也即是否存在对同一函数的修改操作)、单方变更块之间变量的引用关系,单方变更块之间变量的修改关系(也即是否存在对同一变量的修改操作)。
单方变更块与冲突块之间的关联关系包括下列至少一项:
单方变更块与冲突块(也可以理解为冲突块涉及的不同软件代码变更版本的代码变更区域)之间函数的引用关系、单方变更块与冲突块之间函数的修改关系、单方变更块与冲突块之间变量的引用关系、单方变更块与冲突块之间变量的修改关系。
通过上述方法,合并装置可以基于单方变更块之间的关联关系、单方变更块与冲突块之间的关联关系能够更加精确的定位到软件代码初步合并版本中的隐式冲突。
在一种可能的设计中,合并装置在生成第一变更动作集时,可以先构建原始软件代码 的语法树、第一软件代码变更版本的语法树以及第二软件代码变更版本的语法树;之后,再根据原始软件代码的语法树、第一软件代码变更版本的语法树确定第一变更动作集;
类似的,合并装置在生成第二变更动作集时,可以先构建原始软件代码的语法树、第二软件代码变更版本的语法树以及第二软件代码变更版本的语法树;之后,再根据原始软件代码的语法树、第二软件代码变更版本的语法树确定第二变更动作集。
通过上述方法,合并装置比对原始软件代码以及软件代码变更版本的语法树,可以较准确的确定出代码变更区域所执行的变更动作,产生变更动作集。
第二方面,本申请实施例还提供了一种合并装置,有益效果可以参见第一方面的描述此处不再赘述。该装置具有实现上述第一方面的方法实例中行为的功能。所述功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。所述硬件或软件包括一个或多个与上述功能相对应的模块。在一个可能的设计中,所述装置的结构中包括意图理解模块、显式冲突消除模块和隐式冲突预警模块。这些模块可以执行上述第一方面方法示例中的相应功能,具体参见方法示例中的详细描述,此处不做赘述。
第三方面,本申请实施例还提供了一种计算设备,所述计算设备包括处理器和存储器,还可以包括通信接口以及显示屏,所述处理器执行所述存储器中的程序指令执行上述第一方面或第一方面任一可能的实现方式提供的方法。所述存储器与所述处理器耦合,其保存确定交通流量的过程中必要的程序指令和数据。所述通信接口,用于与其他设备进行通信,例如接收原始软件代码、第一软件代码变更版本以及第二软件代码变更版本,又例如发送消除了冲突块(和标注了隐式冲突)的软件代码初步合并版本。所述显示屏用于在所述处器的触发下向用户显示消除了显式冲突的软件代码,还可以显示软件代码中的隐式冲突。
第四方面,本申请提供了一种计算设备集群,该计算设备集群包括至少一个计算设备。每个计算设备包括存储器和处理器。至少一个计算设备的处理器用于访问所述存储器中的代码以执行第一方面或第一方面的任意一种可能的实现方式提供的方法。
第五方面,本申请提供了一种非瞬态的可读存储介质,所述非瞬态的可读存储介质被计算设备执行时,所述计算设备执行前述第一方面或第一方面的任意可能的实现方式中提供的方法。该存储介质中存储了程序。该存储介质包括但不限于易失性存储器,例如随机访问存储器,非易失性存储器,例如快闪存储器、硬盘(hard disk drive,HDD)、固态硬盘(solid state drive,SSD)。
第六方面,本申请提供了一种计算设备程序产品,所述计算设备程序产品包括计算机指令,在被计算设备执行时,所述计算设备执行前述第一方面或第一方面的任意可能的实现方式中提供的方法。该计算机程序产品可以为一个软件安装包,在需要使用前述第一方面或第一方面的任意可能的实现方式中提供的方法的情况下,可以下载该计算机程序产品并在计算设备上执行该计算机程序产品。
第七方面,本申请还提供一种计算机芯片,芯片与存储器相连,芯片用于读取并执行存储器中存储的软件程序,执行前述第一方面或第一方面的任意可能的实现方式中提供的方法。
图1为本申请提供的一种合并装置的结构示意图;
图2为本申请提供的一种软件代码的多变更版本合并方示意图;
图3A为本申请提供的一种软件代码初步合并版本中冲突块的示意图;
图3B为本申请提供的一种代码区域的变更意图的示意图;
图4为本申请提供的一种冲突消除规则的示意图;
图5为本申请提供的一种训练样本的构建示意图;
图6为本申请提供的一种标签与合并策略的对应关系示意图;
图7A为本申请提供的另一种软件代码初步合并版本中冲突块的示意图;
图7B为本申请提供的一种消除冲突块后软件代码的示意图;
图8A为本申请提供的另一种软件代码初步合并版本中冲突块的示意图;
图8B为本申请提供的另一种消除冲突块后软件代码的示意图;
图9为本申请提供的一种计算机集群的结构示意图;
图10为本申请提供一种系统的结构示意图。
在对本申请实施例提供的一种软件代码的多变更版本合并方法进行说明之前,先对本申请实施例涉及的概念进行说明:
(1)、原始软件代码、软件代码变更版本、软件代码初步合并版本。
软件代码是程序员利用开发工具所支持的语言编写而成的。软件代码由一组具有指向意义的数字或字母构成。软件代码中包括多行代码,每行设置一个行号,通过行号标识该行代码。
原始软件代码是指未进行变更的软件代码。软件代码变更版本是指在原始软件代码的基础上,进行了变更的软件代码。在本申请实施例并不限定软件代码变更版本的数量,在本申请实施例中以两个软件代码变更版本(为方便区分,分别称为第一软件代码变更版本以及第二软件代码变更版本)为例进行说明。当软件代码变更版本的数量大于两个时,多个软件代码变更版本的合并方式与两个软件代码变更版本的合并方式类似,本申请实施例不再赘述。
软件代码初步合并版本是指初步将软件代码变更版本进行合并产生的软件代码,例如,软件代码初步合并版本是Git对软件代码变更版本进行合并产生的软件代码,本申请实施例并不限定软件代码初步合并版本的产生方式。在本申请实施例中软件代码初步合并版本中存在较多合并冲突,也就是存在较多冲突块,可能还存在一些未被发现的合并冲突。在本申请实施例中可以消除软件代码初步合并版本的冲突块,还能够发现并提示软件代码初步合并版本中之前未被发现的合并冲突。
需要说明的是,为区分在生成预测模型时训练集中的训练样本所变更的软件代码,将训练集中的训练样本所变更的软件代码称为原始代码。
(2)、类,内部类,包,函数/方法,域/变量
软件代码在编写过程中需要满足一定编写规范,如面向对象程序编程(object-oriented programming,OOP)、面向过程程序编程(procedure-oriented programming,POP)等。面向对象程序编程的程序语言有C++,Java,C#等,面向过程程序编程的程序语言有fortran,C等。
采用一定编写规范所编写而成的软件代码中可以包括类、包、函数/方法、域/变量等代码元素。其中,包中可以包括一个或多个类,每个类中可以包括内部类、函数/方法;函 数/方法中可以调用域/变量。内部类与类相似,内部类中也可以包括函数/方法。
类(class)在面向对象编程中是一种面向对象计算机编程语言的构造,描述了所创建的对象共同的方法和域。内部类(inner class)为包含在类中的类。
函数/方法(function/method)指的是类中的一种子程序。一个方法通常以一系列的语句所组成,并能够完成一个功能。在面向对象编程的编写规范中称为方法,在面向过程编程的编写规范中称为函数。
域/变量(field/variable)存储一些数据,如整数与字符,字符串、散列表、指针等。
包(package)用来说明某段程序的路径结构。一个包通常包含多个类,类引用的时候需要在包导入(import)区填写完整的包路径。
(3)、冲突块、单方变更块。
1、冲突块
针对原始软件代码的一个代码区域(可称为原始代码区域),若两个软件代码变更版本对该代码区域进行了不同的变更,两个不同的变更行为产生了两个不同的代码变更区域,将产生的两个不同的代码变更区域和原始代码区域构成的块称为冲突块。在软件代码初步合并版本中的冲突块可以设置特定的标识符,以便用户查看该冲突块。
在本申请实施例中,第一软件代码变更版本中该代码区域对应的代码变更区域称为第一代码区域,第二软件代码变更版本中该代码区域对应的代码变更区域称为第二代码区域。也就是说,第一代码区域是在第一软件代码变更版本中该代码区域变更后的区域,第二代码区域是在第二软件代码变更版本中该代码区域变更后的区域。
其中,软件代码初步合并版本没有对这两个软件代码变更版本对该代码区的变更进行合并的原因有很多,例如,初始进行软件代码合并的工具(如Git)无法对这两个软件代码变更版本对该代码区域的变更进行合并。
需要说明的是,为区分在生成预测模型时训练集中的训练样本中所涉及的代码变更区域,将训练集中的训练样本所涉及的代码变更区域称为第一变更区域和第二变更区域。训练样本中所涉及的代码变更区域可以是与第一代码区域和第二代码区域不同的代码区域。
2、单方变更块
针对原始软件代码的一个代码区域,若两个软件代码变更版本中只存在一个软件代码变更版本对该代码区域进行了变更,软件代码初步合并版本中该代码区域对应的区域为单方变更块,通常,单方变更块为软件代码变更版本对该代码区域变更后的区域。
(4)、显式冲突、隐式冲突。
在本申请实施例中,将软件代码初步合并版本中存在的合并冲突分为两类,一类为显式冲突,另一类为隐式冲突。
显式冲突为软件代码初步合并版本中冲突块所显示的冲突,是软件代码初步合并版本已标注的冲突块。
隐式冲突是指软件代码初步合并版本中没有提示的冲突、但由于具有关联关系的单方变更导致编译错误的冲突。
在本申请实施例中隐式冲突分为两类,一种为由存在关联关系的单方变更块引起的隐式冲突,另一种为存在关联关系的单方变更块与消除冲突后的冲突块引起的隐式冲突。
举例来说,对于原始代码区域中的代码区域A中存在变量ApK,在第一软件代码变更版本中将该代码区域的变量名更改为mloadedApK,在第二软件代码变更版本中未对该代 码区域进行变更,采用Git进行软件代码的多变更版本合并时,软件代码初步合并版本中该代码区域A将采用第一软件代码变更版本的变更。软件代码初步合并版本中该软件区域A对应的区域即为单方变更块。若对于原始代码区域中的代码区域B中存在变量ApK赋值,将ApK=3,在第一软件代码变更版本中未对该代码区域进行变更,在第二软件代码变更版本中变更了该代码区域的变量所赋的值,将ApK=3更改为ApK=4,采用Git进行软件代码的多变更版本合并时,软件代码初步合并版本中该代码区域B将采用第二软件代码变更版本的变更。软件代码初步合并版本中该代码区域B对应的区域为另一个单方变更块。此时由于软件代码初步合并版本中代码区域A对应的区域已变更了变量名,但代码区域B对应的区域变量名并没有改变,这种冲突在Git并未被发现,属于由存在关联关系的单方变更块引起的隐式冲突。
对于存在关联关系的单方变更与消除冲突后的冲突块引起的隐式冲突,与存在关联关系的单方变更块引起的隐式冲突类似。
举例来说,对于原始代码区域中的代码区域A中存在变量ApK,在第一软件代码变更版本中将该代码区域的变量名更改为mloadedApK,在第二软件代码变更版本中将该代码区域的变量名更改为mloadedinfo,采用Git进行软件代码的多变更版本合并时,该代码区域A无法进行合并,形成冲突块。软件代码初步合并版本中该软件区域A对应的区域即为冲突块。若对于原始代码区域中的代码区域B中存在变量ApK赋值,将ApK=3,在第一软件代码变更版本中未对该代码区域进行变更,在第二软件代码变更版本中变更了该代码区域的变量所赋的值,将mloadedinfo=3更改为mloadedinfo=4,采用Git进行软件代码的多变更版本合并时,软件代码初步合并版本中该代码区域B将采用第二软件代码变更版本的变更。此时若对冲突块存在的冲突进行消除,通过采用第一软件代码变更版本中代码区域的变更消除冲突,也就是说,软件代码初步合并版本中代码区域A对应的区域的变量ApK变量名更改为mloadedApK。但代码区域B中仍采用mloadedinfo=4,使得软件代码初步合并版本中存在隐式冲突。该隐式冲突属于由存在关联关系的单方变更与消除冲突后的冲突块引起的隐式冲突。
(5)、抽象语法树(abstract syntax tree,AST)、语法树的节点。
抽象语法树,也可以简称为语法树,是软件代码的语法结构的一种抽象表示。语法树以树状的形式表现编程语言的语法结构,树上的每个节点表示软件代码中的一种结构,如可以表征变量、函数、方法等。在本申请实施例中以n代表AST节点类型的数量。
(6)、变更动作集,变更动作。
在本申请实施例中,变更动作集用于指示软件代码变更版本中的代码变更区域对原始代码区域的变更动作的集合。变更动作由变更操作和AST节点类型构成。
在本申请实施例中变更操作包括但不限于:增加(add)、修改(change)、移动(move)以及删除(delete)。
在本申请实施例中,将第一代码区域的变更动作集称为第一变更动作集,将第二代码区域的变更动作集称为第二变更动作集。为区分在生成预测模型时训练集中的训练样本中所涉及的变更动作集,将训练集中的训练样本所涉及的变更动作集称为变更动作集1和变更动作集2。由于训练样本中所涉及的代码变更区域可以是与第一代码区域和第二代码区域不同的代码区域,变更动作集1和变更动作集2也可以与第一变更动作集合第二变更动作集不同。
(7)、变更分析器、变更意图。
本申请实施例中,可以构建多个变更分析器,每个变更分析器可以分析代码区域(如第一代码区域和第二代码区域)的变更动作集的变更目的或意图,如变更目的或意图是对该代码区域发生该类型语句的变更、变量、函数或类进行变更(如增加、修改、移动以及删除)。
本申请实施例涉及的变更分析器包括但不限于:变量分析器(variable analyzer)、控制流语句变化分析器(controlflow analyzer)、日志变化语句分析器(log analyzer)、函数签名变换分析器(function analyzer)、函数调用变换分析器(functioninvoke analyzer)、类接口分析器(classorinterface analyzer)以及表达式语句分析器(expression analyzer)。
其中,变量分析器能够基于变更动作集分析该代码区域是否存在变量,是否对变量发生重命名操作,变量分析器所确定的变更意图为该代码区域发生变量重命名。
控制流语句变化分析器能够基于变更动作集判断该代码区域中If、While、Do-While、For、Switch、Try-Catch等语句或表达式的变化是否发生在条件中或者变化体,进而确定是否存在控制流语句的变化。控制流语句变化分析器所确定的变更意图为该代码区域中的控制流语句发生变化。
日志变化语句分析器能够基于变更动作集分析是否存在Log、Trace等相关的包含日志的语句变化。日志变化语句分析器所确定的变更意图为该代码区域中的日志的语句发生变化。
函数签名变换分析器能够基于变更动作集分析函数签名中的修饰符变化、函数参数类型变化、函数参数名变换,确定函数是否存在变化。函数签名变换分析器所确定的变更意图为该代码区域中的函数发生变化。
函数调用变换分析器能够基于变更动作集分析函数调用中的拥有者的变化、函数调用参数的变化。函数调用变换分析器所确定的变更意图为该代码区域中的函数的调用方式发生变化。
类接口分析器能够基于变更动作集分析类或接口中包括名字、继承类、或者实现接口的变化。类接口分析器所确定的变更意图为该代码区域中的类或接口发生变化。
表达式语句分析器能够基于变更动作集分析表达式的变量或者值的变化。表达式语句分析器所确定的变更意图为该代码区域中的表达式发生变化。
图1所示,为本申请实施例提供的一种合并装置100,该合并装置100包括意图理解模块110、显式冲突消除模块120和隐式冲突预警模块130。
意图理解模块110分析软件代码初步合并版本中的冲突块在第一软件代码变更版本中的第一代码区域和在第二软件代码变更版本中的第二代码区域;确定第一代码区域的变更意图和第二代码区域的变更意图。
意图理解模块110中包括一个或多个变更分析器,该变更分析器可以分析第一代码区域的变更意图和第二代码区域的变更意图。
显式冲突消除模块120包括冲突消除规则集合,还可以包括预测模型。显式冲突消除模块120可以基于冲突消除规则集合,根据第一代码区域的变更意图和第二代码区域的变更意图消除初步合并版本中的冲突块,显式冲突消除模块120还可以调用预测模型消除软件代码初步合并版本中的冲突块。
隐式冲突预警模块130分析软件代码初步合并版本中的冲突块中单方变更块,确定单方变更块之间的关联关系、以及单方变更块与冲突块之间的关联关系,基于单方变更块之间的关联关系、以及单方变更块与冲突块之间的关联关系确定软件代码初步合并版本中的隐式冲突,提示存在隐式冲突。
尽管未示出,本申请实施例中还提供了一种训练装置,该训练装置用于训练预测模型,并将训练完成的预测模型发送给显式冲突消除模块120,以使显示显式冲突消除模块120调用预测模型消除软件代码初步合并版本中的冲突块。
下面结合图2对本申请实施例提供的一种软件代码的多变更版本合并方法进行说明。参见图2,该方法可以分为两部分,一部分为显式冲突消除方法(参见步骤201~步骤202),另一部分为隐式冲突预警方法(参见步骤203~204)。这两部分可以独立执行,也可以联合执行(也就是显式冲突消除和隐式冲突预警均执行),在联合执行时,本申请实施例并不限定这两部分的执行顺序,本申请实施例仅是以在执行显式冲突消除方法后执行隐式冲突预警方法为例进行说明。下面对该方法进行说明:
步骤201:意图理解模块110分析软件代码初步合并版本中的冲突块在第一软件代码变更版本中的第一代码区域和在第二软件代码变更版本中的第二代码区域,确定第一代码区域的变更意图和第二代码区域的变更意图。
需要说明的是,本申请实施例中并不限定冲突块的数量,可以是一个,也可以是多个。针对每个冲突块,意图理解模块110先确定该冲突块在第一软件代码变更版本中的第一代码区域和在第一软件代码变更版本中的第二代码区域。
步骤1、意图理解模块110先定位软件代码初步合并版本中的冲突块。以初始进行软件代码合并的工具为Git(也即输出软件代码初步合并版本的工具为Git)为例,软件代码初步合并版本中的冲突块通常采用特定的标识符进行标注,标识符包括但不限于<<<<<<、|||||||、=======、>>>>>>>。
Git输出的软件代码初步合并版本中标注的该冲突块中记录了第一软件代码变更版本中的第一代码区域、原始软件代码的原始代码区域、第二软件代码变更版本中的第二代码区域。例如,"<<<<<<<"和"|||||||"之间的代码区域为第一代码区域。"|||||||"和"======="之间的代码区域为原始代码区域。"======="和">>>>>>>"之间的代码区域为第二代码区域。
步骤2、意图理解模块110分别构建原始软件代码的语法树、第一软件代码变更版本的语法树以及第二软件代码变更版本的语法树。
步骤3、意图理解模块110根据原始软件代码的语法树、第一软件代码变更版本的语法树确定第一软件代码的第一变更动作集,该第一变更动作集记录了基于原始软件代码,第一代码区域的变更动作的集合。
意图理解模块110可以利用Gumtree代码变更动作识别算法通过根据原始软件代码的语法树、第一软件代码变更版本的语法树识别第一变更动作集。
步骤4、意图理解模块110根据原始软件代码的语法树、第一软件代码变更版本的语法树确定第二软件代码的第二变更动作集,该第二变更动作集记录了基于原始代码区域,第二代码区域的变更动作的集合。步骤4与步骤3的执行方式类似,此处不再赘述。
步骤5、意图理解模块110调用变更分析器对第一变更动作集进行分析,确定第一代码区域的变更意图。
意图理解模块110中包括多个变更分析器,意图理解模块110可以分别调用多个变更 分析器对第一变更动作集进行分析。
下面以变量分析器为例,对变更分析器对第一变更动作集进行分析的方式进行说明。
变量分析器可以分析第一变更动作集中各个变更动作所涉及的标识符,分析标识符是否为变量,之后,再分析该标识符是否进行变量重命名的操作,以确定第一代码区域中是否存在变量重命名的变更意图。
步骤6、意图理解模块110调用变更分析器对第二变更动作集进行分析,确定第二代码区域的变更意图。步骤6与步骤5的执行方式相同,此处不再赘述,具体可参见前述内容。
如图3A所示,为软件代码初步合并版本中冲突块对应的第一代码区域、原始代码区域以及第二代码区域。其中,第一个框图中为第一软件代码变更版本中的第一代码区域,第二个框图中为原始软件代码中的原始代码区域,第二个框图中为第二软件代码变更版本中的第二代码区域。
如图3B所示,为通过调用变更分析器确定的第一代码区域的变更意图和第二代码区域的变更意图,图3B种线性框圈出了第一代码区域的变更意图和第二代码区域的变更意图,其中,调用控制流分析器确定第一代码区域的变更意图为控制流语句发生变化,调用表达式分析器确定第一代码区域的变更意图为表达式发生变化。
步骤202:显式冲突消除模块120根据第一代码区域的变更意图和第二代码区域的变更意图消除软件代码初步合并版本中的冲突块。
在确定了第一代码区域的变更意图和第二代码区域的变更意图之后,显式冲突消除模块120可以消除冲突块。
在本申请实施例中消除软件代码初步合并版本中的冲突块中的方式有两种,下面分别进行介绍:
第一种、显式冲突消除模块120基于冲突消除规则集合,根据第一代码区域的变更意图和第二代码区域的变更意图消除软件代码初步合并版本中的冲突块。
显式冲突消除模块120中可以保存冲突消除规则集合,该冲突消除规则集中包括一个或多个冲突消除规则,每个冲突消除规则记录了对冲突块,合并不同软件代码变更版本中的代码变更区域所采用的冲突消除方案。
该冲突消除规则集合可以是预先设置的,本申请实施例并不限定该冲突消除规则记录的具体内容,如图4所示,为本申请实施例提供的冲突消除规则,其中,每行记录的内容为一个冲突消除规则。代码区域指示不同软件代码变更版本中变更的一种类型的代码,作用实体为不同软件代码变更版本中变更的代码。
其中,当第一代码区域和第一代码区域的变更意图为修改时,其中A用于指示第一代码区域修改后的内容,B用于指示第二代码区域修改后的内容。当第一代码区域和第一代码区域的变更意图均为增加(包括在代码区域之外增加),其中A用于指示第一代码区域增加的内容,B用于指示第二代码区域增加的内容。
以序号为1的冲突消除规则为例,该冲突消除规则记录了第一代码区域对import a的变更意图为删除,第二代码区域对import a的变更意图为不删除,最终采用的冲突解决方案为不删除。
以序号为9的冲突消除规则为例,该冲突消除规则记录了第一代码区域对field a执行的变更意图为修改,第一代码区域对field a的变更意图也为修改,最终采用的冲突解决方 案如下:
当第一代码区域对field a修改后的内容A与第二代码区域对field a修改后的内容B相同(也即A和B相同)时,则将field a修改为A或B。
当第一代码区域对field a修改后的内容A与第二代码区域对field a修改后的内容B不同(也即A和B不同)时,则提示有冲突。
如图4所示仅是部分冲突消除规则,除了如图4所示的冲突消除规则之外,本申请实施例还提供了如下冲突消除规则:
规则1、两个软件代码变更版本针对同一原始代码区域,一个为控制流语句变化,另一个为日志语句的变化,冲突消除方案为在控制流语句变化的基础上合并日志语句变化。
规则2、两个软件代码变更版本针对同一原始代码区域,一个为控制流语句变化,另一个为变量的变化,冲突消除方案为在控制流语句变化的基础上合并变量的变化。
规则3、两个软件代码变更版本针对同一原始代码区域,一个为修饰符的变化,另一个为函数参数的变化,冲突消除方案为合并修饰符的变化和函数参数的变化。
规则4、两个软件代码变更版本针对同一原始代码区域为是空或者是注释语句,冲突消除方案为按照设定顺序依次显示软件代码变更版本中该原始代码区域对应的代码变更区域(如第一软件代码区域和第二软件代码区域),如上方显示第一软件代码区域,下方显示第二软件代码区域。
规则5、两个软件代码变更版本针对同一原始代码区域,一个为函数调用的变化,另一个为日志语句的变化,冲突消除方案为在函数调用变化的基础上合并日志语句的变化。
规则6、两个软件代码变更版本针对同一原始代码区域,其中一个软件代码变更版本的代码变更区域中包括原始代码区域,另一个软件代码变更版本的代码变更区域中不包括原始代码区域,冲突消除方案为采用包括原始代码区域的代码变更区域。
规则7、两个软件代码变更版本针对同一原始代码区域,一个软件代码变更版本的代码变更区域中包括另一个软件代码变更版本的代码变更区域,冲突消除方案为采用包括另一个软件代码变更版本的代码变更区域的代码变更区域。
通过冲突消除规则集合能够消除一些较为常见的冲突块。软件代码初步合并版本中可能包括一些利用冲突消除规则集合也无法消除的冲突块。对于剩余的未消除的冲突块,可以判断该冲突块是否为无法消除的冲突块,如该冲突块中,第一软件代码变更版本和第二软件代码变更版本对同一行代码采用不同的变更操作。若为这类无法消除的冲突块,可以提示该冲突块无法消除。否则,认为该冲突块可消除,对于这类采用第一种方式未消除的、且判定为可消除的冲突块,可以采用第二种方式。
第二种、显式冲突消除模块120调用预测模型消除软件代码初步合并版本中的冲突块。预测模型用于基于软件代码初步合并版本中冲突块,输出对该冲突块的冲突消除方案。
预测模型的准确程度与该预测模型的训练方法以及训练集的有关。下面对训练装置构建预测模型的训练集构建方式进行说明:
首先,训练装置先确定多个训练初始样本,每个训练初始样本中包括两个不同软件代码变更版本对一个原始代码中的代码变更区域中的变更动作集合、合并两个代码变更区域时采用的合并策略。每个训练初始样本中合并两个变更区域时采用的合并策略可以是预先收集的。例如合并两个变更区域时采用的变更动作集合可以为在进行人工冲突消除方式时,人工所采用的合并策略。合并策略也可以理解冲突消除方案。
参见图5,训练装置分别确定原始代码中同一区域(为区分原始代码区域,这里原始代码中的代码区域称为原始区域)对应的两个代码变更区域(为方便说明,这里用第一变更区域和第二变更区域区分)的变更动作集(为方便说明,这里用变更动作集1表示第一变更区域的变更动作集和变更动作集2表示第二变更区域的变更动作集)中每种变更动作集合中不同节点类型下不同类型的变更操作的数量。
以节点类型的数量为n为例,对于该原始区域对应的代码变更区域中的变更动作集,训练装置遍历该变更动作集中包括的变更动作,每遍历一个变更动作,确定该变更动作对应的节点类型以及变更操作,该节点类型下该变更操作的数量加一。按前述方式,每个变更动作集合可以转换为一个4*n位的向量。两个变更动作集合可以转换为一个4*n*2位的向量。
训练装置将训练初始样本转换的4*n*2位的向量和一个标签(label)作为一个训练样本,该标签可以指示该合并两个变更区域时采用的合并策略。训练装置采用同样的方式,将多个训练初始样本转换为多个训练样本。
参见图6,为本申请实施例提供的标签与合并策略的对应关系。
标识为1指示合并策略为采用第一变更区域,此时,第一变更区域和第二变更区域均对原始区域进行了变更。
标识为2指示合并策略为采用第二变更区域,此时,第一变更区域和第二变更区域均对原始区域进行了变更。
标识为3指示合并策略为直接合并第一变更区域和第二变更区域,此时,第一变更区域和第二变更区域均对原始区域进行了变更。
标识为4指示合并策略为前一部分采用第一变更区域,后一部分采用第二变更区域,此时,第一变更区域对原始区域中的前一部分进行变更,第二变更区域对原始区域中的后一部分进行变更。
标识为5指示合并策略为前一部分采用第二变更区域,后一部分采用第一变更区域,此时,第一变更区域对原始区域中的后一部分进行变更,第二变更区域对原始区域中的前一部分进行变更。
标识为6指示合并策略为前、后部分采用第一变更区域,中间部分采用第二变更区域,此时,第一变更区域对原始区域中的前、后部分进行变更,第二变更区域对原始区域中的中间部分进行变更。
标识为7指示合并策略为前、后部分采用第二变更区域,中间部分采用第一变更区域,此时,第一变更区域对原始区域中的中间部分进行变更,第二变更区域对原始区域中的前、后部分进行变更。
标识为8指示合并策略为利用变更集合1和变更集合2进行合并,此时,第一变更区域和第二变更区域均对原始区域进行了变更。
标识为9指示无法进行合并,此时,第一变更区域和第二变更区域均对原始区域进行了变更。
由此,训练集构建完成,之后,基于训练集,采用机器学习方法(如随机森林算法)进行模型训练得到预测模型。
预测模型训练完成后,显式冲突消除模块120将第一变更动作集合和第二变更动作集合按照相同的方式转换为4*n*2位的向量,将该向量输入至该预测模型,根据预测模型的 输出结果确定合并策略。显式冲突消除模块120根据该合并策略消除冲突块。
如图7A所示,为软件代码初步合并版本中另一个冲突块对应的第一代码区域、原始代码区域以及第二代码区域。其中,第一个框图中为第一软件代码变更版本中的第一代码区域,第二个框图中为原始软件代码中的原始代码区域,第三个框图中为第二软件代码变更版本中的第二代码区域。
如图7B所示,中间的框图为采用步骤202消除冲突块的结果,通过步骤201可以确定第一代码区域的变更意图为If控制流的变化,第二代码区域的变更意图是变量名的改变,可以在If控制流的变化的基础上改变变量名。
如图8A所示,为软件代码初步合并版本中另一个冲突块对应的第一代码区域、原始代码区域以及第二代码区域。其中,第一个框图中为第一软件代码变更版本中的第一代码区域,第二个框图中为原始软件代码中的原始代码区域,第三个框图中为第二软件代码变更版本中的第二代码区域。
如图8B所示,中间的框图为采用步骤202消除冲突块的结果,通过步骤201可以确定第一代码区域的变更意图为函数修饰符的增加,第二代码区域的变更意图是函数参数的增加,可以将第一代码区域和第二代码区域直接进行合并,既增加函数修饰符,又增加函数参数。
由此,可见采用本申请实施例所提供的方法可以较好的消除软件代码初步合并版本中的冲突块中的冲突,另外,本申请实施例所提供的方法还可以对软件代码初步合并版本中的隐式冲突进行告警。具体可参见步骤203和步骤204。
步骤203:隐式冲突预警模块130分析软件代码初步合并版本中的单方变更块,确定单方变更块之间的关联关系、以及单方变更块与冲突块之间的关联关系。
隐式冲突预警模块130分析软件代码初步合并版本中的单方变更块,分析每个单方变更块中变量的定义以及使用方式、函数的定义以及使用方式。
隐式冲突预警模块130确定根据分析获得的每个单方变更块中变量的定义以及使用方式、函数的定义以及使用方式,确定单方变更块之间的关联关系以及单方变更块与冲突块之间的关联关系。
其中,单方变更块之间的关联关系包括但不限于:单方变更块之间函数的修改或引用关系、单方变更块之间变量的修改或引用关系。
单方变更块与冲突块之间的关联关系包括但不限于:单方变更块与冲突块之间函数的修改或引用关系、单方变更块与冲突块之间变量的修改或引用关系。
步骤204:隐式冲突预警模块130基于单方变更块之间的关联关系、以及单方变更块与冲突块之间的关联关系确定软件代码初步合并版本中的隐式冲突,提示存在隐式冲突。
隐式冲突可以分为两类,一种为由存在关联关系的单方变更块引起的隐式冲突,另一种为存在关联关系的单方变更与消除冲突后的冲突块引起的隐式冲突。
下面列举几种由存在关联关系的单方变更块引起的隐式冲突。
1、一个单方变更块的变更方式为删除函数或变量,另一个单方变更块的变更方式为增加代码,且增加的代码引用了被删除函数或变量。则这两个单方变更块将引起隐式冲突。
例如,一个原始代码区域为int a,第一软件代码变更版本中该原始代码区域对应的代码区域为int a,第二软件代码变更版本中该原始代码区域对应的区域为null(也即删除int a),单方合并块采用第二软件代码变更版本中该原始代码区域对应的区域,也即删除变量。
另一个原始代码区域为null,第一软件代码变更版本中该原始代码区域对应的代码区域为a=3(也即增加代码),第二软件代码变更版本中该原始代码区域对应的代码区域为null(也即不变更原始代码区域),单方合并块采用第一软件代码变更版本中该原始代码区域对应的区域,也即增加代码。
这两个单方合并块之间存在隐式冲突。
2、一个单方变更块的变更方式为修改函数或变量(如修改函数名或变量名,或修改函数或变量中的参数),另一个单方变更块的变更方式为增加代码,且增加的代码引用了修改前函数或变量。则这两个单方变更块将引起隐式冲突。
例如,一个原始代码区域为int a,第一软件代码变更版本中该原始代码区域对应的代码区域为int a,第二软件代码变更版本中该原始代码区域对应的代码区域为int b(也即修改变量a的变量名),单方合并块采用第二软件代码变更版本中该原始代码区域对应的代码区域,也即修改变量名。
另一个原始代码区域为null,第一软件代码变更版本中该原始代码区域对应的代码区域为a=3(也即增加代码),第二软件代码变更版本中该原始代码区域对应的代码区域为null(也即不变更原始代码区域),单方合并块采用第一软件代码变更版本中该原始代码区域对应的代码区域,也即增加代码。
这两个单方合并块之间存在隐式冲突。
下面列举几种由存在关联关系的单方变更与消除冲突后的冲突块引起的隐式冲突。
需要说明的是,这里消除冲突后的冲突块是指消除了冲突块后的代码区域,也就是,对冲突块中的不同变更方式进行合并后的代码区域,这里不限定消除冲突块的方式,可以采用步骤202的方式消除冲突块,也可以是采用其他方式,如人工消除冲突块。
1、一个单方变更块的变更方式为删除函数或变量,消除冲突后的冲突块引用了被删除函数或变量。则这单方变更块和消除冲突后的冲突块将引起隐式冲突。
例如,一个原始代码区域为int a,第一软件代码变更版本中该原始代码区域对应的代码区域为int a,第二软件代码变更版本中该原始代码区域对应的代码区域为int b(也即修改变量a的变量名),单方合并块采用第二软件代码变更版本中该原始代码区域对应的代码区域,也即修改变量。
另一个原始代码区域为a=2,第一软件代码变更版本中该原始代码区域的第一软件代码区域为a=3(也即修改代码),第二软件代码变更版本中该原始代码区域的第二软件代码区域为null(也即删除代码),此时,第一软件代码区域和第二代码区域之间存在冲突,也即为冲突块,在消除冲突块的冲突时,选择了第一软件代码区域。
这个单方合并块和消除冲突后的冲突块之间存在隐式冲突。
2、一个单方变更块的变更方式为修改函数或变量,消除冲突后的冲突块引用了被修改的函数或变量。则这单方变更块和消除冲突后的冲突块将引起隐式冲突。
例如,一个原始代码区域为int a,第一软件代码变更版本中该原始代码区域对应的代码区域为int a,第二软件代码变更版本中该原始代码区域对应的代码区域为null(也即删除int a),单方合并块采用第二软件代码变更版本中该原始代码区域对应的代码区域,也即删除变量。
另一个原始代码区域为a=2,第一软件代码变更版本中该原始代码区域的第一软件代码区域为a=3(也即修改变量),第二软件代码变更版本中该原始代码区域的第二软件代码 区域为b=3(也即修改变量,此时,第一软件代码区域和第二代码区域之间存在冲突,也即为冲突块,在消除冲突块的冲突时,选择了第一软件代码区域。
这个单方合并块和消除冲突后的冲突块之间存在隐式冲突。
3、消除冲突后的冲突块中修改函数或变量,一个单方变更块引用了被修改的函数或变量。则这单方变更块和消除冲突后的冲突块将引起隐式冲突。
例如,一个原始代码区域为func1(){ac;},第一软件代码变更版本中该原始代码区域的第一软件代码区域为<func1(){ab;}(也即修改函数),第二软件代码变更版本中该原始代码区域的第二软件代码区域为func2(int p),也即修改函数,此时,第一软件代码区域和第二代码区域之间存在冲突,也即为冲突块,在消除冲突块的冲突时,选择了第一软件代码区域。
另一个原始代码区域为func1(),第一软件代码变更版本中该原始代码区域对应的代码区域为func1(),第二软件代码变更版本中该原始代码区域对应的代码区域为func2(3)(也即修改了调用的函数),单方合并块采用第二软件代码变更版本中该原始代码区域对应的代码区域,也即修改了调用的函数。
这个单方合并块和消除冲突后的冲突块之间存在隐式冲突。
4、对于一个冲突块,第一软件代码区域修改了变量的初始值,第二软件代码区域删除了该变量,在消除冲突块的冲突时采用了第二软件代码区域。一个单方变更块增加代码,增加的代码引用了该变量。则这单方变更块和消除冲突后的冲突块将引起隐式冲突。
例如,一个原始代码区域为int a=1,第一软件代码变更版本中该原始代码区域的第一软件代码区域为int a=2;(也即修改变量的初始值),第二软件代码变更版本中该原始代码区域的第二软件代码区域为null,也即删除该变量的初始值,此时,第一软件代码区域和第二代码区域之间存在冲突,也即为冲突块,在消除冲突块的冲突时,选择了第二软件代码区域。
另一个原始代码区域为null,第一软件代码变更版本中该原始代码区域对应的代码区域为a++(引用了该变量),第二软件代码变更版本中该原始代码区域对应的代码区域为null(也即未进行修改),单方合并块采用第一软件代码变更版本中该原始代码区域对应的代码区域,也即引用了该变量。
这个单方合并块和消除冲突后的冲突块之间存在隐式冲突。
5、对于一个冲突块,第一软件代码区域修改了变量的初始值,第二软件代码区域对改变了该变量的变量名,在消除冲突块的冲突时采用了第二软件代码区域。一个单方变更块增加代码,增加的代码引用了该变量。则这单方变更块和消除冲突后的冲突块将引起隐式冲突。
例如,一个原始代码区域为int a=1,第一软件代码变更版本中该原始代码区域的第一软件代码区域为int a=2;(也即修改变量的初始值),第二软件代码变更版本中该原始代码区域的第二软件代码区域为int b=1,也即修改该变量的变量名,此时,第一软件代码区域和第二代码区域之间存在冲突,也即为冲突块,在消除冲突块的冲突时,选择了第一软件代码区域。
另一个原始代码区域为null,第一软件代码变更版本中该原始代码区域对应的代码区域为a++(引用了该变量),第二软件代码变更版本中该原始代码区域对应的代码区域为 null(也即未进行修改),单方合并块采用第一软件代码变更版本中该原始代码区域对应的代码区域,也即引用了该变量。
这个单方合并块和消除冲突后的冲突块之间存在隐式冲突。
在消除了软件代码初步合并版本中的冲突块,或发现软件代码初步合并版本中的冲突块中的隐式冲突后,可以输出软件代码合并版本,该软件代码合并版本可以是消除了冲突块的软件代码初步合并版本中,还可以是发现了隐式冲突的软件代码初步合并版本,该软件代码合并版本也可以是消除了冲突块的、以及发现了隐式冲突的软件代码初步合并版本。
基于与方法实施例同一发明构思,本申请实施例还提供了一种计算机集群,用于执行上述方法实施例中所示的方法,相关特征可参见上述方法实施例,此处不再赘述,如图9所示,为本申请实施例提供的一种计算机集群,该计算机集群中包括多个计算设备900,每个计算设备900间通过通信网络建立通信通路。
每个计算设备900中包括总线901、处理器902、通信接口903以及存储器904,可选的,计算设备900中还可以包括显示屏905。处理器902、存储器904和通信接口903之间通过总线901通信。
其中,处理器902可以由一个或者多个通用处理器构成,例如中央处理器(central processing unit,CPU),或者CPU和硬件芯片的组合。上述硬件芯片可以是专用集成电路(application-specific integrated circuit,ASIC)、可编程逻辑器件(programmable logic device,PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(complex programmable logic device,CPLD)、现场可编程逻辑门阵列(field-programmable gate array,FPGA)、通用阵列逻辑(generic array logic,GAL)或其任意组合。
存储器904可以包括易失性存储器(volatile memory),例如随机存取存储器(random access memory,RAM)。存储器904还可以包括非易失性存储器(non-volatile memory,NVM),例如只读存储器(read-only memory,ROM),快闪存储器,硬盘(hard disk drive,HDD)或固态硬盘(solid-state drive,SSD)。存储器904还可以包括上述种类的组合。
存储器904中存储存可执行代码,处理器902可以读取存储器904中的该可执行代码实现功能,还可以通过通信接口903与其他计算设备进行通信,处理器902还可以触发显示屏905向用户显示信息,如本申请实施例中如图3B、7B、8B中的信息,还可以显示软件代码合并版本。在本申请实施例中,处理器902可以实现合并装置100的一个或多个模块(如意图理解模块110、显式冲突消除模块120、隐式冲突预警模块130中的一个或多个模块)的功能,这种情况下,存储器904中存储有合并装置100的一个或多个模块(如意图理解模块110、显式冲突消除模块120、隐式冲突预警模块130的一个或多个模块)。
在本申请实施例中,多个计算设备900中的处理器902可以协调工作,执行本申请实施例提供的软件代码的多变更版本合并方法。
如图10所示,为本申请实施例提供的一种系统架构,该系统架构中包括客户端200和部署有变更装置的云端设备300,客户端200与云端设备300通过网络连接,该云端设备300位于云环境中,可以是部署在云数据中心中的服务器或者虚拟机,图10中,仅是以该合并装置100部署在一个云端设备300为例,作为一种可能的实施方式,该合并装置可以分布式地部署在多个云端设备300上。
如图10所示,客户端200包括总线201、处理器202、通信接口203、存储器204以及显示屏205。处理器202、存储器204和通信接口203之间通过总线201通信。其中, 处理器202和存储器204的类型可以参见处理器902以及存储器904的相关说明,此处不再赘述。存储器204中存储存可执行代码,处理器202可以读取存储器204中的该可执行代码实现功能。处理器202还可以触发显示屏205向用户显示信息,如本申请实施例中如图3B、7B、8B中的信息,还可以显示软件代码合并版本。处理器202还可以通过通信接口203与云端设备进行通信。例如处理器202可以通过显示屏205提示用户选择原始软件代码、软件代码初步合并版本、第一软件代码变更版本以及第二软件代码变更版本,通过通信接口203将架构信息反馈给云端设备300。还可以通过通信接口203接收消除了冲突块以及包括提示隐式冲突的软件代码合并版本,并通过显示屏205展示该软件代码合并版本。
如图10所示,云端设备300包括总线301、处理器302、通信接口303以及存储器304。处理器302、存储器304和通信接口303之间通过总线301通信。其中,处理器302和存储器304的类型可以参见处理器902以及存储器904的相关说明,此处不再赘述。存储器304中存储存可执行代码,处理器302可以读取存储器304中的该可执行代码实现功能,还可以通过通信接口303与客户端200进行通信。在本申请实施例中,处理器302可以实现合并装置100的功能,这种情况下,存储器304中存储有合并装置100的接收模块110、构建模块120、以及展示模块130中的一个或多个模块。
处理器302通过通信接口303从客户端200接收到原始软件代码、软件代码初步合并版本、第一软件代码变更版本以及第二软件代码变更版本后,可以调用存储器304中存储的模块实现本申请实施例提供的软件代码的多变更版本合并方法,生成软件代码合并版本,处理器302可以通过通信接口303向客户端200发送软件代码合并版本。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
以上所述,仅为本发明的具体实施方式。熟悉本技术领域的技术人员根据本发明提供的具体实施方式,可想到变化或替换,都应涵盖在本发明的保护范围之内。
Claims (14)
- 一种软件代码的多变更版本合并方法,其特征在于,该方法包括:分析软件代码初步合并版本中的冲突块在第一软件代码变更版本中的第一代码区域和在第二软件代码变更版本中的第二代码区域,确定所述第一代码区域的变更意图和所述第二代码区域的变更意图,其中,所述第一软件代码变更版本和所述第二软件代码变更版本由原始软件代码变更后获取;基于冲突消除规则集合,根据所述第一代码区域的变更意图和所述第二代码区域的变更意图消除所述冲突块,所述冲突消除规则集合中包括至少一个冲突消除规则,每个冲突消除规则记录了对冲突块,合并不同软件代码变更版本中的代码变更区域所采用的冲突消除方案。
- 如权利要求1所述的方法,其特征在于,所述方法,还包括:调用预测模型消除所述软件代码初步合并版本中的冲突块,所述预测模块用于根据输入的冲突块输出所述冲突块的冲突消除方案。
- 如权利要求1或2所述的方法,其特征在于,所述方法,还包括:分析所述软件代码初步合并版本中的冲突块和单方变更块,确定所述单方变更块之间的关联关系、以及所述单方变更块与所述冲突块之间的关联关系;基于所述单方变更块之间的关联关系、以及所述单方变更块与所述冲突块之间的关联关系,提示存在隐式冲突。
- 如权利要求1~3任一所述的方法,其特征在于,所述确定第一代码区域的变更意图和所述第二代码区域的变更意图,包括:调用多个变更分析器对第一变更动作集进行分析,确定所述第一代码区域的变更意图,所述第一变更动作集记录了针对所述原始软件代码,所述第一代码区域的变更动作;调用所述多个变更分析器对第二变更动作集进行分析,确定所述第二代码区域的变更意图,所述第二变更动作集记录了针对所述原始软件代码,所述第二代码区域的变更动作,其中,一个所述变更分析器用于分析所述第一变更动作集和第二变更动作集中一种类型的语句、变量、函数或类,确定变更意图。
- 如权利要求3所述的方法,其特征在于,所述单方变更块之间的关联关系包括下列至少一项:所述单方变更块之间函数的修改或引用关系、所述单方变更块之间变量的修改或引用关系;所述单方变更块与所述冲突块之间的关联关系包括下列至少一项:所述单方变更块与所述冲突块之间函数的修改或引用关系、所述单方变更块与所述冲突块之间变量的修改或引用关系。
- 如权利要求4任一所述的方法,其特征在于,所述方法,还包括:构建所述原始软件代码的语法树、所述第一软件代码变更版本的语法树以及所述第二软件代码变更版本的语法树;根据所述原始软件代码的语法树、第一软件代码变更版本的语法树确定所述第一变更动作集;根据所述原始软件代码的语法树、所述第二软件代码变更版本的语法树确定所述第二 变更动作集。
- 一种合并装置,其特征在于,该装置包括:意图理解模块,用于分析软件代码初步合并版本中的冲突块在第一软件代码变更版本中的第一代码区域和在第二软件代码变更版本中的第二代码区域,确定所述第一代码区域的变更意图和所述第二代码区域的变更意图,其中,所述第一软件代码变更版本和所述第二软件代码变更版本由原始软件代码变更后获取;显式冲突消除模块,用于基于冲突消除规则集合,根据所述第一代码区域的变更意图和所述第二代码区域的变更意图消除所述冲突块,所述冲突消除规则集合中包括至少一个冲突消除规则,每个冲突消除规则记录了对冲突块,合并不同软件代码变更版本中的代码变更区域所采用的冲突消除方案。
- 如权利要求7所述的装置,其特征在于,所述装置还包括隐式冲突预警模块:所述隐式冲突预警模块,用于调用预测模型消除所述软件代码初步合并版本中的冲突块,所述预测模块用于根据输入的冲突块输出所述冲突块的冲突消除方案。
- 如权利要求7或8所述的装置,其特征在于,所述隐式冲突预警模块,具体用于:分析所述软件代码初步合并版本中的冲突块和单方变更块,确定所述单方变更块之间的关联关系、以及所述单方变更块与所述冲突块之间的关联关系;基于所述单方变更块之间的关联关系、以及所述单方变更块与所述冲突块之间的关联关系,提示存在隐式冲突。
- 如权利要求7~9任一所述的装置,其特征在于,所述意图理解模块在确定第一代码区域的变更意图和所述第二代码区域的变更意图,具体用于:调用多个变更分析器对第一变更动作集进行分析,确定所述第一代码区域的变更意图,所述第一变更动作集记录了针对所述原始软件代码,所述第一代码区域的变更动作;调用所述多个变更分析器对第二变更动作集进行分析,确定所述第二代码区域的变更意图,所述第二变更动作集记录了针对所述原始软件代码,所述第二代码区域的变更动作,其中,一个所述变更分析器用于分析所述第一变更动作集和所述第二变更动作集中一种类型的语句、变量、函数或类,确定变更意图。
- 如权利要求9所述的装置,其特征在于,所述单方变更块之间的关联关系包括下列至少一项:所述单方变更块之间函数的修改或引用关系、所述单方变更块之间变量的修改或引用关系;所述单方变更块与所述冲突块之间的关联关系包括下列至少一项:所述单方变更块与所述冲突块之间函数的修改或引用关系、所述单方变更块与所述冲突块之间变量的修改或引用关系。
- 如权利要求10所述的装置,其特征在于,所述显式冲突消除模块,具体用于:构建所述原始软件代码的语法树、所述第一软件代码变更版本的语法树以及所述第二软件代码变更版本的语法树;根据所述原始软件代码的语法树、第一软件代码变更版本的语法树确定所述第一变更动作集;根据所述原始软件代码的语法树、所述第二软件代码变更版本的语法树确定所述第二变更动作集。
- 一种计算设备,其特征在于,所述计算设备包括处理器和存储器;所述存储器,用于存储计算机程序指令;所述处理器调用所述存储器中的计算机程序指令执行如权利要求1至6中任一项所述的方法。
- 一种计算设备集群,其特征在于,所述计算设备集群中包括多个计算设备,每个计算设备包括处理器和存储器;至少一个所述计算设备中的存储器,用于存储计算机程序指令;至少一个所述计算设备中的处理器调用所述存储器中存储的计算机程序指令执行如权利要求1至6中任一项所述的方法。
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| EP20904984.0A EP4075267B1 (en) | 2019-12-28 | 2020-09-16 | Combination method and apparatus for multiple change versions of software codes |
| US17/851,627 US12001838B2 (en) | 2019-12-28 | 2022-06-28 | Method and apparatus for merging a plurality of software code change versions |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201911383077.0 | 2019-12-28 | ||
| CN201911383077.0A CN111221566B (zh) | 2019-12-28 | 2019-12-28 | 一种软件代码的多变更版本合并方法及装置 |
Related Child Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| US17/851,627 Continuation US12001838B2 (en) | 2019-12-28 | 2022-06-28 | Method and apparatus for merging a plurality of software code change versions |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2021128973A1 true WO2021128973A1 (zh) | 2021-07-01 |
Family
ID=70806249
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2020/115692 Ceased WO2021128973A1 (zh) | 2019-12-28 | 2020-09-16 | 一种软件代码的多变更版本合并方法及装置 |
Country Status (4)
| Country | Link |
|---|---|
| US (1) | US12001838B2 (zh) |
| EP (1) | EP4075267B1 (zh) |
| CN (1) | CN111221566B (zh) |
| WO (1) | WO2021128973A1 (zh) |
Families Citing this family (14)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111221566B (zh) | 2019-12-28 | 2021-10-22 | 华为技术有限公司 | 一种软件代码的多变更版本合并方法及装置 |
| CN111190583B (zh) * | 2019-12-31 | 2021-10-22 | 华为技术有限公司 | 关联冲突块呈现方法和设备 |
| CN112363719A (zh) * | 2020-11-23 | 2021-02-12 | 百度在线网络技术(北京)有限公司 | 小程序模板的合并方法、装置、设备及存储介质 |
| CN114637510A (zh) * | 2020-12-16 | 2022-06-17 | 华为云计算技术有限公司 | 代码分析的方法和相关设备 |
| CN113535206B (zh) * | 2021-07-23 | 2024-02-20 | 上海幻电信息科技有限公司 | 多版本代码升级方法及系统 |
| CN114416094A (zh) * | 2021-12-22 | 2022-04-29 | 北京达佳互联信息技术有限公司 | 语言信息的转换方法及装置 |
| CN114385234A (zh) * | 2022-01-14 | 2022-04-22 | 中国农业银行股份有限公司 | 代码冲突的消除方法、装置及存储介质 |
| US12189515B2 (en) * | 2022-01-18 | 2025-01-07 | International Business Machines Corporation | Identifying regression test failures |
| US12210862B2 (en) * | 2022-03-09 | 2025-01-28 | Adp, Inc. | Periodic refresh of chatbot from virtual assistant timeline analytics of user conversations |
| CN114741320B (zh) * | 2022-05-17 | 2022-11-15 | 杭州优诗科技有限公司 | 单元测试案例管理方法、装置及可读存储介质 |
| US12326721B2 (en) | 2022-07-12 | 2025-06-10 | Rockwell Automation Technologies, Inc. | Extensible profiles for industrial controller devices |
| US12197904B2 (en) * | 2022-09-23 | 2025-01-14 | Rockwell Automation Technologies, Inc. | Collaborative work on translations in industrial system projects |
| CN115757359A (zh) * | 2022-11-30 | 2023-03-07 | 网易(杭州)网络有限公司 | 文件合并方法、装置、存储介质及电子设备 |
| CN116302078B (zh) * | 2023-05-19 | 2023-08-01 | 深圳前海环融联易信息科技服务有限公司 | 代码文件合并方法及装置、存储介质、计算机设备 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106406918A (zh) * | 2016-11-25 | 2017-02-15 | 华胜信泰信息产业发展有限公司 | 源代码自动合并方法和源代码自动合并装置 |
| CN108073501A (zh) * | 2016-11-14 | 2018-05-25 | 阿里巴巴集团控股有限公司 | 一种代码冲突检测方法及设备 |
| CN109343841A (zh) * | 2018-10-15 | 2019-02-15 | 上海理工大学 | 实时协同编程环境下的语义冲突消解方法 |
| US20190339964A1 (en) * | 2018-05-02 | 2019-11-07 | Microsoft Technology Licensing, Llc | Pending merge conflict notification |
| CN111221566A (zh) * | 2019-12-28 | 2020-06-02 | 华为技术有限公司 | 一种软件代码的多变更版本合并方法及装置 |
Family Cites Families (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6678882B1 (en) * | 1999-06-30 | 2004-01-13 | Qwest Communications International Inc. | Collaborative model for software systems with synchronization submodel with merge feature, automatic conflict resolution and isolation of potential changes for reuse |
| US8826222B2 (en) * | 2011-08-02 | 2014-09-02 | International Business Machines Corporation | Pre-merge conflict avoidance |
| US9342285B2 (en) * | 2012-11-30 | 2016-05-17 | Huawei Technologies Co., Ltd. | Method and apparatus for detecting code change |
| 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 |
| CN110119393B (zh) * | 2016-04-29 | 2021-04-09 | 清华大学 | 代码版本管理系统及方法 |
| CN109947462A (zh) * | 2019-03-15 | 2019-06-28 | 武汉大学 | 一种面向软件代码变更集成的决策支持方法及装置 |
| US11483350B2 (en) * | 2019-03-29 | 2022-10-25 | Amazon Technologies, Inc. | Intent-based governance service |
-
2019
- 2019-12-28 CN CN201911383077.0A patent/CN111221566B/zh active Active
-
2020
- 2020-09-16 EP EP20904984.0A patent/EP4075267B1/en active Active
- 2020-09-16 WO PCT/CN2020/115692 patent/WO2021128973A1/zh not_active Ceased
-
2022
- 2022-06-28 US US17/851,627 patent/US12001838B2/en active Active
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108073501A (zh) * | 2016-11-14 | 2018-05-25 | 阿里巴巴集团控股有限公司 | 一种代码冲突检测方法及设备 |
| CN106406918A (zh) * | 2016-11-25 | 2017-02-15 | 华胜信泰信息产业发展有限公司 | 源代码自动合并方法和源代码自动合并装置 |
| US20190339964A1 (en) * | 2018-05-02 | 2019-11-07 | Microsoft Technology Licensing, Llc | Pending merge conflict notification |
| CN109343841A (zh) * | 2018-10-15 | 2019-02-15 | 上海理工大学 | 实时协同编程环境下的语义冲突消解方法 |
| CN111221566A (zh) * | 2019-12-28 | 2020-06-02 | 华为技术有限公司 | 一种软件代码的多变更版本合并方法及装置 |
Non-Patent Citations (1)
| Title |
|---|
| See also references of EP4075267A4 * |
Also Published As
| Publication number | Publication date |
|---|---|
| US20220365775A1 (en) | 2022-11-17 |
| EP4075267A1 (en) | 2022-10-19 |
| US12001838B2 (en) | 2024-06-04 |
| EP4075267A4 (en) | 2023-03-08 |
| CN111221566B (zh) | 2021-10-22 |
| EP4075267B1 (en) | 2025-01-01 |
| CN111221566A (zh) | 2020-06-02 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2021128973A1 (zh) | 一种软件代码的多变更版本合并方法及装置 | |
| US10831456B1 (en) | External code integrations within a computing environment | |
| CN105550594B (zh) | 安卓应用文件的安全性检测方法 | |
| CN111708539A (zh) | 一种应用程序代码转换方法、装置、电子设备和存储介质 | |
| US20200272426A1 (en) | Code completion for dynamically-typed programming languages using machine learning | |
| US20140282444A1 (en) | Programming language transformations with abstract syntax tree extensions | |
| CN110187885A (zh) | 一种量子程序编译的中间代码生成方法及装置 | |
| US11403207B2 (en) | Detection of runtime errors using machine learning | |
| CN114064601B (zh) | 存储过程转换方法、装置、设备和存储介质 | |
| US10534592B2 (en) | Template expressions for constraint-based systems | |
| US12032941B2 (en) | Method and system for updating legacy software | |
| CN114153459A (zh) | 接口文档生成方法及装置 | |
| CN103034486A (zh) | 移动终端操作系统基于全系统扩展调用图的自动优化方法 | |
| CN114968817A (zh) | 代码改动影响范围的评估方法、装置、设备及存储介质 | |
| WO2025081782A1 (zh) | 一种代码分析方法及相关设备 | |
| CN108563561B (zh) | 一种程序隐性约束提取方法及系统 | |
| CN113050935A (zh) | 生成混入对象的方法、装置、计算设备及计算机可读存储介质 | |
| CN117389518A (zh) | 一种针对Python开源生态的细粒度软件供应链构建方法 | |
| CN110716953B (zh) | Sql语句自动生成方法、装置、设备及可读存储介质 | |
| CN113138797A (zh) | 面向Intel SGX的程序自动化移植系统 | |
| CN114756238A (zh) | 一种动态化编译的方法、装置、设备和存储介质 | |
| CN115688108B (zh) | 一种webshell静态检测方法及系统 | |
| CN116595533B (zh) | 一种针对Java Web应用的注入型漏洞检测方法及系统 | |
| CN111796832A (zh) | 热补丁文件生成方法、装置、设备及存储介质 | |
| CN115658030A (zh) | 代码处理方法、装置和电子设备 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20904984 Country of ref document: EP Kind code of ref document: A1 |
|
| ENP | Entry into the national phase |
Ref document number: 2020904984 Country of ref document: EP Effective date: 20220728 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |