CN116302078A - Code file merging method and device, storage medium and computer equipment - Google Patents

Code file merging method and device, storage medium and computer equipment Download PDF

Info

Publication number
CN116302078A
CN116302078A CN202310567287.5A CN202310567287A CN116302078A CN 116302078 A CN116302078 A CN 116302078A CN 202310567287 A CN202310567287 A CN 202310567287A CN 116302078 A CN116302078 A CN 116302078A
Authority
CN
China
Prior art keywords
code
file
files
codes
level
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202310567287.5A
Other languages
Chinese (zh)
Other versions
CN116302078B (en
Inventor
潘孝
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
Original Assignee
Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
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 Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd filed Critical Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
Priority to CN202310567287.5A priority Critical patent/CN116302078B/en
Publication of CN116302078A publication Critical patent/CN116302078A/en
Application granted granted Critical
Publication of CN116302078B publication Critical patent/CN116302078B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/74Reverse engineering; Extracting design information from source code
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application discloses a code file merging method and device, a storage medium and computer equipment, wherein the method comprises the following steps: acquiring a plurality of initial code files to be combined, and respectively arranging an array in each initial code file according to a target arrangement attribute to acquire an intermediate code file; for each intermediate code file, based on the code nesting relation in the intermediate code file, the codes in the same nesting are tiled in the same level to form a tiled code file corresponding to the intermediate code file; step-by-step comparison is carried out on the tiled code files corresponding to the intermediate code files, the differentiated codes in the all-level codes of the tiled code files are marked, and the target codes in the differentiated codes of each level are determined based on the file editing information of the initial code file corresponding to the differentiated codes; and merging the tiled code files based on the target codes to obtain merged code files, and reversely assembling the merged code files to obtain the target code files.

Description

Code file merging method and device, storage medium and computer equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and apparatus for merging code files, a storage medium, and a computer device.
Background
With the continuous development of computer technology, people work and life increasingly depend on digital applications, and program development has been popularized in various fields. Taking JSON file development as an example, JSON (Java Script Object Notation, JS object profile) is a lightweight data exchange format. It stores and presents data in a text format that is completely independent of the programming language based on a subset of ECMAScript (European Computer Manufacturers Association, JS specification by the european computer institute).
In the development process, JSON is edited by some tools, when parallel development is encountered, multiple versions of the JSON file are generated, different developers develop the JSON file aiming at the same or different parts, and multiple versions of the JSON file are often required to be combined. At present, for the problem of merging code files of multiple versions, the codes in the files are compared line by line through a plug-in, codes with differences are identified, and then a technician selects a final code to be reserved from the difference codes, so that the code files are merged.
However, because coding habits of different program developers are different, the line-by-line identification method often has the problem of inaccurate identification, and in practical application, the work of comparing codes of multiple files and selecting reserved codes is mostly done manually. Currently, no good solution to the problem of merging code files for multiple versions is found.
Disclosure of Invention
In view of this, the present application provides a method and apparatus for merging code files, a storage medium, and a computer device, which solve the problem of merging code files of multiple versions, and improve the merging efficiency of code files.
According to one aspect of the present application, there is provided a code file merging method, the method comprising:
acquiring a plurality of initial code files to be combined, and respectively arranging an array in each initial code file according to a target arrangement attribute to acquire an intermediate code file;
for each intermediate code file, based on the code nesting relation in the intermediate code file, tiling codes in the same nesting in the same level to form a tiling code file corresponding to the intermediate code file;
step-by-step comparison is carried out on the tiled code files corresponding to the intermediate code files, differential codes in all levels of codes of the tiled code files are marked, and the target codes in all levels of differential codes are determined based on file editing information of the initial code files corresponding to the differential codes;
And merging the tiled code files based on the target codes to obtain merged code files, and reversely assembling the merged code files according to code nesting relations corresponding to all levels of codes in the merged code files to obtain the target code files.
Optionally, the plurality of initial code files include a base code file and at least two edited code files corresponding to the base code file; the step-by-step comparison is performed on the tiled code files corresponding to the intermediate code files, and the marking of the differentiated codes in the codes at each level of the tiled code files comprises the following steps:
step-by-step comparison is carried out on the edited tiled code files corresponding to the edited code files and the basic tiled code files corresponding to the basic code files respectively, and any level of code in the edited tiled code files is marked as a differential code when any level of code is identified to be different;
correspondingly, the determining the target code in each level of differential code based on the file editing information of the initial code file corresponding to the differential code comprises the following steps:
identifying the number of files in each level of code marked as differentiated code;
If the number of files of the differentiated codes corresponding to any level code is 0, taking the level code in any tiled code file as the target code of the level;
if the number of files of the differential codes corresponding to any level of codes is 1, taking the differential codes as target codes of the level;
if the number of files of the differential codes corresponding to any level of codes is greater than 1, determining the target code in the level of differential codes based on the file editing information of the initial code files corresponding to the level of differential codes, wherein the file editing information comprises editing time and/or editor identity.
Optionally, the file editing information includes editing time and editor identity;
the determining the target code in the level differential code based on the file editing information corresponding to the level differential code comprises the following steps:
based on the editing time of the initial code file corresponding to each level of differential codes, taking the differential code with the latest corresponding editing time as the target code;
if the differentiated code with the latest editing time comprises a plurality of codes, determining the target code based on the corresponding editor identity.
Optionally, after the assembling the merged code file in reverse to obtain the target code file, the method further includes:
Generating a modification description of each edited code file based on the target code file and the edited code file, wherein the modification description comprises an original code of a modified part in the edited code file and a revision code corresponding to the original code;
and sending the modification description to a first editor terminal corresponding to the edited code file.
Optionally, after the sending the modification description to the editor terminal corresponding to the edited code file, the method further includes:
if the to-be-refused feedback information of the modification description is received, determining to-be-refused revision codes in the revision codes based on the to-be-refused feedback information;
inquiring a second editor terminal corresponding to the to-be-refused revision code, and forwarding the to-be-refused feedback information to the second editor terminal;
and when code confirmation information from the first editor terminal or the second editor terminal is received, updating the target code file based on a final code corresponding to the to-be-refused revision code carried in the code confirmation information, wherein the code confirmation information is information commonly confirmed by the first editor terminal and the second editor terminal.
Optionally, the obtaining a plurality of initial code files to be combined includes:
acquiring a basic code file and at least two edited code files of a current version from a code database as the initial code files;
accordingly, the method further comprises:
the object code file is stored in the code database as a next version of the base code file.
Optionally, before the code in the same nest is tiled in the same level based on the code nesting relationship in the intermediate code file, the method further includes:
identifying a code type corresponding to the initial code file, and acquiring a code nesting rule corresponding to the code type;
identifying code nesting relationships in the intermediate code file based on the code nesting rules;
correspondingly, the reverse assembling of the merged code file according to the code nesting relationship corresponding to each level of code in the merged code file to obtain the target code file comprises the following steps:
acquiring a reverse assembly rule corresponding to the code type;
inquiring a reverse assembly method corresponding to the code nesting relationship in the reverse assembly rule according to the code nesting relationship corresponding to each level of code in the merged code file, and reversely assembling the merged code file based on the reverse assembly method to obtain an object code file.
Optionally, the method further comprises:
determining at least one code type to be converted, and acquiring a conversion rule from the code type of the target code file to each code type to be converted;
and performing type conversion on the target code file based on the conversion rule to obtain code conversion files of each code type to be converted.
According to another aspect of the present application, there is provided a code file merging apparatus, the apparatus including:
the acquisition module is used for acquiring a plurality of initial code files to be combined, and respectively arranging the arrays in each initial code file according to the target arrangement attribute to obtain an intermediate code file;
the tiling module is used for tiling codes in the same nesting in the same stage based on the code nesting relation in the intermediate code files for each intermediate code file to form a tiling code file corresponding to the intermediate code file;
the comparison module is used for comparing the tiled code files corresponding to the intermediate code files step by step, marking the differentiated codes in the codes of all levels of the tiled code files, and determining the target codes in the differentiated codes of each level based on the file editing information of the initial code file corresponding to the differentiated codes;
And the assembly module is used for merging the tiled code files based on the target codes to obtain merged code files, and reversely assembling the merged code files according to code nesting relations corresponding to all levels of codes in the merged code files to obtain the target code files.
Optionally, the plurality of initial code files include a base code file and at least two edited code files corresponding to the base code file; the comparison module is also used for:
step-by-step comparison is carried out on the edited tiled code files corresponding to the edited code files and the basic tiled code files corresponding to the basic code files respectively, and any level of code in the edited tiled code files is marked as a differential code when any level of code is identified to be different;
identifying the number of files in each level of code marked as differentiated code;
if the number of files of the differentiated codes corresponding to any level code is 0, taking the level code in any tiled code file as the target code of the level;
if the number of files of the differential codes corresponding to any level of codes is 1, taking the differential codes as target codes of the level;
If the number of files of the differential codes corresponding to any level of codes is greater than 1, determining the target code in the level of differential codes based on the file editing information of the initial code files corresponding to the level of differential codes, wherein the file editing information comprises editing time and/or editor identity.
Optionally, the file editing information includes editing time and editor identity; the comparison module is also used for:
based on the editing time of the initial code file corresponding to each level of differential codes, taking the differential code with the latest corresponding editing time as the target code;
if the differentiated code with the latest editing time comprises a plurality of codes, determining the target code based on the corresponding editor identity.
Optionally, the apparatus further comprises: a sending module, configured to:
generating a modification description of each edited code file based on the target code file and the edited code file, wherein the modification description comprises an original code of a modified part in the edited code file and a revision code corresponding to the original code;
and sending the modification description to a first editor terminal corresponding to the edited code file.
Optionally, the sending module is further configured to:
if the to-be-refused feedback information of the modification description is received, determining to-be-refused revision codes in the revision codes based on the to-be-refused feedback information;
inquiring a second editor terminal corresponding to the to-be-refused revision code, and forwarding the to-be-refused feedback information to the second editor terminal;
the assembly module is further configured to: and when code confirmation information from the first editor terminal or the second editor terminal is received, updating the target code file based on a final code corresponding to the to-be-refused revision code carried in the code confirmation information, wherein the code confirmation information is information commonly confirmed by the first editor terminal and the second editor terminal.
Optionally, the acquiring module is further configured to: acquiring a basic code file and at least two edited code files of a current version from a code database as the initial code files;
correspondingly, the device further comprises: and the storage module is used for storing the target code file in the code database as a basic code file of the next version.
Optionally, the tiling module is further configured to: before the codes in the same nest are tiled in the same stage based on the code nesting relation in the intermediate code file, identifying the code type corresponding to the initial code file and acquiring a code nesting rule corresponding to the code type; identifying code nesting relationships in the intermediate code file based on the code nesting rules;
correspondingly, the assembly module is further configured to: acquiring a reverse assembly rule corresponding to the code type; inquiring a reverse assembly method corresponding to the code nesting relationship in the reverse assembly rule according to the code nesting relationship corresponding to each level of code in the merged code file, and reversely assembling the merged code file based on the reverse assembly method to obtain an object code file.
Optionally, the apparatus further comprises: a conversion module for:
determining at least one code type to be converted, and acquiring a conversion rule from the code type of the target code file to each code type to be converted;
and performing type conversion on the target code file based on the conversion rule to obtain code conversion files of each code type to be converted.
According to still another aspect of the present application, there is provided a storage medium having stored thereon a computer program which, when executed by a processor, implements the above-described code file merging method.
According to still another aspect of the present application, there is provided a computer device including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, the processor implementing the above code file merging method when executing the program.
By means of the technical scheme, the code file merging method, the code file merging device, the storage medium and the computer equipment are used for carrying out array sorting on a plurality of code files to be merged according to attribute rules, then carrying out step-by-step tiling on the sorted code files according to code nesting attributes, and further identifying differentiated codes in the code files and determining target codes in the code files by step-by-step comparison on the code files after tiling, merging the code files based on the target codes, and obtaining the final merged target code file by reversely assembling the merged code files. According to the embodiment of the application, the codes are sorted according to the attribute and are tiled step by utilizing the code nesting relationship, so that step comparison of multiple code files is performed, the problem that identification accuracy is poor when the differentiated codes are identified line by line at present is solved, the target codes to be reserved are automatically selected by utilizing the file editing information of the code files, the workload of manual selection is further reduced, the problem that the code files of multiple versions are combined is solved, and the combination efficiency of the code files is improved.
The foregoing description is only an overview of the technical solutions of the present application, and may be implemented according to the content of the specification in order to make the technical means of the present application more clearly understood, and in order to make the above-mentioned and other objects, features and advantages of the present application more clearly understood, the following detailed description of the present application will be given.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute an undue limitation to the application. In the drawings:
fig. 1 is a schematic flow chart of a code file merging method according to an embodiment of the present application;
FIG. 2 illustrates an example code of an initial code file provided by an embodiment of the present application;
FIG. 3 illustrates an example code of an intermediate code file provided by an embodiment of the present application;
FIG. 4 illustrates an example code of a tiled code file provided by an embodiment of the present application;
FIG. 5 illustrates an example code for merging code files provided by embodiments of the present application;
FIG. 6 illustrates an example of a code of a target code file obtained after merging according to an embodiment of the present application;
FIG. 7 is a flowchart illustrating another method for merging code files according to an embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of a code file merging device according to an embodiment of the present application;
fig. 9 shows a schematic device structure of a computer device according to an embodiment of the present application.
Detailed Description
The present application will be described in detail hereinafter with reference to the accompanying drawings in conjunction with embodiments. It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other.
In this embodiment, a method for merging code files is provided, as shown in fig. 1, and the method includes:
step 101, obtaining a plurality of initial code files to be combined, and respectively arranging the arrays in each initial code file according to the target arrangement attribute to obtain an intermediate code file.
The method and the device are used for combining the code files with certain differences obtained after the same original code file is used as a basis for secondary modification. Firstly, acquiring a plurality of initial code files to be combined, such as JSON files, arranging the arrays in each initial code file according to the same target arrangement attribute, and obtaining an arranged intermediate code file. As shown in fig. 2, are code examples in three initial code files, as shown in fig. 3, are code examples in an intermediate code file after sorting.
Step 102, for each intermediate code file, based on the code nesting relationship in the intermediate code file, the codes in the same nesting are tiled in the same stage to form a tiled code file corresponding to the intermediate code file.
Secondly, each middle code file is tiled according to a code nesting relationship, codes belonging to the same nesting are tiled in the same stage, and the codes of the same stage are presented in a row form to form tiled code files. As shown in fig. 4, is an example of code in a tiled code file after tiling.
Step 103, comparing the tile code files corresponding to the intermediate code files step by step, marking the differential codes in the codes of each level of the tile code files, and determining the target codes in each level of differential codes based on the file editing information of the initial code file corresponding to the differential codes.
Then, comparing the tiled code files step by step to find out the differential code with difference in each level, specifically, one of the codes can be used as a base, and other codes can be compared with the base code, for example, as shown in fig. 4, the first code is used as the base code, and the third code is not identical to the first level code in the first code, so that the first level code in the third code can be marked as the differential code. Further, in combination with the differential codes in each tiled code file, final object codes of each level are determined, for example, in the code example shown in fig. 4, the first level code in the third code is marked as a differential code, so that the differential code in the third code (i.e., the first level code in the third code) can be used as the final first level object code, and the remaining codes of each level remain unchanged without differences.
And 104, merging the tiled code files based on the target codes to obtain merged code files, and reversely assembling the merged code files according to code nesting relations corresponding to all levels of codes in the merged code files to obtain the target code files.
Finally, after determining the final object codes of each level, merging the tiled code files according to the object codes of each level to obtain a merged code file, for example, as shown in fig. 4, replacing the first level code in the third level code with the first level code of the first level code based on the first level code, and not processing the codes of the other levels if each level is the same, as shown in fig. 5, which is a code example in the merged code file. After the merged code file is obtained, reverse assembly of codes is performed based on the code nesting relation corresponding to each level of codes, so that the codes are changed into the original form, and as shown in fig. 6, a code example of the target code file is obtained after reverse assembly.
By applying the technical scheme of the embodiment, for a plurality of code files to be combined, array sorting is firstly performed according to attribute rules, and then the sorted code files are tiled step by step according to code nesting attributes, so that the differentiated codes in the code files are identified and target codes in the code files are determined by comparing the tiled code files step by step, and further the code files are combined based on the target codes, and the final combined target code file is obtained by reversely assembling the combined code files. According to the embodiment of the application, the codes are sorted according to the attribute and are tiled step by utilizing the code nesting relationship, so that step comparison of multiple code files is performed, the problem that identification accuracy is poor when the differentiated codes are identified line by line at present is solved, the target codes to be reserved are automatically selected by utilizing the file editing information of the code files, the workload of manual selection is further reduced, the problem that the code files of multiple versions are combined is solved, and the combination efficiency of the code files is improved.
Further, as a refinement and extension of the foregoing embodiment, in order to fully describe the implementation procedure of this embodiment, another code file merging method is provided, as shown in fig. 7, and the method includes:
step 201, obtaining a basic code file and at least two edited code files of a current version from a code database as the initial code files, and respectively arranging arrays in each initial code file according to a target arrangement attribute to obtain intermediate code files; the plurality of initial code files comprise a basic code file and at least two edited code files corresponding to the basic code file.
In this embodiment of the present application, the plurality of initial code files to be combined includes a base code file and at least two edited code files that are secondarily developed on the base code file, and each initial code file is stored in the code database. After each initial code file is obtained, sorting the initial code files according to the target arrangement attribute to obtain the intermediate code file corresponding to each initial code file.
Step 202, identifying a code type corresponding to the initial code file, and acquiring a code nesting rule corresponding to the code type; identifying code nesting relationships in the intermediate code files based on the code nesting rules for each of the intermediate code files; and based on the code nesting relation in the intermediate code file, tiling codes in the same nesting in the same stage to form a tiling code file corresponding to the intermediate code file.
In this embodiment, since the encoding rules of the codes of different types are different, code nesting rules matched with the code types can be obtained according to the code types of the initial code files, for example, code nesting rules of JSON type are obtained, so that code nesting relationships of intermediate code files are identified based on the code nesting rules, tiling of codes of the same level is performed, and codes belonging to the same level are tiled in one line for presentation.
Step 203, comparing the edited tiled code file corresponding to each edited code file with the basic tiled code file corresponding to the basic code file step by step, and marking any level code in the edited tiled code file as a differential code when identifying that any level code is different.
In this embodiment, after code tiling is performed, tile code files corresponding to the base code files are compared with tile code files corresponding to each edited code file, respectively. Specifically, as shown in fig. 4, the first part is a tiled code file corresponding to the basic code file, the second part and the third part are respectively tiled code files corresponding to the edited code files, the second part and the third part are respectively compared with the first part of the files, wherein the difference between the first level code of the second part of the files and the first level code of the first part of the files is marked as a differential code, namely, a small cherry is marked in the difference between the first level code of the second part of the files and the first level code of the first part of the files, and the difference between the first level code of the third part of the files and the first level code of the first part of the files is marked as a differential code, namely, a big apple is marked in the difference; the codes of the rest levels are the same, and no mark is made.
Step 204, identify the number of files in each level of code that are marked as differencing code.
In step 205, if the number of files of the differential code corresponding to any level code is 0, the level code in any one of the tiled code files is used as the target code of the level.
In step 206, if the number of files of the differential code corresponding to any level code is 1, the differential code is used as the target code of the level.
Step 207, if the number of files of the differential codes corresponding to any level of codes is greater than 1, determining the target code in the level of differential codes based on the file editing information of the initial code file corresponding to each level of differential codes, wherein the file editing information includes editing time and/or editor identity.
In this embodiment, in selecting the code that is ultimately desired to be used in each level, the number of codes may be differentiated by way of stepwise recognition. Continuing the above example, if the first level codes in the second and third files are marked as differentiated codes, determining that the number of files corresponding to the first level codes is 2, and if the second and third level codes are not marked, determining that the number of files corresponding to the second and third level codes is 0. Further, if the number of files of the differentiated code corresponding to a certain level of code is 0, it is indicated that the line code in each file is the same, and the level of code does not need to be changed; if the number of files of the differentiated codes corresponding to a certain level of codes is 1, which means that only one code file modifies the level of codes on the basis of the basic code file, directly selecting a unique modification code as the final target code of the level; if the number of files of the differential codes corresponding to a certain level of codes is greater than 1, which means that two edited codes modify the basic codes of the level, the final target code should be determined by referring to the file editing information of the initial code file where the differential codes are located.
In this embodiment of the present application, optionally, the file editing information includes editing time and an editor identity; the determining the target code in the level differential code based on the file editing information corresponding to the level differential code comprises the following steps: based on the editing time of the initial code file corresponding to each level of differential codes, taking the differential code with the latest corresponding editing time as the target code; if the differentiated code with the latest editing time comprises a plurality of codes, determining the target code based on the corresponding editor identity.
In the above embodiment, if the number of files of the differential codes corresponding to a certain level is greater than 1, it is identified whether the differential codes in the files corresponding to the differential codes are in the same position, so as to modify. As shown in fig. 4, the "cherry" in the basic code is modified to be the "small cherry" in the second file, and the "small cherry" in the second file is directly used as the target code of the place where the modification is not performed in the third file; similarly, the apple in the basic code is modified into a big apple in the third file, and the big apple in the third file is directly used as the target code of the big apple in the second file without modifying the big apple; if the second and third files modify the codes at the same position in the basic code, for example, the second and third files modify the "bananas" of the first-level code in the basic code, the file editing information of the second and third files should be further considered, and the differentiated code with the latest editing time is selected as the final target code at the position, and if the editing time of the second and third files is the same, the differentiated code with the higher-level editor identity is selected as the final target code at the position.
Step 208, merging the tiled code files based on the target code to obtain a merged code file; acquiring a reverse assembly rule corresponding to the code type; inquiring a reverse assembly method corresponding to the code nesting relationship in the reverse assembly rule according to the code nesting relationship corresponding to each level of code in the merged code file, and reversely assembling the merged code file based on the reverse assembly method to obtain an object code file.
Step 209, storing the object code file as a next version of the base code file in the code database.
In this embodiment, after determining the object code corresponding to each level of differential code, the tiled code file corresponding to the base code file may be used as a base, and the object code corresponding to the finally determined differential code may be replaced to the corresponding position of the base code file to implement merging of multiple version files, so as to obtain a merged code file, and further, according to the code nesting relationship of each level of code in the merged code file, the corresponding reverse assembly method is queried, so that the code reverse assembly is performed step by step, and the final object code file is obtained. The object code file is stored in the code database as a new version of the base code file on which the developer can further develop.
In this embodiment of the present application, optionally, after obtaining the object code file, the method further includes:
s1, generating a modification description of each edited code file based on the target code file and the edited code file, wherein the modification description comprises an original code of a modified part in the edited code file and a revision code corresponding to the original code; and sending the modification description to a first editor terminal corresponding to the edited code file.
S2, if the feedback information to be refused for the modification description is received, determining a revision code to be refused in the revision code based on the feedback information to be refused; inquiring a second editor terminal corresponding to the to-be-refused revision code, and forwarding the to-be-refused feedback information to the second editor terminal;
and S3, when code confirmation information from the first editor terminal or the second editor terminal is received, updating the target code file based on a final code corresponding to the to-be-refused revision code carried in the code confirmation information, wherein the code confirmation information is information commonly confirmed by the first editor terminal and the second editor terminal.
In the above embodiment, for the case where the code is modified, notification may also be given to the editor of the modified code file, specifically, according to the difference 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, where 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, the editor 1 of the second set of files modifies "a" in the base code file to "B", and the editor 2 of the third set of files modifies "a" in the base code file to "C", and finally determines "C" as the target code, a modification description is sent to the editor 1. If the first editor refuses the revision, i.e. receives the feedback information to be refused for the description of the modification, the second editor terminal corresponding to the code to be refused may send the corresponding feedback information to be refused, e.g. send the feedback information to be refused to 2 of editor 1 to editor 2. Finally, after receiving the code confirmation information of the first editor terminal or the second editor terminal, the target code file is confirmed or updated based on the confirmed final code, wherein the code confirmation information is jointly confirmed by the first editor terminal and the second editor terminal and sent by any one party.
In this embodiment of the present application, optionally, after obtaining the object code file, the method further includes: determining at least one code type to be converted, and acquiring a conversion rule from the code type of the target code file to each code type to be converted; and performing type conversion on the target code file based on the conversion rule to obtain code conversion files of each code type to be converted.
In the above embodiment, after the final object code file is confirmed, in order to enable the file to be suitable for more application scenarios, format conversion may also be performed on the object code file, specifically, the object code file may be converted based on a rule for converting the code type of the object code file into the code type to be converted, and a specific mode is not limited.
Further, as a specific implementation of the method of fig. 1, an embodiment of the present application provides a code file merging device, as shown in fig. 8, where the device includes:
the acquisition module is used for acquiring a plurality of initial code files to be combined, and respectively arranging the arrays in each initial code file according to the target arrangement attribute to obtain an intermediate code file;
the tiling module is used for tiling codes in the same nesting in the same stage based on the code nesting relation in the intermediate code files for each intermediate code file to form a tiling code file corresponding to the intermediate code file;
The comparison module is used for comparing the tiled code files corresponding to the intermediate code files step by step, marking the differentiated codes in the codes of all levels of the tiled code files, and determining the target codes in the differentiated codes of each level based on the file editing information of the initial code file corresponding to the differentiated codes;
and the assembly module is used for merging the tiled code files based on the target codes to obtain merged code files, and reversely assembling the merged code files according to code nesting relations corresponding to all levels of codes in the merged code files to obtain the target code files.
Optionally, the plurality of initial code files include a base code file and at least two edited code files corresponding to the base code file; the comparison module is also used for:
step-by-step comparison is carried out on the edited tiled code files corresponding to the edited code files and the basic tiled code files corresponding to the basic code files respectively, and any level of code in the edited tiled code files is marked as a differential code when any level of code is identified to be different;
Identifying the number of files in each level of code marked as differentiated code;
if the number of files of the differentiated codes corresponding to any level code is 0, taking the level code in any tiled code file as the target code of the level;
if the number of files of the differential codes corresponding to any level of codes is 1, taking the differential codes as target codes of the level;
if the number of files of the differential codes corresponding to any level of codes is greater than 1, determining the target code in the level of differential codes based on the file editing information of the initial code files corresponding to the level of differential codes, wherein the file editing information comprises editing time and/or editor identity.
Optionally, the file editing information includes editing time and editor identity; the comparison module is also used for:
based on the editing time of the initial code file corresponding to each level of differential codes, taking the differential code with the latest corresponding editing time as the target code;
if the differentiated code with the latest editing time comprises a plurality of codes, determining the target code based on the corresponding editor identity.
Optionally, the apparatus further comprises: a sending module, configured to:
Generating a modification description of each edited code file based on the target code file and the edited code file, wherein the modification description comprises an original code of a modified part in the edited code file and a revision code corresponding to the original code;
and sending the modification description to a first editor terminal corresponding to the edited code file.
Optionally, the sending module is further configured to:
if the to-be-refused feedback information of the modification description is received, determining to-be-refused revision codes in the revision codes based on the to-be-refused feedback information;
inquiring a second editor terminal corresponding to the to-be-refused revision code, and forwarding the to-be-refused feedback information to the second editor terminal;
the assembly module is further configured to: and when code confirmation information from the first editor terminal or the second editor terminal is received, updating the target code file based on a final code corresponding to the to-be-refused revision code carried in the code confirmation information, wherein the code confirmation information is information commonly confirmed by the first editor terminal and the second editor terminal.
Optionally, the acquiring module is further configured to: acquiring a basic code file and at least two edited code files of a current version from a code database as the initial code files;
correspondingly, the device further comprises: and the storage module is used for storing the target code file in the code database as a basic code file of the next version.
Optionally, the tiling module is further configured to: before the codes in the same nest are tiled in the same stage based on the code nesting relation in the intermediate code file, identifying the code type corresponding to the initial code file and acquiring a code nesting rule corresponding to the code type; identifying code nesting relationships in the intermediate code file based on the code nesting rules;
correspondingly, the assembly module is further configured to: acquiring a reverse assembly rule corresponding to the code type; inquiring a reverse assembly method corresponding to the code nesting relationship in the reverse assembly rule according to the code nesting relationship corresponding to each level of code in the merged code file, and reversely assembling the merged code file based on the reverse assembly method to obtain an object code file.
Optionally, the apparatus further comprises: a conversion module for:
determining at least one code type to be converted, and acquiring a conversion rule from the code type of the target code file to each code type to be converted;
and performing type conversion on the target code file based on the conversion rule to obtain code conversion files of each code type to be converted.
It should be noted that, other corresponding descriptions of each functional unit related to the code file merging apparatus provided in the embodiments of the present application may refer to corresponding descriptions in the methods of fig. 1 to 7, and are not repeated herein.
The embodiment of the application also provides a computer device, which may be a personal computer, a server, a network device, etc., as shown in fig. 9, where the computer device includes a bus, a processor, a memory, a communication interface, and may further include an input/output interface and a display device. Wherein the processor of the computer device is configured 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, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing location information. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement the steps in the method embodiments.
It will be appreciated by those skilled in the art that the structure shown in fig. 9 is merely a block diagram of a portion of the structure associated with the present application and is not limiting of the computer device to which the present application applies, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a computer readable storage medium is provided, which may be non-volatile or volatile, and on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
It should be noted that, user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples only represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the present application. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (11)

1. A method of merging code files, the method comprising:
acquiring a plurality of initial code files to be combined, and respectively arranging an array in each initial code file according to a target arrangement attribute to acquire an intermediate code file;
for each intermediate code file, based on the code nesting relation in the intermediate code file, tiling codes in the same nesting in the same level to form a tiling code file corresponding to the intermediate code file;
Step-by-step comparison is carried out on the tiled code files corresponding to the intermediate code files, differential codes in all levels of codes of the tiled code files are marked, and the target codes in all levels of differential codes are determined based on file editing information of the initial code files corresponding to the differential codes;
and merging the tiled code files based on the target codes to obtain merged code files, and reversely assembling the merged code files according to code nesting relations corresponding to all levels of codes in the merged code files to obtain the target code files.
2. The method of claim 1, wherein the plurality of initial code files includes a base code file and at least two edited code files corresponding to the base code file; the step-by-step comparison is performed on the tiled code files corresponding to the intermediate code files, and the marking of the differentiated codes in the codes at each level of the tiled code files comprises the following steps:
step-by-step comparison is carried out on the edited tiled code files corresponding to the edited code files and the basic tiled code files corresponding to the basic code files respectively, and any level of code in the edited tiled code files is marked as a differential code when any level of code is identified to be different;
Correspondingly, the determining the target code in each level of differential code based on the file editing information of the initial code file corresponding to the differential code comprises the following steps:
identifying the number of files in each level of code marked as differentiated code;
if the number of files of the differentiated codes corresponding to any level code is 0, taking the level code in any tiled code file as the target code of the level;
if the number of files of the differential codes corresponding to any level of codes is 1, taking the differential codes as target codes of the level;
if the number of files of the differential codes corresponding to any level of codes is greater than 1, determining the target code in the level of differential codes based on the file editing information of the initial code files corresponding to the level of differential codes, wherein the file editing information comprises editing time and/or editor identity.
3. The method of claim 2, wherein the file editing information includes editing time and editor identity;
the determining the target code in the level differential code based on the file editing information corresponding to the level differential code comprises the following steps:
based on the editing time of the initial code file corresponding to each level of differential codes, taking the differential code with the latest corresponding editing time as the target code;
If the differentiated code with the latest editing time comprises a plurality of codes, determining the target code based on the corresponding editor identity.
4. The method of claim 2, wherein after the assembling the merged code file in reverse to obtain the object code file, the method further comprises:
generating a modification description of each edited code file based on the target code file and the edited code file, wherein the modification description comprises an original code of a modified part in the edited code file and a revision code corresponding to the original code;
and sending the modification description to a first editor terminal corresponding to the edited code file.
5. The method of claim 4, wherein after the transmitting the modification instruction to the editor terminal corresponding to the edited code file, the method further comprises:
if the to-be-refused feedback information of the modification description is received, determining to-be-refused revision codes in the revision codes based on the to-be-refused feedback information;
inquiring a second editor terminal corresponding to the to-be-refused revision code, and forwarding the to-be-refused feedback information to the second editor terminal;
And when code confirmation information from the first editor terminal or the second editor terminal is received, updating the target code file based on a final code corresponding to the to-be-refused revision code carried in the code confirmation information, wherein the code confirmation information is information commonly 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 obtaining a plurality of initial code files to be combined comprises:
acquiring a basic code file and at least two edited code files of a current version from a code database as the initial code files;
accordingly, the method further comprises:
the object code file is stored in the code database as a next version of the base code file.
7. The method of claim 6, wherein the method further comprises, prior to tiling code in the same nest in the same level based on code nesting relationships in the intermediate code file:
identifying a code type corresponding to the initial code file, and acquiring a code nesting rule corresponding to the code type;
Identifying code nesting relationships in the intermediate code file based on the code nesting rules;
correspondingly, the reverse assembling of the merged code file according to the code nesting relationship corresponding to each level of code in the merged code file to obtain the target code file comprises the following steps:
acquiring a reverse assembly rule corresponding to the code type;
inquiring a reverse assembly method corresponding to the code nesting relationship in the reverse assembly rule according to the code nesting relationship corresponding to each level of code in the merged code file, and reversely assembling the merged code file based on the reverse assembly method to obtain an object code file.
8. The method of claim 6, wherein the method further comprises:
determining at least one code type to be converted, and acquiring a conversion rule from the code type of the target code file to each code type to be converted;
and performing type conversion on the target code file based on the conversion rule to obtain code conversion files of each code type to be converted.
9. A code file merging apparatus, the apparatus comprising:
The acquisition module is used for acquiring a plurality of initial code files to be combined, and respectively arranging the arrays in each initial code file according to the target arrangement attribute to obtain an intermediate code file;
the tiling module is used for tiling codes in the same nesting in the same stage based on the code nesting relation in the intermediate code files for each intermediate code file to form a tiling code file corresponding to the intermediate code file;
the comparison module is used for comparing the tiled code files corresponding to the intermediate code files step by step, marking the differentiated codes in the codes of all levels of the tiled code files, and determining the target codes in the differentiated codes of each level based on the file editing information of the initial code file corresponding to the differentiated codes;
and the assembly module is used for merging the tiled code files based on the target codes to obtain merged code files, and reversely assembling the merged code files according to code nesting relations corresponding to all levels of codes in the merged code files to obtain the target code files.
10. A storage medium having stored thereon a computer program, which when executed by a processor, implements the method of any of claims 1 to 8.
11. A computer device comprising a storage medium, a processor and a computer program stored on the storage medium and executable on the processor, characterized in that the processor implements the method of any one of claims 1 to 8 when executing the computer program.
CN202310567287.5A 2023-05-19 2023-05-19 Code file merging method and device, storage medium and computer equipment Active CN116302078B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310567287.5A CN116302078B (en) 2023-05-19 2023-05-19 Code file merging method and device, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310567287.5A CN116302078B (en) 2023-05-19 2023-05-19 Code file merging method and device, storage medium and computer equipment

Publications (2)

Publication Number Publication Date
CN116302078A true CN116302078A (en) 2023-06-23
CN116302078B CN116302078B (en) 2023-08-01

Family

ID=86781944

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310567287.5A Active CN116302078B (en) 2023-05-19 2023-05-19 Code file merging method and device, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN116302078B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902555A (en) * 2012-09-06 2013-01-30 华为终端有限公司 Upgrading method, unit and upgrading device
CN108073501A (en) * 2016-11-14 2018-05-25 阿里巴巴集团控股有限公司 A kind of code conflicts detection method and equipment
US20180349405A1 (en) * 2017-06-02 2018-12-06 Tibco Software Inc. Patching json documents that contain arrays undergoing concurrent modification
JP2019133534A (en) * 2018-02-02 2019-08-08 富士通株式会社 Merging method, merging device, and merging program
CN111221566A (en) * 2019-12-28 2020-06-02 华为技术有限公司 Method and device for combining multiple and changeable versions of software code
CN113535206A (en) * 2021-07-23 2021-10-22 上海幻电信息科技有限公司 Multi-version code upgrading method and system
CN114742028A (en) * 2022-02-24 2022-07-12 中电科数字科技(集团)有限公司 Feature-based JSON consistency comparison detection method and system
CN115357286A (en) * 2022-08-03 2022-11-18 中信建投证券股份有限公司 Program file comparison method and device, electronic equipment and storage medium
CN115421764A (en) * 2022-08-31 2022-12-02 济南浪潮数据技术有限公司 Method, device, equipment and storage medium for identifying module to be upgraded
CN115904480A (en) * 2023-01-09 2023-04-04 成方金融科技有限公司 Code reconstruction method and device, electronic equipment and storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902555A (en) * 2012-09-06 2013-01-30 华为终端有限公司 Upgrading method, unit and upgrading device
CN108073501A (en) * 2016-11-14 2018-05-25 阿里巴巴集团控股有限公司 A kind of code conflicts detection method and equipment
US20180349405A1 (en) * 2017-06-02 2018-12-06 Tibco Software Inc. Patching json documents that contain arrays undergoing concurrent modification
JP2019133534A (en) * 2018-02-02 2019-08-08 富士通株式会社 Merging method, merging device, and merging program
CN111221566A (en) * 2019-12-28 2020-06-02 华为技术有限公司 Method and device for combining multiple and changeable versions of software code
CN113535206A (en) * 2021-07-23 2021-10-22 上海幻电信息科技有限公司 Multi-version code upgrading method and system
CN114742028A (en) * 2022-02-24 2022-07-12 中电科数字科技(集团)有限公司 Feature-based JSON consistency comparison detection method and system
CN115357286A (en) * 2022-08-03 2022-11-18 中信建投证券股份有限公司 Program file comparison method and device, electronic equipment and storage medium
CN115421764A (en) * 2022-08-31 2022-12-02 济南浪潮数据技术有限公司 Method, device, equipment and storage medium for identifying module to be upgraded
CN115904480A (en) * 2023-01-09 2023-04-04 成方金融科技有限公司 Code reconstruction method and device, electronic equipment and storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
GEORG SEIBT等: "Leveraging Structure in Software Merge: An Empirical Study", IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, pages 4590 *
正在吞噬的世界: "两个不同版本源代码文件之间的对比与合并方法", pages 1 - 3, Retrieved from the Internet <URL:https://blog.csdn.net/weixin_43398418/article/details/86487637> *
陈宏君等: "SCL文件逐级自动更新算法设计与实现", 计算机技术与发展, no. 03, pages 121 - 125 *

Also Published As

Publication number Publication date
CN116302078B (en) 2023-08-01

Similar Documents

Publication Publication Date Title
CN112650766B (en) Database data operation method, system and server
US8407262B2 (en) Systems and methods for generating an entity diagram
CN110705237B (en) Automatic document generation method, data processing device and storage medium
CN106557307B (en) Service data processing method and system
CN103246690A (en) Tag inheritance
CN111126019A (en) Report generation method and device based on mode customization and electronic equipment
CN109003012B (en) Goods location recommendation link information acquisition method, goods location recommendation method, device and system
CN112988280B (en) Configuration data processing method and device
CN116302078B (en) Code file merging method and device, storage medium and computer equipment
CN116452123A (en) Method and device for generating characteristic value of inventory item and computer equipment
CN116304189A (en) Image extraction method in excel file and electronic equipment
CN113468446B (en) Method, system and equipment for supporting identification of third party two-dimensional code data
CN112084753B (en) Method and system for assisting in editing document
CN110838338A (en) System, method, storage medium, and electronic device for creating biological analysis item
CN113705180A (en) Document editing and reviewing method and device, electronic equipment and storage medium
CN111178925B (en) Method, apparatus, server and computer readable medium for predicting attribute of user portrait
CN115455035B (en) Data query model construction method and computer-readable storage medium
Gonnella et al. RGFA: powerful and convenient handling of assembly graphs
CN117290236A (en) Software testing method, device, computer equipment and computer readable storage medium
CN116909528A (en) Text generation method, apparatus, computer device and storage medium
CN111460269B (en) Information pushing method and device
CN116737574A (en) Test method, device, equipment, storage medium and product for responding to code change
CN117493333A (en) Data archiving method and device, electronic equipment and storage medium
CN115514417A (en) Matching method and device and computer readable storage medium
CN116451652A (en) Method and system for rapidly converting data format during system docking

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant