Skip to content

Detect conflicts during merge conflict#508

Draft
atanasdinov wants to merge 1 commit into
SUSE:mainfrom
atanasdinov:three-way-merge
Draft

Detect conflicts during merge conflict#508
atanasdinov wants to merge 1 commit into
SUSE:mainfrom
atanasdinov:three-way-merge

Conversation

@atanasdinov

Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Atanas Dinov <atanas.dinov@suse.com>

@davidcassany davidcassany left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate this is in draft review, hence this is probably not ready for review. If you don't mind I have a couple of comments regarding the implementation.

I am wondering if instead of gathering a full diff for both cases wouldn't it be simpler to diff one and then from a first list of modified files then use it to diff them on the other side of the 3 way merge. After all we want to detect conflicts so any file not included in the first diff is known not to be a conflict candidate.

r := regexp.MustCompile(`(([-+ct.])[p.][u.][g.][x.][a.])\s+(.*)`)

scanner := bufio.NewScanner(statusF)
for scanner.Scan() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be possible to check for conflict on file per file basis here in this loop instead of walking the whole tree? So here we just check the user modified tree if it is also modified by the new image. So we only diff the files which are potentially conflicting and we do not need to parse again snapper diff status, load it in memory, iterate over it again and walk the whole tree of the snapshot.
So we basically create the list of files to merge and the list of conflicting files together at the same time.

Old string // old unmodified tree
New string // new base tree where modifications should be applied
Modified string // modified tree on top of the old tree
NewStock string // new stock snapshot path (for conflict detection)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed. This has the same content as New at merge time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants