WO2021135373A1 - 关联冲突块呈现方法和设备 - Google Patents

关联冲突块呈现方法和设备 Download PDF

Info

Publication number
WO2021135373A1
WO2021135373A1 PCT/CN2020/114557 CN2020114557W WO2021135373A1 WO 2021135373 A1 WO2021135373 A1 WO 2021135373A1 CN 2020114557 W CN2020114557 W CN 2020114557W WO 2021135373 A1 WO2021135373 A1 WO 2021135373A1
Authority
WO
WIPO (PCT)
Prior art keywords
code
code block
block
processed
conflict
Prior art date
Application number
PCT/CN2020/114557
Other languages
English (en)
French (fr)
Inventor
魏昭
梁广泰
程善滨
王千祥
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP20908909.3A priority Critical patent/EP4071598A4/en
Publication of WO2021135373A1 publication Critical patent/WO2021135373A1/zh
Priority to US17/852,721 priority patent/US20220334812A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • G06F8/433Dependency analysis; Data or control flow analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/33Intelligent editors
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/75Structural analysis for program understanding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/77Software metrics

Definitions

  • This application relates to the technical field of software development, and in particular to a method and device for presenting associated conflict blocks.
  • the SemanticMerge tool displays insights into conflict blocks that cannot be resolved automatically. For example: the change information of the current version relative to the base version and the change information of the version to be merged relative to the base version. Users can intuitively understand one of the three versions of the code fragments contained in the current conflict block through these insights when doing resolution. However, users often need to view the code snippets of the associated conflicting block when they are doing resolution. The above method only provides insight into the current conflicting block, which cannot meet the needs of users to quickly locate the associated conflicting block.
  • the present application provides a method and device for presenting associated conflicting blocks to improve the efficiency of manually resolving conflicting blocks.
  • this application provides a method for presenting an associated conflict block, including:
  • each code block includes a code snippet of the current version of the code block, a code snippet of the basic version of the code block, and the code block to be merged Version of the code snippet;
  • each associated code block is one of an unresolved conflict block, a unilateral change block, and a resolved conflict block
  • the relationship between each associated code block and the to-be-processed code block is a dependent relationship or a dependent relationship
  • N is greater than or equal to 1.
  • the method further includes:
  • the user interface is provided with a dependent group, a dependent group, and a similar group;
  • the presenting the index of the N associated code blocks of the code block to be processed on the user interface includes:
  • the index of each associated code block is presented in the dependent group, the dependent group, or the similar group.
  • the method before the index of the N associated code blocks of the to-be-processed code block is presented on the user interface, the method further includes:
  • At least one associated code block of the to-be-processed code block is determined from the first conflict file.
  • the method before the index of the N associated code blocks of the to-be-processed code block is presented on the user interface, the method further includes:
  • At least one code block associated with the to-be-processed code block is determined from the second conflict file.
  • the determining at least one associated code block of the to-be-processed code block from the first conflict file includes:
  • an associated code block that has a similar relationship with the code block to be processed is determined from the first conflict file.
  • the index of each associated code block is presented in the dependent group, the dependent group, or the dependent group.
  • Similar groups include:
  • the utilization status of the variables and/or functions in the to-be-processed code block in other code blocks of the first conflict file determine from the first conflict file and
  • the associated code blocks with dependencies of the to-be-processed code blocks include:
  • the variables defined in the code block to be processed are used in a total of M code blocks among other code blocks in the first conflict file, it is determined that the M code blocks are all associated code blocks that have a dependency relationship with the code block to be processed.
  • the variables used in the code block to be processed are defined in a total of K code blocks among other code blocks in the first conflict file, it is determined that the K code blocks are all associated code blocks that have a dependent relationship with the code block to be processed.
  • the above method also includes:
  • the code to be processed is determined according to the abstract syntax subtree corresponding to each of the three versions of code fragments contained in the code block and the abstract syntax subtree corresponding to each of the three versions of code fragments contained in each code block.
  • the abstract syntax corresponding to each of the three versions of the code fragments contained in the to-be-processed code block is determined according to the line number ranges of the three versions of the code fragments contained in the to-be-processed code block Subtree, including:
  • the abstract syntax tree is searched, and a subtree whose line number range falls within the line number range corresponding to the code segment of the first version is determined as the abstract syntax subtree corresponding to the code segment of the first version.
  • the Token of each version of the code snippet between the three versions of the code snippets contained in the code block to be processed and the three versions of the code snippets contained in each code block includes:
  • the code block whose second similarity value is greater than the preset threshold is determined as an associated code block having a similar relationship with the code block to be processed.
  • this application provides a terminal device, including:
  • the obtaining module is used to obtain the first conflict file, the first conflict file includes a plurality of code blocks, each code block includes the code fragment of the current version of the code block, the code fragment of the basic version of the code block, and all the code blocks. Code snippets of the version of the code block to be merged;
  • a receiving module configured to receive a first instruction triggered by a user interface for activating a code block to be processed, where the type of the code block to be processed is an unresolved conflict block or a unilateral change block;
  • a presentation module configured to present the code fragments contained in the code block to be processed and the indexes of the N associated code blocks of the code block to be processed on the user interface;
  • the receiving module is further configured to receive a second instruction triggered by the user interface for activating any associated code block;
  • the presentation module is further configured to jump the code fragments included in the to-be-processed code block presented by the user interface to the code fragments included in the associated code block.
  • the index of each associated code block is presented in the dependent group, the dependent group, or the similar group.
  • the above-mentioned terminal device further includes: a dependency analysis module and a similarity analysis module, the dependency analysis module and the similarity analysis module are used to determine from the first conflict file At least one associated code block of the code block to be processed.
  • the acquiring module is further used to: acquire the second conflict file
  • the dependency relationship analysis module and the similarity relationship analysis module are further configured to determine at least one code block associated with the to-be-processed code block from the second conflict file.
  • dependency analysis module and the similarity analysis module are specifically used for:
  • the utilization status of the variables and/or functions in the to-be-processed code block in other code blocks of the first conflicting file it is determined from the first conflicting file that there is a dependency relationship with the to-be-processed code block and The associated code block of the dependent relationship;
  • an associated code block that has a similar relationship with the code block to be processed is determined from the first conflict file.
  • the presentation module is specifically used for:
  • the code blocks that have a similar relationship with the to-be-processed code block among the N associated code blocks are presented in a similar group.
  • the dependency analysis module is specifically used for:
  • the variables defined in the code block to be processed are used in a total of M code blocks among other code blocks in the first conflict file, it is determined that the M code blocks are all associated code blocks that have a dependency relationship with the code block to be processed.
  • the dependency analysis module is specifically used for:
  • the variables used in the code block to be processed are defined in a total of K code blocks among other code blocks in the first conflict file, it is determined that the K code blocks are all associated code blocks that have a dependent relationship with the code block to be processed.
  • the similarity relationship analysis module is specifically used for:
  • the dependency analysis module is also used to:
  • the similarity relationship analysis module is specifically used for:
  • the code to be processed is determined according to the abstract syntax subtree corresponding to each of the three versions of code fragments contained in the code block and the abstract syntax subtree corresponding to each of the three versions of code fragments contained in each code block The structural similarity of the code snippets of each version between the three versions of the code fragments contained in the block and the three versions of the code snippets contained in each code block.
  • the similarity relationship analysis module is specifically used for:
  • the abstract syntax tree is searched, and a subtree whose line number range falls within the line number range corresponding to the code segment of the first version is determined as the abstract syntax subtree corresponding to the code segment of the first version.
  • the similarity relationship analysis module is specifically used for:
  • the code block whose second similarity value is greater than the preset threshold is determined as an associated code block having a similar relationship with the code block to be processed.
  • this application provides a terminal device, including: a memory and a processor;
  • the memory is used to store program instructions
  • the processor is used to call the program instructions in the memory to execute the above-mentioned associated conflict block presentation method.
  • the present application provides a readable storage medium with a computer program stored on the readable storage medium; when the computer program is executed, the above-mentioned associated conflict block presentation method is realized.
  • the associated conflict block presentation method and device obtained the associated code block list of the current conflict block through the dependency analysis module and the similarity relationship analysis module, so that after the current conflict block is activated, the terminal device can index the associated code blocks Presented on the user interface, when the user needs to view the code snippets contained in an associated code block, click the index of the associated code block, and the user interface can jump to the code snippets contained in the associated code block, so that the user can quickly find the current conflict
  • the definition and usage of variables and/or functions in the block can also refer to the resolution scheme of the code block that is similar to the current conflict block and has been resolved, which greatly improves the efficiency of the user to resolve the conflict block.
  • FIG. 1 is a system framework diagram provided by this application.
  • FIG. 2 is a schematic diagram of the structure of the terminal device provided by this application.
  • FIG. 3 is a schematic flowchart of an embodiment of a method for presenting an associated conflict block provided by this application;
  • Figure 4 is the first schematic diagram of the user interface provided by this application.
  • Figure 5 is a second schematic diagram of the user interface provided by this application.
  • Figure 6 is the third schematic diagram of the user interface provided by this application.
  • Figure 7 is a fourth schematic diagram of the user interface provided by this application.
  • Figure 8 is the fifth schematic diagram of the user interface provided by this application.
  • FIG. 10 is a schematic structural diagram of a terminal device 100 provided by this application.
  • FIG. 11 is a schematic diagram of the hardware structure of the terminal device 110 provided by this application.
  • Three versions of code files including the current version of the code file, the basic version of the code file, and the code file of the version to be merged.
  • the code contained in the current version of the code file and the code file of the version to be merged are all To further develop the obtained code on the basis of the code contained in the code file of the basic version.
  • the current version is referred to as “Ours version” in the following
  • the basic version is referred to as “Base version”
  • the version to be merged is referred to as “Theirs version”.
  • the Ours version, the Base version and the Theatre version are abbreviated as “Theirs version”.
  • Conflict file the file generated after the code is merged.
  • the conflict file includes two parts: the successfully merged part and several conflict parts.
  • Each conflict part can use " ⁇ ""
  • " in the conflict file can be used as the code snippets of the Ours version of the conflict part, and "
  • the snippet is a code snippet of the Theirs version of the conflict part.
  • code fragments of different versions in conflict files generated by different merging tools use different identifiers.
  • the above identifier is only an example, and this application is not limited to this.
  • the following uses this identifier Take an example to introduce the scheme of this application.
  • Conflict block When the code is merged, a conflict corresponds to a conflict block.
  • Each conflict block contains the code snippets of the Ours version, the code snippets of the Base version, and the code snippets of the Theory version. The following will introduce the resolution of the conflict block from the conflict file process.
  • Unilateral change block When the code is merged, a unilateral change corresponds to a unilateral change block.
  • Each unilateral change block contains the code snippets of the Ours version, the code snippets of the Base version and the code snippets of the Theirs version. The conflicting files will be introduced below. The process of extracting unilateral change blocks.
  • the SemanticMerge tool is often used to automatically resolve conflict blocks.
  • insights inside the conflict block will be displayed, such as the change information of the Ours version relative to the Base version and the Theory version.
  • users can intuitively understand the difference between the three versions of the code fragments contained in the current conflict block through these insights when doing resolution.
  • users when users are doing resolution, they often need to look up the definition and usage of variables and/or functions in the current conflict block in other code blocks, or refer to the resolution scheme of a code block that is similar to the current conflict block and has been resolved. The above is only Providing insight into the current conflicting block cannot meet the needs of users to quickly locate the associated conflicting block.
  • Figure 1 is a framework diagram of the system provided by this application.
  • the system provided by this application includes a terminal device and a server.
  • Figure 2 is a schematic diagram of the structure of the terminal device provided by this application.
  • the terminal device includes: a dependency analysis module and a similarity analysis module.
  • the dependency analysis module is used to determine from the conflict file the code block to be processed.
  • the similar relationship analysis module is used to determine the associated code blocks that have a similar relationship with the code block to be processed from the conflicting file.
  • the server is used to store the associated code block list obtained by the above-mentioned dependency analysis module and similarity analysis module from the conflict file.
  • the terminal device may be a desktop computer, a mobile phone, a tablet computer, a notebook computer, a smart watch, a TV or other electronic device with a display screen;
  • the server may be a device with corresponding processing capabilities such as a physical server or a cloud server.
  • the associated code block list of conflicting blocks so that after the current conflicting block is activated, the terminal device can display the index of these associated code blocks on the user interface.
  • the user interface can jump to the code snippets contained in the associated code block, so that the user can quickly find the definition and usage of the variables and/or functions in the current conflict block.
  • you can also refer to the The resolution scheme of the resolved code blocks greatly improves the efficiency of users in resolving conflicting blocks.
  • FIG. 3 is a schematic flowchart of an embodiment of the method for presenting association conflict blocks provided by this application. This embodiment can be executed by the terminal device in FIG. 1. As shown in FIG. 3, the association provided by this embodiment Conflict block presentation methods, including:
  • S301 Receive a first instruction triggered by a user interface for activating a code block to be processed.
  • S302 Present the code fragments included in the code block to be processed and the indexes of the N associated code blocks of the code block to be processed on the user interface.
  • the type of the code block to be processed above can be an unresolved conflict block or a unilateral change block. That is to say, the method of this application can not only present the index of the associated code block of the conflict block, but also The index of the associated code block of the unilateral change block.
  • each associated code block in the N associated code blocks of the to-be-processed code block is one of the unresolved conflict block, the unilateral change block, and the resolved conflict block, that is to say, this application not only presents The unresolved conflict blocks that are related to the code block to be processed, and the resolved conflict blocks that are related to the code block to be processed are also presented, so that users can refer to the resolution plan of the resolved conflict block when performing conflict resolution. Improve the user's efficiency in resolving conflicting blocks.
  • this application also presents a unilateral change block associated with the code block to be processed, to avoid the problem that the user cannot locate the associated code block when the variables and/or functions in the code block to be processed are defined or used in the unilateral change block .
  • each of the N associated code blocks of the to-be-processed code block and the to-be-processed code block is one of a dependency relationship, a dependent relationship, and a similar relationship.
  • the user can communicate with the to-be-processed code block.
  • Code blocks that have dependencies on code blocks View the usage of variables and/or functions defined in the code block to be processed, and view variables and/or used in the code block to be processed through code blocks that have a dependent relationship with the code block to be processed For the definition of the function, view the resolution plan of the resolved conflict block through the code block that has a similar relationship with the code block to be processed, and perform batch resolution on other similar unresolved conflict blocks, thereby improving the efficiency of the user in resolving conflict blocks.
  • a dependent group and a dependent group similarity group can be set in the user interface. And according to the association relationship between each associated code block and the code block to be processed, the index of each associated code block is presented in the above-mentioned dependent group, or dependent group, or similar group. Specifically, the code blocks in the N associated code blocks that have a dependency relationship with the code block to be processed can be presented in the dependency group; the code blocks in the N associated code blocks that have a dependency relationship with the code block to be processed are presented in the dependent group.
  • Dependent group present the code blocks in the N associated code blocks that have a similar relationship with the code block to be processed in the similar group.
  • the user can click the up and down arrows next to the conflicting block on the user interface shown in Figure 4 to trigger the first instruction to activate the code block to be processed.
  • the first instruction is the click action trigger Instructions.
  • the user interface jumps to Figure 5, as shown in Figure 5.
  • the user interface presents the code snippet of the fourth conflict block Ours version, the code snippet of the Base version, and the code snippet of the Theory version; at the same time, the index of the code block that has a dependency on the fourth conflict block is also displayed.
  • the index of the code block that has a dependent relationship with the fourth code block and the index of the code block similar to the fourth conflicting block is the 10th conflict block (Conflict Block 10 of File 313) in the 313th conflict file, which is dependent on the 4th conflict block
  • the code block of the relationship is the 13th single-side change block (Single-Side Change 13 of File 2) in the second conflicting file
  • the code block that has a similar relationship with the fourth conflicting block is the third conflicting file in the 313th conflict file.
  • 20 conflict blocks (Conflict Block 20 of File 313).
  • the user can click the up and down arrows next to the conflicting block on the user interface shown in Figure 4 to first trigger the display of three versions of the code snippets of the code block to be processed, and then the user interface jumps to Figure 6. Then click the drop-down button of the associated code block on the left side of the user interface shown in Figure 6 to trigger the display of the associated code block of the code block to be processed. For example, click the drop-down button corresponding to the dependent group to trigger the display of the code that has a dependent relationship with the code block to be processed. The index of the block.
  • the user interface jumps to Figure 7.
  • the first instruction in S301 includes the instruction triggered by the user clicking the up and down arrows next to the conflicting block in Figure 4, and the user clicking the dependent group in Figure 6 The instruction triggered by the drop-down button.
  • the first instruction specifically includes several instructions depending on the drop-down buttons used to click several groups. If the user clicks the drop-down buttons of the dependent group, the dependent group, and the similar group Then, the first instruction includes the instruction triggered by the user clicking the up and down arrows next to the conflict block in Figure 4 and the instruction triggered by clicking the drop-down buttons of the three groups.
  • the process of presenting the index of the N associated code blocks of the code block to be processed on the user interface is introduced.
  • the following describes how to determine the N associated code blocks from the conflict file.
  • the process can be determined by the dependency analysis module and The similar relationship analysis module is executed.
  • the conflict file consists of two parts: a successful merge part and several conflict parts, one conflict part corresponds to a conflict block, and each conflict part uses " ⁇ ""
  • the change list records the change object of the Ours version based on the Base version, the change action, the line number range of the change object in the code file of the Ours version, and the line number range of the change object in the code file of the Base version; on the other hand, get Theirs
  • the version is based on the second change list of the Base version.
  • the second change list records the change object, the change action, the line number range of the change object in the code file of the Theory version and the code of the change object in the Base version based on the Base version.
  • this application is to determine N associated conflict blocks of the code block to be processed from the conflict blocks and unilateral change blocks contained in all the conflict files obtained, and all conflict files can be divided into two types: One is the conflict file where the code block to be processed is located, and the second is the conflict file that does not contain the code block to be processed.
  • the first conflict file is called the first conflict file
  • the second conflict file is called the second conflict file.
  • the method of determining the associated code block of the to-be-processed code block from the first conflict file in this application is the same as the method of determining the associated code block of the to-be-processed code block from the second conflict file, the following uses the first conflict file as an example , Explain the process of determining the associated conflict block.
  • the conflict blocks and unilateral change blocks are collectively referred to as code blocks.
  • the first conflict file contains multiple code blocks, and each code block includes code snippets of the Ours version of the code block, code snippets of the Base version of the code block, and code snippets of the Theirs version of the code block.
  • the functions and/or functions involved in the three versions of the code block are the same For each code block, store the variables and/or functions defined in the code block and the variables and/or functions used, and then divide the variables and/or functions in the first conflict file according to the variables and/or functions in the code block to be processed.
  • the utilization of other code blocks of the to-be-processed code block does indeed result in associated code blocks that have a dependent relationship and a dependent relationship with the to-be-processed code block.
  • variables defined in the code block and the variables used can be stored in the following ways: define the variable declaration Map in each code block, use the Map for the variable, the variable dependent List and the variable dependent List.
  • variable declaration Map maps Map
  • variable dependent List maps variable dependent List
  • each variable Var can be defined as follows:
  • Integer startLine represents the variable start line
  • Integer endLine represents the variable end line
  • String varRawData represents the original code that defines or uses the variable
  • Integer blockIndex represents the conflict block index
  • String fileName represents the conflict file name.
  • variable defined in the code block to be processed is used in other code blocks except the code block to be processed in the first conflict file. If the judgment result is that the variable defined in the code block to be processed is in If it is used in M code blocks, it is determined that the M code blocks are all associated code blocks that have a dependency relationship with the code block to be processed, and the indexes of the M code blocks can be put into the variable dependency List of the code block to be processed.
  • the variables used in the code block to be processed are defined in other code blocks except the code block to be processed in the first conflict file. If the judgment result is that the variables used in the code block to be processed are defined in K code blocks , It is determined that the K code blocks are all associated code blocks that have a dependent relationship with the code block to be processed, and the indexes of the K code blocks can be put into the variable dependent List of the code block to be processed.
  • the conflict block The unilateral change block is collectively referred to as a code block, that is, the first conflict file contains multiple code blocks, and each code block includes the code snippet of the code block Ours version, the code snippet of the code block Base version, and the code block Theirs version of the code. Fragment.
  • the associated code block that has a similar relationship with the code block to be processed can be determined according to the Token string and the abstract syntax subtree corresponding to the code fragments of the Ours version, the Base version and the Theory version contained in the code block to be processed. .
  • the first step is to calculate one of the code fragments of the Ours version of the code block to be processed and the Ours version of the code block for each of the multiple code blocks contained in the first conflict file except the code block to be processed.
  • Token similarity (recorded as "Ours version Token similarity"), calculate the Token similarity between the Base version of the code block to be processed and the Base version of the code block (recorded as “Base version Token similarity" “Degree”), calculate the Token similarity between the Theirs version of the code block to be processed and the Theirs version of the code block (denoted as "Theirs version Token similarity").
  • To calculate the Token similarity of each version of the code snippets between two code blocks first extract the Token string corresponding to the code snippets of each version of the two code blocks, for example: To calculate the code snippets of the Ours version of the code block to be processed To determine the Token similarity between the code fragment of the Ours version of a certain code block, first extract the Token string corresponding to the code fragment of the Ours version of the code block to be processed and the Token string corresponding to the code fragment of the Ours version of the code block, and then use The similarity calculation method of the cosine included angle determines the Token similarity of the two.
  • the following takes the code snippets of the Ours version of the code block to be processed as an example to illustrate the process of extracting the token string: use a conversion tool, such as Google java format, to convert the code snippets of the Ours version line by line, and remove the parentheses and points.
  • Tokens such as commas, commas, colons, arithmetic operators, logical operators, and bitwise operators, have a small effect on the code content, so as to obtain the Token string corresponding to the code fragment of the Ours version.
  • the second step is to calculate one of the code fragments of the Ours version of the code block to be processed and the Ours version of the code block for each of the multiple code blocks contained in the first conflict file except the code block to be processed.
  • Structural similarity (recorded as "Ours version structural similarity"), calculate the structural similarity between the code fragment of the Base version of the code block to be processed and the code fragment of the Base version of the code block (recorded as "Base version structural similarity" “Degree), calculate the structural similarity between the code fragment of the Theirs version of the code block to be processed and the code fragment of the Theirs version of the code block (denoted as "Theirs version structural similarity").
  • each version of the code snippets between two code blocks first determine the abstract syntax subtree corresponding to the code snippets of each version of the two code blocks, for example: To calculate the Ours version of the code block to be processed The structural similarity between the code snippet and the code snippet of the Ours version of a certain code block must first determine the abstract syntax subtree corresponding to the code snippet of the Ours version of the code block to be processed and the abstraction corresponding to the code snippet of the Ours version of the code block Syntax subtree, and then based on these two abstract syntax subtrees, determine the structural similarity between the two.
  • the following takes the code snippet of the Ours version of the code block to be processed as an example to illustrate the process of determining the abstract syntax subtree: parse the code file of the Ours version where the code snippet of the Ours version of the code block to be processed is located, and get the code file corresponding to the Ours version The abstract syntax tree is searched for, and the subtree whose line number range of the abstract syntax tree falls within the line number range corresponding to the code fragment of the Ours version is determined as the abstract syntax subtree corresponding to the code fragment of the Ours version.
  • the third step according to the Token similarity and structural similarity between the Ours version of the code block to be processed and the code fragments of the Ours version of the code block obtained in the first and second steps, the Base of the code block to be processed Token similarity and structural similarity between the code fragments of the version and the Base version of each code block, and the Token similarity between the code fragments of the Theirs version of the code block to be processed and the code fragments of the Theirs version of each code block Structural similarity, to determine the code block associated with the code to be processed and the similar relationship.
  • this step may include the following steps:
  • Step A The Token similarity and structure similarity between the Ours version of the code block to be processed and the Ours version of each code block can be weighted averaged to obtain the Ours version of the code snippet to be processed
  • the first similarity value between the code snippets of the Ours version of each code block; the Token similarity and structural similarity between the code snippets of the Base version of the code block to be processed and the code snippets of the Base version of each code block are weighted On average, get the first similarity value between the code snippet of the Base version of the code block to be processed and the code snippet of the Base version of each code block; the code snippet of the Theirs version of the code block to be processed and the code of the Theirs version of each code block
  • the Token similarity and the structural similarity between the fragments are weighted average, and the first similarity value between the code fragment of the Theirs version of the code block to be processed and the code fragment of the Theirs version of each code block is obtained.
  • Step B Take a weighted average of the three first similarity values between the code block to be processed and each code block to obtain the second similarity value between the code block to be processed and each code block;
  • Step C Determine a code block with a second similarity value greater than a preset threshold among other code blocks in the first conflict file except the code to be processed as an associated code block that has a similar relationship with the code to be processed.
  • code blocks in the first conflict file used for the above association analysis are obtained through the conflict block resolution process and the unilateral change extraction process described above. Some of these code blocks may have been resolved by the user, and some It may not be resolved, no matter which state the code block is in, it belongs to the scope of the above-mentioned association analysis.
  • S304 Receive a second instruction triggered by the user interface for activating any associated code block.
  • the user can click on the index of any associated code block to trigger the second instruction to activate the associated code block.
  • the user can click on the 10th conflict block in the 313th conflict file in the dependency group (Conflict Block). 10 of File 313), the second instruction to activate the conflicting block can be triggered.
  • the terminal device can jump the user interface to the code fragment contained in the associated code block.
  • File 313) the user interface jumps to Figure 9.
  • the user can view the variables and/or functions defined in the fourth conflict block (code block to be processed) in the second conflict file in the 313 conflict file
  • the usage of the 10th conflict block speeds up the user's understanding and analysis of conflict blocks, and improves the efficiency of resolution.
  • the user can click the return button in Figure 9 to return to the code snippets contained in the code block to be processed (the fourth conflict block in the second conflict file). Switching back and forth between associated code blocks improves user experience.
  • a list of associated code blocks of the current conflicting block is obtained through the dependency analysis module and the similarity relationship analysis module, so that after the current conflicting block is activated, the terminal device can present the index of these associated code blocks
  • the terminal device can present the index of these associated code blocks
  • the user interface when the user needs to view the code snippets contained in a certain associated code block, click the index of the associated code block, and the user interface can jump to the code snippets contained in the associated code block, so that the user can quickly find the current conflicting block
  • FIG. 10 is a schematic structural diagram of a terminal device 100 provided by this application. As shown in FIG. 10, the terminal device 100 provided in this embodiment includes:
  • the obtaining module 1001 is configured to obtain a first conflict file, where the first conflict file includes a plurality of code blocks, and each code block includes a code fragment of the current version of the code block, a code fragment of the basic version of the code block, and The code fragment of the version of the code block to be merged;
  • the receiving module 1002 is configured to receive a first instruction triggered by a user interface for activating a code block to be processed, where the type of the code block to be processed is an unresolved conflict block or a unilateral change block;
  • the presentation module 1003 is configured to present the code fragments contained in the code block to be processed and the indexes of the N associated code blocks of the code block to be processed on the user interface;
  • each associated code block is one of an unresolved conflict block, a unilateral change block, and a resolved conflict block
  • the relationship between each associated code block and the to-be-processed code block is a dependent relationship or a dependent relationship
  • N is greater than or equal to 1.
  • the receiving module 1002 is further configured to receive a second instruction triggered by the user interface for activating any associated code block;
  • the user interface is provided with a dependent group, a dependent group, and a similar group; the presentation module 1003 is specifically configured to:
  • the index of each associated code block is presented in the dependent group, the dependent group, or the similar group.
  • the terminal device of this embodiment further includes: as shown in FIG. 2, a dependency relationship analysis module 1004 and a similarity relationship analysis module 1005, the dependency relationship analysis module 1004 and the similarity relationship analysis module 1005 are used to read from the At least one associated code block of the code block to be processed is determined in the first conflict file.
  • the obtaining module 1001 is further configured to: obtain a second conflict file
  • the dependency relationship analysis module 1004 and the similarity relationship analysis module 1005 are further configured to determine at least one code block associated with the code block to be processed from the second conflict file.
  • dependency analysis module 1004 and the similarity analysis module 1005 are specifically configured to:
  • an associated code block that has a similar relationship with the code block to be processed is determined from the first conflict file.
  • FIG. 11 is a schematic diagram of the hardware structure of the terminal device 110 provided by this application.
  • the terminal device 110 includes a memory 1101 and at least one processor 1102.
  • the memory 1101 is used to store program instructions
  • the at least one processor 1102 is used to call the program instructions in the memory 1101 to execute the steps in the foregoing method embodiments.
  • the steps, implementation principles and beneficial effects are similar and will not be repeated here.
  • the present application also provides a readable storage medium.
  • the readable storage medium stores an execution instruction.
  • the steps in the foregoing method embodiment are implemented, and its implementation principles and beneficial effects are It is similar and will not be repeated here.
  • the program product includes a computer program (that is, an execution instruction), and the computer program is stored in a readable storage medium.
  • the at least one processor 1102 of the terminal device 110 can read the computer program from a readable storage medium, and the at least one processor 1102 executes the computer program to enable the terminal device 110 to implement the associated conflict block presentation method provided by the foregoing various embodiments.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

一种关联冲突块呈现方法和设备。该方法包括:获取第一冲突文件,所述第一冲突文件中包括多个代码块,每个代码块包括所述代码块当前版本的代码片段、所述代码块基础版本的代码片段和所述代码块待合并版本的代码片段;接收用户界面触发的用于激活待处理代码块的第一指令(301),所述待处理代码块的类型为未消解冲突块或者单方变更块;在所述用户界面呈现所述待处理代码块包含的代码片段以及所述待处理代码块的N个关联代码块的索引(302);使得用户可以快速查找到当前冲突块中变量和/或函数的定义以及使用情况,另外还可参考与当前冲突块相似的并且已经消解的代码块的消解方案,极大提高了用户消解冲突块的效率。

Description

关联冲突块呈现方法和设备
本申请要求于2019年12月31日提交中国专利局、申请号为201911417340.3、申请名称为“关联冲突块呈现方法和设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及软件开发技术领域,尤其涉及一种关联冲突块呈现方法和设备。
背景技术
在软件开发过程中,不同的项目组在同一版本代码的基础上并行开发情况下,开发完成后,基于功能合并等原因,需要将各自开发的代码进行合并。但是,如果不同项目组在开发过程中对基础版本中相同代码实体进行了不同的变更,在合并时就会产生代码冲突。目前,很多用户采用SemanticMerge工具进行冲突块的自动消解,然而,该工具并不能完全消解代码合并过程中产生的所有冲突,也就是说,代码冲突的彻底消解仍依赖人工参与,如何提高人工消解效率成为主要问题。
SemanticMerge工具中对于不能自动消解的冲突块展示了冲突块内部洞察信息。比如:当前版本相对于基础版本的变更信息以及待合并版本相对于基础版本的变更信息等,用户在做消解时可以通过这些洞察信息直观地了解到当前冲突块包含的三个版本的代码片段之间的不同,然而,用户在做消解时,更多时候需要查看关联冲突块的代码片段,上述仅提供当前冲突块内部洞察信息的方法,不能满足用户快速定位关联冲突块的需求。
发明内容
本申请提供一种关联冲突块呈现方法和设备,用以提升人工消解冲突块的效率。
第一方面,本申请提供一种关联冲突块呈现方法,包括:
获取第一冲突文件,所述第一冲突文件中包括多个代码块,每个代码块包括所述代码块当前版本的代码片段、所述代码块基础版本的代码片段和所述代码块待合并版本的代码片段;
接收用户界面触发的用于激活待处理代码块的第一指令,所述待处理代码块的类型为未消解冲突块或者单方变更块;
在所述用户界面呈现所述待处理代码块包含的代码片段以及所述待处理代码块的N个关联代码块的索引;
其中,每个关联代码块的类型为未消解冲突块、单方变更块和已消解冲突块中的一种,每个关联代码块与所述待处理代码块的关联关系为依赖关系、被依赖关系和相似关系中的一种,N大于等于1。
在一种可能的设计中,所述方法还包括:
接收所述用户界面触发的用于激活任一关联代码块的第二指令;
将所述用户界面呈现的所述待处理代码块包含的代码片段跳转为所述关联代码块包含的代码片段。
在一种可能的设计中,所述用户界面设有依赖组、被依赖组和相似组;
所述在所述用户界面呈现所述待处理代码块的N个关联代码块的索引,包括:
根据每个关联代码块与所述待处理代码块的关联关系,将每个关联代码块的索引呈现在所述依赖组、所述被依赖组或所述相似组中。
在一种可能的设计中,所述在所述用户界面呈现所述待处理代码块的N个关联代码块的索引之前,还包括:
从所述第一冲突文件中确定所述待处理代码块的至少一个关联代码块。
在一种可能的设计中,所述在所述用户界面呈现所述待处理代码块的N个关联代码块的索引之前,还包括:
获取第二冲突文件;
从所述第二冲突文件中确定与所述待处理代码块的至少一个关联代码块。
在一种可能的设计中,所述从所述第一冲突文件中确定所述待处理代码块的至少一个关联代码块,包括:
根据所述待处理代码块中的变量和/或函数在所述第一冲突文件的其他代码块中的利用情况,从所述第一冲突文件中确定与所述待处理代码块有依赖关系和被依赖关系的关联代码块;和/或
根据所述待处理代码块包含的代码片段各自对应的Token串和抽象语法子树,从所述第一冲突文件中确定与所述待处理代码块有相似关系的关联代码块。
在一种可能的设计中,所述根据每个关联代码块与所述待处理代码块的关联关系,将每个关联代码块的索引呈现在所述依赖组、所述被依赖组或所述相似组中,包括:
将N个关联代码块中与待处理代码块有依赖关系的代码块呈现在依赖组中;
将N个关联代码块中与待处理代码块有被依赖关系的代码块呈现在被依赖组中;
将N个关联代码块中与待处理代码块有相似关系的代码块呈现在相似组中。
在一种可能的设计中,所述根据所述待处理代码块中的变量和/或函数在所述第一冲突文件的其他代码块中的利用情况,从所述第一冲突文件中确定与所述待处理代码块有依赖关系的关联代码块,包括:
若待处理代码块中定义的变量在第一冲突文件中的其他代码块中共M个代码块中使用,则确定该M个代码块均为与待处理代码块有依赖关系的关联代码块。
在一种可能的设计中,所述根据所述待处理代码块中的变量和/或函数在所述第一冲突文件的其他代码块中的利用情况,从所述第一冲突文件中确定与所述待处理代码块有被依赖关系的关联代码块,包括:
若待处理代码块中使用的变量在第一冲突文件中的其他代码块中共K个代码块中定义,则确定该K个代码块均为与待处理代码块有被依赖关系的关联代码块。
在一种可能的设计中,所述根据所述待处理代码块包含的代码片段各自对应的Token串和抽象语法子树,从所述第一冲突文件中确定与所述待处理代码块有相似关系的关联代码块,包括:
针对第一冲突文件包含的多个代码块中的除待处理代码块的每个代码块,计算所述待处理代码块包含的三个版本的代码片段各自对应的Token串和所述代码块包含的三个版本的代码片段各自对应的Token串之间每个版本的代码片段的Token相似度;
针对第一冲突文件包含的多个代码块中的除待处理代码块的每个代码块,计算所述待处理代码块包含的三个版本的代码片段各自对应的抽象语法子树和所述代码块包含的三个版本的代码片段各自对应的抽象语法子树之间每个版本的代码片段的结构相似度;
根据所述待处理代码块包含的三个版本的代码片段和所述每个代码块包含的三个版本的代码片段之间每个版本的代码片段的Token相似度和结构相似度,确定与所述待处理代码块有相似关系的关联代码块。
在一种可能的设计中,上述方法还包括:
针对第一冲突文件包含的每个代码块,存储该代码块中定义的变量和/或函数,以及使用的变量和/或函数;
判断待处理代码块中定义的变量是否在第一冲突文件中除待处理代码块的其他代码块中使用;以及判断待处理代码块中使用的变量是否在第一冲突文件中除待处理代码块的其他代码块中定义。
在一种可能的设计中,所述计算所述待处理代码块包含的三个版本的代码片段各自对应的抽象语法子树和所述代码块包含的三个版本的代码片段各自对应的抽象语法子树之间每个版本的代码片段的结构相似度,包括:
根据所述待处理代码块包含的三个版本的代码片段的行号范围,确定所述待处理代码块包含的三个版本的代码片段各自对应的抽象语法子树;
针对第一冲突文件包含的多个代码块中的除待处理代码块的每个代码块,根据所述代码块包含的三个版本的代码片段的行号范围,确定所述代码块包含的三个版本的代码片段各自对应的抽象语法子树;
根据所述待处理代码块的包含的三个版本的代码片段各自对应的抽象语法子树和每个代码块包含的三个版本的代码片段各自对应的抽象语法子树,确定所述待处理代码块包含的三个版本的代码片段和每个代码块包含的三个版本的代码片段之间每个版本的代码片段的结构相似度。
在一种可能的设计中,所述根据所述待处理代码块包含的三个版本的代码片段的行号范围,确定所述待处理代码块包含的三个版本的代码片段各自对应的抽象语法子树,包括:
针对所述待处理代码块包含的三个版本的代码片段中的第一版本的代码片段,解析所述第一版本的代码片段所在的代码文件,得到所述代码文件对应的抽象语法树;
搜索所述抽象语法树,将行号范围落在所述第一版本的代码片段对应的行号范围内的子树确定为所述第一版本的代码片段对应的抽象语法子树。
在一种可能的设计中,所述根据所述待处理代码块包含的三个版本的代码片段和所述每个代码块包含的三个版本的代码片段之间每个版本的代码片段的Token相似度和结构相似度,确定与所述待处理代码块有相似关系的关联代码块,包括:
针对所述待处理代码块包含的三个版本的代码片段中第一版本的代码片段,以及 所述每个代码块包含的三个版本的代码片段中第一版本的代码片段;
对所述待处理代码块的第一版本的代码片段和所述每个代码块的第一版本的代码片段之间的Token相似度和结构相似度取加权平均,得到所述待处理代码块的第一版本的代码片段和所述每个代码块的第一版本的代码片段之间第一相似度值;
对所述待处理代码块包含的三个版本的代码片段和所述每个代码块包含的三个版本的代码片段之间的三个所述第一相似度值取加权平均,得到所述待处理代码块包含的三个版本的代码片段和所述每个代码块包含的三个版本的代码片段之间的第二相似度值;
将所述第二相似度值大于预设阈值的代码块确定为与所述待处理代码块有相似关系的关联代码块。
第二方面,本申请提供一种终端设备,包括:
获取模块,用于获取第一冲突文件,所述第一冲突文件中包括多个代码块,每个代码块包括所述代码块当前版本的代码片段、所述代码块基础版本的代码片段和所述代码块待合并版本的代码片段;
接收模块,用于接收用户界面触发的用于激活待处理代码块的第一指令,所述待处理代码块的类型为未消解冲突块或者单方变更块;
呈现模块,用于在所述用户界面呈现所述待处理代码块包含的代码片段以及所述待处理代码块的N个关联代码块的索引;
其中,每个关联代码块的类型为未消解冲突块、单方变更块和已消解冲突块中的一种,每个关联代码块与所述待处理代码块的关联关系为依赖关系、被依赖关系和相似关系中的一种,N大于等于1。
在一种可能的设计中,所述接收模块,还用于接收所述用户界面触发的用于激活任一关联代码块的第二指令;
所述呈现模块还用于,将所述用户界面呈现的所述待处理代码块包含的代码片段跳转为所述关联代码块包含的代码片段。
在一种可能的设计中,所述用户界面设有依赖组、被依赖组和相似组;所述呈现模块具体用于:
根据每个关联代码块与所述待处理代码块的关联关系,将每个关联代码块的索引呈现在所述依赖组、所述被依赖组或所述相似组中。
在一种可能的设计中,上述终端设备还包括:依赖关系分析模块和相似关系分析模块,所述依赖关系分析模块和所述相似关系分析模块用于从所述第一冲突文件中确定所述待处理代码块的至少一个关联代码块。
在一种可能的设计中,所述获取模块还用于:获取第二冲突文件;
所述依赖关系分析模块和所述相似关系分析模块还用于从所述第二冲突文件中确定与所述待处理代码块的至少一个关联代码块。
在一种可能的设计中,所述依赖关系分析模块和相似关系分析模块具体用于:
根据所述待处理代码块中的变量和/或函数在所述第一冲突文件的其他代码块中的利用情况,从所述第一冲突文件中确定与所述待处理代码块有依赖关系和被依赖关系的关联代码块;和/或
根据所述待处理代码块包含的代码片段各自对应的Token串和抽象语法子树,从所述第一冲突文件中确定与所述待处理代码块有相似关系的关联代码块。
在一种可能的设计中,所述呈现模块具体用于:
将N个关联代码块中与待处理代码块有依赖关系的代码块呈现在依赖组中;
将N个关联代码块中与待处理代码块有被依赖关系的代码块呈现在被依赖组中;
将N个关联代码块中与待处理代码块有相似关系的代码块呈现在相似组中。
在一种可能的设计中,所述依赖关系分析模块具体用于:
若待处理代码块中定义的变量在第一冲突文件中的其他代码块中共M个代码块中使用,则确定该M个代码块均为与待处理代码块有依赖关系的关联代码块。
在一种可能的设计中,所述依赖关系分析模块具体用于:
若待处理代码块中使用的变量在第一冲突文件中的其他代码块中共K个代码块中定义,则确定该K个代码块均为与待处理代码块有被依赖关系的关联代码块。
在一种可能的设计中,所述相似关系分析模块具体用于:
针对第一冲突文件包含的多个代码块中的除待处理代码块的每个代码块,计算所述待处理代码块包含的三个版本的代码片段各自对应的Token串和所述代码块包含的三个版本的代码片段各自对应的Token串之间每个版本的代码片段的Token相似度;
针对第一冲突文件包含的多个代码块中的除待处理代码块的每个代码块,计算所述待处理代码块包含的三个版本的代码片段各自对应的抽象语法子树和所述代码块包含的三个版本的代码片段各自对应的抽象语法子树之间每个版本的代码片段的结构相似度;
根据所述待处理代码块包含的三个版本的代码片段和所述每个代码块包含的三个版本的代码片段之间每个版本的代码片段的Token相似度和结构相似度,确定与所述待处理代码块有相似关系的关联代码块。
在一种可能的设计中,所述依赖关系分析模块还用于:
针对第一冲突文件包含的每个代码块,存储该代码块中定义的变量和/或函数,以及使用的变量和/或函数;
判断待处理代码块中定义的变量是否在第一冲突文件中除待处理代码块的其他代码块中使用;以及判断待处理代码块中使用的变量是否在第一冲突文件中除待处理代码块的其他代码块中定义。
在一种可能的设计中,所述相似关系分析模块具体用于:
根据所述待处理代码块包含的三个版本的代码片段的行号范围,确定所述待处理代码块包含的三个版本的代码片段各自对应的抽象语法子树;
针对第一冲突文件包含的多个代码块中的除待处理代码块的每个代码块,根据所述代码块包含的三个版本的代码片段的行号范围,确定所述代码块包含的三个版本的代码片段各自对应的抽象语法子树;
根据所述待处理代码块的包含的三个版本的代码片段各自对应的抽象语法子树和每个代码块包含的三个版本的代码片段各自对应的抽象语法子树,确定所述待处理代码块包含的三个版本的代码片段和每个代码块包含的三个版本的代码片段之间每个版本的代码片段的结构相似度。
在一种可能的设计中,所述相似关系分析模块具体用于:
针对所述待处理代码块包含的三个版本的代码片段中的第一版本的代码片段,解析所述第一版本的代码片段所在的代码文件,得到所述代码文件对应的抽象语法树;
搜索所述抽象语法树,将行号范围落在所述第一版本的代码片段对应的行号范围内的子树确定为所述第一版本的代码片段对应的抽象语法子树。
在一种可能的设计中,所述相似关系分析模块具体用于:
针对所述待处理代码块包含的三个版本的代码片段中第一版本的代码片段,以及所述每个代码块包含的三个版本的代码片段中第一版本的代码片段;
对所述待处理代码块的第一版本的代码片段和所述每个代码块的第一版本的代码片段之间的Token相似度和结构相似度取加权平均,得到所述待处理代码块的第一版本的代码片段和所述每个代码块的第一版本的代码片段之间第一相似度值;
对所述待处理代码块包含的三个版本的代码片段和所述每个代码块包含的三个版本的代码片段之间的三个所述第一相似度值取加权平均,得到所述待处理代码块包含的三个版本的代码片段和所述每个代码块包含的三个版本的代码片段之间的第二相似度值;
将所述第二相似度值大于预设阈值的代码块确定为与所述待处理代码块有相似关系的关联代码块。
第三方面,本申请提供一种终端设备,包括:存储器和处理器;
所述存储器用于存储程序指令,所述处理器用于调用所述存储器中的程序指令执行上述关联冲突块呈现方法。
第四方面,本申请提供一种可读存储介质,所述可读存储介质上存储有计算机程序;所述计算机程序在被执行时,实现上述关联冲突块呈现方法。
本申请提供的关联冲突块呈现方法和设备,通过依赖关系分析模块和相似关系分析模块获取当前冲突块的关联代码块列表,使得当前冲突块被激活后,终端设备可以将这些关联代码块的索引呈现在用户界面,用户需要查看某关联代码块包含的代码片段时,点击该关联代码块的索引,用户界面便可跳转到该关联代码块包含的代码片段,使得用户可以快速查找到当前冲突块中变量和/或函数的定义以及使用情况,另外还可参考与当前冲突块相似的并且已经消解的代码块的消解方案,极大提高了用户消解冲突块的效率。
附图说明
图1为本申请提供的***框架图;
图2为本申请提供的终端设备的结构示意图;
图3为本申请提供的关联冲突块呈现方法的实施例的流程示意图;、
图4为本申请提供的用户界面示意图一;
图5为本申请提供的用户界面示意图二;
图6为本申请提供的用户界面示意图三;
图7为本申请提供的用户界面示意图四;
图8为本申请提供的用户界面示意图五;
图9为本申请提供的用户界面示意图六;
图10为本申请提供的终端设备100的结构示意图;
图11为本申请提供的终端设备110的硬件结构示意图。
具体实施方式
以下,对本申请中的部分用语进行解释说明,以便于本领域技术人员理解。
1)三个版本的代码文件:包括当前版本的代码文件、基础版本的代码文件和待合并版本的代码文件,当前版本的代码文件中包含的代码和待合并版本的代码文件中包含的代码均为在基础版本的代码文件中包含的代码的基础上进一步开发得到的代码。
为方便描述,下文中将当前版本简称为“Ours版本”,将基础版本简称为“Base版本”,将待合并版本简称为“Theirs版本”,可以理解的是,Ours版本、Base版本和Theirs版本仅仅是为了描述清楚本申请的方案所使用的示意性的名称,本领域技术人员还可以使用其他的名称,使用其他名称来实施的本申请的步骤时得到的方案均在本申请保护范围内。
2)代码合并:基于功能合并等原因,需将Ours版本的代码文件中包含的代码和Theirs版本的代码文件中包含的代码进行合并。
3)代码冲突:针对Base版本的代码文件中的相同代码实体,如果Ours版本和Theirs版本分别对其做了不同的变更,在代码合并时就会产生代码冲突。比如:Ours版本和Theirs版本对Base版本中同一变量进行了不同的命名操作,在代码合并时就会产生关于这个变量的代码冲突。
4)单方变更:针对Base版本的代码文件中的相同代码实体,Ours版本和Theirs版本中只有一个版本做了变更,这种情况下,在代码合并时可直接取做出变更的一方。
5)冲突文件:代码合并后生成的文件,冲突文件包括两部分:成功合并部分和若干个冲突部分,每个冲突部分可使用“<<<<<<<”“|||||||”“=======”“>>>>>>>”等标识符划分该冲突部分对应的不同版本的代码片段。比如:可将冲突文件中“<<<<<<<”和“|||||||”之间的代码片段作为冲突部分的Ours版本的代码片段,将“|||||||”和“=======”之间的代码片段作为冲突部分的Base版本的代码片段,将“=======”和“>>>>>>>”之间的代码片段作为冲突部分的Theirs版本的代码片段。
可以理解的是:不同的合并工具生成的冲突文件中划分不同版本的代码片段所使用的标识符不同,上述标识符仅是一种示例,本申请不以此为限,下文以这种标识符为例介绍本申请的方案。
6)冲突块:代码合并时一处冲突对应一个冲突块,每个冲突块均包含Ours版本的代码片段、Base版本的代码片段和Theirs版本的代码片段,下文会介绍从冲突文件解析冲突块的过程。
7)单方变更块:代码合并时一处单方变更对应一个单方变更块,每个单方变更块均包含Ours版本的代码片段、Base版本的代码片段和Theirs版本的代码片段,下文会介绍从冲突文件提取单方变更块的过程。
现有技术中,在代码合并时,多采用语义合并SemanticMerge工具自动消解冲突块,对于不能自动消解的冲突块会展示冲突块内部洞察信息,比如:Ours版本相对于 Base版本的变更信息以及Theirs版本相对于Base版本的变更信息等,用户在做消解时可以通过这些洞察信息直观地了解到当前冲突块包含的三个版本的代码片段之间的不同。然而,用户在做消解时,常常需要在其他代码块查找当前冲突块中变量和/或函数的定义以及使用情况,或者参考与当前冲突块相似的并且已经消解的代码块的消解方案,上述仅提供当前冲突块内部洞察信息,不能满足用户快速定位关联冲突块的需求。
图1为本申请提供的***框架图,如图1所示,本申请提供的***包括:终端设备和服务器。图2为本申请提供的终端设备的结构示意图,如图2所示,终端设备包括:依赖关系分析模块和相似关系分析模块,依赖关系分析模块用于从冲突文件中确定与待处理代码块有依赖关系的关联代码块,以及与待处理代码块有被依赖关系的关联代码块。相似关系分析模块用于从冲突文件中确定与待处理代码块有相似关系的关联代码块。服务器用于存储上述依赖关系分析模块和相似关系分析模块从冲突文件中分析得到的关联代码块列表。
可选的,终端设备可以是台式电脑、手机,平板电脑,笔记本电脑,智能手表,电视机或者其他具有显示屏的电子设备;服务器可以是实体服务器或者云服务器等具有相应处理能力的设备。
由于现有技术仅提供当前冲突块内部洞察信息,导致用户做消解时无法快速定位到当前冲突块的关联冲突块,本申请以此为切入点,通过依赖关系分析模块和相似关系分析模块获取当前冲突块的关联代码块列表,使得当前冲突块被激活后,终端设备可以将这些关联代码块的索引呈现在用户界面,用户需要查看某关联代码块包含的代码片段时,点击该关联代码块的索引,用户界面便可跳转到该关联代码块包含的代码片段,使得用户可以快速查找到当前冲突块中变量和/或函数的定义以及使用情况,另外还可参考与当前冲突块相似的并且已经消解的代码块的消解方案,极大提高了用户消解冲突块的效率。
下面结合具体的实施例对本申请提供的关联冲突块呈现方法进行详细说明。
基于图1所示***,图3为本申请提供的关联冲突块呈现方法的实施例的流程示意图,本实施例可由图1中终端设备来执行,如图3所示,本实施例提供的关联冲突块呈现方法,包括:
S301、接收用户界面触发的用于激活待处理代码块的第一指令。
S302、在所述用户界面呈现所述待处理代码块包含的代码片段以及所述待处理代码块的N个关联代码块的索引。
需要说明的是:上述待处理代码块的类型可以为未消解的冲突块,也可为单方变更块,也就是说,本申请的方法不仅可以呈现冲突块的关联代码块的索引,还可呈现单方变更块的关联代码块的索引。
需要说明的是:待处理代码块的N个关联代码块中每个关联代码块的类型为未消解冲突块、单方变更块和已消解冲突块中的一种,也就是说,本申请不仅呈现与待处理代码块有关联关系的未消解冲突块,还呈现了与待处理代码块有关联关系的已消解冲突块,可以使用户做冲突块消解时可以参考已消解的冲突块的消解方案,提升了用户消解冲突块的效率。另外,本申请还呈现与待处理代码块有关联关系的单方变更块, 避免待处理代码块中的变量和/或函数在单方变更块中定义或使用时,用户无法定位该关联代码块的问题。
需要说明的是:待处理代码块的N个关联代码块中每个关联代码块与待处理代码块的关联关系为依赖关系、被依赖关系和相似关系中的一种,用户可以通过与待处理代码块有依赖关系的代码块查看待处理代码块中定义的变量和/或函数的使用情况,通过与待处理代码块有被依赖关系的代码块查看待处理代码块中使用的变量和/或函数的定义情况,通过与待处理代码块有相似关系的代码块查看已消解冲突块的消解方案,并对其他相似的未消解冲突块进行批量消解,从而提升用户消解冲突块的效率。
为了使用户界面呈现的N个关联代码块与待处理代码块的关系更加明了,可在用户界面设置依赖组、被依赖组合相似组。并根据每个关联代码块与待处理代码块的关联关系,将每个关联代码块的索引呈现在上述依赖组,或者被依赖组,或者相似组中。具体的,可将N个关联代码块中与待处理代码块有依赖关系的代码块呈现在依赖组中;将N个关联代码块中与待处理代码块有被依赖关系的代码块呈现在被依赖组中;将N个关联代码块中与待处理代码块有相似关系的代码块呈现在相似组中。
下面对第一指令的可实现方式进行说明:
一种可实现的方式中,用户可以通过点击图4所示用户界面上冲突块旁边的上下箭头来触发激活待处理代码块的第一指令,这种情况下,第一指令为该点击动作触发的指令。以待处理代码块为冲突文件2中未消解的第4个冲突块为例,用户点击图4所示用户界面上冲突块旁边的向下箭头后,用户界面跳转到图5,如图5所示,用户界面上呈现了第4个冲突块Ours版本的代码片段、Base版本的代码片段以及Theirs版本的代码片段;同时还会呈现与第4个冲突块有依赖关系的代码块的索引,与第4代码块有被依赖关系的代码块的索引以及与第4个冲突块相似的代码块的索引。具体的,参见图5,与第4个冲突块有依赖关系的代码块为第313个冲突文件中的第10个冲突块(Conflict Block 10 of File 313),与第4个冲突块有被依赖关系的代码块为第2个冲突文件中的第13个单方变更块(Single-Side Change 13 of File 2),与第4个冲突块有相似关系的代码块为第313个冲突文件中的第20个冲突块(Conflict Block 20of File 313)。
另一种可实现方式中,用户可以通过点击图4所示用户界面上冲突块旁边的上下箭头先触发显示待处理代码块的三个版本的代码片段,这时用户界面跳转到图6,然后通过点击图6所示用户界面左侧关联代码块的下拉按钮触发显示待处理代码块的关联代码块,比如点击被依赖组对应的下拉按钮触发显示与待处理代码块有被依赖关系的代码块的索引,这时用户界面跳转到图7,这种情况下,S301中的第一指令包括图4中用户点击冲突块旁边的上下箭头触发的指令,以及图6中用户点击被依赖组的下拉按钮触发的指令。
需要说明的是:上述第二种实现方式下第一指令具体包括几个指令取决于用于点击了几个组的下拉按钮,如果用户对依赖组、被依赖组和相似组的下拉按钮都点击了,那么第一指令就包括了图4中用户点击冲突块旁边的上下箭头触发的指令以及点击三个组的下拉按钮所触发的指令。
以上,介绍了在用户界面呈现待处理代码块的N个关联代码块的索引的过程,下 面介绍如何从冲突文件中确定出该N个关联代码块,该过程可由图2中依赖关系分析模块和相似关系分析模块执行。
需要说明的是:由于本申请是要从冲突块和单方变更块中确定出N个关联代码块,因此,需要先从冲突文件中把冲突块解析出来,把单方变更块提取出来。下文先介绍冲突块解析过程以及单方变更块提取过程。
冲突块解析过程:
参见上文描述,冲突文件包括两部分:成功合并部分和若干个冲突部分,一个冲突部分对应一个冲突块,每个冲突部分使用“<<<<<<<”“|||||||”“=======”“>>>>>>>”等标识符划分该冲突部分对应的不同版本的代码片段。针对每个冲突部分,提取“<<<<<<<”和“|||||||”之间的代码片段作为对应冲突块的Ours版本的代码片段,提取“|||||||”和“=======”之间的代码片段作为对应冲突块的Base版本的代码片段,提取“=======”和“>>>>>>>”之间的代码片段作为对应冲突块的Theirs版本的代码片段;然后,将Ours版本的代码片段在Ours版本的代码文件中做匹配,得到Ours版本的代码片段在Ours版本的代码文件中的行号范围,将Base版本的代码片段在Base版本的代码文件中做匹配,得到Base版本的代码片段在Base版本的代码文件中的行号范围,将Theirs版本的代码片段在Theirs版本的代码文件中做匹配,得到Theirs版本的代码片段在Theirs版本的代码文件中的行号范围,把每个版本代码文件中相应行号范围内的代码片段截取出来便构成了一个冲突块。
对所有的冲突文件做上面的相同的操作,便可得到所有冲突文件各自包含的冲突块。
单方变更块提取过程:
先从冲突文件中解析得到Ours版本,Base版本和Theirs版本这个三个版本的代码文件,基于这三个版本的代码文件,一方面,获取Ours版本基于Base版本的第一变更列表,该第一变更列表记载有Ours版本基于Base版本的变更对象、变更动作、变更对象在Ours版本的代码文件中的行号范围以及变更对象在Base版本的代码文件中的行号范围;另一方面,获取Theirs版本基于Base版本的第二变更列表,该第二变更列表记载有Theirs版本基于Base版本的变更对象、变更动作、变更对象在Theirs版本的代码文件中的行号范围以及变更对象在Base版本的代码文件中的行号范围;然后以上述两个变更列表中Base版本的行号为基准,若第一变更列表中Base版本的某个行号不在第二变更列表中,则确定该行的变更为Ours版本基于Base版本的单方变更,若第二变更列表中Base版本的某个行号不在第一变更列表中,则确定该行的变更为Theirs版本基于Base版本的单方变更,把每个版本代码文件中单方变更对应的行号范围内的代码片段截取出来便构成了一个单方变更块。
对所有的冲突文件做上面的相同的操作,便可得到所有冲突文件各自包含的单方变更块。
需要说明的是,本申请是要从获取到的所有冲突文件各自包含的冲突块和单方变更块中确定待处理代码块的N个关联冲突块,而所有冲突文件可被划分为两种:第一种为待处理代码块所在的冲突文件,第二种为不包含待处理代码块的冲突文件。为方便描述,下文中将第一种冲突文件称为第一冲突文件,将第二种冲突文件称为第二冲 突文件。由于本申请从第一冲突文件中确定待处理代码块的关联代码块的方法和从第二冲突文件中确定待处理代码块的关联代码块的方法相同,因此,下文以第一冲突文件为例,对确定关联冲突块的过程进行说明。
下面介绍从第一冲突文件包含的冲突块和单方变更块中确定与待处理代码块有依赖关系和被的依赖关系的代码块:
对第一冲突文件进行上文的冲突块解析和单方变更提取后,可以得到第一冲突文件包含的多个冲突块和单方变更块,为方面描述,将冲突块和单方变更块统称为代码块,即第一冲突文件包含多个代码块,每个代码块包括该代码块Ours版本的代码片段、该代码块Base版本的代码片段和该代码块Theirs版本的代码片段。
由于冲突块或者单方变更块正是因为对相同的变量和/或函数做了两方或一方变更引起的,因此,代码块的三个版本的代码片段涉及到的函数和/或函数是相同的,可针对每个代码块,存储该代码块中定义的变量和/或函数,以及使用的变量和/或函数,然后根据待处理代码块中的变量和/或函数在第一冲突文件中除待处理代码块的其他代码块中的利用情况,确实出与待处理代码块有依赖关系和被依赖关系的关联代码块。
一种可实现的方式中,可通过如下方式存储代码块中定义的变量以及使用的变量:在每个代码块定义变量声明Map,变量使用Map,变量依赖List和变量被依赖List。
上述变量声明Map,变量使用Map,变量依赖List和变量被依赖List的数据结构可以为:
Figure PCTCN2020114557-appb-000001
每个变量Var的数据结构可定义如下:
Figure PCTCN2020114557-appb-000002
其中,Integer startLine表示变量起始行,Integer endLine表示变量终止行,String varRawData表示定义或使用该变量的原始代码,Integer blockIndex表示冲突块索引,String fileName表示冲突文件名称。
一种可实现的方式中,可判断待处理代码块中定义的变量是否在第一冲突文件中除待处理代码块的其他代码块中使用,若判断结果为待处理代码块中定义的变量在M个代码块中使用,则确定该M个代码块均为与待处理代码块有依赖关系的关联代码块,可将该M个代码块的索引放入待处理代码块的变量依赖List。
另外,可判断待处理代码块中使用的变量是否在第一冲突文件中除待处理代码块的其他代码块中定义,若判断结果为待处理代码块中使用的变量在K个代码块中定义,则确定该K个代码块均为与待处理代码块有被依赖关系的关联代码块,可将该K个代 码块的索引放入待处理代码块的变量被依赖List。
需要说明的是:上文基于变量确定与待处理代码块有依赖关系的关联代码块以及被依赖关系的关联代码块的方法适用于函数,本申请不再针对函数赘述。
下面介绍从第一冲突文件包含的冲突块和单方变更块中确定与待处理代码块有相似关系的代码块:
同依赖关系与被依赖关系,对第一冲突文件进行上文的冲突块解析和单方变更提取后,可以得到第一冲突文件包含的多个冲突块和单方变更块,为方面描述,将冲突块和单方变更块统称为代码块,即第一冲突文件包含多个代码块,每个代码块包括该代码块Ours版本的代码片段、该代码块Base版本的代码片段和该代码块Theirs版本的代码片段。
一种可实现方式中,可根据待处理代码块包含的Ours版本、Base版本和Theirs版本的代码片段各自对应的Token串和抽象语法子树来确定与待处理代码块有相似关系的关联代码块。
在上述可实现方式中,确定相似关系的关联代码块的过程可分为以下几步:
第一步、针对第一冲突文件包含的多个代码块中的除待处理代码块的每个代码块,计算待处理代码块的Ours版本的代码片段和该代码块的Ours版本的代码片段之间Token相似度(记为“Ours版本Token相似度”),计算待处理代码块的Base版本的代码片段和该代码块的Base版本的代码片段之间Token相似度(记为“Base版本Token相似度”),计算待处理代码块的Theirs版本的代码片段和该代码块的Theirs版本的代码片段之间Token相似度(记为“Theirs版本Token相似度”)。
要计算两个代码块之间各个版本的代码片段的Token相似度,需先提取两个代码块的各个版本的代码片段对应的Token串,比如:要计算待处理代码块的Ours版本的代码片段和某代码块的Ours版本的代码片段之间Token相似度,需先提取待处理代码块的Ours版本的代码片段对应的Token串以及该代码块的Ours版本的代码片段对应的Token串,然后采用余弦夹角的相似度计算方法确定两者的Token相似度。
下面以待处理代码块的Ours版本的代码片段为例,对提取Token串的过程进行说明:使用转换工具,比如Google java format,将Ours版本的代码片段按行进行Token转换,并去除括号、分号、逗号、冒号、算术运算符、逻辑运算符以及位运算符等对代码内容影响较小的Token,从而得到Ours版本的代码片段对应的Token串。
第二步、针对第一冲突文件包含的多个代码块中的除待处理代码块的每个代码块,计算待处理代码块的Ours版本的代码片段和该代码块的Ours版本的代码片段之间结构相似度(记为“Ours版本结构相似度”),计算待处理代码块的Base版本的代码片段和该代码块的Base版本的代码片段之间结构相似度(记为“Base版本结构相似度”),计算待处理代码块的Theirs版本的代码片段和该代码块的Theirs版本的代码片段之间结构相似度(记为“Theirs版本结构相似度”)。
要计算两个代码块之间各个版本的代码片段的结构相似度,需先确定两个代码块的各个版本的代码片段对应的抽象语法子树,比如:要计算待处理代码块的Ours版本的代码片段和某代码块的Ours版本的代码片段之间结构相似度,需先确定待处理代码块的Ours版本的代码片段对应的抽象语法子树以及该代码块的Ours版本的代码片段 对应的抽象语法子树,然后根据这两个抽象语法子树,确定两者的结构相似度。
下面以待处理代码块的Ours版本的代码片段为例,对确定抽象语法子树的过程进行说明:解析待处理代码块的Ours版本的代码片段所在的Ours版本代码文件,得到Ours版本代码文件对应的抽象语法树,搜索该抽象语法树,将该抽象语法树上行号范围落在Ours版本的代码片段对应的行号范围内的子树确定为Ours版本的代码片段对应的抽象语法子树。
需要说明的是:得到两个抽象语法子树后,分别遍历两个子树,并计算对应节点的相似度,将相似度值大于预设阈值的两个节点匹配成一对,然后采用杰卡德相似系数计算两个子树匹配对应的节点数量和两个子树节点总数量的比值,用其作为两个子树的结构相似度。
第三步、根据第一步和第二步得到的待处理代码块的Ours版本的代码片段和各代码块Ours版本的代码片段之间的Token相似度和结构相似度,待处理代码块的Base版本的代码片段和各代码块Base版本的代码片段之间的Token相似度和结构相似度,待处理代码块的Theirs版本的代码片段和各代码块Theirs版本的代码片段之间的Token相似度和结构相似度,确定与待处理代码与相似关系的关联代码块。
一种可实现方式中,本步骤又可包括如下几个步骤:
步骤A、可先对待处理代码块的Ours版本的代码片段和每个代码块Ours版本的代码片段之间的Token相似度和结构相似度取加权平均,得到待处理代码块的Ours版本的代码片段和每个代码块Ours版本的代码片段之间第一相似度值;对待处理代码块的Base版本的代码片段和每个代码块Base版本的代码片段之间的Token相似度和结构相似度取加权平均,得到待处理代码块的Base版本的代码片段和每个代码块Base版本的代码片段之间第一相似度值;对待处理代码块的Theirs版本的代码片段和每个代码块Theirs版本的代码片段之间的Token相似度和结构相似度取加权平均,得到待处理代码块的Theirs版本的代码片段和每个代码块Theirs版本的代码片段之间第一相似度值。
步骤B、对待处理代码块和每个代码块之间上述三个第一相似度值取加权平均,得到待处理代码块和每个代码块之间第二相似度值;
步骤C、将第一冲突文件中除待处理代码的其他代码块中第二相似度值大于预设阈值的代码块确定为与待处理代码有相似关系的关联代码块。
需要说明的是:用于做上述关联分析的第一冲突文件中的代码块是通过上文描述的冲突块解析过程和单方变更提取过程得到的,这些代码块中有些可能已经被用户消解,有些可能未消解,无论代码块处于那种状态,均属于上述关联分析的范围。
S304、接收所述用户界面触发的用于激活任一关联代码块的第二指令。
S305、将所述用户界面呈现的所述待处理代码块包含的代码片段跳转为所述关联代码块包含的代码片段。
参见图8所示,用户可以通过点击任一关联代码块的索引来触发激活该关联代码块的第二指令,比如用户可以点击依赖组中第313个冲突文件中第10个冲突块(Conflict Block 10 of File 313),便可触发激活该冲突块的第二指令。终端设备接收到该第二指令后,可将用户界面跳转到该关联代码块的包含的代码片段,比如:用户 点击依赖组中第313个冲突文件中第10个冲突块(Conflict Block 10 of File 313),用户界面跳转到图9,用户可以在图9中查看第2个冲突文件中第4个冲突块(待处理代码块)定义的变量和/或函数在第313个冲突文件中第10个冲突块中的使用情况,加快了用户理解分析冲突块的速度,提升了消解效率。
一种可实现的方式中,用户可以点击图9中返回按钮返回待处理代码块(第2个冲突文件中第4个冲突块)包含的代码片段,该按钮可以使用户在待处理代码块和关联代码块之间来回切换,提高了用户体验。
本实施例提供的关联冲突块呈现方法,通过依赖关系分析模块和相似关系分析模块获取当前冲突块的关联代码块列表,使得当前冲突块被激活后,终端设备可以将这些关联代码块的索引呈现在用户界面,用户需要查看某关联代码块包含的代码片段时,点击该关联代码块的索引,用户界面便可跳转到该关联代码块包含的代码片段,使得用户可以快速查找到当前冲突块中变量和/或函数的定义以及使用情况,另外还可参考与当前冲突块相似的并且已经消解的代码块的消解方案,极大提高了用户消解冲突块的效率。
图10为本申请提供的终端设备100的结构示意图。如图10所示,本实施例提供的终端设备100,包括:
获取模块1001,用于获取第一冲突文件,所述第一冲突文件中包括多个代码块,每个代码块包括所述代码块当前版本的代码片段、所述代码块基础版本的代码片段和所述代码块待合并版本的代码片段;
接收模块1002,用于接收用户界面触发的用于激活待处理代码块的第一指令,所述待处理代码块的类型为未消解冲突块或者单方变更块;
呈现模块1003,用于在所述用户界面呈现所述待处理代码块包含的代码片段以及所述待处理代码块的N个关联代码块的索引;
其中,每个关联代码块的类型为未消解冲突块、单方变更块和已消解冲突块中的一种,每个关联代码块与所述待处理代码块的关联关系为依赖关系、被依赖关系和相似关系中的一种,N大于等于1。
可选的,所述接收模块1002,还用于接收所述用户界面触发的用于激活任一关联代码块的第二指令;
所述呈现模块1003还用于,将所述用户界面呈现的所述待处理代码块包含的代码片段跳转为所述关联代码块包含的代码片段。
可选的,所述用户界面设有依赖组、被依赖组和相似组;所述呈现模块1003具体用于:
根据每个关联代码块与所述待处理代码块的关联关系,将每个关联代码块的索引呈现在所述依赖组、所述被依赖组或所述相似组中。
可选的,本实施例的终端设备还包括:图2所示,依赖关系分析模块1004和相似关系分析模块1005,所述依赖关系分析模块1004和所述相似关系分析模块1005用于从所述第一冲突文件中确定所述待处理代码块的至少一个关联代码块。
可选的,所述获取模块1001还用于:获取第二冲突文件;
所述依赖关系分析模块1004和所述相似关系分析模块1005还用于从所述第二冲 突文件中确定与所述待处理代码块的至少一个关联代码块。
可选的,所述依赖关系分析模块1004和相似关系分析模块1005具体用于:
根据所述待处理代码块中的变量和/或函数在所述第一冲突文件的其他代码块中的利用情况,从所述第一冲突文件中确定与所述待处理代码块有依赖关系和被依赖关系的关联代码块;和/或
根据所述待处理代码块包含的代码片段各自对应的Token串和抽象语法子树,从所述第一冲突文件中确定与所述待处理代码块有相似关系的关联代码块。
本申请提供的上述终端设备,可以执行上述方法实施例中的步骤,其实现原理以及有益效果类似,此处不再进行赘述。
图11为本申请提供的终端设备110的硬件结构示意图。如图11所示,该终端设备110包括:存储器1101和至少一个处理器1102,存储器1101用于存储程序指令,至少一个处理器1102用于调用存储器1101中的程序指令执行上述方法实施例中的步骤,其实现原理以及有益效果类似,此处不再进行赘述。
本申请还提供一种可读存储介质,可读存储介质中存储有执行指令,终端设备110的至少一个处理器1102执行该执行指令时实现上述方法实施例中的步骤,其实现原理以及有益效果类似,此处不再进行赘述。
本申请还提供一种程序产品,该程序产品包括计算机程序(即执行指令),该计算机程序存储在可读存储介质中。终端设备110的至少一个处理器1102可以从可读存储介质读取该计算机程序,至少一个处理器1102执行该计算机程序使得终端设备110实施前述各种实施方式提供的关联冲突块呈现方法。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。

Claims (14)

  1. 一种关联冲突块呈现方法,其特征在于,包括:
    获取第一冲突文件,所述第一冲突文件中包括多个代码块,每个代码块包括所述代码块当前版本的代码片段、所述代码块基础版本的代码片段和所述代码块待合并版本的代码片段;
    接收用户界面触发的用于激活待处理代码块的第一指令,所述待处理代码块的类型为未消解冲突块或者单方变更块;
    在所述用户界面呈现所述待处理代码块包含的代码片段以及所述待处理代码块的N个关联代码块的索引;
    其中,每个关联代码块的类型为未消解冲突块、单方变更块和已消解冲突块中的一种,每个关联代码块与所述待处理代码块的关联关系为依赖关系、被依赖关系和相似关系中的一种,N大于等于1。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    接收所述用户界面触发的用于激活任一关联代码块的第二指令;
    将所述用户界面呈现的所述待处理代码块包含的代码片段跳转为所述关联代码块包含的代码片段。
  3. 根据权利要求1或2所述的方法,其特征在于,所述用户界面设有依赖组、被依赖组和相似组;
    所述在所述用户界面呈现所述待处理代码块的N个关联代码块的索引,包括:
    根据每个关联代码块与所述待处理代码块的关联关系,将每个关联代码块的索引呈现在所述依赖组、所述被依赖组或所述相似组中。
  4. 根据权利要求1-3任一项所述的方法,其特征在于,所述在所述用户界面呈现所述待处理代码块的N个关联代码块的索引之前,还包括:
    从所述第一冲突文件中确定所述待处理代码块的至少一个关联代码块。
  5. 根据权利要求1-4任一项所述的方法,其特征在于,所述在所述用户界面呈现所述待处理代码块的N个关联代码块的索引之前,还包括:
    获取第二冲突文件;
    从所述第二冲突文件中确定与所述待处理代码块的至少一个关联代码块。
  6. 根据权利要求4所述的方法,其特征在于,所述从所述第一冲突文件中确定所述待处理代码块的至少一个关联代码块,包括:
    根据所述待处理代码块中的变量和/或函数在所述第一冲突文件的其他代码块中的利用情况,从所述第一冲突文件中确定与所述待处理代码块有依赖关系和被依赖关系的关联代码块;和/或
    根据所述待处理代码块包含的代码片段各自对应的Token串和抽象语法子树,从所述第一冲突文件中确定与所述待处理代码块有相似关系的关联代码块。
  7. 一种终端设备,其特征在于,包括:
    获取模块,用于获取第一冲突文件,所述第一冲突文件中包括多个代码块,每个代码块包括所述代码块当前版本的代码片段、所述代码块基础版本的代码片段和所述代码块待合并版本的代码片段;
    接收模块,用于接收用户界面触发的用于激活待处理代码块的第一指令,所述待处理代码块的类型为未消解冲突块或者单方变更块;
    呈现模块,用于在所述用户界面呈现所述待处理代码块包含的代码片段以及所述待处理代码块的N个关联代码块的索引;
    其中,每个关联代码块的类型为未消解冲突块、单方变更块和已消解冲突块中的一种,每个关联代码块与所述待处理代码块的关联关系为依赖关系、被依赖关系和相似关系中的一种,N大于等于1。
  8. 根据权利要求7所述的终端设备,其特征在于,
    所述接收模块还用于:接收所述用户界面触发的用于激活任一关联代码块的第二指令;
    所述呈现模块还用于:将所述用户界面呈现的所述待处理代码块包含的代码片段跳转为所述关联代码块包含的代码片段。
  9. 根据权利要求7或8所述的终端设备,其特征在于,所述用户界面设有依赖组、被依赖组和相似组;所述呈现模块具体用于:
    根据每个关联代码块与所述待处理代码块的关联关系,将每个关联代码块的索引呈现在所述依赖组、所述被依赖组或所述相似组中。
  10. 根据权利要求7-9任一项所述的终端设备,其特征在于,所述终端设备还包括:依赖关系分析模块和相似关系分析模块;
    所述依赖关系分析模块和所述相似关系分析模块用于:从所述第一冲突文件中确定所述待处理代码块的至少一个关联代码块。
  11. 根据权利要求7-10任一项所述的终端设备,其特征在于,
    所述获取模块还用于:获取第二冲突文件;
    所述依赖关系分析模块和所述相似关系分析模块还用于:从所述第二冲突文件中确定与所述待处理代码块的至少一个关联代码块。
  12. 根据权利要求10所述的终端设备,其特征在于,所述依赖关系分析模块和相似关系分析模块具体用于:
    根据所述待处理代码块中的变量和/或函数在所述第一冲突文件的其他代码块中的利用情况,从所述第一冲突文件中确定与所述待处理代码块有依赖关系和被依赖关系的关联代码块;和/或
    根据所述待处理代码块包含的代码片段各自对应的Token串和抽象语法子树,从所述第一冲突文件中确定与所述待处理代码块有相似关系的关联代码块。
  13. 一种终端设备,其特征在于,包括:存储器和处理器;
    所述存储器用于存储程序指令,所述处理器用于调用所述存储器中的程序指令执行权利要求1-6任一项所述的方法。
  14. 一种可读存储介质,其特征在于,所述可读存储介质上存储有计算机程序;所述计算机程序在被执行时,实现上述权利要求1-6任一项所述的方法。
PCT/CN2020/114557 2019-12-31 2020-09-10 关联冲突块呈现方法和设备 WO2021135373A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP20908909.3A EP4071598A4 (en) 2019-12-31 2020-09-10 METHOD AND DEVICE FOR REPRESENTING CONFLICT BLOCKS
US17/852,721 US20220334812A1 (en) 2019-12-31 2022-06-29 Method for Presenting Associated Conflict Block and Device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911417340.3A CN111190583B (zh) 2019-12-31 2019-12-31 关联冲突块呈现方法和设备
CN201911417340.3 2019-12-31

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/852,721 Continuation US20220334812A1 (en) 2019-12-31 2022-06-29 Method for Presenting Associated Conflict Block and Device

Publications (1)

Publication Number Publication Date
WO2021135373A1 true WO2021135373A1 (zh) 2021-07-08

Family

ID=70710570

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/114557 WO2021135373A1 (zh) 2019-12-31 2020-09-10 关联冲突块呈现方法和设备

Country Status (4)

Country Link
US (1) US20220334812A1 (zh)
EP (1) EP4071598A4 (zh)
CN (1) CN111190583B (zh)
WO (1) WO2021135373A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111190583B (zh) * 2019-12-31 2021-10-22 华为技术有限公司 关联冲突块呈现方法和设备
CN112363719A (zh) * 2020-11-23 2021-02-12 百度在线网络技术(北京)有限公司 小程序模板的合并方法、装置、设备及存储介质
CN114637510A (zh) * 2020-12-16 2022-06-17 华为云计算技术有限公司 代码分析的方法和相关设备
CN114675839B (zh) * 2022-05-30 2022-08-30 炫彩互动网络科技有限公司 一种基于有向图的代码仓库Java冲突文件排序分组方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105183789A (zh) * 2015-08-21 2015-12-23 福建天晴数码有限公司 基于git源代码冲突的文件合并方法及***
CN106126410A (zh) * 2016-05-26 2016-11-16 华为技术有限公司 代码冲突的提示方法及装置
US20190339964A1 (en) * 2018-05-02 2019-11-07 Microsoft Technology Licensing, Llc Pending merge conflict notification
CN110489087A (zh) * 2019-07-31 2019-11-22 北京字节跳动网络技术有限公司 一种生成分形结构的方法、装置、介质和电子设备
CN111190583A (zh) * 2019-12-31 2020-05-22 华为技术有限公司 关联冲突块呈现方法和设备

Family Cites Families (29)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101697121A (zh) * 2009-10-26 2010-04-21 哈尔滨工业大学 一种基于程序源代码语义分析的代码相似度检测方法
US9110769B2 (en) * 2010-04-01 2015-08-18 Microsoft Technology Licensing, Llc Code-clone detection and analysis
US8719239B2 (en) * 2010-07-16 2014-05-06 International Business Machines Corporation Displaying changes to versioned files
US20120159434A1 (en) * 2010-12-20 2012-06-21 Microsoft Corporation Code clone notification and architectural change visualization
US10957310B1 (en) * 2012-07-23 2021-03-23 Soundhound, Inc. Integrated programming framework for speech and text understanding with meaning parsing
CN105229617A (zh) * 2013-05-21 2016-01-06 肯赛里克斯公司 用于导航应用代码的图表
US9122561B2 (en) * 2013-09-24 2015-09-01 International Business Machines Corporation Program integration that accommodates restrictions on merge-locations
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
US9448769B1 (en) * 2015-03-30 2016-09-20 International Business Machines Corporation Employing code overlays to facilitate software development
US9921828B2 (en) * 2015-09-22 2018-03-20 Oracle International Corporation Merging versions of an inclusion application that is incorporated into a master application
US9804829B2 (en) * 2016-03-31 2017-10-31 Ca, Inc. Interface definition language compiler with version reconciliation
CN108073501B (zh) * 2016-11-14 2021-08-13 阿里巴巴集团控股有限公司 一种代码冲突检测方法及设备
US10579368B2 (en) * 2017-03-10 2020-03-03 Salesforce.Com, Inc. Blockchain version control systems
US10146530B1 (en) * 2017-07-12 2018-12-04 International Business Machines Corporation Simulating and evaluating code branch merge
CN109308253B (zh) * 2017-07-27 2022-07-12 华为终端有限公司 一种代码检测方法及装置
CN110147407B (zh) * 2017-09-29 2023-02-14 华为技术有限公司 一种数据处理方法、装置及数据库管理服务器
US10877746B2 (en) * 2018-05-06 2020-12-29 Methodics, Inc. Component dependency tree normalization through contextual dependency
US10789054B2 (en) * 2018-05-24 2020-09-29 Find it EZ Software Corp. Methods, systems, apparatuses and devices for facilitating change impact analysis (CIA) using modular program dependency graphs
US10719336B1 (en) * 2019-05-14 2020-07-21 Microsoft Technology Licensing, Llc Dependency version conflict auto-resolution
US11144311B2 (en) * 2019-05-17 2021-10-12 Sap Se Static analysis of higher-order merge conflicts in large software development projects
CN111176983B (zh) * 2019-10-18 2021-10-22 华为技术有限公司 一种代码冲突消解***、方法、装置、设备及介质
CN111221566B (zh) * 2019-12-28 2021-10-22 华为技术有限公司 一种软件代码的多变更版本合并方法及装置
US11205146B2 (en) * 2020-02-14 2021-12-21 Atlassian Pty Ltd. Computer implemented methods and systems for project management
US11354118B2 (en) * 2020-06-05 2022-06-07 Cross Vista, Inc. Version control system
US11175972B1 (en) * 2021-02-24 2021-11-16 Contentful GmbH Application framework for integrating APPs for editing content of a content management system
CN115469844A (zh) * 2021-06-10 2022-12-13 华为云计算技术有限公司 代码处理方法、***、计算机集群、介质及程序产品
US11853746B2 (en) * 2022-03-01 2023-12-26 Microsoft Technology Licensing, Llc Source code merge conflict resolution
CN115098109A (zh) * 2022-06-24 2022-09-23 南京邮电大学 一种基于有向图的代码仓库代码块级别冲突排序分组方法
US12013946B2 (en) * 2022-07-19 2024-06-18 Dell Products L.P. Baseboard memory controller (BMC) reliability availability and serviceability (RAS) driver firmware update via basic input/output system (BIOS) update release

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105183789A (zh) * 2015-08-21 2015-12-23 福建天晴数码有限公司 基于git源代码冲突的文件合并方法及***
CN106126410A (zh) * 2016-05-26 2016-11-16 华为技术有限公司 代码冲突的提示方法及装置
US20190339964A1 (en) * 2018-05-02 2019-11-07 Microsoft Technology Licensing, Llc Pending merge conflict notification
CN110489087A (zh) * 2019-07-31 2019-11-22 北京字节跳动网络技术有限公司 一种生成分形结构的方法、装置、介质和电子设备
CN111190583A (zh) * 2019-12-31 2020-05-22 华为技术有限公司 关联冲突块呈现方法和设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4071598A4

Also Published As

Publication number Publication date
CN111190583A (zh) 2020-05-22
EP4071598A1 (en) 2022-10-12
US20220334812A1 (en) 2022-10-20
CN111190583B (zh) 2021-10-22
EP4071598A4 (en) 2023-02-08

Similar Documents

Publication Publication Date Title
WO2021135373A1 (zh) 关联冲突块呈现方法和设备
CN108197311B (zh) 房源数据聚合展示方法、装置、设备及可读存储介质
TW201814565A (zh) Sql審核方法和裝置
TW201322024A (zh) 資料集和資料服務的上下文趨向
US10824345B2 (en) Systems and methods for storing object state on hash chains
WO2019169723A1 (zh) 测试用例选择方法、装置、设备以及计算机可读存储介质
CN109491736B (zh) 一种弹框窗口的显示方法及设备
US11386067B2 (en) Data integrity checking in a distributed filesystem using object versioning
WO2019161620A1 (zh) 应用依赖关系更新方法、终端、设备及存储介质
CN111737137A (zh) 接口测试数据生成方法、装置、主机及存储介质
CN113672628A (zh) 数据血缘分析方法、终端设备及介质
CN111563015A (zh) 数据监控方法及装置、计算机可读介质及终端设备
CN112925954A (zh) 用于在图数据库中查询数据的方法和装置
US10372760B2 (en) Building queries directed to objects hosted on clouds
US9195763B2 (en) Identifying unknown parameter and name value pairs
CN112559913B (zh) 一种数据处理方法、装置、计算设备及可读存储介质
WO2018145574A1 (zh) 一种信息处理方法及装置、终端、服务器、存储介质
WO2017097102A1 (zh) 检索方法和检索装置
CN113806647A (zh) 识别开发框架的方法及相关设备
CN111078671A (zh) 数据表字段的修改方法、装置、设备和介质
US20150347402A1 (en) System and method for enabling a client system to generate file system operations on a file system data set using a virtual namespace
WO2017175247A1 (en) Method and system for generating content from search results rendered by a search engine
JP6646699B2 (ja) 検索装置及び検索方法
US9037551B2 (en) Redundant attribute values
JP4690232B2 (ja) 情報処理装置、ソフトウェア登録方法およびプログラム

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: 20908909

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020908909

Country of ref document: EP

Effective date: 20220704

NENP Non-entry into the national phase

Ref country code: DE