CN105183789A - File merging method and system based on git source code confliction - Google Patents
File merging method and system based on git source code confliction Download PDFInfo
- Publication number
- CN105183789A CN105183789A CN201510516497.7A CN201510516497A CN105183789A CN 105183789 A CN105183789 A CN 105183789A CN 201510516497 A CN201510516497 A CN 201510516497A CN 105183789 A CN105183789 A CN 105183789A
- Authority
- CN
- China
- Prior art keywords
- file
- conflict
- merging
- source code
- piece
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/16—File or folder operations, e.g. details of user interfaces specifically adapted to file systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/43—Checking; Contextual analysis
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Human Computer Interaction (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a file merging method and system based on git source code confliction. The method comprises: S1: respectively obtaining modification information of a first file to generate a second file and a third file; S2: merging the three files to generate confliction files; S3: with reference to the first file, detecting new-added line of the confliction files, and deleting the merging tags; S4: compiling and inspecting the confliction files to obtain a fourth file. According to the method disclosed by the present invention, automatic merging of the modified files can be realized, confliction caused by new-added files in source code project configuration files is avoided, and strong operability is ensured.
Description
Technical field
The present invention relates to Document Editing field, especially relate to a kind of Piece file mergence method and system based on the conflict of git source code.
Background technology
At present, when there being many people to modify to source code item file simultaneously, often can, due to different alter modes, to produce different newly-increased files, item file be caused to increase different content newly with a line.This directly causes merging instrument automatically cannot merge amended newly-increased file.
Existing patent (application number: 201210390805.2) disclose a kind of network synchronization method and device, described method comprises step: the source file catalogue in monitor client computing machine, collects the change events occurred in source file catalogue; According to the time sequencing that described change events occurs, obtain initial change sequence of events; According to preset rules, the redundancy event in described initial change sequence of events is merged, generate Significant Change sequence of events; According to described Significant Change sequence of events, send synchronization request to high in the clouds storage server.This patent is Network Based to be merged source file, and the sequencing simultaneously for the time realizes merging in order, to highlight the difference in sequential.But still the merging not to the new line increment occurred in the same position related in a file.
Summary of the invention
Technical matters to be solved by this invention is:
In order to solve the problems of the technologies described above, the technical solution used in the present invention is: provide a kind of Piece file mergence method based on the conflict of git source code, comprise the steps:
S1: obtain the amendment information to the first file respectively, to generate the second file and the 3rd file;
S2: merge above-mentioned three parts of files, generates conflict file;
S3: with reference to the first file, detect the new line increment in described conflict file, and delete merging mark;
S4: carry out compiling inspection to described conflict file, obtains the 4th file.
In order to solve the problems of the technologies described above, the invention provides a kind of Piece file mergence system based on the conflict of git source code, comprising:
Modified module, for obtaining the amendment information to the first file respectively, to generate the second file and the 3rd file;
Merging module, for merging above-mentioned three parts of files, generating conflict file;
Removing module, for reference to the first file, detects the new line increment in described conflict file, and deletes merging mark;
Object module, for carrying out compiling inspection to described conflict file, obtains the 4th file.
Beneficial effect of the present invention is: be different from prior art, and the present invention to be modified the automatic merging of file by compiling inspection, can avoid in source code project profile due to conflict that newly-increased file causes.Workable.
Accompanying drawing explanation
Fig. 1 is the schematic flow sheet of the inventive method embodiment one;
Fig. 2 is the schematic flow sheet of the inventive method embodiment two;
Fig. 3 is the reference diagram of specific embodiments of the invention;
Fig. 4 is the structured flowchart of present system embodiment three;
Fig. 5 is the structured flowchart of present system embodiment four.
Embodiment
By describing technology contents of the present invention in detail, realized object and effect, accompanying drawing is coordinated to be explained below in conjunction with embodiment.
The design of most critical of the present invention is: check code by compiling, realizes automatically merging.
Please refer to Fig. 1, the embodiment of the present invention one provides a kind of Piece file mergence method based on the conflict of git source code, comprises the steps:
S1: obtain the amendment information to the first file respectively, to generate the second file and the 3rd file;
S2: merge above-mentioned three parts of files, generates conflict file;
S3: with reference to the first file, detect the new line increment in described conflict file, and delete merging mark;
S4: carry out compiling inspection to described conflict file, obtains the 4th file.
Be different from prior art, the present invention checks the automatic merging of file of modifying by compiling, can avoid due to the conflict that newly-increased file causes in source code project profile, and workable.
As shown in Figure 2, on the basis of embodiment one, in the embodiment of the present invention two, step S2 is specially:
S21: with reference to the first file, compare the second file and the 3rd file respectively line by line, detect new line increment;
S22: use merging instrument to be merged in the correspondence position of the first file by the new line increment in the second file and the 3rd file, generates conflict file.
Wherein, step S3 is specially:
S31: with reference to the first file, detects the new line increment in conflict file respectively line by line, merges mark to locate;
S32: the merging mark deleting conflict file.
Wherein, step S4 is specially:
S41: call compiler directive and compiling inspection is carried out to described conflict file;
S42: judge that compiling checks whether and pass through;
If so, then S43 is performed: confirm to merge successfully, marking described conflict file is the 4th file;
Otherwise, then S44 is performed: confirm to merge unsuccessfully; And return execution step S1.
Be different from prior art, the present invention is with reference to the first file, and the new line increment of comparison one by one in the conflict file generated, when merging, adds the new line increment of correspondence position corresponding to the first file to.If there is same new line increment, the new content of two files is incomplete same, then there will be mark, shown in following example.Here, there is no the comparison cycle, just trigger and merge code, automatically merge.In this case, likely occur that merging cannot be carried out, after therefore needing to navigate to mark, deleted, finally use compiler to carry out compiling inspection to code, pass through if check, then represent that merging is correct.Therefore adopt and can avoid due to the conflict that newly-increased file causes in source code project profile in this way, actual workable.
Give an example, as shown in Figure 3, in a specific embodiment, version 1 file can be selected as source document, i.e. the first file, version 2 file, version 3 file are all the corresponding amendments made on version 1 file, i.e. the second file and the 3rd file.Version 2 file and version 3 file are all occur new line increment at the correspondence position of version 1, be respectively " <item>/ file 1</item> ", " <item>/ file 2</item> " by merging instrument, gitmerge Command combination as an illustrative example becomes temporary file 3 (namely conflict file).Here, should be understood that, merging instrument can be except the gitmerge order that git carries, and can also be the comparison instrument of some files, such as AraxisMerge etc.
After generation temporary file 3, because new line increment content is incomplete same, therefore occurred merging mark: " <<<< <<<HEAD " and "=======" and " >>>GreatT.Grea T.GT>>>master ", with reference to shown in Fig. 3, version 2 file, the left and right sides of version 3 file apportion and version 1 file, therefore the <<<< <<< occurred and >>>GreatT.Grea T.GT>>> sign flag, these are located for carrying out differentiation with the title of version 1 file.HEAD or master is wherein the filename of version 2 file and version 3 file."=======" be the separator of two new line increments of different content.
When COMPUTER DETECTION is to the above-mentioned row containing merging tag format, automatically can deletes and merge mark, then the last file generating merging, be i.e. the 4th file.Particularly, the compilation tool of Microsoft can be used to carry out compiling inspection, as carried out compiling inspection to final merged file MyApp.csproj.Compilation script MSBuildMyApp.csproj/t:Clean/p:Configuration=Debug can be used; / p:Platform=x86; TargetFrameworkVersion=v3.5.If the success of execution compilation script, then represent and merge correctly, otherwise expression merges unsuccessfully.
Example:
Version 1 file: pro.project content is as follows
<filelist>
The original file </item> of <item>/
The original file </item> of <item>/
</filelist>
Version 2 file: programmer 1 adds file 1:
<filelist>
The original file </item> of <item>/
<item>/ file 1</item>
The original file </item> of <item>/
</filelist>
Version 3 file: programmer 2 adds file 2:
<filelist>
The original file </item> of <item>/
<item>/ file 2</item>
The original file </item> of <item>/
</filelist>
After gitmerge Command combination, generate temporary file 3
<filelist>
The original file </item> of <item>/
<<<<<<<HEAD
<item>/ file 2</item>
=======
<item>/ file 1</item>
>>>>>>>master
The original file </item> of <item>/
</filelist>
In addition, because when different editions file is modified to same a line source code simultaneously, due to cannot merge order be determined, namely cannot determine whether it is that two kinds of different amendments are carried out to original position, possibly cannot compile after merging.But in embodiments of the present invention, the compiler automatic Verification of use, can be combined result verification automatically, passes through if can compile after merging, then represent that amalgamation result is correct.
As shown in Figure 4, the embodiment of the present invention three provides a kind of Piece file mergence system 100 based on the conflict of git source code, comprising:
Modified module 110, for obtaining the amendment information to the first file respectively, to generate the second file and the 3rd file;
Merging module 120, for merging above-mentioned three parts of files, generating conflict file;
Removing module 130, for reference to the first file, detects the new line increment in described conflict file, and deletes merging mark;
Object module 140, for carrying out compiling inspection to described conflict file, obtains the 4th file.
As shown in Figure 5, wherein said merging module 120 comprises:
Comparing unit 121, for reference to the first file, compares the second file and the 3rd file respectively line by line, detects new line increment;
Merge cells 122, for being merged in the correspondence position of the first file by merging instrument by the new line increment in the second file and the 3rd file, generates conflict file.
Wherein, described removing module 130 comprises:
Positioning unit 131, for reference to the first file, detects the new line increment in conflict file respectively line by line, merges mark to locate;
Delete cells 132, for deleting the merging mark of conflict file.
Wherein, described object module 140 comprises:
Call unit 141, carries out compiling inspection for calling compiler directive to described conflict file;
Judging unit 142, passes through for judging that compiling checks whether
The foregoing is only embodiments of the invention; not thereby the scope of the claims of the present invention is limited; every equivalents utilizing instructions of the present invention and accompanying drawing content to do, or be directly or indirectly used in relevant technical field, be all in like manner included in scope of patent protection of the present invention.
Claims (8)
1., based on a Piece file mergence method for git source code conflict, it is characterized in that, comprising:
S1: obtain the amendment information to the first file respectively, to generate the second file and the 3rd file;
S2: merge above-mentioned three parts of files, generates conflict file;
S3: with reference to the first file, detect the new line increment in described conflict file, and delete merging mark;
S4: carry out compiling inspection to described conflict file, obtains the 4th file.
2., according to claim 1 based on the Piece file mergence method of git source code conflict, it is characterized in that, step S2 is specially:
S21: with reference to the first file, compare the second file and the 3rd file respectively line by line, detect new line increment;
S22: use merging instrument to be merged in the correspondence position of the first file by the new line increment in the second file and the 3rd file, generates conflict file.
3., according to claim 1 based on the Piece file mergence method of git source code conflict, it is characterized in that, step S3 is specially:
S31: with reference to the first file, detects the new line increment in conflict file respectively line by line, merges mark to locate;
S32: the merging mark deleting conflict file.
4., according to claim 1 based on the Piece file mergence method of git source code conflict, it is characterized in that, step S4 is specially:
S41: call compiler directive and compiling inspection is carried out to described conflict file;
S42: judge that compiling checks whether and pass through;
If so, then S43 is performed: confirm to merge successfully, marking described conflict file is the 4th file;
Otherwise, then S44 is performed: confirm to merge unsuccessfully; And return execution step S1.
5., based on a Piece file mergence system for git source code conflict, it is characterized in that, comprising:
Modified module, for obtaining the amendment information to the first file respectively, to generate the second file and the 3rd file;
Merging module, for merging above-mentioned three parts of files, generating conflict file;
Removing module, for reference to the first file, detects the new line increment in described conflict file, and deletes merging mark;
Object module, for carrying out compiling inspection to described conflict file, obtains the 4th file.
6., according to claim 5 based on the Piece file mergence system of git source code conflict, it is characterized in that, described merging module comprises:
Comparing unit, for reference to the first file, compares the second file and the 3rd file respectively line by line, detects new line increment;
Merge cells, for being merged in the correspondence position of the first file by merging instrument by the new line increment in the second file and the 3rd file, generates conflict file.
7., according to claim 5 based on the Piece file mergence system of git source code conflict, it is characterized in that, described removing module comprises:
Positioning unit, for reference to the first file, detects the new line increment in conflict file respectively line by line, merges mark to locate;
Delete cells, for deleting the merging mark of conflict file.
8., according to claim 5 based on the Piece file mergence system of git source code conflict, it is characterized in that, described object module comprises:
Call unit, carries out compiling inspection for calling compiler directive to described conflict file;
Judging unit, passes through for judging that compiling checks whether.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510516497.7A CN105183789A (en) | 2015-08-21 | 2015-08-21 | File merging method and system based on git source code confliction |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510516497.7A CN105183789A (en) | 2015-08-21 | 2015-08-21 | File merging method and system based on git source code confliction |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105183789A true CN105183789A (en) | 2015-12-23 |
Family
ID=54905872
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510516497.7A Pending CN105183789A (en) | 2015-08-21 | 2015-08-21 | File merging method and system based on git source code confliction |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105183789A (en) |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108073501A (en) * | 2016-11-14 | 2018-05-25 | 阿里巴巴集团控股有限公司 | A kind of code conflicts detection method and equipment |
CN109117139A (en) * | 2018-07-05 | 2019-01-01 | 珠海市魅族科技有限公司 | A kind of software building method and device, server and readable storage medium storing program for executing |
CN109656621A (en) * | 2018-12-19 | 2019-04-19 | 睿驰达新能源汽车科技(北京)有限公司 | A kind of method and device merging code |
CN110427177A (en) * | 2019-06-18 | 2019-11-08 | 平安科技(深圳)有限公司 | Code optimization method, apparatus, computer installation and storage medium |
CN111273944A (en) * | 2018-12-05 | 2020-06-12 | 北京奇虎科技有限公司 | Method and device for generating program file and uploading program file to code warehouse |
WO2021135373A1 (en) * | 2019-12-31 | 2021-07-08 | 华为技术有限公司 | Associated conflict block presentation method and device |
CN113110868A (en) * | 2021-04-07 | 2021-07-13 | 网易(杭州)网络有限公司 | File merging method and device, computer equipment and storage medium |
CN113703778A (en) * | 2021-09-06 | 2021-11-26 | 工银科技有限公司 | Engineering file conflict processing method and device based on mobile communication equipment |
CN114840250A (en) * | 2022-07-04 | 2022-08-02 | 金现代信息产业股份有限公司 | Code conflict merging method, system, electronic equipment and readable storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20060106889A1 (en) * | 2004-11-12 | 2006-05-18 | Mannby Claes-Fredrik U | Method, system, and program for managing revisions to a file |
CN101145101A (en) * | 2006-09-14 | 2008-03-19 | 国际商业机器公司 | Method, device and system for customizing and executing strategy in edition control |
CN103077062A (en) * | 2012-11-30 | 2013-05-01 | 华为技术有限公司 | Method and device for detecting code change |
CN103279459A (en) * | 2012-03-30 | 2013-09-04 | 微软公司 | Semantic diff and automerge |
CN104461578A (en) * | 2014-12-26 | 2015-03-25 | 广州唯品会信息科技有限公司 | Automatic code merging method and system |
-
2015
- 2015-08-21 CN CN201510516497.7A patent/CN105183789A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20060106889A1 (en) * | 2004-11-12 | 2006-05-18 | Mannby Claes-Fredrik U | Method, system, and program for managing revisions to a file |
CN101145101A (en) * | 2006-09-14 | 2008-03-19 | 国际商业机器公司 | Method, device and system for customizing and executing strategy in edition control |
CN103279459A (en) * | 2012-03-30 | 2013-09-04 | 微软公司 | Semantic diff and automerge |
CN103077062A (en) * | 2012-11-30 | 2013-05-01 | 华为技术有限公司 | Method and device for detecting code change |
CN104461578A (en) * | 2014-12-26 | 2015-03-25 | 广州唯品会信息科技有限公司 | Automatic code merging method and system |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108073501A (en) * | 2016-11-14 | 2018-05-25 | 阿里巴巴集团控股有限公司 | A kind of code conflicts detection method and equipment |
CN108073501B (en) * | 2016-11-14 | 2021-08-13 | 阿里巴巴集团控股有限公司 | Code conflict detection method and device |
CN109117139A (en) * | 2018-07-05 | 2019-01-01 | 珠海市魅族科技有限公司 | A kind of software building method and device, server and readable storage medium storing program for executing |
CN111273944A (en) * | 2018-12-05 | 2020-06-12 | 北京奇虎科技有限公司 | Method and device for generating program file and uploading program file to code warehouse |
CN111273944B (en) * | 2018-12-05 | 2024-01-30 | 三六零科技集团有限公司 | Method and device for generating program file and uploading program file to code warehouse |
CN109656621A (en) * | 2018-12-19 | 2019-04-19 | 睿驰达新能源汽车科技(北京)有限公司 | A kind of method and device merging code |
CN110427177A (en) * | 2019-06-18 | 2019-11-08 | 平安科技(深圳)有限公司 | Code optimization method, apparatus, computer installation and storage medium |
WO2021135373A1 (en) * | 2019-12-31 | 2021-07-08 | 华为技术有限公司 | Associated conflict block presentation method and device |
CN113110868A (en) * | 2021-04-07 | 2021-07-13 | 网易(杭州)网络有限公司 | File merging method and device, computer equipment and storage medium |
CN113110868B (en) * | 2021-04-07 | 2023-08-08 | 网易(杭州)网络有限公司 | File merging method, device, computer equipment and storage medium |
CN113703778A (en) * | 2021-09-06 | 2021-11-26 | 工银科技有限公司 | Engineering file conflict processing method and device based on mobile communication equipment |
CN114840250A (en) * | 2022-07-04 | 2022-08-02 | 金现代信息产业股份有限公司 | Code conflict merging method, system, electronic equipment and readable storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105183789A (en) | File merging method and system based on git source code confliction | |
CN109063477B (en) | Automatic intelligent contract code defect detection system and method | |
Duala-Ekoko et al. | Tracking code clones in evolving software | |
US20160139916A1 (en) | Build Deployment Automation for Information Technology Mangement | |
US10353702B2 (en) | Source code element signatures | |
US20080301648A1 (en) | Model oriented debugging | |
CN103559123B (en) | Based on function call stack analytical approach and the device of vxworks operating system | |
US20130007709A1 (en) | Software configuration management | |
CN101308471B (en) | Method and device for data restoration | |
US9311078B2 (en) | Parallel development of a software system | |
US8918766B2 (en) | Analysis of propagated information using annotated forests | |
CN101866315A (en) | Test method and system of software development tool | |
CN106681783A (en) | Detection method and system for SVN code | |
CN102902770B (en) | Method and system for assembling mirror image files | |
US9658845B2 (en) | Generating a where-used objects list for updating data | |
WO2023040151A1 (en) | Algorithm application element generating method and apparatus, electronic device, computer readable storage medium, and computer program product | |
US20200379956A1 (en) | Version control of electronic files defining a model of a system or component of a system | |
CN113515303B (en) | Project transformation method, device and equipment | |
CN103559132B (en) | A kind of detection method of JAVA application program robustness and device | |
US9396239B2 (en) | Compiling method, storage medium and compiling apparatus | |
Demuth et al. | Co-evolution of Metamodels and Models through Consistent Change Propagation. | |
Borodin et al. | Deterministic static analysis | |
CN110321130B (en) | Non-repeatable compiling and positioning method based on system call log | |
Anbalagan et al. | APTE: Automated pointcut testing for AspectJ programs | |
CN110515653B (en) | Document generation method and device, electronic equipment and computer readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination |