A method, device, equipment and storage medium for determining a code merging scheme

By analyzing and automatically merging conflicts between local code and updating code in multi-person collaborative development on the client side, the time-consuming and error-prone problem of manual merging code is solved, and development efficiency is improved.

CN119781809APending Publication Date: 2025-04-08CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411773085.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

In multi-person collaborative development, different developers modify the same piece of code to cause code conflicts. Existing solutions require manual merging of code, which is time-consuming and error-prone.

Method used

By establishing a communication connection with the server at the first client, receiving the update code sent by the server, analyzing whether there is a conflict between the local code and the update code, and determining the merging plan based on the analysis results, and automatically merging the code.

Benefits of technology

The code merging process is automated, reducing the workload of manually resolving conflicts, improving development efficiency, and avoiding the cumbersome and omissions of manual inspections.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119781809A_ABST
    Figure CN119781809A_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a method, apparatus, device and storage medium for determining a code merging scheme, modifying the target code to obtain the local code, and establishing a communication connection with the server; the server is connected in communication with the second client; receiving the update code sent by the server; the update code is the code sent to the server after the second client modifies the target code; analyzing whether there is a conflict between the local code and the update code, and obtaining an analysis result; according to the analysis result, determining a merging scheme for merging the local code and the update code. The embodiment of the present application can automatically push the update code to the client when there is an update code on the server, avoiding the need for developers to obtain the update code repeatedly from time to time, automatically detecting whether there is a conflict by analyzing the local code and the update code, and automatically determining the merging scheme according to the analysis result, reducing the workload of manually resolving conflicts and improving development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer software technology, and in particular to a method and device for determining a code merging solution, an electronic device, and a storage medium. Background Art

[0002] In software development, multi-person collaborative development is a common problem. However, in traditional multi-person collaborative development, different developers make different modifications to the same piece of code on the local client. When these modifications are attempted to be merged into the main branch of the server, code conflicts between multiple clients will occur, which will hinder development progress. Existing solutions usually require manual merging of multiple client codes to resolve code conflicts, but this solution is not only time-consuming but also prone to errors. Summary of the invention

[0003] The embodiment of the present application provides a method for determining a code merging solution to solve the problem of manually merging codes of multiple clients due to code conflicts.

[0004] Correspondingly, an embodiment of the present application also provides a device for determining a code merging scheme, an electronic device, and a storage medium to ensure the implementation and application of the above method.

[0005] In order to solve the above problem, an embodiment of the present application discloses a method for determining a code merging solution, which is applied to a first client, and the method includes:

[0006] Modifying the target code to obtain the local code and establishing a communication connection with the server; the server is in communication connection with the second client;

[0007] receiving an update code sent by the server; the update code is a code sent to the server after the second client modifies the target code;

[0008] Analyze whether there is a conflict between the local code and the update code, and obtain an analysis result;

[0009] A merging scheme for merging the local code and the updated code is determined according to the analysis result.

[0010] Optionally, the analyzing whether there is a conflict between the local code and the update code to obtain an analysis result includes:

[0011] determining a code portion where no conflict exists between the local code and the update code as a first local code and a first update code;

[0012] Determine a second local code and a second update code from a code portion where there is a conflict between the local code and the update code;

[0013] Obtain a first analysis result according to the first local code and the first update code;

[0014] Obtain a second analysis result according to the second local code and the second update code;

[0015] The first analysis result and the second analysis result are determined as the analysis results.

[0016] Optionally, obtaining a second analysis result according to the second local code and the second update code includes:

[0017] Performing semantic analysis on the second local code and the second update code to obtain a context corresponding to the second local code and a context corresponding to the second update code;

[0018] Parsing a context corresponding to the second local code and a context corresponding to the second update code to determine semantic information corresponding to the second local code and semantic information corresponding to the second update code;

[0019] Determining semantic similarity information and semantic difference information between the semantic information corresponding to the second local code and the semantic information corresponding to the second update code;

[0020] Determining a semantic analysis result according to the semantic similarity information and the semantic difference information;

[0021] The semantic analysis result is determined as the second analysis result.

[0022] Optionally, obtaining a second analysis result according to the second local code and the second update code further includes:

[0023] Running the second local code and the second update code to obtain a running result corresponding to the second local code and a running result corresponding to the second update code;

[0024] Determine an operation similarity result and an operation difference result between an operation result corresponding to the second local code and an operation result corresponding to the second update code;

[0025] Determining an operation analysis result according to the operation similarity result and the operation difference result;

[0026] The operation analysis result is determined as the second analysis result.

[0027] Optionally, determining a merging scheme for merging the local code and the update code according to the analysis result includes:

[0028] Determine, according to the first analysis result, a first merging scheme for merging the first local code and the first update code;

[0029] Based on the semantic analysis result, determine a second merging scheme for merging the second local code corresponding to the semantic difference information and the second update code corresponding to the semantic difference information; or, based on the operation analysis result, determine a third merging scheme for merging the second local code corresponding to the operation difference result and the second update code corresponding to the operation difference result.

[0030] Optionally, the determining, according to the analysis result, a merging scheme for merging the local code and the update code further includes:

[0031] Creating, according to the semantic analysis result, a first compatible code for being compatible with a second local code corresponding to the semantic difference information and a second updated code corresponding to the semantic difference information;

[0032] Running the first compatible code to obtain an operation result corresponding to the first compatible code;

[0033] Determining whether the running result corresponding to the first compatible code satisfies both the second local code corresponding to the semantic difference information and the second update code corresponding to the semantic difference information;

[0034] If the running result corresponding to the first compatible code simultaneously satisfies the second local code corresponding to the semantic difference information and the second update code corresponding to the semantic difference information, a fourth merging scheme is determined for replacing the second local code corresponding to the semantic difference information and the second update code corresponding to the semantic difference information with the first compatible code.

[0035] Optionally, the determining, according to the analysis result, a merging scheme for merging the local code and the update code further includes:

[0036] Creating, according to the operation analysis result, a second compatible code for being compatible with a second local code corresponding to the operation difference result and a second updated code corresponding to the operation difference result;

[0037] Running the second compatible code to obtain a running result corresponding to the second compatible code;

[0038] Determine whether the operation result corresponding to the second compatible code satisfies both the second local code corresponding to the operation difference result and the second update code corresponding to the operation difference result;

[0039] If the running result corresponding to the second compatible code simultaneously satisfies the second local code corresponding to the running difference result and the second update code corresponding to the running difference result, a fifth merging scheme is determined for replacing the second local code corresponding to the running difference result and the second update code corresponding to the running difference result with the second compatible code.

[0040] The embodiment of the present application further discloses a device for determining a code merging solution, which is applied to a first client, and the device includes:

[0041] A communication connection establishment module, used to modify the target code, obtain the local code, and establish a communication connection with the server; the server is in communication connection with the second client;

[0042] An update code receiving module, used for receiving an update code sent by the server; the update code is a code sent to the server after the second client modifies the target code;

[0043] A code conflict analysis module, used to analyze whether there is a conflict between the local code and the update code, and obtain an analysis result;

[0044] A merging scheme determining module is used to determine a merging scheme for merging the local code and the updated code according to the analysis result.

[0045] An embodiment of the present application also discloses an electronic device, including: a processor; and a memory, on which executable code is stored. When the executable code is executed, the processor executes a method for determining a code merging scheme as described in any one of the embodiments of the present application.

[0046] The embodiments of the present application also disclose one or more machine-readable media on which executable codes are stored. When the executable codes are executed, the processor executes the method for determining the code merging scheme as described in any one of the embodiments of the present application.

[0047] Compared with the prior art, the embodiments of the present application have the following advantages:

[0048] In an embodiment of the present application, a first client modifies a target code to obtain a local code, and establishes a communication connection with a server; the server is in communication connection with a second client; receives an update code sent by the server; the update code is a code sent to the server after the second client modifies the target code; analyzes whether there is a conflict between the local code and the update code, and obtains an analysis result; and determines a merging scheme for merging the local code and the update code based on the analysis result. The embodiment of the present application can automatically push the update code to the client when there is an update code on the server, avoiding the need for developers to repeatedly obtain remote update codes from time to time. By analyzing the differences between the local code and the update code, it automatically detects whether there is a conflict, avoiding the tediousness and omissions of manual checks, and automatically determines a merging scheme based on the analysis results, reducing the workload of manually resolving conflicts and improving development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 It is a flowchart of a method for determining a code merging solution of the present application;

[0050] Figure 2 This is a flow chart of a server pushing update code in this application;

[0051] Figure 3 It is a flowchart of determining a merger plan of the present application;

[0052] Figure 4 It is a flowchart of determining similarities and differences between local code and update code of the present application;

[0053] Figure 5 It is a flowchart of determining compatible codes of the present application;

[0054] Figure 6 It is a structural block diagram of an embodiment of a device for determining a code merging solution of the present application;

[0055] Figure 7 It is a schematic diagram of the structure of a device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0056] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0057] In an embodiment of the present application, Git is selected as the team's version control system for unified code management, which can record the change history of files and help multiple developers work together.

[0058] Reference Figure 1, is a flowchart of a method for determining a code merging solution of the present application, which is applied to a first client and includes the following steps:

[0059] Step 101, modify the target code to obtain the local code, and establish a communication connection with the server; the server is in communication connection with the second client;

[0060] In the embodiments of the present application, the target code refers to the code that already exists in the code library, which is usually maintained by multiple developers. The local code refers to the version of the target code modified by the first client (i.e., the current developer). Specifically, the developer makes some modifications to the target code in his own development environment, and these modified codes are called local codes.

[0061] When the first client modifies the target code, it is necessary to implement a two-way connection between the first client and the server's websocket on Git so that data can be exchanged with the server. The server acts as a centralized code management platform, responsible for coordinating code synchronization and merging between multiple clients (developers).

[0062] The server not only communicates with the first client, but also with the second client (i.e., other developers), which means that the second client can also modify the target code and send the modified code to the server. It should be noted that the second client connects to the server in the same way.

[0063] Step 102, receiving an update code sent by the server; the update code is a code sent to the server after the second client modifies the target code;

[0064] In an embodiment of the present application, the updated code refers to the code obtained after the second client modifies the target code. At this time, the modified code needs to be sent to the server and the target code for code merging. In order to achieve code synchronization, the server needs to send these modified codes (updated codes) to the first client.

[0065] Reference Figure 2 , is a flow chart of a server push update code of the present application.

[0066] When a user creates a sub-branch based on a main branch (the main branch corresponding to the target code) on the client for the first time, a websocket bidirectional link will be automatically created with the remote server. Once the main branch of the server has updated code, the user will be notified and the updated code will be pushed to the user's local (client).

[0067] Alternatively, when the user works on the sub-branch again (modifies the target code), a websocket two-way link will be automatically created with the remote server. If the server's main branch has updated code, the user will also be notified and the updated code will be pushed to the user's local (client).

[0068] Step 103: Analyze whether there is a conflict between the local code and the update code, and obtain an analysis result;

[0069] In the embodiment of the present application, when two or more developers (clients) make different modifications to the same code, a conflict will occur. For example, the first client and the second client may both modify the same function, but the modifications are different, which will cause a conflict.

[0070] Therefore, the first client needs to analyze whether there is a conflict between the local code and the updated code. This analysis process usually involves comparing the two versions of the code to find out which parts have been modified and whether these modifications will cause conflicts.

[0071] After the analysis is completed, the first client will obtain an analysis result, which indicates whether there is a conflict between the local code and the updated code.

[0072] Step 104: Determine a merging solution for merging the local code and the update code according to the analysis result.

[0073] Based on the analysis results, the first client needs to determine how to merge the local code and the updated code. If there is a conflict, a suitable merge solution needs to be selected to merge the local code and the updated code based on resolving the code conflict. If there is no conflict, a merge solution will be obtained to directly merge the local code and the updated code.

[0074] The server in the embodiment of the present application can ensure that modifications made by multiple developers to the same code can be merged smoothly through a merging solution to avoid conflicts, and can effectively manage code version control and collaborative development.

[0075] In one embodiment of the present application, after the first client determines the merging plan, it will upload the merging plan and the local code to the server. The server may execute the merging plan or not. The merging plan here is equivalent to providing a merging opinion.

[0076] In one embodiment of the present application, there is an IDE (Integrated Development Environment) on the first client, which provides a convenient platform for developers to write, test and debug various software applications.

[0077] Specifically, in the embodiments of the present application, the code is analyzed and a merging solution is provided in an IDE.

[0078] The embodiments of the present application can automatically push updated code to the client when there is updated code on the server, avoiding the need for developers to repeatedly obtain remote updated code at irregular intervals. By analyzing the differences between local code and updated code, it can automatically detect whether there are conflicts, avoiding the tediousness and omissions of manual checking, and automatically determine the merge plan based on the analysis results, reducing the workload of manual conflict resolution and improving development efficiency.

[0079] In actual applications, each developer can create a sub-branch corresponding to the main branch and develop and modify it on the sub-branch. The developer will submit the code on the sub-branch to the sub-branch corresponding to the version control system, merge the sub-branch code with the main branch code, and once the main branch has the merged code, it will be automatically pushed to each sub-branch. Specifically:

[0080] 1) Once the server's main branch completes a merge, the latest code will be automatically pushed to the sub-branch of the client that is currently connected to the server and is under development; or

[0081] 2) When the client opens a sub-branch for development, it will automatically open a two-way network connection with the main branch of the server and synchronize the latest code on the main branch.

[0082] When the client's sub-branch pulls the latest code, it will perform intelligent analysis on the code, merge the non-conflicting code, perform intelligent semantic analysis on the conflicting code, and provide reasonable conflict resolution methods for users to choose. Users can also resolve conflicts by themselves.

[0083] In one embodiment of the present application, the analyzing whether there is a conflict between the local code and the update code to obtain an analysis result includes:

[0084] determining a code portion where no conflict exists between the local code and the update code as a first local code and a first update code;

[0085] Determine a second local code and a second update code from a code portion where there is a conflict between the local code and the update code;

[0086] Obtain a first analysis result according to the first local code and the first update code;

[0087] Obtain a second analysis result according to the second local code and the second update code;

[0088] The first analysis result and the second analysis result are determined as the analysis results.

[0089] In the local code and the updated code, some parts of the code are not modified by the two developers at the same time, or the modified contents are compatible and will not cause conflicts. Therefore, the parts of the local code that do not conflict are extracted, and this part of the code is called the first local code, and the parts of the updated code that do not conflict are extracted, and this part of the code is called the first updated code.

[0090] Similarly, in the local code and the updated code, some parts of the code may be modified by two developers at the same time, and the modified contents are incompatible, resulting in conflicts. Therefore, the conflicting parts in the local code are extracted, and this part of the code is called the second local code, and the conflicting parts in the updated code are extracted, and this part of the code is called the second updated code.

[0091] Since there is no conflict between the first local code and the first updated code, they can be directly merged. The first analysis result shows that this part of the code can be automatically merged without manual intervention.

[0092] Since there is a conflict between the second local code and the second updated code, it is necessary to further analyze the specific content and cause of the conflict. The second analysis result shows that this part of the code needs to manually resolve the conflict or use a specific merge strategy.

[0093] The final analysis result consists of the first analysis result and the second analysis result. The first analysis result shows which parts of the code can be automatically merged, while the second analysis result shows which parts of the code have conflicts and need to be manually resolved.

[0094] The embodiment of the present application divides the local code and the updated code into parts without conflicts and parts with conflicts, and analyzes them separately, so that the problems that may be encountered during the code merging process can be more clearly understood. This divide-and-conquer approach helps to improve the efficiency and accuracy of code merging, ensuring that the final merged code is correct and conflict-free.

[0095] In one embodiment of the present application, obtaining a second analysis result according to the second local code and the second update code includes:

[0096] Performing semantic analysis on the second local code and the second update code to obtain a context corresponding to the second local code and a context corresponding to the second update code;

[0097] Parsing a context corresponding to the second local code and a context corresponding to the second update code to determine semantic information corresponding to the second local code and semantic information corresponding to the second update code;

[0098] Determining semantic similarity information and semantic difference information between the semantic information corresponding to the second local code and the semantic information corresponding to the second update code;

[0099] Determining a semantic analysis result according to the semantic similarity information and the semantic difference information;

[0100] The semantic analysis result is determined as the second analysis result.

[0101] By performing semantic analysis on the second local code, the corresponding context information is obtained. By performing semantic analysis on the second updated code, the corresponding context information is obtained.

[0102] Semantic analysis refers to an in-depth understanding of the code, not just the superficial syntax analysis, but also includes the logical structure of the code, the usage of variables and functions, etc. Context refers to the environment in which the code is located, for example, the calling relationship of the code, the scope of variables, the parameters and return values ​​of functions, etc.

[0103] By parsing the context of the second local code, the corresponding semantic information is determined. By parsing the context of the second updated code, the corresponding semantic information is determined.

[0104] Parsing the context refers to further analyzing the context information to extract the semantic information of the code. Semantic information refers to the logical meaning of the code, such as the use of variables, function calls, conditional judgments, etc.

[0105] By comparing the semantic information of the second local code and the second updated code, semantic similarity information and semantic difference information between them are determined.

[0106] The semantic similarity information refers to the semantic similarities between the second local code and the second updated code, for example, both modify the same variable in a similar manner. The semantic difference information refers to the semantic differences between the second local code and the second updated code, for example, both modify the same variable in a different manner.

[0107] According to the semantic similarity information and the semantic difference information, the semantic relationship between the second local code and the second updated code is determined, for example, whether they can be automatically merged or whether conflicts need to be manually resolved, thereby obtaining a semantic analysis result.

[0108] The semantic analysis result is determined as the second analysis result as a part of the second analysis result.

[0109] In the embodiment of the present application, through semantic analysis, the logical meaning of the second local code and the second updated code can be deeply understood, so as to determine the semantic similarity information and semantic difference information between them. Based on this information, a semantic analysis result can be obtained to indicate the semantic relationship between the codes, providing a basis for subsequent merging solutions. This method helps to more accurately identify and resolve conflicts in code merging.

[0110] In one embodiment of the present application, obtaining the second analysis result according to the second local code and the second update code further includes:

[0111] Running the second local code and the second update code to obtain a running result corresponding to the second local code and a running result corresponding to the second update code;

[0112] Determine an operation similarity result and an operation difference result between an operation result corresponding to the second local code and an operation result corresponding to the second update code;

[0113] Determining an operation analysis result according to the operation similarity result and the operation difference result;

[0114] The operation analysis result is determined as the second analysis result.

[0115] Running code means executing the code in a specific environment to observe the behavior and output results of the code. In the embodiment of the present application, by running the second local code, the corresponding running result is obtained, and by running the second update code, the corresponding running result is obtained. The running result may include the output of the program, the value of the variable, the return value of the function, etc.

[0116] By comparing the running results of the second local code and the second updated code, the running similarity results and the running difference results between the two are determined.

[0117] The similarity result of the operation refers to the similar behavior or output of the second local code and the second updated code when they are running. For example, both of them output the same result. The difference result of the operation refers to the different behavior or output of the second local code and the second updated code when they are running. For example, the results output by the two are different.

[0118] According to the similarity results and the difference results of the operations, the relationship between the second local code and the second updated code at runtime is determined, for example, whether they can be automatically merged or whether conflicts need to be manually resolved, thereby obtaining an operation analysis result.

[0119] The running analysis result is determined as a second semantic analysis result as a part of the second analysis result.

[0120] In the embodiment of the present application, by running the second local code and the second updated code, their behaviors and output results during actual execution can be observed, thereby determining the similarity results and difference results between them. Based on these results, the operation analysis results can be obtained, indicating the relationship between the codes at runtime, providing a basis for subsequent merging solutions. This method helps to more comprehensively identify and resolve conflicts in code merging.

[0121] In an embodiment of the present application, determining a merging scheme for merging the local code and the update code according to the analysis result includes:

[0122] Determine, according to the first analysis result, a first merging scheme for merging the first local code and the first update code;

[0123] Based on the semantic analysis result, determine a second merging scheme for merging the second local code corresponding to the semantic difference information and the second update code corresponding to the semantic difference information; or, based on the operation analysis result, determine a third merging scheme for merging the second local code corresponding to the operation difference result and the second update code corresponding to the operation difference result.

[0124] Since there is no conflict between the first local code and the first updated code, the merge solution can simply select automatic merging. The automatic merging tool can directly merge the content of the first updated code into the first local code without manual intervention.

[0125] The second local code and the second updated code corresponding to the semantic difference information may be merged automatically simply because these code parts have obvious semantic differences.

[0126] The second local code and the second updated code corresponding to the running difference result, because these code parts have obvious differences during the running, the merging scheme can also simply choose automatic merging.

[0127] In the embodiment of the present application, different merging schemes can be determined according to different analysis results (first analysis result, semantic analysis result, and operation analysis result). For the parts without conflicts (first local code and first updated code), automatic merging can be performed directly (first merging scheme); for the parts of code with semantic differences or operation differences (second local code and second updated code), due to the large differences, they can also be directly merged (second merging scheme or third merging scheme). This method ensures the accuracy and reliability of code merging and avoids potential conflicts and errors.

[0128] In one embodiment of the present application, determining a merging scheme for merging the local code and the update code according to the analysis result further includes:

[0129] Creating, according to the semantic analysis result, a first compatible code for being compatible with a second local code corresponding to the semantic difference information and a second updated code corresponding to the semantic difference information;

[0130] Running the first compatible code to obtain an operation result corresponding to the first compatible code;

[0131] Determining whether the running result corresponding to the first compatible code satisfies both the second local code corresponding to the semantic difference information and the second update code corresponding to the semantic difference information;

[0132] If the running result corresponding to the first compatible code simultaneously satisfies the second local code corresponding to the semantic difference information and the second update code corresponding to the semantic difference information, a fourth merging scheme is determined for replacing the second local code corresponding to the semantic difference information and the second update code corresponding to the semantic difference information with the first compatible code.

[0133] The second local code and the second updated code corresponding to the semantic difference information need special processing because these code parts have semantic differences.

[0134] In order to resolve the semantic differences, a new code fragment may be created, which is called the first compatible code. The first compatible code is intended to be compatible with the semantic differences of the second local code and the second updated code, so that the merged code can run correctly.

[0135] The first compatible code is run in a specific environment to observe its behavior and output results, and the running results corresponding to the first compatible code are obtained, such as program output, variable values, function return values, etc.

[0136] By comparing the running result of the first compatible code with the expected results of the second local code and the second updated code, it is determined whether the first compatible code can simultaneously meet the semantic requirements of both codes.

[0137] If the running result of the first compatible code satisfies the semantic requirements of the second local code and the second updated code at the same time, a fourth merging scheme can be determined. The fourth merging scheme refers to using the first compatible code to replace the second local code and the second updated code, thereby resolving the semantic differences. Specifically, during the merging process, the semantically different parts of the second local code and the second updated code can be replaced with the first compatible code to ensure that the merged code can run correctly.

[0138] In the embodiment of the present application, by creating the first compatible code and verifying its running result, it can be determined whether the compatible code can be used to replace the semantically different parts of the second local code and the second updated code. If the first compatible code can meet the semantic requirements of both, the fourth merging scheme can be used for merging. This method ensures the accuracy and reliability of code merging and avoids potential conflicts and errors.

[0139] In one embodiment of the present application, determining a merging scheme for merging the local code and the update code according to the analysis result further includes:

[0140] Creating, according to the operation analysis result, a second compatible code for being compatible with a second local code corresponding to the operation difference result and a second updated code corresponding to the operation difference result;

[0141] Running the second compatible code to obtain a running result corresponding to the second compatible code;

[0142] Determine whether the operation result corresponding to the second compatible code satisfies both the second local code corresponding to the operation difference result and the second update code corresponding to the operation difference result;

[0143] If the running result corresponding to the second compatible code simultaneously satisfies the second local code corresponding to the running difference result and the second update code corresponding to the running difference result, a fifth merging scheme is determined for replacing the second local code corresponding to the running difference result and the second update code corresponding to the running difference result with the second compatible code.

[0144] The second local code and the second updated code corresponding to the running difference result need special processing because these code parts are different at runtime.

[0145] In order to resolve the runtime differences, a new code fragment needs to be created, called the second compatible code. The second compatible code is intended to be compatible with the runtime differences of the second local code and the second updated code, so that the merged code can run correctly.

[0146] By running the second compatible code in a specific environment, the corresponding running result is obtained, for example, the output of the program, the value of a variable, the return value of a function, etc.

[0147] By comparing the running result of the second compatible code with the expected results of the second local code and the second updated code, it is determined whether the second compatible code can meet the running requirements of both codes at the same time.

[0148] If the running result of the second compatible code satisfies the running requirements of the second local code and the second updated code at the same time, the fifth merging scheme can be determined. The fifth merging scheme refers to using the second compatible code to replace the second local code and the second updated code, thereby resolving the difference in runtime. Specifically, during the merging process, the part of the second local code and the second updated code that has the running difference is replaced with the second compatible code to ensure that the merged code can run correctly.

[0149] In the embodiment of the present application, by creating a second compatible code and verifying its running result, it can be determined whether the compatible code can be used to replace the part of the second local code and the second updated code that has running differences. If the second compatible code can meet the running requirements of both, the fifth merging scheme can be used for merging. This method ensures the accuracy and reliability of code merging and avoids potential conflicts and errors.

[0150] Reference Figure 3 , is a flowchart of determining a merge solution in the present application, which describes how to handle conflicts between local code and updated code in code merging. First, after the client obtains the updated code, it is necessary to confirm whether there is a conflict between the local code and the updated code; for codes without conflicts, they are directly merged automatically; for codes with conflicts, it is necessary to obtain the context of the code through semantic analysis, and then analyze the similarities and differences between the codes on both sides. For similar code blocks, try to generate compatible code, and for different codes, maintain the independence of the codes on both sides and merge them directly to determine the merge solution.

[0151] Reference Figure 4 , is a flowchart of determining the similarity and difference between local code and updated code of the present application, describing two methods of analyzing code similarity and difference. The first method is to compile and run the code on both sides (local code and updated code), and then judge the similarity and difference of the code based on the running results. The second method is to use a machine learning algorithm to parse the context of the code and judge the similarity and difference of the code based on the algorithm results.

[0152] Both methods aim to automatically analyze and compare code through different technical means to better understand and resolve conflicts in code merging.

[0153] Reference Figure 5 , is a flowchart of determining compatible codes in this application, which describes how to handle similar code blocks in code merging. First, a machine learning algorithm is used to create compatible codes that are compatible with the logic on both sides, and then the compatible codes are run to verify whether they can meet the code requirements on both sides.

[0154] This process aims to generate compatible code in an automated and intelligent way, ensuring that the merged code is logically correct and conflict-free.

[0155] The embodiments of the present application can automatically push updated code to the client when there is updated code on the server, avoiding the need for developers to repeatedly obtain remote updated code at irregular intervals. By analyzing the differences between local code and updated code, it can automatically detect whether there are conflicts, avoiding the tediousness and omissions of manual checking, and automatically determine the merge plan based on the analysis results, reducing the workload of manual conflict resolution and improving development efficiency.

[0156] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the described order of actions, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.

[0157] On the basis of the above embodiments, this embodiment further provides a device for determining a code merging solution, which is applied to electronic devices such as terminal devices and servers.

[0158] Reference Figure 6 , shows a structural block diagram of an embodiment of a device for determining a code merging solution of the present application, which is applied to a first client and may specifically include the following modules:

[0159] The communication connection establishment module 601 is used to modify the target code, obtain the local code, and establish a communication connection with the server; the server is in communication connection with the second client;

[0160] An update code receiving module 602 is used to receive an update code sent by the server; the update code is a code sent to the server after the second client modifies the target code;

[0161] A code conflict analysis module 603 is used to analyze whether there is a conflict between the local code and the update code, and obtain an analysis result;

[0162] The merging scheme determining module 604 is used to determine a merging scheme for merging the local code and the updated code according to the analysis result.

[0163] The embodiment of the present application also provides a non-volatile readable storage medium, which stores one or more modules (programs). When the one or more modules are applied to a device, the device can execute instructions (instructions) of each method step in the embodiment of the present application.

[0164] The present application embodiment provides one or more machine-readable media on which instructions are stored, and when executed by one or more processors, an electronic device executes one or more of the methods described in the above embodiments. In the present application embodiment, the electronic device includes various types of devices such as terminal devices and servers (clusters).

[0165] The embodiments of the present disclosure may be implemented as a device configured as desired using any appropriate hardware, firmware, software, or any combination thereof, and the device may include electronic devices such as terminal devices and servers (clusters). Figure 7 An exemplary apparatus 700 that can be used to implement various embodiments described in this application is schematically illustrated.

[0166] For one embodiment, Figure 7 An exemplary apparatus 700 is shown having one or more processors 702, a control module (chip set) 704 coupled to at least one of the processor(s) 702, a memory 706 coupled to the control module 704, a non-volatile memory (NVM) / storage device 708 coupled to the control module 704, one or more input / output devices 710 coupled to the control module 704, and a network interface 712 coupled to the control module 704.

[0167] The processor 702 may include one or more single-core or multi-core processors, and the processor 702 may include any combination of general-purpose processors or special-purpose processors (such as graphics processors, application processors, baseband processors, etc.). In some embodiments, the device 700 can be used as a terminal device, server (cluster), etc. described in the embodiments of the present application.

[0168] In some embodiments, the apparatus 700 may include one or more computer-readable media (e.g., memory 706 or NVM / storage device 708) having instructions 714 and one or more processors 702 combined with the one or more computer-readable media and configured to execute the instructions 714 to implement a module to perform the actions described in the present disclosure.

[0169] For one embodiment, the control module 704 may include any suitable interface controller to provide any suitable interface to at least one of the processor(s) 702 and / or any suitable device or component in communication with the control module 704 .

[0170] The control module 704 may include a memory controller module to provide an interface to the memory 706. The memory controller module may be a hardware module, a software module, and / or a firmware module.

[0171] The memory 706 may be used, for example, to load and store data and / or instructions 714 for the device 700. For one embodiment, the memory 706 may include any suitable volatile memory, such as a suitable DRAM. In some embodiments, the memory 706 may include double data rate type four synchronous dynamic random access memory (DDR4 SDRAM).

[0172] For one embodiment, control module 704 may include one or more input / output controllers to provide an interface to NVM / storage device 708 and input / output device(s) 710 .

[0173] For example, NVM / storage 708 may be used to store data and / or instructions 714. NVM / storage 708 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable non-volatile storage device(s) (e.g., one or more hard disk drives (HDDs), one or more compact disk (CD) drives, and / or one or more digital versatile disk (DVD) drives).

[0174] NVM / storage device 708 may include storage resources that are physically part of the device on which apparatus 700 is installed, or it may be accessible to the device without being part of the device. For example, NVM / storage device 708 may be accessed via input / output device(s) 710 over a network.

[0175] (One or more) input / output devices 710 may provide an interface for the apparatus 700 to communicate with any other appropriate device, and the input / output device 710 may include a communication component, an audio component, a sensor component, etc. The network interface 712 may provide an interface for the apparatus 700 to communicate through one or more networks, and the apparatus 700 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, for example, accessing a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G, etc., or a combination thereof for wireless communication.

[0176] For one embodiment, at least one of the processor(s) 702 may be packaged together with the logic of one or more controllers (e.g., a memory controller module) of the control module 704. For one embodiment, at least one of the processor(s) 702 may be packaged together with the logic of one or more controllers of the control module 704 to form a system-in-package (SiP). For one embodiment, at least one of the processor(s) 702 may be integrated on the same die with the logic of one or more controllers of the control module 704. For one embodiment, at least one of the processor(s) 702 may be integrated on the same die with the logic of one or more controllers of the control module 704 to form a system-on-chip (SoC).

[0177] In various embodiments, the apparatus 700 may be, but is not limited to, a terminal device such as a server, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.). In various embodiments, the apparatus 700 may have more or fewer components and / or a different architecture. For example, in some embodiments, the apparatus 700 includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit (ASIC), and a speaker.

[0178] Among them, the main control chip can be used as a processor or control module in the detection device, sensor data, location information, etc. are stored in a memory or NVM / storage device, the sensor group can be used as an input / output device, and the communication interface may include a network interface.

[0179] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0180] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0181] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable code merging scheme to determine a terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable code merging scheme to determine the terminal device generate instructions for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0182] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other terminal device of a programmable code incorporation solution to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0183] These computer program instructions can also be loaded onto a computer or other terminal device that determines the programmable code incorporation scheme, so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable terminal device provide for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0184] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0185] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0186] The above is a detailed introduction to a method and device for determining a code merging scheme, an electronic device and a storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for a person skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for determining a code merging scheme, characterized in that: Applied to a first client, the method includes: Modifying the target code to obtain the local code and establishing a communication connection with the server; the server is in communication connection with the second client; receiving an update code sent by the server; the update code is a code sent to the server after the second client modifies the target code; Analyze whether there is a conflict between the local code and the update code, and obtain an analysis result; A merging scheme for merging the local code and the updated code is determined according to the analysis result.

2. The method according to claim 1, characterized in that The analyzing whether there is a conflict between the local code and the update code to obtain an analysis result includes: determining a code portion where no conflict exists between the local code and the update code as a first local code and a first update code; Determine a second local code and a second update code from a code portion where there is a conflict between the local code and the update code; Obtain a first analysis result according to the first local code and the first update code; Obtain a second analysis result according to the second local code and the second update code; The first analysis result and the second analysis result are determined as the analysis results.

3. The method according to claim 2, characterized in that The obtaining a second analysis result according to the second local code and the second update code includes: Performing semantic analysis on the second local code and the second update code to obtain a context corresponding to the second local code and a context corresponding to the second update code; Parsing a context corresponding to the second local code and a context corresponding to the second update code to determine semantic information corresponding to the second local code and semantic information corresponding to the second update code; Determining semantic similarity information and semantic difference information between the semantic information corresponding to the second local code and the semantic information corresponding to the second update code; Determining a semantic analysis result according to the semantic similarity information and the semantic difference information; The semantic analysis result is determined as the second analysis result.

4. The method according to claim 3, characterized in that The obtaining of the second analysis result according to the second local code and the second update code further includes: Running the second local code and the second update code to obtain a running result corresponding to the second local code and a running result corresponding to the second update code; Determine an operation similarity result and an operation difference result between an operation result corresponding to the second local code and an operation result corresponding to the second update code; Determining an operation analysis result according to the operation similarity result and the operation difference result; The operation analysis result is determined as the second analysis result.

5. The method according to claim 4, characterized in that The step of determining a merging scheme for merging the local code and the updated code according to the analysis result includes: Determine, according to the first analysis result, a first merging scheme for merging the first local code and the first update code; Based on the semantic analysis result, determine a second merging scheme for merging the second local code corresponding to the semantic difference information and the second update code corresponding to the semantic difference information; or, based on the operation analysis result, determine a third merging scheme for merging the second local code corresponding to the operation difference result and the second update code corresponding to the operation difference result.

6. The method according to claim 3, characterized in that: The step of determining a merging scheme for merging the local code and the update code according to the analysis result further includes: Creating, according to the semantic analysis result, a first compatible code for being compatible with a second local code corresponding to the semantic difference information and a second updated code corresponding to the semantic difference information; Running the first compatible code to obtain an operation result corresponding to the first compatible code; Determining whether the running result corresponding to the first compatible code satisfies both the second local code corresponding to the semantic difference information and the second update code corresponding to the semantic difference information; If the running result corresponding to the first compatible code simultaneously satisfies the second local code corresponding to the semantic difference information and the second update code corresponding to the semantic difference information, a fourth merging scheme is determined for replacing the second local code corresponding to the semantic difference information and the second update code corresponding to the semantic difference information with the first compatible code.

7. The method according to claim 4, characterized in that The step of determining a merging scheme for merging the local code and the update code according to the analysis result further includes: Creating, according to the operation analysis result, a second compatible code for being compatible with a second local code corresponding to the operation difference result and a second updated code corresponding to the operation difference result; Running the second compatible code to obtain a running result corresponding to the second compatible code; Determine whether the operation result corresponding to the second compatible code satisfies both the second local code corresponding to the operation difference result and the second update code corresponding to the operation difference result; If the running result corresponding to the second compatible code simultaneously satisfies the second local code corresponding to the running difference result and the second update code corresponding to the running difference result, a fifth merging scheme is determined for replacing the second local code corresponding to the running difference result and the second update code corresponding to the running difference result with the second compatible code.

8. A device for determining a code merging scheme, characterized in that: Applied to a first client, the device comprises: A communication connection establishment module, used to modify the target code, obtain the local code, and establish a communication connection with the server; the server is in communication connection with the second client; An update code receiving module, used for receiving an update code sent by the server; the update code is a code sent to the server after the second client modifies the target code; A code conflict analysis module, used to analyze whether there is a conflict between the local code and the update code, and obtain an analysis result; A merging scheme determining module is used to determine a merging scheme for merging the local code and the updated code according to the analysis result.

9. An electronic device, characterized in that: include: processor; and A memory having executable codes stored thereon, which, when executed, causes the processor to execute the method for determining a code merging solution as claimed in any one of claims 1 to 7.

10. One or more machine-readable media having executable codes stored thereon, which, when executed, cause a processor to execute the method for determining a code merging solution according to any one of claims 1 to 7.