Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function mergeNodes(base, remote, target) {
if (_option === 'force_local' || deepEqual(target.nodes, remote.nodes)) {
return target;
}
if (_option === 'force_remote') {
return target.update({nodes: remote.nodes});
}
var ccount = _conflicts.length;
var o = base.nodes || [];
var a = target.nodes || [];
var b = remote.nodes || [];
var nodes = [];
var hunks = diff3Merge(a, o, b, true);
for (var i = 0; i < hunks.length; i++) {
var hunk = hunks[i];
if (hunk.ok) {
nodes.push.apply(nodes, hunk.ok);
} else {
// for all conflicts, we can assume c.a !== c.b
// because `diff3Merge` called with `true` option to exclude false conflicts..
var c = hunk.conflict;
if (deepEqual(c.o, c.a)) { // only changed remotely
nodes.push.apply(nodes, c.b);
} else if (deepEqual(c.o, c.b)) { // only changed locally
nodes.push.apply(nodes, c.a);
} else { // changed both locally and remotely
_conflicts.push(t('merge_remote_changes.conflict.nodelist', { user: user(remote.user) }));
break;
const merge = (fileA, originalFile, fileB) => {
const merged = diff3Merge(fileA, originalFile, fileB, true);
const fileHasConflict = merged.some((item) => !item.ok);
const fileDiffResult = merged.reduce((fileContent, item) => {
if (item.ok) {
return fileContent.concat(item.ok);
}
return fileContent.concat(
['<<<<<<<<<'],
item.conflict.a,
['========='],
item.conflict.b,
['>>>>>>>>>']
);
}, []);
createPatch: (a, b) => compress(stripPatch(diffPatch(toArr(a), toArr(b)))),
}
export const createPatch = (a: string, b: string): Patch =>
compress(stripPatch(diffPatch(toArr(a), toArr(b))))
export const applyPatch = (a: string, p: Patch): string | undefined =>
fromArr(patch(toArr(a), decompress(p)))
applyPatch: (a, p) => fromArr(patch(toArr(a), decompress(p))),
merge3: (a, o, b) => {