Changeset 1560 in josm for trunk


Ignore:
Timestamp:
2009-04-27T23:49:19+02:00 (16 years ago)
Author:
framm
Message:
  • "learn" new version numbers on repeated download
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java

    r1523 r1560  
    5858            HashMap<Long, P> primhash) {
    5959        // 1. Try to find an identical prim with the same id.
    60         if (mergeAfterId(myprims, primhash, other))
     60        if (mergeById(myprims, primhash, other))
    6161            return;
    6262
     
    200200                my.id = other.id;
    201201                my.modified = other.modified; // match a new node
     202                my.version = other.version;
    202203            } else if (my.id != 0 && other.id != 0 && other.modified)
    203204                my.modified = true;
     
    218219     * @return <code>true</code>, if no merge is needed or merge is performed already.
    219220     */
    220     private <P extends OsmPrimitive> boolean mergeAfterId(
     221    private <P extends OsmPrimitive> boolean mergeById(
    221222            Collection<P> primitives, HashMap<Long, P> hash, P other) {
    222223        // Fast-path merging of identical objects
     
    235236            }
    236237            if (my.realEqual(other, true)) {
    237                 Date myd = my.getTimestamp();
    238                 Date otherd = other.getTimestamp();
    239 
    240                 // they differ in modified/timestamp combination only. Auto-resolve it.
    241                 merged.put(other, my);
    242                 if (myd.before(otherd)) {
     238                // they differ in modified/version combination only. Auto-resolve it.
     239                merged.put(other, my);
     240                if (my.version < other.version) {
     241                    my.version = other.version;
    243242                    my.modified = other.modified;
    244243                    my.setTimestamp(other.getTimestamp());
     
    247246            }
    248247            if (my.id == other.id && my.id != 0) {
    249                 Date myd = my.getTimestamp();
    250                 Date otherd = other.getTimestamp();
    251 
    252248                if (my.incomplete || other.incomplete) {
    253249                    if (my.incomplete) {
     
    257253                    conflicts.put(my, other);
    258254                } else if (!my.modified && !other.modified) {
    259                     if (myd.before(otherd)) {
     255                    if (my.version < other.version) {
    260256                        my.cloneFrom(other);
    261257                    }
    262258                } else if (other.modified) {
    263                     if (myd.after(otherd)) {
     259                    if (my.version > other.version) {
    264260                        conflicts.put(my, other);
    265261                    } else {
     
    267263                    }
    268264                } else if (my.modified) {
    269                     if (myd.before(otherd)) {
     265                    if (my.version < other.version) {
    270266                        conflicts.put(my, other);
    271267                    }
Note: See TracChangeset for help on using the changeset viewer.