CN110069455B - File merging method and device - Google Patents

File merging method and device Download PDF

Info

Publication number
CN110069455B
CN110069455B CN201710859738.7A CN201710859738A CN110069455B CN 110069455 B CN110069455 B CN 110069455B CN 201710859738 A CN201710859738 A CN 201710859738A CN 110069455 B CN110069455 B CN 110069455B
Authority
CN
China
Prior art keywords
file
content
content blocks
merging
blocks contained
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.)
Active
Application number
CN201710859738.7A
Other languages
Chinese (zh)
Other versions
CN110069455A (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.)
Huawei Technologies Co Ltd
XFusion Digital Technologies Co Ltd
Original Assignee
Beijing Huawei Digital Technologies 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 Beijing Huawei Digital Technologies Co Ltd filed Critical Beijing Huawei Digital Technologies Co Ltd
Priority to CN201710859738.7A priority Critical patent/CN110069455B/en
Publication of CN110069455A publication Critical patent/CN110069455A/en
Application granted granted Critical
Publication of CN110069455B publication Critical patent/CN110069455B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/194Calculation of difference between files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a file merging method and device, which are used for improving the efficiency of file merging. The method comprises the following steps: the method comprises the steps of obtaining a first file and a second file, determining content blocks contained in the first file according to the semantics of the content in the first file, determining content blocks contained in the second file according to the semantics of the content in the second file, comparing the content blocks contained in the first file with the content blocks contained in the second file, and merging the first file with the second file according to the comparison result. The automatic merging of the content block parts with consistent semantics can be realized, the conflict of users can not be prompted, and the automatic merging efficiency is improved.

Description

File merging method and device
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a file merging method and device.
Background
In the field of computer technology applications, application scenarios are often presented in which two files are merged. In this application scenario, the server needs to compare the two files by using a comparison tool, and automatically merge the two files according to a comparison result, and if the two files cannot be automatically merged, the server manually selects the content to be merged by using the user to merge the two files. For example, in the software development process, a code file is stored in the version management system, and a user can download the code file from the version management system for modification and submit the modified content to the version management system. The code file before modification may be referred to as a baseline file, and after the baseline file is modified, the version management system needs to merge the baseline file with the modified file, which may also be referred to as merge, that is, add the modification made by the user to the baseline file. If a code file is modified by at least two users in parallel, conflicts may arise when the files are merged.
In the existing file merging method, two files are generally analyzed based on character strings, the difference of the two files is prompted, and merging is executed according to the prompted difference. For example, a baseline file and two modified files are used as inputs, and the modified portions of the files are analyzed and identified based on the character strings. If the modified portion only appears in a modified file, the modified portion and the baseline file are automatically merged. If the same part is modified in the two modified files, automatic combination is realized according to a certain algorithm, and modification conflict is prompted for the part which cannot realize automatic combination, so that a user can manually select the content to be combined.
However, the existing method for comparing and merging files based on character strings can suggest modification conflicts for semantically compatible modification parts, and cannot automatically merge, so that the efficiency of file merging is low.
Disclosure of Invention
The embodiment of the application provides a file merging method and device, which are used for improving the efficiency of file merging.
The embodiment of the application provides the following specific technical scheme:
according to the method provided by the embodiment of the application, the content blocks can be used as comparison units to replace character strings, the content blocks are automatically combined, and the efficiency and the accuracy of file comparison and combination are improved.
In one possible design, a first file and a second file are obtained, a content block contained in the first file is determined according to the semantic meaning of the content in the first file, a content block contained in the second file is determined according to the semantic meaning of the content in the second file, the content block contained in the first file and the content block contained in the second file are compared, and the first file and the second file are merged according to the comparison result. Therefore, automatic merging can be realized for parts with consistent semantics without prompting user conflict, and the efficiency of automatic merging is improved.
In one possible design, the file types of the first file and the second file are respectively determined, a first content block division model corresponding to the file type of the first file and a second content block division model corresponding to the file type of the second file are obtained according to the corresponding relation between the pre-stored file type and the content block division model, semantic recognition is carried out on the content in the first file according to the obtained first content block division model, the content block contained in the first file is determined according to the result of the semantic recognition, semantic recognition is carried out on the content in the second file according to the obtained second content block division model, and the content block contained in the second file is determined according to the result of the semantic recognition. Therefore, by storing the content block division models of different file types, after the file type is determined, the pre-stored content block division model corresponding to the determined file type can be selected, so that the method can be suitable for various different file types.
In one possible design, comparing the content blocks contained in the first file with the content blocks contained in the second file, and merging the first file and the second file according to the comparison result, by: and combining the content blocks with different identifications in the first file and the second file according to the identifications of the content blocks contained in the first file and the second file respectively. Therefore, the content blocks can be compared and combined one by one according to the identification of the content blocks, the comparison speed is improved, and the combination accuracy can be ensured.
In one possible design, this may also be achieved by: and comparing content blocks with the same identifier in the first file and the second file based on character strings according to the identifiers of the content blocks contained in the first file and the second file respectively, and merging according to the comparison result of the character strings.
In one possible design, after the first file and the second file are merged according to the comparison result, the accuracy of the merged result is evaluated, and the result of the accuracy evaluation is prompted to a user.
In one possible design, if the first file and the second file are both modified files based on a baseline file, the content blocks included in the first file and the content blocks included in the second file are compared according to the content blocks included in the baseline file, and the first file and the second file are merged according to the comparison result.
In one possible design, the content blocks identified in the first file and the second file are prompted to a user for manual merging.
In one possible design, after the end of the file merge, the user is provided with at least one of the number of content blocks that are at risk of merging, an identification of the content block, and a content of the content block.
In a second aspect, there is provided a document merge device having functionality to implement the method of any one of the possible designs of the first aspect and the first aspect described above. The functions can be realized by hardware, and the functions can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the above-described functions.
In a third aspect, a file merging apparatus is provided, which structurally includes a memory and a processor, wherein the memory is configured to store a set of programs, and the processor is configured to call the programs stored in the memory to perform the method as set forth in the first aspect and any one of the possible designs of the first aspect.
In a fourth aspect, a computer storage medium is provided, in which a computer program is stored, the computer program comprising instructions for carrying out the method of the first aspect, any of the possible implementations of the first aspect.
In a fifth aspect, the present application provides a computer program product containing instructions which, when run on a computer, cause the computer to perform the method of the above aspects.
Drawings
FIG. 1 is a diagram of an application system architecture according to an embodiment of the present application;
FIG. 2 is a flowchart illustrating a document merging method according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating a merging method for merging documents A and B according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a server according to an embodiment of the present application;
FIG. 5 is a schematic structural diagram of a document merge device according to an embodiment of the present application;
FIG. 6 is a second schematic structural diagram of a document merging device in an embodiment of the present application.
Detailed Description
The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
As shown in fig. 1, a system architecture applied in the embodiment of the present application includes a server 101 and a client 102, where the client 102 is a device used for a user to interact with the server 101, and the server 101 is used for managing files and performing operations such as comparison and merging on the files. The file merging method provided below in the present application can be applied to code files of various programming languages, and can also be applied to files having a fixed syntax structure such as xml.
It should be noted that, in the embodiments of the present application, the number of "a" or "an" is at least one, and usually two or more.
Based on the system architecture shown in fig. 1, the file merging method provided in the embodiment of the present application will be described in detail below. As shown in fig. 2, a flow of the file merging method provided in the embodiment of the present application is as follows. The execution subject of the file merging method provided by the embodiment of the present application may be considered as the server 101, and may also be considered as an integrated circuit or a chip integrated in the server 101.
Step 201, acquiring a first file and a second file; the first file and the second file are files to be merged.
Step 202, determining the content blocks contained in the first file according to the semantics of the content in the first file, and determining the content blocks contained in the second file according to the semantics of the content in the second file.
Specifically, one file contains a plurality of character strings, and the content of the file can be divided into a plurality of content blocks according to the semantics of the character strings. The way in which content blocks are determined according to semantics is different for different file types. Optionally, in this embodiment of the present application, content block division models corresponding to different file types may be stored in advance, where the content block division models include how to divide content blocks according to semantics. Specifically, file types of a first file and a second file are respectively determined, a first content block division model corresponding to the file type of the first file and a second content block division model corresponding to the file type of the second file are obtained according to a corresponding relation between a pre-stored file type and the content block division models, semantic recognition is carried out on the content in the first file according to the obtained first content block division model, and content blocks contained in the first file are determined according to the result of the semantic recognition; and performing semantic recognition on the content in the second file according to the acquired second content block division model, and determining content blocks contained in the second file according to the result of the semantic recognition. Optionally, the content block division model may further include a manner of determining an identifier of a content block, where the identifier of the content block included in the first file is determined according to the first content block division model, and the identifier of the content block included in the second file is determined according to the second content block division model.
For example, for a C language code file, all statements defining and declaring a function are divided into one content block based on the syntax of the C language. The function name is determined as an identification of the content block. The following is an example of the identification of content blocks and content blocks in several C language code files.
Example 1: function(s)
Figure BDA0001414786210000031
Taking the above entire function as one content block, the function name is foo, and all the contents of the above entire content block starting from "void" to the end of the brace "}" can be identified by the function name foo.
Example 2: structural body
Figure BDA0001414786210000041
Taking the above whole structure as a content block, the name of the structure is Point _ s, and all the contents of the above whole content block starting from "Typedef" to "Point _ s" can be identified by the name of the structure, Point _ s.
Example 3: macro definition
#define max(a,b)(((a)>(b))?(a):(b))
Taking the above entire macro definition as one content block, the name of the macro definition is max, and the above "# define max (a, b) (((a) > (b)).
Step 203, comparing the first file and the second file according to the determined content blocks, and merging according to the comparison result. The first file and the second file are compared by taking the content block as a comparison unit, but not by taking the character string as a comparison unit. Specifically, content blocks with different identifications in the first file and the second file are merged. The content block identifier may be determined according to the preset content block dividing manner, or may be determined in other manners.
For the content blocks with the same identification in the first file and the second file, the content blocks with the same identification in the first file and the second file can be compared based on the character strings, and automatic combination is performed according to the comparison result of the character strings, or the content blocks with the same identification in the first file and the second file can be prompted to a user for manual combination. The policy of automatic merging is not limited in the present application, and the same content in the first file and the second file may be directly placed in the merged file, and different content is selectively merged according to a certain rule. For example, compared with the second file, the first file has m rows of character strings more than the second file, and the rest rows of character strings have the same content, and if automatic merging is performed, the character strings of the same part in the two files are directly placed into the merged file, and the m rows of character strings can be selected to be merged into the merged file.
In an implementation manner, one of the first file and the second file can be selected as a basic comparison object, and according to the identification of the content block, the content block in the other file is sequentially compared with the content block in the basic comparison object to determine the merging manner. It is assumed that the basic comparison object is a file whose input time is later, and the other file is a file whose input time is closer to the current time. For example, the first file is used as a basic comparison object, content blocks in the second file are respectively compared with content blocks in the first file, and if the identifier of a certain content block in the second file is the same as the identifier of a certain content block in the first file, the comparison is performed based on the character strings as described above, and automatic merging is performed according to the comparison result of the character strings, or the user is prompted to perform manual merging; if the identification of a certain content block in the second file is different from the identification of any content block in the first file, whether the content block is renamed content of the certain content block in the first file needs to be confirmed, and if the content block is not renamed, the content block is determined to be a newly added content block; if a certain content block in the first file does not exist in the second file, the content block is a deleted content block. And carrying out zero-risk combination on the newly added content blocks and the deleted content blocks. If the first file and the second file are modified files of the baseline file, the first file deletes a function relative to the baseline file, and the second file retains the function, the second file and the first file look to have an added function when comparing content blocks of the function, in this case, the comparison is performed in combination with the baseline file, it is determined that a function is deleted for the first file, automatic merging can be performed according to deletion or non-deletion, and certainly, a user can be prompted to perform manual merging according to intention.
In another implementation manner, a comparison and merging strategy can be formulated according to the category of the content block. For example, the categories of content blocks in the C language code file include: function, data structure, enumeration type. And for functions, combining the synonym functions, and automatically combining the homonym functions based on character string comparison or prompting a user to manually combine the homonym functions. And adding the added members of the first file and the added members of the second file into the merged file in sequence for the data type and the enumeration type. For example, the member may be an integer or a character string in C language.
After the merging according to the comparison result in step 203, further risk assessment, that is, accuracy assessment, may be performed on the merged result, and the result of the accuracy assessment may be prompted to the user. In particular, during the merging process, there are no risks for merging of some content in the file and risks for merging of some content. For example, the risk of merging for content blocks in two files that identify differences is zero or close to zero. After content blocks with the same identification are compared based on character strings, automatic merging according to the comparison result is risky. And comparing and combining all the content blocks, recording the risk value of each combination, and prompting the risk value to a user. And after the file merging is finished, providing at least one of the number of the content blocks with risk merging, the identification of the content blocks and the content of the content blocks for the user. For example, 100 content blocks are combined, 93 content blocks are combined at zero risk, 7 content blocks are combined at certain risk, and after the file combination is finished, at least one item of the number of the content blocks with risk combination being 7, the identification of the 7 content blocks, and the content of the 7 content blocks is provided to the user.
And for the content blocks with certain risks, not automatically combining, and prompting the user of the content blocks which cannot be automatically combined so as to facilitate the user to manually combine. Therefore, the merging speed is improved, and meanwhile, the merging accuracy can be guaranteed.
Of course, if the first file and the second file are both modified files based on the baseline file, the content blocks included in the first file, the content blocks included in the second file, and the content blocks included in the baseline file may also be compared, and combined according to the comparison result. For example, a function is deleted from a first file compared with a baseline file, a function is reserved in a second file, if the first file and the second file are directly compared, it is confirmed that the function is added to the second file relative to the first file, automatic merging has risks relatively, and certain accuracy deviation exists, the second file is comprehensively compared with the first file and the baseline file, the first file deletion function is determined, the result of the function is reserved in the second file, targeted policy merging is performed according to the result, automatic merging can be performed, and a user can be prompted to perform manual processing according to the risk value.
The file merging method provided in the embodiment of the present application will be further described in detail with reference to specific application scenarios. Based on the system architecture shown in fig. 1, file a and file B are assumed to be modified files after modification of the baseline file. As shown in fig. 3, the method for merging the file a and the file B is specifically described as follows. The execution subject of a specific method may be the server 101 in fig. 1.
Step 301, receiving a file A, a file B and a baseline file X input by a user.
Step 302, the file types of file A, file B and baseline file X are obtained. Generally, the files being compared are of the same file type. The file type is first identified by a file name suffix, for example, C-language code files with C, cpp, h as suffixes. Java as a suffix and python as a suffix. The user may also specify the type of file as a C language code file or a Java language code file or a python language code file in other ways.
Step 303, determining a content block division model corresponding to the file type according to the acquired file type, and performing content block division on content blocks contained in the file a, the file B and the baseline file X according to the content block division model. Each file type corresponds to a content block division model, and the content block division model comprises a mode of dividing content blocks according to semantics and a determination mode of content block identification. For example, for a C language code file, a function may be divided into one content block and a data structure may be divided into one content block.
And step 304, judging whether the files A and B have the content blocks with the same identifiers which are not compared. If yes, go to step 305-step 312, otherwise go to step 306-step 327.
And step 305, comparing whether the contents in the content blocks identified in the file A and the file B are identical, if so, executing step 307, and otherwise, executing step 308.
Let us assume that the identities of the same content blocks in file a and file B are both denoted by Y.
And step 307, identifying the same content in the same content block in the file A and the file B as a merging result, and returning to continue executing step 304.
Step 308, determine whether the baseline file X also contains a content block denoted as Y, if yes, execute step 309, otherwise execute step 310.
Step 309, compare file a with baseline file X, compare file B with baseline X, and determine whether both file a and file B have modified the content block identified as Y in baseline file X. If only one of the files A and B modifies the content block marked as Y in the baseline file X, executing step 311; if both file a and file B have modifications to the content block identified as Y in the baseline file X, then step 310 is performed.
And step 311, merging the modified content blocks into the merged file as the merged content.
And 310, comparing the content blocks marked as Y in the file A and the file B according to character strings, and automatically combining the content blocks according to a comparison result, or prompting a user to manually combine the content blocks.
And step 312, performing risk prediction on the combination of the content blocks marked as Y in the file A and the file B, storing the combination result, and continuously returning to the step 304.
As for the determination result in step 304, if the file a and the file B do not identify the same content block, step 306 to step 326 are executed, and step 327 is finally executed.
Step 306, selecting whether there are content blocks contained in the file a and not contained in the file B, if yes, executing step 313, otherwise executing step 314.
Step 313, assuming that the identifier of the content block is P, determining whether the baseline file X includes the content block identified as P, if so, executing step 315, otherwise, indicating that the file a adds the content block identified as P in the baseline file X, and executing step 316.
Step 315, determining whether the content of the content block identified as P in the file a and the baseline file X is the same, if so, indicating that the file B performs deletion processing on the content block identified as P in the baseline file X, then executing step 317, otherwise, indicating that the file a modifies the content block identified as P in the baseline file X, and if not, executing step 318, indicating that the file B performs deletion processing on the content block identified as P in the baseline file X.
Step 316, with the content block marked as P added as the result of merging the content blocks of file a and file B, step 319 is executed.
Step 317, with the content block marked as P deleted as the result of merging the content blocks of the file a and the file B, executes step 319.
Step 318, prompting the user to perform manual combination, and executing step 319.
In the case of such a conflict, the automatic merging does not truly reflect the intention of the user, so the user is prompted to perform manual merging.
319, risk prediction is carried out on the combination of the content blocks marked as P in the file A and the file B, the combination result is stored, and the step 306 is continuously executed.
Step 314, selecting whether there is a content block contained in the file B and not contained in the file a, if yes, executing step 320. If not, go to step 327.
Step 320, assuming that the identifier of the content block is Q, determining whether the baseline file X includes the content block identified as Q, if so, executing step 321, otherwise, indicating that the file B adds the content block identified as Q in the baseline file X, and executing step 322.
Step 321, determining whether the content of the content block identified as Q in the file B and the baseline file X is the same, if so, indicating that the file a deletes the content block identified as Q in the baseline file X, then performing step 323, otherwise, indicating that the file B modifies the content block identified as Q in the baseline file X, and if so, executing step 324.
Step 323, merge the content blocks with file a and file B with the added content block identified as Q, execute step 326.
Step 324, with the deleted content block identified as Q as the result of merging the content blocks for file a and file B, executes step 326.
Step 325, prompt the user to perform manual merge, and execute step 326. In the case of such a conflict, the automatic merging does not truly reflect the intention of the user, so the user is prompted to perform manual merging.
And 326, performing risk prediction on the combination of the content blocks marked as Q in the file A and the file B, storing the combination result, and continuously returning to execute the step 314.
And 327, saving the merging result of the file A and the file B, and outputting the risk value of the merged file. The risk value may be the number of content blocks, content, identification, etc. in file a and file B that incorporate the risk.
It should be noted that, whether content blocks included in different files are the same or not may be determined according to the identifier of the content block, or may be determined according to other manners, which is not limited in this application.
Based on the above embodiment, as shown in fig. 4, the server 101 in the embodiment of the present application may be divided into several functional modules. Including an input-output module 401, a comparison module 402, a merging module 403, and a scoring module 404. Wherein:
and the input and output module 401 is configured to receive a file input by a user, present a result of comparing and merging to the user, and prompt the user with information such as a risk value of manually merging and merging files.
An information model module 402, configured to store a file type and a corresponding content block division model. Specifically, content block division models corresponding to different file types may be stored. For example, for a C language code file, the module includes a way of decomposing a C language code file into a plurality of content blocks and a comparison and merging policy for each content block. By storing the content block division models corresponding to various file types in the module, the function of comparing different file types based on semantics can be realized.
And a comparing module 403, configured to compare the input files based on the content blocks to obtain a comparison result.
A merging module 404, configured to perform merging according to the comparison result of the comparing module 403, or perform merging according to the operation of the user, so as to generate a new merged file.
And the scoring module 405 is configured to perform risk prediction on the merged result, and quantify the risk of the merged result by using a numerical value.
In summary, in the embodiment of the present application, by dividing the content blocks of the files to be compared, the files can be merged based on semantics, which is helpful for improving the efficiency and accuracy of merging the files and for realizing automatic merging, and after the method is integrated into a code change management system, the efficiency and accuracy of automatically combining and merging the files can be improved, and quantitative risk assessment can be provided for the automatically combined and structured files.
Based on the same inventive concept as the document merging method shown in fig. 2, as shown in fig. 5, the embodiment of the present application further provides a document merging apparatus 500, and the document merging apparatus 500 can be used for executing the method shown in fig. 5. The file merging apparatus 500 includes a processor 501 and a memory 502, and the processor 501 is configured to execute code in the memory 502, and when the code is executed, the execution causes the processor 501 to execute the file method shown in fig. 2.
The processor 501 may be a Central Processing Unit (CPU), a Network Processor (NP), or a combination of a CPU and an NP.
The processor 501 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a Programmable Logic Device (PLD), or a combination thereof. The PLD may be a Complex Programmable Logic Device (CPLD), a field-programmable gate array (FPGA), a General Array Logic (GAL), or any combination thereof.
Memory 502 may include volatile memory (volatile memory), such as random-access memory (RAM); the memory 502 may also include a non-volatile memory (non-volatile memory), such as a flash memory (flash memory), a Hard Disk Drive (HDD) or a solid-state drive (SSD); the memory 502 may also comprise a combination of memories of the kind described above.
Based on the same inventive concept as the document merging method shown in fig. 2, as shown in fig. 6, the embodiment of the present application further provides a document merging apparatus 600, and the document merging apparatus 600 can be used for executing the method shown in fig. 2. The file merging apparatus 600 includes: an acquisition unit 601 and a processing unit 602. Wherein:
an acquisition unit 601 configured to acquire a first file and a second file;
a processing unit 602, configured to determine content blocks included in a first file according to semantics of content in the first file, and determine content blocks included in a second file according to semantics of content in the second file;
the processing unit 602 is further configured to compare content blocks included in the first file with content blocks included in the second file, and merge the first file and the second file according to a comparison result.
Optionally, when determining the content blocks included in the first file and the content blocks included in the second file, the processing unit 602 is specifically configured to: respectively determining the file types of the first file and the second file; acquiring a first content block division model corresponding to the file type of a first file and a second content block division model corresponding to the file type of a second file according to the corresponding relation between the pre-stored file type and the content block division model; performing semantic recognition on the content in the first file according to the acquired first content block division model, and determining content blocks contained in the first file according to the result of the semantic recognition; and performing semantic recognition on the content in the second file according to the acquired second content block division model, and determining the content blocks contained in the second file according to the result of the semantic recognition.
Optionally, when the processing unit 602 compares the content blocks included in the first file with the content blocks included in the second file, and merges the first file and the second file according to the comparison result, the processing unit is specifically configured to:
and combining the content blocks with different identifications in the first file and the second file according to the identifications of the content blocks contained in the first file and the second file respectively.
Optionally, when the processing unit 602 compares the content blocks included in the first file with the content blocks included in the second file, and merges the first file and the second file according to the comparison result, the processing unit is specifically configured to:
and comparing the content blocks with the same identifier in the first file and the second file based on the character strings according to the identifiers of the content blocks contained in the first file and the second file respectively, and merging according to the comparison result of the character strings.
Optionally, the processing unit 602 is further configured to:
and after the first file and the second file are merged according to the comparison result, carrying out accuracy evaluation on the merged result, and prompting the result of the accuracy evaluation to a user.
Optionally, when the processing unit 602 compares the content blocks included in the first file with the content blocks included in the second file, and merges the first file and the second file according to the comparison result, the processing unit is specifically configured to:
if the first file and the second file are both modified files based on the baseline file, comparing the content blocks contained in the first file with the content blocks contained in the second file according to the content blocks contained in the baseline file, and merging the first file and the second file according to the comparison result.
An embodiment of the present application provides a computer storage medium, which stores a computer program, where the computer program includes a program for executing the file merging method shown in fig. 2.
Embodiments of the present application provide a computer program product containing instructions that, when executed on a computer, cause the computer to perform the file merging method shown in fig. 2.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While the preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various changes and modifications may be made in the embodiments of the present application without departing from the spirit and scope of the embodiments of the present application. Thus, if such modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to encompass such modifications and variations.

Claims (9)

1. A method for merging files, comprising:
acquiring a first file and a second file, wherein the first file and the second file are code files of a programming language;
determining content blocks contained in the first file according to the semantics of the content in the first file, and determining content blocks contained in the second file according to the semantics of the content in the second file; wherein the categories of the content blocks include: a function or an enumerated type;
comparing the content blocks contained in the first file with the content blocks contained in the second file, and merging the first file and the second file according to the comparison result;
wherein comparing the content blocks contained in the first file with the content blocks contained in the second file, and merging the first file and the second file according to the comparison result comprises:
merging content blocks with different identifications in the first file and the second file according to the identifications of the content blocks contained in the first file and the second file respectively; and comparing content blocks with the same identifier in the first file and the second file based on character strings according to the identifiers of the content blocks contained in the first file and the second file respectively, and merging according to the comparison result of the character strings.
2. The method of claim 1, wherein determining the content blocks contained in the first file according to semantics of content in the first file and determining the content blocks contained in the second file according to semantics of content in the second file comprises:
respectively determining the file types of the first file and the second file;
acquiring a first content block division model corresponding to the file type of the first file and a second content block division model corresponding to the file type of the second file according to the corresponding relation between the pre-stored file type and the content block division model;
performing semantic recognition on the content in the first file according to the acquired first content block division model, and determining content blocks contained in the first file according to a semantic recognition result; and
and performing semantic recognition on the content in the second file according to the acquired second content block division model, and determining content blocks contained in the second file according to the result of the semantic recognition.
3. The method of claim 1 or 2, wherein after merging the first file and the second file according to the comparison result, further comprising:
and carrying out accuracy evaluation on the combined result, and prompting the accuracy evaluation result to a user.
4. The method of claim 1 or 2, wherein comparing the content blocks contained in the first file with the content blocks contained in the second file and merging the first file and the second file according to the comparison result comprises:
if the first file and the second file are both modified files based on a baseline file, comparing the content blocks contained in the first file with the content blocks contained in the second file according to the content blocks contained in the baseline file, and merging the first file and the second file according to the comparison result.
5. A file merging apparatus, comprising:
the device comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for acquiring a first file and a second file which are code files of a programming language;
the processing unit is used for determining content blocks contained in the first file according to the semantics of the content in the first file and determining content blocks contained in the second file according to the semantics of the content in the second file; wherein the categories of the content blocks include: a function or an enumerated type;
the processing unit is further configured to compare content blocks included in the first file with content blocks included in the second file, and merge the first file and the second file according to a comparison result;
the processing unit is specifically configured to, when comparing the content block included in the first file with the content block included in the second file, and merging the first file and the second file according to a comparison result:
merging content blocks with different identifications in the first file and the second file according to the identifications of the content blocks contained in the first file and the second file respectively; and comparing content blocks with the same identifier in the first file and the second file based on character strings according to the identifiers of the content blocks contained in the first file and the second file respectively, and merging according to the comparison result of the character strings.
6. The apparatus according to claim 5, wherein the processing unit, when determining the content blocks included in the first file and the content blocks included in the second file, is specifically configured to:
respectively determining the file types of the first file and the second file;
acquiring a first content block division model corresponding to the file type of the first file and a second content block division model corresponding to the file type of the second file according to the corresponding relation between the pre-stored file type and the content block division model;
performing semantic recognition on the content in the first file according to the acquired first content block division model, and determining content blocks contained in the first file according to a semantic recognition result; and
and performing semantic recognition on the content in the second file according to the acquired second content block division model, and determining content blocks contained in the second file according to the result of the semantic recognition.
7. The apparatus of claim 5 or 6, wherein the processing unit is further to:
and after the first file and the second file are merged according to the comparison result, carrying out accuracy evaluation on the merged result, and prompting the result of the accuracy evaluation to a user.
8. The apparatus according to claim 5 or 6, wherein the processing unit is configured to compare content blocks contained in the first file with content blocks contained in the second file, and when merging the first file with the second file according to the comparison result, specifically:
if the first file and the second file are both modified files based on a baseline file, comparing the content blocks contained in the first file with the content blocks contained in the second file according to the content blocks contained in the baseline file, and merging the first file and the second file according to the comparison result.
9. A file merging apparatus, comprising:
a memory storing a computer program;
a processor for executing a computer program stored in the memory to implement the method of any one of claims 1 to 4.
CN201710859738.7A 2017-09-21 2017-09-21 File merging method and device Active CN110069455B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710859738.7A CN110069455B (en) 2017-09-21 2017-09-21 File merging method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710859738.7A CN110069455B (en) 2017-09-21 2017-09-21 File merging method and device

Publications (2)

Publication Number Publication Date
CN110069455A CN110069455A (en) 2019-07-30
CN110069455B true CN110069455B (en) 2021-12-14

Family

ID=67364366

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710859738.7A Active CN110069455B (en) 2017-09-21 2017-09-21 File merging method and device

Country Status (1)

Country Link
CN (1) CN110069455B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110688140B (en) * 2019-10-11 2023-11-21 上海创功通讯技术有限公司 Code management method and terminal
CN110929500B (en) * 2019-11-08 2022-07-08 腾讯科技(深圳)有限公司 File comparison method and related device
CN113110868B (en) * 2021-04-07 2023-08-08 网易(杭州)网络有限公司 File merging method, device, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1773506A (en) * 2004-11-12 2006-05-17 国际商业机器公司 Method and system for managing revisions to a file
CN102945226A (en) * 2011-10-13 2013-02-27 微软公司 Application used for transferring a plurality of content items and functions to electronic content items
CN103279459A (en) * 2012-03-30 2013-09-04 微软公司 Semantic diff and automerge
CN105843841A (en) * 2016-03-07 2016-08-10 青岛理工大学 Small file storing method and system
CN106855861A (en) * 2015-12-09 2017-06-16 北京金山安全软件有限公司 File merging method and device and electronic equipment

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100684887B1 (en) * 2005-02-04 2007-02-20 삼성전자주식회사 Data storing device including flash memory and merge method of thereof
JP2007304998A (en) * 2006-05-12 2007-11-22 Hitachi Software Eng Co Ltd Source code generation method, device, and program
CN100538633C (en) * 2007-10-11 2009-09-09 金蝶软件(中国)有限公司 A kind of merging method and system of structural model
CN101533346B (en) * 2008-03-13 2012-10-10 中兴通讯股份有限公司 Source file comparing unit and method thereof
CN101635854B (en) * 2009-08-26 2012-07-04 腾讯科技(深圳)有限公司 Method and device for realizing transcoding merging
CN102681830B (en) * 2011-03-17 2015-09-02 阿里巴巴集团控股有限公司 A kind of method and apparatus of comparison program text
US9858052B2 (en) * 2013-03-21 2018-01-02 Razer (Asia-Pacific) Pte. Ltd. Decentralized operating system
CN104536959B (en) * 2014-10-16 2018-03-06 南京邮电大学 A kind of optimization method of Hadoop accessing small high-volume files
CN106227668B (en) * 2016-07-29 2017-11-17 腾讯科技(深圳)有限公司 Data processing method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1773506A (en) * 2004-11-12 2006-05-17 国际商业机器公司 Method and system for managing revisions to a file
CN102945226A (en) * 2011-10-13 2013-02-27 微软公司 Application used for transferring a plurality of content items and functions to electronic content items
CN103279459A (en) * 2012-03-30 2013-09-04 微软公司 Semantic diff and automerge
CN106855861A (en) * 2015-12-09 2017-06-16 北京金山安全软件有限公司 File merging method and device and electronic equipment
CN105843841A (en) * 2016-03-07 2016-08-10 青岛理工大学 Small file storing method and system

Also Published As

Publication number Publication date
CN110069455A (en) 2019-07-30

Similar Documents

Publication Publication Date Title
US9898280B2 (en) Automatic code review and code reviewer recommendation
CN110968325B (en) Applet conversion method and device
CN106547527B (en) JavaScript file construction method and device
US11036491B1 (en) Identifying and resolving firmware component dependencies
JP6933736B2 (en) Methods, devices, equipment and media for acquiring data models in the knowledge graph
CN110069455B (en) File merging method and device
US9218411B2 (en) Incremental dynamic document index generation
CN111290785B (en) Method, device, electronic equipment and storage medium for evaluating compatibility of deep learning framework system
US20140188929A1 (en) Computer-readable storage medium, file management apparatus, and file management method
US20200057635A1 (en) Information processing apparatus, information processing method and program
KR101975272B1 (en) System and method for recommending component reuse based on collaboration dependency
US10782942B1 (en) Rapid onboarding of data from diverse data sources into standardized objects with parser and unit test generation
US9436460B2 (en) Regression alerts
CN109388568B (en) Code testing method and device
CN110928941B (en) Data fragment extraction method and device
WO2011134982A1 (en) Edit sessions using change lists
US20140188950A1 (en) Computer-readable storage medium, file management apparatus, and file management method
EP3818437A1 (en) Binary software composition analysis
CN115795059A (en) Threat modeling method and system for agile development
US20140129934A1 (en) Dynamic model-based management tooling
US20140129532A1 (en) Packaging, storing and distributing guidance packages
CN113901025A (en) Database management method, device, equipment and storage medium
CN113094122A (en) Method and device for executing data processing script
US11429560B2 (en) Systems and methods for detection of automatable sheet modification actions
KR20210147354A (en) Method and apparatus for automatic merging between source codes

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
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20211229

Address after: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen

Patentee after: HUAWEI TECHNOLOGIES Co.,Ltd.

Address before: 100085, No. 3, information road, Haidian District, Beijing

Patentee before: Beijing Huawei Digital Technology Co.,Ltd.

Effective date of registration: 20211229

Address after: 450046 Floor 9, building 1, Zhengshang Boya Plaza, Longzihu wisdom Island, Zhengdong New Area, Zhengzhou City, Henan Province

Patentee after: xFusion Digital Technologies Co., Ltd.

Address before: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen

Patentee before: HUAWEI TECHNOLOGIES Co.,Ltd.