# US 12,001,838 B2 · Method and apparatus for merging a plurality of software code change versions

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,001,838 B2
- Document ID: US12001838B2
- Status: Granted
- Kind: B2
- Application number: 17/851,627
- Filed: 2022-06-28
- Published: 2022-11-17
- Granted: 2024-06-04
- Earliest claimed: 2019-12-28
- Assignees: Huawei Cloud Computing Technology Co., Ltd.
- Applicants: Huawei Cloud Computing Technologies Co., Ltd.
- Inventors: Zhao Wei; Guangtai Liang; Lin Li; Qianxiang Wang
- Web page: https://patentgrep.com/patent/US12001838B2

## CPC

- G06F 8/71: Version control (security arrangements therefor G06F21/57); Configuration management
- G06F 8/72: Code refactoring
- G06F 11/3604: Analysis of software for verifying properties of programs (testing of software G06F11/3668)
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for merging a plurality of software code change versions, where a merging apparatus may first analyze code change areas in a software code preliminarily merged version and two different software code change versions. After change intents of the two code change areas are determined, the merging apparatus eliminates, based on a conflict elimination rule set and the change intents of the two code change areas, a conflict block in the software code preliminarily merged version.

## Claims

### Claim 1

A method for merging a plurality of software code change versions, the method comprising:
obtaining, based on original software code that has been changed, both a first software code change version of a conflict block in a software code preliminarily merged version and a second software code change version of the conflict block;
analyzing both a first code area in the first software code change version and a second code area in the second software code change version;
determining, based on analyzing both the first code area in the first software code change version and the second code area in the second software code change version, a first change intent of the first code area in the first software code change version and a second change intent of the second code area in the second software code change version; and
eliminating the conflict block based on a conflict elimination rule set, the first change intent of the first code area in the first software code change version, and the second change intent of the second code area in the second software code change version,
wherein the conflict elimination rule set comprises at least one conflict elimination rule, and
wherein each of the at least one conflict elimination rule records a conflict elimination solution used for merging code change areas in different software code change versions for conflict blocks.

### Claim 2 (depends on 1)

The method of claim 1, further comprising invoking a prediction model to eliminate the conflict block, wherein the prediction model is configured to output the conflict elimination solution based on an input conflict block.

### Claim 3 (depends on 1)

The method of claim 1, further comprising:
analyzing the conflict block and a first unilateral change block in the software code preliminarily merged version;
determining, based on analyzing the conflict block and the first unilateral change block in the software code preliminarily merged version, a first association relationship between second unilateral change blocks and a second association relationship between the first unilateral change block and the conflict block; and
prompting, based on the first association relationship and the second association relationship, that an implicit conflict exists.

### Claim 4 (depends on 3)

The method of claim 3, wherein the first association relationship comprises a first modification or reference relationship of a first function between the second unilateral change blocks, and wherein the second association relationship comprises a second modification or reference relationship of a second function between the first unilateral change block and the conflict block.

### Claim 5 (depends on 3)

The method of claim 3, wherein the first association relationship comprises a first modification or reference relationship of a function between the second unilateral change blocks, and wherein the second association relationship comprises a second modification or reference relationship of a variable between the first unilateral change block and the conflict block.

### Claim 6 (depends on 3)

The method of claim 3, wherein the first association relationship comprises a first modification or reference relationship of a variable between the second unilateral change blocks, and wherein the second association relationship comprises a second modification or reference relationship of a function between the first unilateral change block and the conflict block.

### Claim 7 (depends on 3)

The method of claim 3, wherein the first association relationship comprises a first modification or reference relationship of a first variable between the second unilateral change blocks, and wherein the second association relationship comprises a second modification or reference relationship of a second variable between the first unilateral change block and the conflict block.

### Claim 8 (depends on 1)

The method of claim 1, further comprising:
invoking a plurality of change analyzers to analyze a first change action set, wherein the first change action set records a first change action in the first code area in the first software code change version for the original software code;
determining, based on analyzing the first change action set, the first change intent of the first code area in the first software code change version;
invoking the plurality of change analyzers to analyze a second change action set, wherein the second change action set records a second change action in the second code area in the second software code change version for the original software code, and wherein one of the plurality of change analyzers is configured to analyze one type of statement, variable, function, or class in the first change action set and the second change action set; and
determining, based on analyzing the second change action set, the second change intent of the second code area in the second software code change version.

### Claim 9 (depends on 8)

The method of claim 8, further comprising:
constructing a first syntax tree of the original software code, a second syntax tree of the first software code change version, and a third syntax tree of the second software code change version;
determining, based on the first syntax tree of the original software code and the second syntax tree of the first software code change version, the first change action set; and
determining, based on the first syntax tree of the original software code and the third syntax tree of the second software code change version, the second change action set.

### Claim 10

A computing device cluster comprising a plurality of computing devices, wherein the plurality of computing devices comprise:
a memory configured to store computer program instructions; and
a processor coupled to the memory and configured to execute the computer program instructions to cause the computing device cluster to:
obtain, based on original software code that has been changed, both a first software code change version of a conflict block in a software code preliminarily merged version and a second software code change version of the conflict block;
analyze both a first code area in the first software code change version and a second code area in the second software code change version;
determine, based on analyzing both the first code area in the first software code change version and the second code area in the second software code change version, a first change intent of the first code area in the first software code change version and a second change intent of the second code area in the second software code change version; and
eliminate the conflict block based on a conflict elimination rule set, the first change intent of the first code area in the first software code change version, and the second change intent of the second code area in the second software code change version,
wherein the conflict elimination rule set comprises at least one conflict elimination rule, and
wherein each of the at least one conflict elimination rule records a conflict elimination solution used for merging code change areas in different software code change versions for conflict blocks.

### Claim 11 (depends on 10)

The computing device cluster of claim 10, wherein the processor is further configured to execute the computer program instructions to cause the computing device cluster to invoke a prediction model to eliminate the conflict block, and wherein the prediction model is configured to output the conflict elimination solution based on an input conflict block.

### Claim 12 (depends on 10)

The computing device cluster of claim 10, wherein the processor is further configured to execute the computer program instructions to cause the computing device cluster to:
analyze the conflict block and a first unilateral change block in the software code preliminarily merged version;
determine, based on analyzing the conflict block and the first unilateral change block in the software code preliminarily merged version, a first association relationship between second unilateral change blocks and a second association relationship between the first unilateral change block and the conflict block; and
prompt, based on the first association relationship and the second association relationship, that an implicit conflict exists.

### Claim 13 (depends on 12)

The computing device cluster of claim 12, wherein the first association relationship comprises a first modification or reference relationship of a first function between the second unilateral change blocks, and wherein the second association relationship comprises a second modification or reference relationship of a second function between the first unilateral change block and the conflict block.

### Claim 14 (depends on 12)

The computing device cluster of claim 12, wherein the first association relationship comprises a first modification or reference relationship of a function between the second unilateral change blocks, and wherein the second association relationship comprises a second modification or reference relationship of a variable between the first unilateral change block and the conflict block.

### Claim 15 (depends on 12)

The computing device cluster of claim 12, wherein the first association relationship comprises a first modification or reference relationship of a variable between the second unilateral change blocks, and wherein the second association relationship comprises a second modification or reference relationship of a function between the first unilateral change block and the conflict block.

### Claim 16 (depends on 12)

The computing device cluster of claim 12, wherein the first association relationship comprises a first modification or reference relationship of a first variable between the second unilateral change blocks, and wherein the second association relationship comprises a second modification or reference relationship of a second variable between the first unilateral change block and the conflict block.

### Claim 17 (depends on 10)

The computing device cluster of claim 10, wherein the processor is further configured to execute the computer program instructions to cause the computing device cluster to:
invoke a plurality of change analyzers to analyze a first change action set, wherein the first change action set records a first change action in the first code area in the first software code change version for the original software code;
determine, based on analyzing the first change action set, the first change intent of the first code area in the first software code change version;
invoke the plurality of change analyzers to analyze a second change action set, wherein the second change action set records a second change action in the second code area in the second software code change version for the original software code, and wherein one of the plurality of change analyzers is configured to analyze one type of statement, variable, function, or class in the first change action set and the second change action set; and
determine, based on analyzing the second change action set, the second change intent of the second code area in the second software code change version.

### Claim 18 (depends on 17)

The computing device cluster of claim 17, wherein the processor is further configured to execute the computer program instructions to cause the computing device cluster to:
construct a first syntax tree of the original software code, a second syntax tree of the first software code change version, and a third syntax tree of the second software code change version;
determine, based on the first syntax tree of the original software code and the second syntax tree of the first software code change version, the first change action set; and
determine, based on the first syntax tree of the original software code and the third syntax tree of the second software code change version, the second change action set.

### Claim 19

A computer program product comprising computer-executable instructions that are stored on a non-transitory computer-readable medium and that, when executed by a processor of an apparatus, cause the apparatus to:
obtain, based on original software code that has been changed, both a first software code change version of a conflict block in a software code preliminarily merged version and a second software code change version of the conflict block;
analyze both a first code area in the first software code change version and a second code area in the second software code change version;
determine, based on analyzing both the first code area in the first software code change version and the second code area in the second software code change version, a first change intent of the first code area in the first software code change version and a second change intent of the second code area in the second software code change version; and
eliminate the conflict block based on a conflict elimination rule set, the first change intent of the first code area in the first software code change version, and the second change intent of the second code area in the second software code change version,
wherein the conflict elimination rule set comprises at least one conflict elimination rule, and
wherein each of the at least one conflict elimination rule records a conflict elimination solution used for merging code change areas in different software code change versions for conflict blocks.

### Claim 20 (depends on 19)

The computer program product of claim 19, wherein the computer-executable instructions further cause the apparatus to invoke a prediction model to eliminate the conflict block, and wherein the prediction model is configured to output the conflict elimination solution based on an input conflict block.
