mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-16 18:52:57 +00:00
Conflict Resolution childnode fixes.
* don't try to fetch newly created childnodes from the remote server * a modified way with new childnodes will safely merge, but will return the same graph (no diff), so check conflicts.length instead
This commit is contained in:
@@ -8,10 +8,13 @@ iD.modes.Save = function(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function save(e, tryAgain) {
|
function save(e, tryAgain) {
|
||||||
function withChildNodes(ids) {
|
function withChildNodes(ids, graph) {
|
||||||
return _.uniq(_.reduce(toCheck, function(result, id) {
|
return _.uniq(_.reduce(ids, function(result, id) {
|
||||||
var e = context.entity(id);
|
var e = graph.entity(id);
|
||||||
if (e.type === 'way') result.push.apply(result, e.nodes);
|
if (e.type === 'way') {
|
||||||
|
var cn = graph.childNodes(e);
|
||||||
|
result.push.apply(result, _.pluck(_.filter(cn, 'version'), 'id'));
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}, _.clone(ids)));
|
}, _.clone(ids)));
|
||||||
}
|
}
|
||||||
@@ -23,7 +26,7 @@ iD.modes.Save = function(context) {
|
|||||||
remoteGraph = iD.Graph(history.base(), true),
|
remoteGraph = iD.Graph(history.base(), true),
|
||||||
modified = _.filter(history.difference().summary(), {changeType: 'modified'}),
|
modified = _.filter(history.difference().summary(), {changeType: 'modified'}),
|
||||||
toCheck = _.pluck(_.pluck(modified, 'entity'), 'id'),
|
toCheck = _.pluck(_.pluck(modified, 'entity'), 'id'),
|
||||||
toLoad = withChildNodes(toCheck),
|
toLoad = withChildNodes(toCheck, localGraph),
|
||||||
conflicts = [],
|
conflicts = [],
|
||||||
errors = [];
|
errors = [];
|
||||||
|
|
||||||
@@ -96,10 +99,12 @@ iD.modes.Save = function(context) {
|
|||||||
if (compareVersions(local, remote)) return;
|
if (compareVersions(local, remote)) return;
|
||||||
|
|
||||||
var action = iD.actions.MergeRemoteChanges,
|
var action = iD.actions.MergeRemoteChanges,
|
||||||
merge = action(id, localGraph, remoteGraph, formatUser),
|
merge = action(id, localGraph, remoteGraph, formatUser);
|
||||||
diff = history.replace(merge);
|
|
||||||
|
|
||||||
if (diff.length()) return; // merged safely
|
history.replace(merge);
|
||||||
|
|
||||||
|
var conflicts = merge.conflicts();
|
||||||
|
if (!conflicts.length) return; // merged safely
|
||||||
|
|
||||||
var forceLocal = action(id, localGraph, remoteGraph).withOption('force_local'),
|
var forceLocal = action(id, localGraph, remoteGraph).withOption('force_local'),
|
||||||
forceRemote = action(id, localGraph, remoteGraph).withOption('force_remote'),
|
forceRemote = action(id, localGraph, remoteGraph).withOption('force_remote'),
|
||||||
@@ -109,7 +114,7 @@ iD.modes.Save = function(context) {
|
|||||||
conflicts.push({
|
conflicts.push({
|
||||||
id: id,
|
id: id,
|
||||||
name: entityName(local),
|
name: entityName(local),
|
||||||
details: merge.conflicts(),
|
details: conflicts,
|
||||||
chosen: 1,
|
chosen: 1,
|
||||||
choices: [
|
choices: [
|
||||||
choice(id, keepMine, forceLocal),
|
choice(id, keepMine, forceLocal),
|
||||||
|
|||||||
Reference in New Issue
Block a user