Changeset 1567 in josm for trunk


Ignore:
Timestamp:
2009-05-02T20:09:40+02:00 (15 years ago)
Author:
framm
Message:
  • fixed some more conflict resolution bugs, especially relating to keeping your local modification. patches by Karl Guggisberg <kguggisberg@…> with some modifications. Fixes #2510, #2507.
Location:
trunk/src/org/openstreetmap/josm/data
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/conflict/DeleteConflict.java

    r1561 r1567  
    2222    @Override public void apply(OsmPrimitive target, OsmPrimitive other) {
    2323        target.deleted = other.deleted;
    24         target.version = Math.max(target.version, other.version);
     24        int newversion = Math.max(target.version, other.version);
     25        // set version on "other" as well in case user decides to keep local
     26        target.version = newversion;
     27        other.version = newversion;
     28
    2529    }
    2630}
  • trunk/src/org/openstreetmap/josm/data/conflict/PositionConflict.java

    r1561 r1567  
    2525            ((Node)target).coor = ((Node)other).coor;
    2626            ((Node)target).eastNorth = ((Node)other).eastNorth;
    27             target.version = Math.max(target.version, other.version);
     27            int newversion = Math.max(target.version, other.version);
     28            // set version on "other" as well in case user decides to keep local
     29            target.version = newversion;
     30            other.version = newversion;
    2831        }
    2932    }
  • trunk/src/org/openstreetmap/josm/data/conflict/PropertyConflict.java

    r1561 r1567  
    2828    @Override public void apply(OsmPrimitive target, OsmPrimitive other) {
    2929        target.put(key, other.get(key));
    30         target.version = Math.max(target.version, other.version);
     30        int newversion = Math.max(target.version, other.version);
     31        // set version on "other" as well in case user decides to keep local
     32        target.version = newversion;
     33        other.version = newversion;
    3134    }
    3235}
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java

    r1560 r1567  
    217217
    218218    /**
    219      * @return <code>true</code>, if no merge is needed or merge is performed already.
     219     * Tries to merge a primitive <code>other</code> into an existing primitive with the same id.
     220     *
     221     * @param myPrimitives the complete set of my primitives (potential merge targets)
     222     * @param myPrimitivesWithID the map of primitives (potential merge targets) with an id <> 0, for faster lookup
     223     *    by id. Key is the id, value the primitive with the given value. myPrimitives.valueSet() is a
     224     *    subset of primitives.
     225     * @param other  the other primitive which is to be merged with a primitive in primitives if possible
     226     * @return true, if this method was able to merge <code>other</code> with an existing node; false, otherwise 
    220227     */
    221228    private <P extends OsmPrimitive> boolean mergeById(
    222             Collection<P> primitives, HashMap<Long, P> hash, P other) {
    223         // Fast-path merging of identical objects
    224         if (hash.containsKey(other.id)) {
    225             P my = hash.get(other.id);
    226             if (my.realEqual(other, true)) {
     229            Collection<P> myPrimitives, HashMap<Long, P> myPrimitivesWithID, P other) {
     230       
     231        // merge other into an existing primitive with the same id, if possible
     232        //
     233        if (myPrimitivesWithID.containsKey(other.id)) {
     234            P my = myPrimitivesWithID.get(other.id);
     235            if (my.realEqual(other, true /* compare semantic fields only */)) {
     236                // make sure the merge target becomes the higher version number
     237                // and the later timestamp
     238                //
     239                my.version = Math.max(other.version, my.version);
     240                if (other.getTimestamp().after(my.getTimestamp())) {
     241                    my.setTimestamp(other.getTimestamp());
     242                }
    227243                merged.put(other, my);
    228244                return true;
     
    230246        }
    231247
    232         for (P my : primitives) {
    233             if (my.realEqual(other, false)) {
     248        // try to merge into one of the existing primitives
     249        //
     250        for (P my : myPrimitives) {
     251            if (my.realEqual(other, false /* compare all fields */)) {
    234252                merged.put(other, my);
    235253                return true; // no merge needed.
Note: See TracChangeset for help on using the changeset viewer.