Code file merging method and apparatus, storage medium and computer device
By sorting attributes of JSON files and comparing them step by step, and automatically selecting the target code with editing information, efficient merging of multiple versions of files is achieved, the problem of inaccurate line-by-line identification is solved, and the efficiency of code file merging is improved.
Patent Information
- Application Number
- PCT/CN2023/125910
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-19
- Filing Date
- 2023-10-23
- Publication Date
- 2024-11-28
AI Technical Summary
In the process of merging multiple versions of JSON files, line-by-line comparison leads to inaccurate identification, relying on manual intervention, and lack of efficient automation solutions.
By obtaining the initial code file to be merged, sorting it according to the target attributes, tiling and comparing the code files step by step, determining the target code based on the editing information of the differentiated code, reverse assembly and merging, and generating the final target code file.
Improve the accuracy and efficiency of code file merging, reduce manual intervention, and automate the merging process of multi-version files.
Smart Images

Figure CN2023125910_28112024_PF_FP_ABST
Abstract
Description
Code file merging method and device, storage medium, and computer equipment
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on May 19, 2023, with application number 202310567287.5, and invention name “Code file merging method and device, storage medium, and computer equipment”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of computer technology, and in particular to a code file merging method and device, a storage medium, and a computer device. Background Art
[0003] With the continuous development of computer technology, people's work and lives are increasingly dependent on digital applications, and program development has become widespread in all fields. Take JSON file development as an example. JSON (Java Script Object Notation) is a lightweight data exchange format. Based on a subset of ECMAScript (the JS specification developed by the European Computer Manufacturers Association), it uses a text format that is completely independent of the programming language to store and represent data.
[0004] During the development process, JSON is edited using various tools. When parallel development occurs, multiple versions of the JSON file are generated. As different developers work on the same or different parts of the file, these versions often need to be merged. Currently, merging multiple versions of code files involves using a plugin to compare the code line by line across files, identifying any differences. Then, technicians select the final code they want to retain from the differences and merge the code files.
[0005] However, due to the varying coding habits of different programmers, this line-by-line recognition approach often suffers from inaccuracies. In practice, code comparison across multiple files and the selection of retained code are often done manually. Currently, no effective solution has been found for merging multiple versions of code files.
[0006] Application Contents
[0007] In view of this, the present application provides a code file merging method and apparatus, a storage medium, and a computer device, which solve the problem of merging multiple versions of code files and improve the efficiency of code file merging.
[0008] According to one aspect of the present application, a code file merging method is provided, the method comprising:
[0009] Acquire multiple initial code files to be merged, and arrange the arrays in each of the initial code files according to the target arrangement attribute to obtain an intermediate code file;
[0010] For each intermediate code file, based on the code nesting relationship in the intermediate code file, the codes in the same nest are tiled at the same level to form a tiled code file corresponding to the intermediate code file;
[0011] Comparing the tiled code files corresponding to the plurality of intermediate code files level by level, marking the differentiated codes in the codes at each level of the plurality of tiled code files, and determining the target code in each level of the differentiated codes based on the file editing information of the initial code files corresponding to the differentiated codes;
[0012] The tiled code files are merged based on the target code to obtain a merged code file, and the merged code file is reversely assembled according to the code nesting relationship corresponding to each level of code in the merged code file to obtain a target code file.
[0013] In some embodiments, the plurality of initial code files include a base code file and at least two edited code files corresponding to the base code file; and the step of comparing the tiled code files corresponding to the plurality of intermediate code files level by level and marking the differentiated codes in the codes at each level of the plurality of tiled code files includes:
[0014] Comparing the edited tiled code file corresponding to each of the edited code files with the base tiled code file corresponding to the base code file level by level, and marking any level of code in the edited tiled code file as a differentiated code when any level of code is identified to be different;
[0015] Accordingly, the determining of the target code in each level of the differentiated code based on the file editing information of the initial code file corresponding to the differentiated code includes:
[0016] Identify the number of files marked as differential code at each level of code;
[0017] If the number of files of differential codes corresponding to any level of code is 0, the code of that level in any tiled code file is used as the target code of that level;
[0018] If the number of differential code files corresponding to any level of code is 1, the differential code is used as the target code of that level;
[0019] If the number of differential code files corresponding to any level of code is greater than 1, the target code in the differential code of this level is determined based on the file editing information of the initial code files corresponding to each differential code of this level, wherein the text editing information includes the editing time and / or the identity of the editor.
[0020] In some embodiments, the text editing information includes the editing time and the identity of the editor;
[0021] The determining of the target code in the differential code of the level based on the file editing information corresponding to each differential code of the level includes:
[0022] Based on the editing time of the initial code files corresponding to the differential codes of the level, the differential code with the latest editing time is used as the target code;
[0023] If there are multiple differential codes with the latest editing time, the target code is determined based on the corresponding editor identity.
[0024] In some embodiments, after reverse assembling the merged code file to obtain the target code file, the method further includes:
[0025] generating, based on the target code file and the edited code file, a modification description for each of the edited code files, wherein the modification description includes the original code of the modified portion in the edited code file and the revised code corresponding to the original code;
[0026] The modification description is sent to a first editor terminal corresponding to the edited code file.
[0027] In some embodiments, after sending the modification instructions to the editor terminal corresponding to the edited code file, the method further includes:
[0028] If feedback information indicating a proposed rejection of the modification description is received, determining a proposed rejection revision code in the revision code based on the proposed rejection feedback information;
[0029] querying a second editor terminal corresponding to the proposed rejection revision code, and forwarding the proposed rejection feedback information to the second editor terminal;
[0030] When code confirmation information is received from the first editor terminal or the second editor terminal, the target code file is updated based on the final code corresponding to the proposed rejected revision code carried in the code confirmation information, wherein the code confirmation information is information jointly confirmed by the first editor terminal and the second editor terminal.
[0031] In some embodiments, obtaining a plurality of initial code files to be merged includes:
[0032] Obtain a base code file and at least two edited code files of a current version from a code database as the initial code files;
[0033] Accordingly, the method further comprises:
[0034] The target code file is stored in the code database as a base code file for a next version.
[0035] In some embodiments, before tiling the codes in the same nesting at the same level based on the code nesting relationship in the intermediate code file, the method further includes:
[0036] Identifying a code type corresponding to the initial code file, and obtaining a code nesting rule corresponding to the code type;
[0037] Based on the code nesting rule, identifying the code nesting relationship in the intermediate code file;
[0038] Accordingly, the reverse assembly of the merged code file to obtain the target code file according to the code nesting relationship corresponding to each level of code in the merged code file includes:
[0039] Obtain the reverse assembly rules corresponding to the code type;
[0040] According to the code nesting relationship corresponding to each level of code in the merged code file, the reverse assembly method corresponding to the code nesting relationship is searched in the reverse assembly rule, and the merged code file is reverse assembled based on the reverse assembly method to obtain the target code file.
[0041] In some embodiments, the method further comprises:
[0042] Determining at least one code type to be converted, and obtaining a conversion rule from the code type of the target code file to each of the code types to be converted;
[0043] Based on the conversion rule, the target code file is converted into a type to obtain a code conversion file of each type of the code to be converted.
[0044] According to another aspect of the present application, a code file merging device is provided, the device comprising:
[0045] An acquisition module, configured to acquire a plurality of initial code files to be merged, and arrange the arrays in each of the initial code files according to a target arrangement attribute to obtain an intermediate code file;
[0046] A tiling module is configured to, for each intermediate code file, tile the codes in the same nest at the same level based on the code nesting relationship in the intermediate code file to form a tiled code file corresponding to the intermediate code file;
[0047] a comparison module, configured to compare the tiled code files corresponding to the plurality of intermediate code files level by level, mark the differentiated codes in the codes at each level of the plurality of tiled code files, and determine the target code in each level of the differentiated codes based on the file editing information of the initial code files corresponding to the differentiated codes;
[0048] An assembly module is used to merge the tiled code files based on the target code to obtain a merged code file, and reversely assemble the merged code file according to the code nesting relationship corresponding to each level of code in the merged code file to obtain a target code file.
[0049] In some embodiments, the plurality of initial code files include a base code file and at least two edited code files corresponding to the base code file; and the comparison module is further configured to:
[0050] Comparing the edited tiled code file corresponding to each of the edited code files with the base tiled code file corresponding to the base code file level by level, and marking any level of code in the edited tiled code file as a differentiated code when any level of code is identified to be different;
[0051] Identify the number of files marked as differential code at each level of code;
[0052] If the number of files of differential codes corresponding to any level of code is 0, the code of that level in any tiled code file is used as the target code of that level;
[0053] If the number of differential code files corresponding to any level of code is 1, the differential code is used as the target code of that level;
[0054] If the number of differential code files corresponding to any level of code is greater than 1, the target code in the differential code of this level is determined based on the file editing information of the initial code files corresponding to each differential code of this level, wherein the text editing information includes the editing time and / or the identity of the editor.
[0055] In some embodiments, the text editing information includes editing time and editor identity; the comparison module is further configured to:
[0056] Based on the editing time of the initial code files corresponding to the differential codes of the level, the differential code with the latest editing time is used as the target code;
[0057] If there are multiple differential codes with the latest editing time, the target code is determined based on the corresponding editor identity.
[0058] In some embodiments, the apparatus further includes a sending module configured to:
[0059] generating, based on the target code file and the edited code file, a modification description for each of the edited code files, wherein the modification description includes the original code of the modified portion in the edited code file and the revised code corresponding to the original code;
[0060] The modification description is sent to a first editor terminal corresponding to the edited code file.
[0061] In some embodiments, the sending module is further configured to:
[0062] If feedback information indicating a proposed rejection of the modification description is received, determining a proposed rejection revision code in the revision code based on the proposed rejection feedback information;
[0063] querying a second editor terminal corresponding to the proposed rejection revision code, and forwarding the proposed rejection feedback information to the second editor terminal;
[0064] The assembly module is further configured to update the target code file based on the final code corresponding to the proposed rejected revision code carried in the code confirmation information when receiving code confirmation information from the first editor terminal or the second editor terminal, wherein the code confirmation information is information jointly confirmed by the first editor terminal and the second editor terminal.
[0065] In some embodiments, the acquisition module is further configured to: acquire a base code file and at least two edited code files of a current version from a code database as the initial code file;
[0066] Correspondingly, the device further includes: a storage module, configured to store the target code file as a base code file of a next version in the code database.
[0067] In some embodiments, the tiling module is further configured to: before tiling the codes in the same nest at the same level based on the code nesting relationship in the intermediate code file, identify the code type corresponding to the initial code file and obtain a code nesting rule corresponding to the code type; and identify the code nesting relationship in the intermediate code file based on the code nesting rule;
[0068] Correspondingly, the assembly module is also used to: obtain the reverse assembly rules corresponding to the code type; based on the code nesting relationship corresponding to the codes at each level in the merged code file, query the reverse assembly method corresponding to the code nesting relationship in the reverse assembly rules, and reverse assemble the merged code file based on the reverse assembly method to obtain the target code file.
[0069] In some embodiments, the apparatus further comprises: a conversion module configured to:
[0070] Determining at least one code type to be converted, and obtaining a conversion rule from the code type of the target code file to each of the code types to be converted;
[0071] Based on the conversion rule, the target code file is converted into a type to obtain a code conversion file of each type of the code to be converted.
[0072] According to another aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the above-mentioned code file merging method is implemented.
[0073] According to another aspect of the present application, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the above-mentioned code file merging method when executing the program.
[0074] By means of the above technical solution, the present application provides a code file merging method and device, storage medium, and computer equipment. For multiple code files to be merged, the array is first sorted according to the attribute rules, and then the sorted code files are tiled step by step according to the code nesting attributes, so that the differentiated codes in the code files are identified and the target codes therein are determined by comparing the tiled code files step by step, and then the code files are merged based on the target codes, and the merged code files are reversely assembled to obtain the final merged target code files. The embodiment of the present application sorts the codes by attributes and tiles the codes step by step using the code nesting relationship, thereby performing a step-by-step comparison of multiple code files, which helps to solve the problem of poor recognition accuracy caused by the current line-by-line recognition of differentiated codes, and automatically selects the target code to be retained using the file editing information of the code file, further reducing the workload of manual selection, thereby solving the problem of merging multiple versions of code files and improving the efficiency of code file merging.
[0075] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0077] FIG1 is a schematic diagram showing a flow chart of a code file merging method provided in an embodiment of the present application;
[0078] FIG2 shows a code example of an initial code file provided in an embodiment of the present application;
[0079] FIG3 shows a code example of an intermediate code file provided in an embodiment of the present application;
[0080] FIG4 shows a code example of a tiled code file provided in an embodiment of the present application;
[0081] FIG5 shows a code example of a merged code file provided in an embodiment of the present application;
[0082] FIG6 shows a code example of a target code file obtained after merging provided in an embodiment of the present application;
[0083] [Corrected 07.11.2023 according to Rule 91] FIG7 shows a flow chart of another code file merging method provided in an embodiment of the present application;
[0084] FIG8 shows a schematic structural diagram of a code file merging device provided in an embodiment of the present application;
[0085] FIG9 shows a schematic diagram of the device structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0086] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that, unless there is a conflict, the embodiments and features in the embodiments of the present application can be combined with each other.
[0087] In this embodiment, a code file merging method is provided, as shown in FIG1 , the method includes:
[0088] Step 101 : obtaining a plurality of initial code files to be merged, and arranging the arrays in each of the initial code files according to a target arrangement attribute to obtain an intermediate code file.
[0089] The embodiments of the present application are used to merge multiple code files that have certain differences after secondary modifications are made to the same original code file. First, multiple initial code files to be merged, such as JSON files, are obtained, and the arrays in each initial code file are arranged according to the same target arrangement properties to obtain an intermediate code file after arrangement. Figure 2 shows code examples from three initial code files, and Figure 3 shows code examples from the sorted intermediate code file.
[0090] Step 102 : for each intermediate code file, based on the code nesting relationship in the intermediate code file, flatten the codes in the same nesting at the same level to form a flattened code file corresponding to the intermediate code file.
[0091] Next, each intermediate code file is flattened according to the code nesting relationship. Code belonging to the same nesting is flattened at the same level. Code at the same level is presented in rows, forming a flattened code file. Figure 4 shows an example of code in a flattened code file.
[0092] Step 103: perform a level-by-level comparison on the tiled code files corresponding to each of the plurality of intermediate code files, mark the differentiated codes in the codes at each level of the plurality of tiled code files, and determine the target code in each level of the differentiated code based on the file editing information of the initial code files corresponding to the differentiated codes.
[0093] Then, after tiling, the codes of each tiled code file are compared level by level to find the differentiated codes that are different in each level. Specifically, one of the codes can be used as the basis and the other codes can be compared with the basic code. For example, as shown in FIG4 , the first code is used as the basic code, and the third code is not exactly the same as the first-level code in the first code. Therefore, the first-level code in the third code can be marked as differentiated code. Furthermore, the differentiated codes in each tiled code file are combined to determine the final target code of each level. For example, in the code example shown in FIG4 , the first-level code in the third code is marked as differentiated code. Then, the differentiated code in the third code (i.e., the first-level code in the third code) can be used as the final first-level target code. The codes at other levels remain unchanged if there is no difference.
[0094] Step 104 : Based on the target code, the tiled code files are merged to obtain a merged code file, and according to the code nesting relationship corresponding to each level of code in the merged code file, the merged code file is reversely assembled to obtain a target code file.
[0095] Finally, after determining the final target code for each level, the tiled code files are merged based on the target code for each level to obtain a merged code file. For example, as shown in Figure 4, based on the first code, the first-level code in the third code is replaced with the first-level code in the first code. The remaining levels of code are identical and are not processed. Figure 5 shows a code example in the merged code file. After obtaining the merged code file, the code is reverse-assembled based on the code nesting relationship corresponding to each level of code to return it to its original form. Figure 6 shows a code example of the target code file obtained after reverse assembly.
[0096] By applying the technical solution of this embodiment, for multiple code files to be merged, the arrays are first sorted according to the attribute rules, and then the sorted code files are tiled step by step according to the code nesting attributes, so that the differentiated codes in the code files are identified and the target codes therein are determined by comparing the tiled code files step by step, and then the code files are merged based on the target codes, and the merged code files are assembled in reverse order to obtain the final merged target code files. The embodiment of the present application sorts the codes by attributes and tiles the codes step by step using the code nesting relationship, thereby performing a step-by-step comparison of multiple code files, which helps to solve the problem of poor recognition accuracy caused by the current line-by-line identification of differentiated codes, and automatically selects the target code to be retained using the file editing information of the code files, further reducing the workload of manual selection, thereby solving the problem of merging multiple versions of code files and improving the efficiency of merging code files.
[0097] Furthermore, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, another code file merging method is provided, as shown in FIG7 , the method includes:
[0098] Step 201: Obtain a base code file and at least two edited code files of the current version from a code database as the initial code files, and arrange the arrays in each of the initial code files according to target arrangement attributes to obtain intermediate code files; the multiple initial code files include a base code file and at least two edited code files corresponding to the base code file.
[0099] In this embodiment of the present application, the multiple initial code files to be merged include a base code file and at least two edited code files that are secondary developed based on the base code file. Each initial code file is stored in a code database. After obtaining each initial code file, each initial code file is first sorted according to the target arrangement attribute to obtain an intermediate code file corresponding to each initial code file.
[0100] Step 202: Identify the code type corresponding to the initial code file and obtain the code nesting rules corresponding to the code type; for each intermediate code file, identify the code nesting relationship in the intermediate code file based on the code nesting rules; based on the code nesting relationship in the intermediate code file, tile the codes in the same nest at the same level to form a tiled code file corresponding to the intermediate code file.
[0101] In this embodiment, since the encoding rules of different types of codes are different, the code nesting rules that match the code type can be obtained according to the code type of the initial code file, such as obtaining the code nesting rules of the JSON type, so as to identify the code nesting relationship of the intermediate code file based on the code nesting rules, and flatten the codes of the same level, and flatten the codes belonging to the same level in one row for presentation.
[0102] Step 203 : Compare the edited tiled code file corresponding to each of the edited code files with the basic tiled code file corresponding to the basic code file level by level, and when any level of code is identified as different, mark any level of code in the edited tiled code file as differential code.
[0103] In this embodiment, after code tiling is performed, the tiled code files corresponding to each edited code file are compared with the tiled code files corresponding to the base code file. Specifically, as shown in FIG4 , the first is the tiled code file corresponding to the base code file, and the second and third are the tiled code files corresponding to the edited code files. The second and third files are compared with the first file respectively. If there is a difference between the first-level code of the second file and the first-level code of the first file, the difference in the first-level code of the second file is marked as a differential code, i.e., the "small cherry" is marked therein. If there is a difference between the first-level code of the third file and the first-level code of the first file, the difference in the first-level code of the third file is marked as a differential code, i.e., the "big apple" is marked therein. If the codes of the remaining levels are the same, no marking is done.
[0104] Step 204 : Identify the number of files marked as differential codes in each level of code.
[0105] Step 205: If the number of differential code files corresponding to any level of code is 0, the code of that level in any tiled code file is used as the target code of that level.
[0106] Step 206: If the number of differential code files corresponding to any level of code is 1, the differential code is used as the target code of that level.
[0107] Step 207: If the number of files of differential codes corresponding to any level of code is greater than 1, the target code in the differential code of that level is determined based on the file editing information of the initial code files corresponding to each differential code of that level, wherein the text editing information includes the editing time and / or the identity of the editor.
[0108] In this embodiment, when selecting the code that you ultimately want to use in each level, you can identify the number of differential codes level by level. Continuing with the above example, if the first-level codes in the second and third files are both marked as differential codes, then the number of files corresponding to the first-level code is determined to be 2, and if neither the second-level code nor the third-level code is marked, then the number of files corresponding to the second-level code and the third-level code is determined to be 0. Furthermore, if the number of differential code files corresponding to a certain level of code is 0, it means that the line of code in each file is the same, and the code at this level does not need to be changed; if the number of differential code files corresponding to a certain level of code is 1, it means that only one code file has modified the code at this level based on the basic code file, then the only modified code is directly selected as the final target code at this level; if the number of differential code files corresponding to a certain level of code is greater than 1, it means that both edited codes have modified the basic code at this level, then the file editing information of the initial code file where the differential code is located should be referenced to determine the final target code.
[0109] In some embodiments of the present application, the text editing information includes the editing time and the identity of the editor; the target code in the differential code of this level is determined based on the file editing information corresponding to each differential code of this level, including: based on the editing time of the initial code file corresponding to each differential code of this level, the differential code with the latest editing time is used as the target code; if the differential code with the latest editing time includes multiple differential codes, the target code is determined based on the corresponding editor identity.
[0110] In the above embodiment, if the number of files corresponding to a level of differential code is greater than one, the differential code in the files corresponding to each differential code is identified as being in the same location, and modifications are made accordingly. As shown in Figure 4, if the second file modifies the base code "cherry" to "small cherry" and the third file does not modify this location, then the "small cherry" in the second file is directly used as the target code for that location. Similarly, if the third file modifies the base code "apple" to "big apple" and the second file does not modify this location, then the "big apple" in the third file is directly used as the target code for that location. If both the second and third files modify the code at the same location in the base code, for example, if both files modify the first-level code "banana" in the base code, then the file editing information of each file should be further considered, and the differential code with the latest editing time should be selected as the final target code for that location. Alternatively, if the editing time of the two files is the same, then the differential code corresponding to the higher-level editor identity should be selected as the final target code for that location.
[0111] Step 208: Merge the tiled code files based on the target code to obtain a merged code file; obtain the reverse assembly rule corresponding to the code type; query the reverse assembly method corresponding to the code nesting relationship in the reverse assembly rule based on the code nesting relationship corresponding to each level of code in the merged code file, and reverse assemble the merged code file based on the reverse assembly method to obtain the target code file.
[0112] Step 209: Store the target code file as a base code file for the next version in the code database.
[0113] In this embodiment, after determining the target code corresponding to each level of differentiated code, the tiled code file corresponding to the base code file can be used as a basis. The target code corresponding to the final differentiated code can be replaced with the corresponding position in the base code file to merge multiple versions of the file, resulting in a merged code file. Further, based on the code nesting relationship of each level of code in the merged code file, the corresponding reverse assembly method is queried, and the code is reversed and assembled level by level to obtain the final target code file. The target code file is stored in the code database as the new version of the base code file, so that developers can further develop on it.
[0114] In some embodiments of the present application, after obtaining the target code file, the method further includes:
[0115] S1. Based on the target code file and the edited code file, generate a modification description for each edited code file, wherein the modification description includes the original code of the modified part in the edited code file and the revised code corresponding to the original code; and send the modification description to the first editor terminal corresponding to the edited code file.
[0116] S2, if proposed rejection feedback information regarding the modification description is received, determining a proposed rejection revision code in the revision code based on the proposed rejection feedback information; querying a second editor terminal corresponding to the proposed rejection revision code, and forwarding the proposed rejection feedback information to the second editor terminal;
[0117] S3. When code confirmation information is received from the first editor terminal or the second editor terminal, the target code file is updated based on the final code corresponding to the proposed rejected revision code carried in the code confirmation information, wherein the code confirmation information is information jointly confirmed by the first editor terminal and the second editor terminal.
[0118] In the above embodiment, in the case where the code is modified, the editor of the modified code file can also be notified. Specifically, based on the differences between the target code file and the edited code file, a modification description of the edited code file is generated and sent to the corresponding first editor terminal. The description includes the original code originally edited (or originally not modified) by the editor and the revised code after the original code is modified. For example, editor 1 of the second file modifies "A" in the base code file to "B", and editor 2 of the third file modifies "A" in the base code file to "C", and finally determines "C" as the target code, and then sends the modification description to editor 1. If the first editor refuses to revise, that is, receives the intended rejection feedback information for the modification description, then the corresponding intended rejection feedback information can be sent to the second editor terminal corresponding to the intended rejection code, for example, editor 1's intended rejection feedback information 2 is sent to editor 2. Finally, after receiving the code confirmation information from the first editor terminal or the second editor terminal, the target code file will be confirmed or updated based on the confirmed final code, wherein the code confirmation information is jointly confirmed by the first and second editor terminals and can be issued by either party.
[0119] In some embodiments of the present application, after obtaining the target code file, it also includes: determining at least one code type to be converted, and obtaining a conversion rule of the code type of the target code file to each of the code types to be converted; based on the conversion rule, performing type conversion on the target code file to obtain a code conversion file for each of the code types to be converted.
[0120] In the above embodiment, after the final target code file is confirmed, in order to make the file applicable to more application scenarios, the target code file can also be converted into a format. Specifically, the target code file can be converted based on the conversion rules from the code type of the target code file to the code type to be converted. The specific method is not limited.
[0121] Furthermore, as a specific implementation of the method of FIG1 , an embodiment of the present application provides a code file merging device, as shown in FIG8 , which includes:
[0122] An acquisition module, configured to acquire a plurality of initial code files to be merged, and arrange the arrays in each of the initial code files according to a target arrangement attribute to obtain an intermediate code file;
[0123] A tiling module is configured to, for each intermediate code file, tile the codes in the same nest at the same level based on the code nesting relationship in the intermediate code file to form a tiled code file corresponding to the intermediate code file;
[0124] a comparison module, configured to compare the tiled code files corresponding to the plurality of intermediate code files level by level, mark the differentiated codes in the codes at each level of the plurality of tiled code files, and determine the target code in each level of the differentiated codes based on the file editing information of the initial code files corresponding to the differentiated codes;
[0125] An assembly module is used to merge the tiled code files based on the target code to obtain a merged code file, and reversely assemble the merged code file according to the code nesting relationship corresponding to each level of code in the merged code file to obtain a target code file.
[0126] In some embodiments, the plurality of initial code files include a base code file and at least two edited code files corresponding to the base code file; and the comparison module is further configured to:
[0127] Comparing the edited tiled code file corresponding to each of the edited code files with the base tiled code file corresponding to the base code file level by level, and marking any level of code in the edited tiled code file as a differentiated code when any level of code is identified to be different;
[0128] Identify the number of files marked as differential code at each level of code;
[0129] If the number of files of differential codes corresponding to any level of code is 0, the code of that level in any tiled code file is used as the target code of that level;
[0130] If the number of differential code files corresponding to any level of code is 1, the differential code is used as the target code of that level;
[0131] If the number of differential code files corresponding to any level of code is greater than 1, the target code in the differential code of this level is determined based on the file editing information of the initial code files corresponding to each differential code of this level, wherein the text editing information includes the editing time and / or the identity of the editor.
[0132] In some embodiments, the text editing information includes editing time and editor identity; the comparison module is further configured to:
[0133] Based on the editing time of the initial code files corresponding to the differential codes of the level, the differential code with the latest editing time is used as the target code;
[0134] If there are multiple differential codes with the latest editing time, the target code is determined based on the corresponding editor identity.
[0135] In some embodiments, the apparatus further includes a sending module configured to:
[0136] generating, based on the target code file and the edited code file, a modification description for each of the edited code files, wherein the modification description includes the original code of the modified portion in the edited code file and the revised code corresponding to the original code;
[0137] The modification description is sent to a first editor terminal corresponding to the edited code file.
[0138] In some embodiments, the sending module is further configured to:
[0139] If feedback information indicating a proposed rejection of the modification description is received, determining a proposed rejection revision code in the revision code based on the proposed rejection feedback information;
[0140] querying a second editor terminal corresponding to the proposed rejection revision code, and forwarding the proposed rejection feedback information to the second editor terminal;
[0141] The assembly module is further configured to update the target code file based on the final code corresponding to the proposed rejected revision code carried in the code confirmation information when receiving code confirmation information from the first editor terminal or the second editor terminal, wherein the code confirmation information is information jointly confirmed by the first editor terminal and the second editor terminal.
[0142] In some embodiments, the acquisition module is further configured to: acquire a base code file and at least two edited code files of a current version from a code database as the initial code file;
[0143] Correspondingly, the device further includes: a storage module, configured to store the target code file as a base code file of a next version in the code database.
[0144] In some embodiments, the tiling module is further configured to: before tiling the codes in the same nest at the same level based on the code nesting relationship in the intermediate code file, identify the code type corresponding to the initial code file and obtain a code nesting rule corresponding to the code type; and identify the code nesting relationship in the intermediate code file based on the code nesting rule;
[0145] Correspondingly, the assembly module is also used to: obtain the reverse assembly rules corresponding to the code type; based on the code nesting relationship corresponding to the codes at each level in the merged code file, query the reverse assembly method corresponding to the code nesting relationship in the reverse assembly rules, and reverse assemble the merged code file based on the reverse assembly method to obtain the target code file.
[0146] In some embodiments, the apparatus further comprises: a conversion module configured to:
[0147] Determining at least one code type to be converted, and obtaining a conversion rule from the code type of the target code file to each of the code types to be converted;
[0148] Based on the conversion rule, the target code file is converted into a type to obtain a code conversion file of each type of the code to be converted.
[0149] It should be noted that for other corresponding descriptions of the functional units involved in the code file merging device provided in an embodiment of the present application, reference can be made to the corresponding descriptions in the methods of Figures 1 to 7, and no further details will be given here.
[0150] The embodiment of the present application also provides a computer device, which can be specifically a personal computer, a server, a network device, etc. As shown in Figure 9, the computer device includes a bus, a processor, a memory and a communication interface, and may also include an input and output interface and a display device. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store location information. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in each method embodiment are implemented.
[0151] Those skilled in the art will understand that the structure shown in FIG9 is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0152] In one embodiment, a computer-readable storage medium is provided. The computer-readable storage medium may be non-volatile or volatile, and stores a computer program thereon. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0153] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the above-described method embodiments. Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.) or a volatile storage medium, and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0154] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0155] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.
[0156] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0157] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A code file merging method, wherein: The method comprises: Acquire multiple initial code files to be merged, and arrange the arrays in each of the initial code files according to the target arrangement attribute to obtain an intermediate code file; For each of the intermediate code files, based on the code nesting relationship in the intermediate code file, the codes in the same nesting are tiled at the same level to form a tiled code file corresponding to the intermediate code file; Compare the tiled code files corresponding to the plurality of intermediate code files level by level, mark the differential codes in the codes at each level of the plurality of tiled code files, and determine the target code in each level of differential code based on the file editing information of the initial code files corresponding to the differential codes; The tiled code files are merged based on the target code to obtain a merged code file, and the merged code file is reversely assembled according to the code nesting relationship corresponding to each level of code in the merged code file to obtain a target code file.
2. The method according to claim 1, wherein: The multiple initial code files include a basic code file and at least two edited code files corresponding to the basic code file; the step of comparing the tiled code files corresponding to the multiple intermediate code files level by level, and marking the differentiated codes in the codes at each level of the multiple tiled code files, includes: Comparing the edited tiled code file corresponding to each of the edited code files with the basic tiled code file corresponding to the basic code file level by level, and marking any level of code in the edited tiled code file as a differential code when any level of code is identified to be different; Accordingly, the determining of the target code in each level of the differential code based on the file editing information of the initial code file corresponding to the differential code includes: Identify the number of files marked as differential code at each level of code; If the number of files of differential codes corresponding to any level of code is 0, the code of that level in any tiled code file is used as the target code of that level; If the number of files of differential codes corresponding to any level of code is 1, the differential code is used as the target code of that level; If the number of files of differential codes corresponding to any level of code is greater than 1, the target code in the differential code of this level is determined based on the file editing information of the initial code files corresponding to each differential code of this level, wherein the text editing information includes the editing time and / or the identity of the editor.
3. The method according to claim 2, wherein: The text editing information includes editing time and editor identity; The determining the target code in the differential code of the level based on the file editing information corresponding to each differential code of the level includes: Based on the editing time of the initial code files corresponding to the differential codes of the level, the differential codes with the latest editing time are used as the target codes; If the differential code with the latest editing time includes multiple codes, the target code is determined based on the corresponding editor identity.
4. The method according to claim 2, wherein: After reverse assembling the merged code file to obtain the target code file, the method further includes: Based on the target code file and the edited code file, generating a modification description of each edited code file, wherein the modification description includes the original code of the modified part in the edited code file and the revised code corresponding to the original code; The modification description is sent to a first editor terminal corresponding to the edited code file.
5. The method according to claim 4, wherein: After sending the modification description to the editor terminal corresponding to the edited code file, the method further includes: If proposed rejection feedback information for the modification description is received, determining a proposed rejection revision code in the revision code based on the proposed rejection feedback information; querying a second editor terminal corresponding to the proposed rejection revision code, and forwarding the proposed rejection feedback information to the second editor terminal; When code confirmation information is received from the first editor terminal or the second editor terminal, the target code file is updated based on the final code corresponding to the proposed rejected revision code carried in the code confirmation information, wherein the code confirmation information is information jointly confirmed by the first editor terminal and the second editor terminal.
6. The method according to any one of claims 2 to 5, wherein: The step of obtaining a plurality of initial code files to be merged includes: Obtain a basic code file and at least two edited code files of the current version from a code database as the initial code files; Accordingly, the method further comprises: The target code file is stored in the code database as a base code file for a next version.
7. The method according to claim 6, wherein: Before tiling the codes in the same nesting in the same level based on the code nesting relationship in the intermediate code file, the method further includes: Identify the code type corresponding to the initial code file, and obtain the code nesting rule corresponding to the code type; Based on the code nesting rule, identifying the code nesting relationship in the intermediate code file; Accordingly, the reverse assembly of the merged code file to obtain the target code file according to the code nesting relationship corresponding to each level of code in the merged code file includes: Obtaining the reverse assembly rule corresponding to the code type; According to the code nesting relationship corresponding to each level of code in the merged code file, the reverse assembly method corresponding to the code nesting relationship is searched in the reverse assembly rule, and the merged code file is reversely assembled based on the reverse assembly method to obtain the target code file.
8. The method according to claim 6, wherein: The method further comprises: Determine at least one code type to be converted, and obtain a conversion rule from the code type of the target code file to each code type to be converted; Based on the conversion rule, the target code file is converted into a type to obtain a code conversion file of each type of the code to be converted.
9. A code file merging device, wherein: The device comprises: An acquisition module, used for acquiring a plurality of initial code files to be merged, and arranging the arrays in each of the initial code files according to the target arrangement attribute to obtain an intermediate code file; A tiling module, for tiling codes in the same nesting at the same level for each intermediate code file based on the code nesting relationship in the intermediate code file, to form a tiling code file corresponding to the intermediate code file; A comparison module, used to compare the tiled code files corresponding to the plurality of intermediate code files level by level, mark the differential codes in the codes at each level of the plurality of tiled code files, and determine the target code in each level of differential code based on the file editing information of the initial code files corresponding to the differential codes; An assembly module is used to merge the tiled code files based on the target code to obtain a merged code file, and to reversely assemble the merged code file according to the code nesting relationship corresponding to each level of code in the merged code file to obtain a target code file.
10. A computer-readable storage medium having a computer program stored thereon, wherein: When the computer program is executed by a processor, the following steps are implemented: Acquire multiple initial code files to be merged, and arrange the arrays in each of the initial code files according to the target arrangement attribute to obtain an intermediate code file; For each of the intermediate code files, based on the code nesting relationship in the intermediate code file, the codes in the same nesting are tiled at the same level to form a tiled code file corresponding to the intermediate code file; Comparing the tiled code files corresponding to the plurality of intermediate code files level by level, marking the differential codes in the codes at each level of the plurality of tiled code files, and determining the target code in each level of the differential code based on the file editing information of the initial code files corresponding to the differential codes; The tiled code files are merged based on the target code to obtain a merged code file, and the merged code file is reversely assembled according to the code nesting relationship corresponding to each level of code in the merged code file to obtain a target code file.
11. The computer-readable storage medium of claim 10, wherein: The plurality of initial code files include a basic code file and at least two edited code files corresponding to the basic code file; The step of comparing the tiled code files corresponding to the plurality of intermediate code files level by level, and marking the differentiated codes in the codes at each level of the plurality of tiled code files, comprises: Comparing the edited tiled code file corresponding to each of the edited code files with the basic tiled code file corresponding to the basic code file level by level, and marking any level of code in the edited tiled code file as a differential code when any level of code is identified to be different; Accordingly, the determining of the target code in each level of the differential code based on the file editing information of the initial code file corresponding to the differential code includes: Identify the number of files marked as differential code at each level of code; If the number of files of differential codes corresponding to any level of code is 0, the code of that level in any tiled code file is used as the target code of that level; If the number of files of differential codes corresponding to any level of code is 1, the differential code is used as the target code of that level; If the number of files of differential codes corresponding to any level of code is greater than 1, the target code in the differential code of this level is determined based on the file editing information of the initial code files corresponding to each differential code of this level, wherein the text editing information includes the editing time and / or the identity of the editor.
12. The computer-readable storage medium of claim 11, wherein: The text editing information includes editing time and editor identity; The determining the target code in the differential code of the level based on the file editing information corresponding to each differential code of the level includes: Based on the editing time of the initial code files corresponding to the differential codes of the level, the differential codes with the latest editing time are used as the target codes; If the differential code with the latest editing time includes multiple codes, the target code is determined based on the corresponding editor identity.
13. The computer-readable storage medium of claim 11, wherein: When the computer program is executed by a processor, the following steps are implemented: After the merged code file is reversely assembled to obtain a target code file, a modification description of each edited code file is generated based on the target code file and the edited code file, wherein the modification description includes the original code of the modified part in the edited code file and the revised code corresponding to the original code; The modification description is sent to a first editor terminal corresponding to the edited code file.
14. The computer-readable storage medium of claim 13, wherein: When the computer program is executed by a processor, the following steps are implemented: After sending the modification description to the editor terminal corresponding to the edited code file, if proposed rejection feedback information for the modification description is received, determining the proposed rejection revision code in the revision code based on the proposed rejection feedback information; querying a second editor terminal corresponding to the proposed rejection revision code, and forwarding the proposed rejection feedback information to the second editor terminal; When code confirmation information is received from the first editor terminal or the second editor terminal, the target code file is updated based on the final code corresponding to the proposed rejected revision code carried in the code confirmation information, wherein the code confirmation information is information jointly confirmed by the first editor terminal and the second editor terminal.
15. The computer-readable storage medium according to any one of claims 11 to 14, wherein: The step of obtaining a plurality of initial code files to be merged includes: Obtain a basic code file and at least two edited code files of the current version from a code database as the initial code files; Accordingly, the method further comprises: The target code file is stored in the code database as a base code file for a next version.
16. The computer-readable storage medium of claim 15, wherein: When the computer program is executed by a processor, the following steps are implemented: Before tiling the codes in the same nesting at the same level based on the code nesting relationship in the intermediate code file, identifying the code type corresponding to the initial code file and obtaining the code nesting rule corresponding to the code type; Based on the code nesting rule, identifying the code nesting relationship in the intermediate code file; Accordingly, the reverse assembly of the merged code file to obtain the target code file according to the code nesting relationship corresponding to each level of code in the merged code file includes: Obtaining the reverse assembly rule corresponding to the code type; According to the code nesting relationship corresponding to each level of code in the merged code file, the reverse assembly method corresponding to the code nesting relationship is searched in the reverse assembly rule, and the merged code file is reversely assembled based on the reverse assembly method to obtain the target code file.
17. The computer-readable storage medium of claim 15, wherein: When the computer program is executed by a processor, the following steps are implemented: Determine at least one code type to be converted, and obtain a conversion rule from the code type of the target code file to each code type to be converted; Based on the conversion rule, the target code file is converted into a type to obtain a code conversion file of each type of the code to be converted.
18. A computer device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.
19. A computer program product comprising a computer program, wherein: When the computer program is executed by a processor, the following steps are implemented: Acquire multiple initial code files to be merged, and arrange the arrays in each of the initial code files according to the target arrangement attribute to obtain an intermediate code file; For each of the intermediate code files, based on the code nesting relationship in the intermediate code file, the codes in the same nesting are tiled at the same level to form a tiled code file corresponding to the intermediate code file; Compare the tiled code files corresponding to the plurality of intermediate code files level by level, mark the differential codes in the codes at each level of the plurality of tiled code files, and determine the target code in each level of differential code based on the file editing information of the initial code files corresponding to the differential codes; The tiled code files are merged based on the target code to obtain a merged code file, and the merged code file is reversely assembled according to the code nesting relationship corresponding to each level of code in the merged code file to obtain a target code file.
20. The computer program product of claim 19, wherein: The plurality of initial code files include a basic code file and at least two edited code files corresponding to the basic code file; The step of comparing the tiled code files corresponding to the plurality of intermediate code files level by level, and marking the differentiated codes in the codes at each level of the plurality of tiled code files, comprises: Comparing the edited tiled code file corresponding to each of the edited code files with the basic tiled code file corresponding to the basic code file level by level, and marking any level of code in the edited tiled code file as a differential code when any level of code is identified to be different; Accordingly, the determining of the target code in each level of the differential code based on the file editing information of the initial code file corresponding to the differential code includes: Identify the number of files marked as differential code at each level of code; If the number of files of differential codes corresponding to any level of code is 0, the code of that level in any tiled code file is used as the target code of that level; If the number of files of differential codes corresponding to any level of code is 1, the differential code is used as the target code of that level; If the number of files of differential codes corresponding to any level of code is greater than 1, the target code in the differential code of this level is determined based on the file editing information of the initial code files corresponding to each differential code of this level, wherein the text editing information includes the editing time and / or the identity of the editor.
Citation Information
Patent Citations
Automatic code merging method and system
CN104461578A
Feature-based JSON consistency comparison detection method and system
CN114742028A
Code conflict merging method and system, electronic equipment and readable storage medium
CN114840250A
Code file merging method and device, storage medium and computer equipment
CN116302078A
Simulating and evaluating code branch merge
US10146530B1
