Fossil

Check-in [070ce24d83]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Report the number of conflicts at the end of a merge or update and offer a hint to the user about the "fossil undo" command.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 070ce24d838a6278fd4af9fca26a559bacc79677
User & Date: drh 2010-12-15 01:49:39.000
References
2011-10-14
22:16
Reporting the number of merge conflicts at the end of merge, as with update. I think the information is of value to the user. I think that had to be introduced in [070ce24d838a6], from its comment, but that change made the opposite of commented. check-in: e1a7a1d9e2 user: viriketo tags: declined
Context
2010-12-15
02:19
Make three new TH1 variables available the footer on /doc pages: $doc_name, $doc_version, and $doc_date. check-in: 1b0e6c0fbb user: drh tags: trunk
01:49
Report the number of conflicts at the end of a merge or update and offer a hint to the user about the "fossil undo" command. check-in: 070ce24d83 user: drh tags: trunk
01:36
Change the merge conflict marks to identify which part is original content and which part is the content merged in. check-in: 76ae862ec9 user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/merge.c.
434
435
436
437
438
439
440
441
442

443
444

445
446
447
448
449
450
451
    }
  }
  db_finalize(&q);


  /* Report on conflicts
  */
  if( nConflict ){
    printf("WARNING: %d merge conflicts.\n"

           "    ...  Use \"fossil undo\" to back out this merge\n",
           nConflict);

  }
  
  /*
  ** Clean up the mid and pid VFILE entries.  Then commit the changes.
  */
  db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
  if( !pickFlag ){







|
|
>
|
<
>







434
435
436
437
438
439
440
441
442
443
444

445
446
447
448
449
450
451
452
    }
  }
  db_finalize(&q);


  /* Report on conflicts
  */
  if( nConflict && !nochangeFlag ){
    printf(
      "WARNING: merge conflicts - see messages above for details.\n"
      "HINT:    The \"fossil undo\" command will back out this merge if "

                "you want\n");
  }
  
  /*
  ** Clean up the mid and pid VFILE entries.  Then commit the changes.
  */
  db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
  if( !pickFlag ){
Changes to src/update.c.
63
64
65
66
67
68
69

70
71
72
73
74
75
76
  int latestFlag;       /* --latest.  Pick the latest version if true */
  int nochangeFlag;     /* -n or --nochange.  Do a dry run */
  int verboseFlag;      /* -v or --verbose.  Output extra information */
  int debugFlag;        /* --debug option */
  int nChng;            /* Number of file renames */
  int *aChng;           /* Array of file renames */
  int i;                /* Loop counter */


  url_proxy_options();
  latestFlag = find_option("latest",0, 0)!=0;
  nochangeFlag = find_option("nochange","n",0)!=0;
  verboseFlag = find_option("verbose","v",0)!=0;
  debugFlag = find_option("debug",0,0)!=0;
  db_must_be_within_tree();







>







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  int latestFlag;       /* --latest.  Pick the latest version if true */
  int nochangeFlag;     /* -n or --nochange.  Do a dry run */
  int verboseFlag;      /* -v or --verbose.  Output extra information */
  int debugFlag;        /* --debug option */
  int nChng;            /* Number of file renames */
  int *aChng;           /* Array of file renames */
  int i;                /* Loop counter */
  int nConflict;        /* Number of merge conflicts */

  url_proxy_options();
  latestFlag = find_option("latest",0, 0)!=0;
  nochangeFlag = find_option("nochange","n",0)!=0;
  verboseFlag = find_option("verbose","v",0)!=0;
  debugFlag = find_option("debug",0,0)!=0;
  db_must_be_within_tree();
285
286
287
288
289
290
291

292
293
294
295
296
297
298
    zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName);
    nameChng = strcmp(zName, zNewName);
    if( idv>0 && ridv==0 && idt>0 && ridt>0 ){
      /* Conflict.  This file has been added to the current checkout
      ** but also exists in the target checkout.  Use the current version.
      */
      printf("CONFLICT %s\n", zName);

    }else if( idt>0 && idv==0 ){
      /* File added in the target. */
      printf("ADD %s\n", zName);
      undo_save(zName);
      if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
    }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){
      /* The file is unedited.  Change it to the target version */







>







286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
    zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName);
    nameChng = strcmp(zName, zNewName);
    if( idv>0 && ridv==0 && idt>0 && ridt>0 ){
      /* Conflict.  This file has been added to the current checkout
      ** but also exists in the target checkout.  Use the current version.
      */
      printf("CONFLICT %s\n", zName);
      nConflict++;
    }else if( idt>0 && idv==0 ){
      /* File added in the target. */
      printf("ADD %s\n", zName);
      undo_save(zName);
      if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
    }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){
      /* The file is unedited.  Change it to the target version */
309
310
311
312
313
314
315
316

317
318
319
320
321
322
323
      if( ridv==0 ){
        /* Added in current checkout.  Continue to hold the file as
        ** as an addition */
        db_multi_exec("UPDATE vfile SET vid=%d WHERE id=%d", tid, idv);
      }else if( chnged ){
        /* Edited locally but deleted from the target.  Do not track the
        ** file but keep the edited version around. */
        printf("CONFLICT %s\n", zName);

      }else{
        printf("REMOVE %s\n", zName);
        undo_save(zName);
        if( !nochangeFlag ) unlink(zFullPath);
      }
    }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){
      /* Merge the changes in the current tree into the target version */







|
>







311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
      if( ridv==0 ){
        /* Added in current checkout.  Continue to hold the file as
        ** as an addition */
        db_multi_exec("UPDATE vfile SET vid=%d WHERE id=%d", tid, idv);
      }else if( chnged ){
        /* Edited locally but deleted from the target.  Do not track the
        ** file but keep the edited version around. */
        printf("CONFLICT %s - edited locally but deleted by update\n", zName);
        nConflict++;
      }else{
        printf("REMOVE %s\n", zName);
        undo_save(zName);
        if( !nochangeFlag ) unlink(zFullPath);
      }
    }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){
      /* Merge the changes in the current tree into the target version */
334
335
336
337
338
339
340

341
342
343
344

345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363









364
365
366
367
368
369
370
      blob_zero(&e);
      blob_read_from_file(&e, zFullPath);
      rc = blob_merge(&v, &e, &t, &r);
      if( rc>=0 ){
        if( !nochangeFlag ) blob_write_to_file(&r, zFullNewPath);
        if( rc>0 ){
          printf("***** %d merge conflicts in %s\n", rc, zNewName);

        }
      }else{
        if( !nochangeFlag ) blob_write_to_file(&t, zFullNewPath);
        printf("***** Cannot merge binary file %s\n", zNewName);

      }
      if( nameChng && !nochangeFlag ) unlink(zFullPath);
      blob_reset(&v);
      blob_reset(&e);
      blob_reset(&t);
      blob_reset(&r);
    }else if( verboseFlag ){
      if( chnged ){
        printf("EDITED %s\n", zName);
      }else{
        printf("UNCHANGED %s\n", zName);
      }
    }
    free(zFullPath);
    free(zFullNewPath);
  }
  db_finalize(&q);
  printf("--------------\n");
  show_common_info(tid, "updated-to:", 1, 0);









  
  /*
  ** Clean up the mid and pid VFILE entries.  Then commit the changes.
  */
  if( nochangeFlag ){
    db_end_transaction(1);  /* With --nochange, rollback changes */
  }else{







>




>



















>
>
>
>
>
>
>
>
>







337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
      blob_zero(&e);
      blob_read_from_file(&e, zFullPath);
      rc = blob_merge(&v, &e, &t, &r);
      if( rc>=0 ){
        if( !nochangeFlag ) blob_write_to_file(&r, zFullNewPath);
        if( rc>0 ){
          printf("***** %d merge conflicts in %s\n", rc, zNewName);
          nConflict++;
        }
      }else{
        if( !nochangeFlag ) blob_write_to_file(&t, zFullNewPath);
        printf("***** Cannot merge binary file %s\n", zNewName);
        nConflict++;
      }
      if( nameChng && !nochangeFlag ) unlink(zFullPath);
      blob_reset(&v);
      blob_reset(&e);
      blob_reset(&t);
      blob_reset(&r);
    }else if( verboseFlag ){
      if( chnged ){
        printf("EDITED %s\n", zName);
      }else{
        printf("UNCHANGED %s\n", zName);
      }
    }
    free(zFullPath);
    free(zFullNewPath);
  }
  db_finalize(&q);
  printf("--------------\n");
  show_common_info(tid, "updated-to:", 1, 0);

  /* Report on conflicts
  */
  if( nConflict && !nochangeFlag ){
    printf(
      "WARNING: merge conflicts - see messages above for details.\n"
      "HINT:    The \"fossil undo\" command will back out this update if "
                "you want\n");
  }
  
  /*
  ** Clean up the mid and pid VFILE entries.  Then commit the changes.
  */
  if( nochangeFlag ){
    db_end_transaction(1);  /* With --nochange, rollback changes */
  }else{