Method and device for confirming difference fragment introduced by variable base in version comparison
By identifying and annotating the differential fragments introduced by the variable basis, the review interference caused by the variable basis operation is solved, and the code review efficiency is improved.
Patent Information
- Application Number
- CN202510318324.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2025-07-22
AI Technical Summary
During the code review process, the differences introduced by the variable-base operation interfere with the reviewer's judgment, resulting in inefficient review.
By obtaining the merged basic version and change list of the code review version, the differential fragments introduced by the variable base are identified and marked during the review process to reduce interference from the reviewer.
It improves the efficiency of code review and reduces the communication and understanding costs of reviewers.
Smart Images

Figure CN120353692A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and more specifically, to a method and device for identifying differential segments introduced by rebasing in version comparison. Background Art
[0002] During the code review process, as the mainline code is updated, it is often necessary to rebase the mainline code when changing branches to resolve conflicts or use new features added to the mainline code. However, this may lead to a situation where the differences in the mainline code introduced by the above-mentioned rebase interfere with the reviewer's judgment when comparing the code versions before and after rebasing the change branch. That is, the code versions before and after rebasing the change branch include not only the differences of the change branch itself but also the differences introduced by the mainline code due to rebase. The differences introduced by the above-mentioned rebase bring certain communication and understanding costs to both the code review submitter and the reviewer, and reduce the review efficiency.
[0003] In summary, how to identify the differential segments introduced by rebase in the code version comparison before and after rebasing the change branch, reduce the interference to the reviewer, and improve the review efficiency are the problems that need to be solved currently. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a method and device for identifying differential segments introduced by rebasing in version comparison, which can identify the differential segments introduced by rebase in the code version comparison before and after rebasing the change branch, reduce the interference to the reviewer, and improve the review efficiency.
[0005] In a first aspect, an embodiment of the present invention provides a method for identifying differential segments introduced by rebasing in version comparison. The method includes: obtaining a first code review version and a second code review version, where the second code review version is the code review version after rebasing the first code review version; obtaining a first merge base version of the first code review version and a second merge base version of the second code review version; determining a first change list between the first merge base version and the second merge base version, where the first change list includes multiple differential segments; determining a second change list between the first code review version and the second code review version, where the second change list includes multiple differential segments; and identifying, in the second change list, target differential segments that appear in the first change list, where the target differential segments are the differential segments introduced by rebase.
[0006] Optionally, the method further includes: marking the target differential segments with a specific color in the second change list.
[0007] Optionally, obtaining the first merge base version of the first code review version specifically includes: determining the corresponding first main trunk code version according to the first code review version; and determining the first merge base version according to the first code review version and the first main trunk code version.
[0008] Optionally, obtaining the second merge base version of the second code review version specifically includes: determining the corresponding second main trunk code version according to the second code review version; and determining the second merge base version according to the second code review version and the second main trunk code version.
[0009] Optionally, identifying the target difference segments that appear in the first change list in the second change list specifically includes: in response to at least one same file in the second change list and the first change list having changed; obtaining the old path and the new path of the file, as well as the old identifier and the new identifier; and in response to the old path and the new path being the same, and the old identifier and the new identifier being the same, determining the multiple difference segments corresponding to the file as the target difference segments.
[0010] Optionally, the method further includes: in response to the old path and the new path being different, and / or the old identifier and the new identifier being different, determining multiple candidate difference segments corresponding to each file; and determining the target difference segments from the multiple candidate difference segments.
[0011] Optionally, determining the target difference segments from the multiple candidate difference segments specifically includes: for each candidate difference segment, determining the first position information of the candidate difference segment in the first change list; performing line number tracking according to the first position information to determine the updated second position information; matching the candidate difference segment corresponding to the first position information in the first change list with the candidate difference segment corresponding to the second position information in the second change list; and in response to a successful match, determining the candidate difference segment as the target difference segment.
[0012] Optionally, performing line number tracking according to the first position information to determine the updated second position information specifically includes: performing line number tracking on the start position of the first position information to determine the start position of the updated second position information; and performing line number tracking on the end position of the first position information to determine the end position of the updated second position information.
[0013] Second aspect, an embodiment of the present invention provides an apparatus for identifying differential segments introduced by rebase in version comparison. The apparatus includes: an acquisition unit configured to acquire a first code review version and a second code review version, where the second code review version is the code review version after rebase of the first code review version; the acquisition unit is further configured to: acquire a first merge base version of the first code review version and a second merge base version of the second code review version; a determination unit configured to determine a first change list between the first merge base version and the second merge base version, where the first change list includes multiple differential segments; the determination unit is further configured to determine a second change list between the first code review version and the second code review version, where the first change list includes multiple differential segments; an identification unit configured to identify, in the second change list, target differential segments that appear in the first change list, where the target differential segments are differential segments introduced by rebase.
[0014] Optionally, the apparatus further includes a processing unit configured to label the target differential segments with a specific color in the second change list.
[0015] Optionally, the acquisition unit is specifically configured to: determine a first mainline code version corresponding to the first code review version according to the first code review version; and determine the first merge base version according to the first code review version and the first mainline code version.
[0016] Optionally, the acquisition unit is specifically configured to: determine a second mainline code version corresponding to the second code review version according to the second code review version; and determine the second merge base version according to the second code review version and the second mainline code version.
[0017] Optionally, the identification unit is specifically configured to: in response to at least one same file in the second change list and the first change list having changed; acquire an old path and a new path of the file, as well as an old identifier and a new identifier; and in response to the old path and the new path being the same, and the old identifier and the new identifier being the same, determine multiple differential segments corresponding to the file as the target differential segments.
[0018] Optionally, the identification unit is further specifically configured to: in response to the old path and the new path being different, and / or the old identifier and the new identifier being different, determine multiple candidate differential segments corresponding to each file; and determine the target differential segments from the multiple candidate differential segments.
[0019] Optionally, the recognition unit is specifically configured to: for each candidate difference segment, determine the first position information of the candidate difference segment in the first change list; perform line number tracking according to the first position information to determine the updated second position information; match the candidate difference segment corresponding to the first position information in the first change list with the candidate difference segment corresponding to the second position information in the second change list; in response to a successful match, determine the candidate difference segment as the target difference segment.
[0020] Optionally, the recognition unit is further specifically configured to: perform line number tracking on the start position of the first position information to determine the updated start position of the second position information; and perform line number tracking on the end position of the first position information to determine the updated end position of the second position information.
[0021] In a third aspect, an embodiment of the present invention provides an electronic device, including a memory and a processor, where the memory is used to store one or more computer program instructions, and wherein the one or more computer program instructions are executed by the processor to implement the method described in any one of the first aspect or any possible implementation of the first aspect.
[0022] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which computer program instructions are stored, and the computer program instructions, when executed by a processor, implement the method described in any one of the first aspect or any possible implementation of the first aspect.
[0023] In an embodiment of the present invention, by obtaining a first code review version and a second code review version, where the second code review version is the code review version after rebasing the first code review version; obtaining a first merge base version of the first code review version and a second merge base version of the second code review version; determining a first change list between the first merge base version and the second merge base version, where the first change list includes a plurality of difference segments; determining a second change list between the first code review version and the second code review version, where the first change list includes a plurality of difference segments; identifying a target difference segment that appears in the first change list in the second change list, where the target difference segment is a difference segment introduced by rebasing. Through the above method, it is possible to confirm the difference segments introduced by rebasing in the comparison of code versions before and after the change branch rebase, reduce the interference to reviewers, and improve the review efficiency. Description of the Drawings
[0024] Through the following description of the embodiments of the present invention with reference to the drawings, the above and other objects, features, and advantages of the present invention will become clearer. In the drawings:
[0025] Figure 1 It is a schematic diagram of a branch change in an embodiment of the present invention;
[0026] Figure 2 It is a schematic diagram of a device for confirming the differential segments introduced by rebase in version comparison in an embodiment of the present invention;
[0027] Figure 3 It is a flowchart of a method for identifying target differential segments in an embodiment of the present invention;
[0028] Figure 4 It is another flowchart of a method for identifying target differential segments in an embodiment of the present invention;
[0029] Figure 5 It is a diff schematic diagram of a line number tracking algorithm in an embodiment of the present invention;
[0030] Figure 6 It is a schematic diagram of the algorithm analysis of a line number tracking algorithm in an embodiment of the present invention;
[0031] Figure 7 It is another schematic diagram of a device for confirming the differential segments introduced by rebase in version comparison in an embodiment of the present invention;
[0032] Figure 8 It is a schematic diagram of a device for confirming the differential segments introduced by rebase in version comparison in an embodiment of the present invention;
[0033] Figure 9 It is a schematic diagram of an electronic device in an embodiment of the present invention. Detailed implementation manners
[0034] The following describes the present application based on embodiments, but the present application is not limited to these embodiments. In the following detailed description of the present application, some specific details are described in detail. Those skilled in the art can fully understand the present application without the description of these detail parts. In order to avoid obscuring the essence of the present application, well-known methods, processes, procedures, components, and circuits are not described in detail.
[0035] In addition, those of ordinary skill in the art should understand that the drawings provided herein are for illustrative purposes only, and the drawings are not necessarily drawn to scale.
[0036] Unless the context clearly requires otherwise, words such as "including" and "comprising" in the entire application document should be interpreted in an inclusive sense rather than an exclusive or exhaustive sense; that is, in the sense of "including but not limited to".
[0037] In the description of this application, it should be understood that the terms "first", "second", etc. are only for descriptive purposes and cannot be construed as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "a plurality of" is two or more.
[0038] In the code review process of the prior art, due to the update of the main code, when changing branches, it is often necessary to rebase the main code to resolve conflicts or use the new features added to the main code. For example, Figure 1 As shown, the main branch (main) is commit B, where commit is a command in the git system used to commit the changed content in the staging area to the code repository. A commit can be regarded as a state snapshot of the code repository at a specific time point. The above commit B represents the main code version at the time of commit B; a change branch - feature branch is generated based on commit B, and functions C1, C2, and C3 are developed on the feature branch. While developing new functions on the feature branch, D and E are also added to the main code. Therefore, the differences in the main code are introduced into the code version after rebasing the feature branch. In the feature-rebase code version generated after rebasing the feature branch, in addition to introducing the differences in the main code, the C4 function is also added. The feature-rebase code version also includes functions C1, C2, and C3 developed on the feature branch. After rebasing, since the commit ID changes, they are represented by functions C1', C2', and C3' respectively. That is, in the code versions of the feature branch and the feature-rebase code version, not only the differences in function C4 are included, but also the differences in the main code introduced by rebasing. The above differences in the main code introduced by rebasing interfere with the reviewer's judgment, bringing certain communication and understanding costs to both the code review submitter and the reviewer, and reducing the review efficiency. Therefore, how to confirm the difference segments introduced by rebasing in the comparison of code versions before and after changing branches, reduce the interference to the reviewer, and improve the review efficiency is a problem that needs to be solved currently.
[0039] In the embodiments of the present invention, various code versions are recorded and saved in git, and git is an open-source distributed version control system for efficiently managing code versions; the rebase is a command in git for moving a series of commits from one branch to another branch.
[0040] In an embodiment of the present invention, to solve the above problems, a method for confirming the differential segments introduced by rebase in version comparison is proposed, specifically as follows: Figure 2 The method includes:
[0041] Step S201, obtain a first code review version and a second code review version.
[0042] Wherein, the second code review version is the code review version after rebasing the first code review version.
[0043] In a possible implementation manner, the first code review version is the Figure 1 code version corresponding to the feature branch in, and the feature branch is the code version generated after adding functions C1, C2, and C3 on the basis of the main trunk code commitB; the second code review version is the Figure 1 code version generated after rebasing the feature branch in, that is, the feature-rebase code version.
[0044] Step S202, obtain a first merge base version of the first code review version and a second merge base version of the second code review version.
[0045] In a possible implementation manner, obtaining the first merge base version of the first code review version includes: determining the corresponding first main trunk code version according to the first code review version; determining the first merge base version according to the first code review version and the first main trunk code version.
[0046] Illustrate by way of example, as Figure 1 shown, the first code review version is the code version corresponding to the feature branch, and the first main trunk code version is Figure 1 shown as the commitB code version. Determine the merge base of the feature branch and the commitB code version as the commitB code version, that is, the first merge base version; the first merge base version is recorded in the code review push version record table; wherein, the merge base represents the common ancestor commit that can be found when two or more branches are merged. In Git, each commit has a unique hash value used to identify the commit. When two branches need to be merged, Git will find the nearest common ancestor commit on these two branches.
[0047] In a possible implementation manner, obtaining the second merge base version of the second code review version includes: determining the corresponding second mainline code version according to the second code review version; and determining the second merge base version according to the second code review version and the second mainline code version.
[0048] For example, as Figure 1 shown, the second code review version is the code version corresponding to the feature-rebase branch, and the second mainline code version is Figure 1 shown as the commitE code version. Determine that the merge base of the feature-rebase branch and the commitE code version is the commitE code version, that is, the second merge base version; the second merge base version is recorded in the code review push version record table.
[0049] Step S203: Determine a first change list between the first merge base version and the second merge base version.
[0050] Wherein, the first change list includes a plurality of difference segments.
[0051] Specifically, as Figure 1 shown, since the first merge base version is the commitB code version and the second merge base version is the commitE code version, use the git diff -U0 B..E command to obtain the first change list (changesets) of the commitB code version and the commitE code version, which can also be called merge-base-changesets; wherein, the first change list includes a plurality of difference segments (diffhunk), and the difference (diff) segment is the diff introduced by the above rebase.
[0052] In a possible implementation, U0 indicates that the format of the diff is the unified diff format with 0 lines of context. Here, the unified diff has a specific format. Specifically, "---" represents the file name before the change, and "+++" represents the file name after the change. A line starting and ending with "@@" indicates the line range where the change occurs. For example, "@@ -1,7 +1,7 @@" means there is a difference between 7 consecutive lines starting from line 1 in the first file and 7 consecutive lines starting from line 1 in the second file. Each line is preceded by an identifier indicating whether the line is deleted in the original file (represented by "-"), added in the modified file (represented by "+"), or unchanged (represented by a space). The above unified diff is only for illustrative purposes. The number of context lines can also be increased in the unified diff, which is specifically determined according to the actual situation and is not limited in the embodiments of the present invention.
[0053] Step S204: Determine the second change list between the first code review version and the second code review version.
[0054] Among them, the second change list includes multiple difference segments.
[0055] Specifically, as Figure 1 shown, since the first code review version is the feature code version, that is, the code version after adding function C3, and the second code review version is the feature-rebase code version, that is, the code version after adding function C4, the second change list (changesets) of the featur code version and the feature-rebase code version is obtained through the git diff -U0 C3..C4 instruction, which can also be called feature-changesets. Among them, the second change list includes multiple difference segments (diff hunk), and the diff in the second change list is the diff shown to the reviewer for review.
[0056] Step S205: Identify the target difference segments that appear in the first change list in the second change list.
[0057] Among them, the target difference segments are the difference segments (diff hunk) introduced by rebase.
[0058] Specifically, the diff hunks that appear in the merge-base-changesets are identified in the feature-changesets, so that when presented to the reviewer for review, it can be distinguished whether the diff hunks are introduced by rebase. Among them, the format of the diff hunk is "@@ - starting line number, number of lines + new starting line number, number of lines @@", and the diff hunk is the basic component of the unified diff.
[0059] Illustratively, part of the content of the merge-base-changesets is as follows:
[0060]
[0061] Among them, the merge-base-changesets include three diff hunks, namely diff hunk1, diff hunk2, and diff hunk3. Among them, the diff hunk1 is:
[0062]
[0063] The diff hunk2 is:
[0064]
[0065]
[0066] The diff hunk3 is:
[0067]
[0068] Part of the content of the feature-changesets is as follows:
[0069]
[0070] In the feature-changesets, it can be identified that the merge-base-changesets include diff hunk1, diff hunk2, and diff hunk3, and it is determined that the diff hunk1, diff hunk2, and diff hunk3 are target difference segments.
[0071] In the embodiments of the present invention, the above illustration is only a result representation. The specific steps of identifying the target difference segments that appear in the first change list in the second change list are as Figure 3 shown and include the following:
[0072] Step S301: In response to at least one same file in the second change list and the first change list having changed.
[0073] Specifically, perform a file-level comparison between the second change list feature-changesets and the first change list merge-base-changesets, that is, determine that changes to the same file appear in both the feature-changesets and the merge-base-changesets.
[0074] Step S302: Obtain the old path and the new path of the file, as well as the old identifier and the new identifier.
[0075] Specifically, determine the old path (oldPath) and the new path (newPath) of the above-mentioned same file, that is, the oldPath and the newPath of the same file in the code repository; and the old identifier (oldObjectId) and the new identifier (newObjectId), where the oldObjectId refers to the ID of the file pointed to before the reference update or deletion, and is used to uniquely identify an object in the Git repository; the newObjectId refers to the ID of the new file pointed to after the reference update.
[0076] Step S303: In response to the old path and the new path being the same, and the old identifier and the new identifier being the same, determine that the multiple difference segments corresponding to the file are the target difference segments.
[0077] Specifically, through the above Step S303, determine that all the difference segments of the entire file are the target difference segments.
[0078] In the embodiment of the present invention, the above Figure 3 Shows a file-level comparison and then determines the target difference segments.
[0079] In a possible implementation manner, after Step S302, there are also other steps, specifically as Figure 4 shown, including the following:
[0080] Step S304: In response to the old path and the new path being different, and / or the old identifier and the new identifier being different, determine multiple candidate difference segments corresponding to each file.
[0081] Specifically, in response to the difference between the old path and the new path, and / or the difference between the old identifier and the new identifier, it indicates that there is no file-level completely matching object in the second change list feature-changesets and the first change list merge-base-changesets. Therefore, it is necessary to perform identification at the diff hunk level. Among them, the identification at the diff hunk level means identifying each diff hunk as a whole, that is, each diff hunk to be identified in the first change list merge-base-changesets is respectively matched in the second change list feature-changesets.
[0082] Suppose that the file H in the first change list merge-base-changesets includes 3 diff hunks, namely diff hunk (A), diff hunk (B), and diff hunk (C). After the comparison at the file level of the file H fails, the diff hunk (A), diff hunk (B), and diff hunk (C) are respectively used as candidate difference segments for comparison in the second change list feature-changesets.
[0083] Step S305, determine the target difference segment among the multiple candidate difference segments.
[0084] Specifically, for each candidate difference segment, determine the first position information of the candidate difference segment in the first change list; perform line number tracking according to the first position information to determine the updated second position information; match the candidate difference segment corresponding to the first position information in the first change list with the candidate difference segment corresponding to the second position information in the second change list; in response to a successful match, determine the candidate difference segment as the target difference segment.
[0085] In a possible implementation, the diff hunks included in the changes of the files that fail the file-level comparison are calculated through git Diff between the mergebases, namely merge-base-diff-hunks; specifically, the merge-base-diff-hunks are obtained through the git diff -U0 B..E instruction, and each diff hunk includes corresponding first oldPath and first newPath, and the first oldPath and first newPath are the above-mentioned first position information; the line number tracking is performed on the start position of the first position information to determine the start position of the updated second position information; and, the line number tracking is performed on the end position of the first position information to determine the end position of the updated second position information; the second position information is the expected position when comparing the two code versions of feature and feature-rebase, namely merge-base-diff-hunks-range-updated; the list of diff hunks actually obtained during the code version comparison is obtained through the Diff between feature and feature-rebased, namely feature-diff-hunks; specifically, the feature-diff-hunks are obtained through the git diff -U0 C3..C4 instruction, and each diff hunk includes corresponding second oldPath and second newPath, and the second oldPath and second newPath are the above-mentioned second position information; it is determined whether the diff hunk in the feature-diff-hunks matches the diff hunk in the merge-base-diff-hunks-range-updated, and if it matches, it is determined that the above diff hunk is a diff hunk introduced by rebase.
[0086] In a possible implementation, when performing line number tracking to calculate the line number offset, if there is an intersection between the diff hunk in the merge-base-diff-hunks and the diff hunks obtained from the diff between the prev merge base and feature, namely merge-base-left-side-diff-hunk; or the diff hunks obtained from the diff between the new merge base and feature-rebased, namely merge-base-right-side-diff-hunks, then this diff hunk is not regarded as a diff hunk introduced by rebase.
[0087] In a possible implementation, when obtaining the diff between the prev merge base and the feature, the git command used can be git diff -U0 B..C3, where the prev merge base is the commit B code version, and the feature code version is the code version after adding function C3. The hunk in the generated merge-base-left-side-diff-hunk only includes oldPath, where the prev merge base is the merge base before rebase; when obtaining the diff between the new merge base and the feature-rebased, the git command used can be git diff -U0 E..C4, where the new merge base is the commit E code version, and the feature-rebased code version is the code version after adding function C4. The hunk in the generated merge-base-right-side-diff-hunks only includes newPath, where the new merge base is the merge base after rebase.
[0088] In a possible implementation, the diff schematic diagram of the line number tracking algorithm is as Figure 5 shown. Assume git diff X..Y. The first hunk in file X starts from line 15 and has 9 consecutive lines. After Figure 6 the algorithm parsing schematic diagram, it is determined that the first hunk in file Y starts from line 15 and has 7 consecutive lines;
[0089] The second hunk in file X starts from line 26 and has 7 consecutive lines. After Figure 6 the algorithm parsing schematic diagram, it is determined that the second hunk in file Y starts from line 24 and has 6 consecutive lines;
[0090] The third hunk in file X starts from line 81 and has 12 consecutive lines. After Figure 6Schematic diagram of the algorithm parsing, it is determined that the third hunk starts from line 78 in the Y file and has 6 consecutive lines; after line number tracking, line 8 in the X file is line 8 in the Y file; after line number tracking, line 25 in the X file is line 23 in the Y file; after line number tracking, line 60 in the X file is line 57 in the Y file; after line number tracking, line 98 in the X file is line 89 in the Y file; the middle lines of the hunk in the X file cannot be tracked for line numbers, that is, the line numbers between 15 - 23, between 26 - 32, and between 81 - 92 cannot be tracked for line numbers.
[0091] In the embodiments of the present invention, other algorithms for line number tracking can also be adopted, which are specifically determined according to the actual situation, and the embodiments of the present invention do not limit it.
[0092] In a possible implementation manner, after step S205, there are also other steps, specifically as Figure 7 shown, including the following:
[0093] Step S206, mark the target difference segment with a specific color in the second change list.
[0094] For example, assume that all the words in the second change list are black. When the target difference segment is determined, set the color of the target difference segment to red, or blue, or other colors different from black. The colors here are only for illustrative purposes and are specifically determined according to the actual situation.
[0095] Through the above embodiments, the complete data during the review version generation can be obtained. After determining the target difference segment in the complete data and staining it, when presenting it to the reviewer, the reviewer can determine the difference segments introduced by rebase according to the color. Since the difference segments introduced by rebase are relatively stable, the reviewer can reduce the review of the stained difference segments and improve the review efficiency.
[0096] In the embodiments of the present invention, a device for confirming the difference segments introduced by rebase in version comparison is provided, such as Figure 8As shown in the figure, it specifically includes: an acquisition unit 801, a determination unit 802, and an identification unit 803; wherein, the acquisition unit 801 is configured to acquire a first code review version and a second code review version, where the second code review version is the code review version after rebasing the first code review version; the acquisition unit 801 is further configured to: acquire a first merge base version of the first code review version and a second merge base version of the second code review version; the determination unit 802 is configured to determine a first change list between the first merge base version and the second merge base version, where the first change list includes a plurality of difference segments; the determination unit 802 is further configured to determine a second change list between the first code review version and the second code review version, where the second change list includes a plurality of difference segments; the identification unit 803 is configured to identify a target difference segment that appears in the first change list in the second change list, where the target difference segment is a difference segment introduced by rebasing.
[0097] Further, the apparatus further includes a processing unit, configured to mark the target difference segment with a specific color in the second change list.
[0098] Further, the acquisition unit is specifically configured to: determine a first main trunk code version corresponding to the first code review version according to the first code review version; determine the first merge base version according to the first code review version and the first main trunk code version.
[0099] Further, the acquisition unit is specifically configured to: determine a second main trunk code version corresponding to the second code review version according to the second code review version; determine the second merge base version according to the second code review version and the second main trunk code version.
[0100] Further, the identification unit is specifically configured to: in response to at least one same file in the second change list and the first change list having changed; acquire the old path and the new path of the file, as well as the old identifier and the new identifier; in response to the old path and the new path being the same, and the old identifier and the new identifier being the same, determine the plurality of difference segments corresponding to the file as the target difference segment.
[0101] Further, the identification unit is specifically further configured to: in response to the old path and the new path being different, and / or the old identifier and the new identifier being different, determine a plurality of candidate difference segments corresponding to each file; determine the target difference segment among the plurality of candidate difference segments.
[0102] Further, the recognition unit is specifically configured to: for each candidate difference segment, determine the first position information of the candidate difference segment in the first change list; perform line number tracking according to the first position information to determine the updated second position information; match the candidate difference segment corresponding to the first position information in the first change list with the candidate difference segment corresponding to the second position information in the second change list; and in response to a successful match, determine the candidate difference segment as the target difference segment.
[0103] Further, the recognition unit is specifically further configured to: perform line number tracking on the start position of the first position information to determine the start position of the updated second position information; and perform line number tracking on the end position of the first position information to determine the end position of the updated second position information.
[0104] Figure 9 is a schematic structural diagram of the electronic device in the embodiment of the present invention. As Figure 9 shown, it includes a general computer hardware structure, which at least includes a processor 901 and a memory 902. The processor 901 and the memory 902 are connected through a bus 903. The memory 902 is adapted to store instructions or programs executable by the processor 901. The processor 901 can be an independent microprocessor or a set of one or more microprocessors. Thus, by executing the instructions stored in the memory 902, the processor 901 executes the method flow of the embodiment of the present invention as described above to implement data processing and control of other devices. The bus 903 connects the above-mentioned multiple components together, and at the same time connects the above-mentioned components to a display controller 904, a display device, and an input / output (I / O) device 905. The input / output (I / O) device 905 can be a mouse, a keyboard, a modem, a network interface, a touch input device, a somatosensory input device, a printer, and other devices well known in the art. Typically, the input / output device 905 is connected to the system through an input / output (I / O) controller 906.
[0105] Among them, the instructions stored in the memory 902 are executed by at least one processor 901 to implement: obtaining a first code review version and a second code review version, where the second code review version is the code review version after rebasing the first code review version; obtaining a first merge base version of the first code review version and a second merge base version of the second code review version; determining a first change list between the first merge base version and the second merge base version, where the first change list includes a plurality of difference segments; determining a second change list between the first code review version and the second code review version, where the first change list includes a plurality of difference segments; identifying a target difference segment that appears in the second change list in the second change list, where the target difference segment is a difference segment introduced by rebasing.
[0106] Specifically, the electronic device includes: one or more processors 901 and a memory 902. Figure 9 Taking one processor 901 as an example. The processor 901 and the memory 902 can be connected through a bus or other means. Figure 9 Taking the connection through the bus as an example. The memory 902, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The processor 901 executes various functional applications and data processing of the device by running the non-volatile software programs, instructions, and modules stored in the memory 902, that is, implementing the method for determining the difference segments introduced by rebasing in the version comparison described above.
[0107] The memory 902 can include a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store an option list, etc. In addition, the memory 902 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 902 can optionally include a memory remotely set relative to the processor 901, and these remote memories can be connected to an external device through a network. Examples of the above network include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0108] One or more modules are stored in the memory 902 and, when executed by one or more processors 901, implement the method for determining the difference segments introduced by rebasing in the version comparison in any of the above method embodiments.
[0109] As those skilled in the art will realize, various aspects of the embodiments of the present invention can be implemented as a system, a method, or a computer program product. Accordingly, various aspects of the embodiments of the present invention may take the form of: a full hardware implementation, a full software implementation (including firmware, resident software, microcode, etc.), or an implementation combining software aspects with hardware aspects that may generally be referred to herein as "circuitry", "module", or "system". In addition, various aspects of the embodiments of the present invention may take the form of a computer program product implemented in one or more computer-readable media having computer-readable program code embodied thereon.
[0110] Any combination of one or more computer-readable media may be utilized. The computer-readable media may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium may be, for example but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of the embodiments of the present invention, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
[0111] A computer-readable signal medium may include a propagated digital signal having computer-readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated signal may take any of a variety of forms, including but not limited to: electromagnetic, optical, or any suitable combination thereof. A computer-readable signal medium may be any computer-readable medium that is not a computer-readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
[0112] Any suitable medium may be used to transmit the program code embodied on the computer-readable medium, including but not limited to wireless, wireline, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
[0113] Computer program code for performing operations for aspects of the embodiments of the present invention may be written in any combination of one or more programming languages, including: object-oriented programming languages such as Java, Smalltalk, C++; and conventional procedural programming languages such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer as a stand-alone software package, partially on the user's computer, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In the latter case, the remote computer may be connected to the user's computer through any type of network including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0114] The flowcharts and / or block diagrams of the methods, apparatus (systems), and computer program products according to the embodiments of the present invention described above depict various aspects of the embodiments of the present invention. It will be understood that each block of the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts 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, a special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, executed by the processor of the computer or other programmable data processing apparatus, create means for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0115] These computer program instructions may also be stored in a computer-readable medium that can direct a computer, other programmable data processing apparatus, or other devices to operate in a particular manner, such that the instructions stored in the computer-readable medium produce an article of manufacture including instructions for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0116] The computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable device, or other device to produce a computer-implemented process, such that the instructions executed on the computer or other programmable device provide a process for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0117] The above are only the preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.
[0118] It should be noted that the user information involved in this application (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) are all information and data that have been authorized by the user or fully authorized by all parties. Moreover, the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or refuse. If a user refuses to process personal information other than the necessary information required for basic functions, it will not affect the user's use of basic functions.
Claims
1. A method for identifying differential segments introduced by rebase in version comparison, characterized in that, The method includes: Obtaining a first code review version and a second code review version, where the second code review version is the code review version after rebasing the first code review version; Obtaining a first merge base version of the first code review version and a second merge base version of the second code review version; Determining a first change list between the first merge base version and the second merge base version, where the first change list includes multiple difference segments; Determining a second change list between the first code review version and the second code review version, where the second change list includes multiple difference segments; Identifying a target difference segment that appears in the first change list in the second change list, where the target difference segment is a difference segment introduced by rebasing.
2. The method according to claim 1, characterized in that, The method further includes: Marking the target difference segment with a specific color in the second change list.
3. The method according to claim 1, wherein The obtaining of the first merge base version of the first code review version specifically includes: Determining a first main trunk code version corresponding to the first code review version according to the first code review version; Determining the first merge base version according to the first code review version and the first main trunk code version.
4. The method according to claim 1, characterized in that The obtaining of the second merge base version of the second code review version specifically includes: Determining a second main trunk code version corresponding to the second code review version according to the second code review version; Determining the second merge base version according to the second code review version and the second main trunk code version.
5. The method according to claim 1, characterized in that, The identifying of the target difference segment that appears in the first change list in the second change list specifically includes: Responding to at least one same file in the second change list and the first change list having changes; Obtaining the old path and the new path of the file, as well as the old identifier and the new identifier; Responding to the old path and the new path being the same, and the old identifier and the new identifier being the same, and determining multiple difference segments corresponding to the file as the target difference segment.
6. The method according to claim 5, characterized in that, The method further includes: Responding to the old path and the new path being different, and / or the old identifier and the new identifier being different, and determining multiple candidate difference segments corresponding to each file; Determining the target difference segment among the multiple candidate difference segments.
7. The method according to claim 6, wherein The determining of the target difference segment among the multiple candidate difference segments specifically includes: For each candidate difference segment, determining a first position information of the candidate difference segment in the first change list; Performing line number tracking according to the first position information to determine an updated second position information; Matching the candidate difference segment corresponding to the first position information in the first change list with the candidate difference segment corresponding to the second position information in the second change list; Responding to a successful match and determining the candidate difference segment as the target difference segment.
8. The method according to claim 7, wherein The performing of line number tracking according to the first position information to determine the updated second position information specifically includes: Performing line number tracking on the start position of the first position information to determine the start position of the updated second position information; and, Track the line number of the termination position of the first position information to determine the termination position of the updated second position information.
9. An apparatus for identifying a differential segment introduced by rebase in version comparison, characterized in that, The device includes: An acquisition unit, configured to acquire a first code review version and a second code review version, where the second code review version is the code review version after rebasing the first code review version; The acquisition unit is further configured to: acquire a first merge base version of the first code review version and a second merge base version of the second code review version; A determination unit, configured to determine a first change list between the first merge base version and the second merge base version, where the first change list includes a plurality of difference segments; The determination unit is further configured to determine a second change list between the first code review version and the second code review version, where the first change list includes a plurality of difference segments; An identification unit, configured to identify, in the second change list, a target difference segment that appears in the first change list, where the target difference segment is a difference segment introduced by rebasing.
10. An electronic device, comprising a memory and a processor, characterized in that, The memory is configured to store one or more computer program instructions, where the one or more computer program instructions are executed by the processor to implement the method according to any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the method according to any one of claims 1-8.