Fossil

Diff
Login

Differences From Artifact [488db85abe]:

To Artifact [5c506420a8]:


562
563
564
565
566
567
568

569

570
571


572


573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590

591
592
593
594
595
562
563
564
565
566
567
568
569
570
571
572
573
574
575

576
577
578
579

580
581
582
583
584
585
586
587
588
589
590
591

592
593
594
595
596
597
598
599







+

+


+
+
-
+
+


-












-


+





  db_prepare(&q, "SELECT name FROM torevert");
  if( zRevision==0 ){
    int vid = db_lget_int("checkout", 0);
    zRevision = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
  }
  while( db_step(&q)==SQLITE_ROW ){
    int isExe = 0;
    char *zFull;
    zFile = db_column_text(&q, 0);
    zFull = mprintf("%/%/", g.zLocalRoot, zFile);
    errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
    if( errCode==2 ){
      undo_save(zFile);
      unlink(zFull);
      fossil_warning("file not in repository: %s", zFile);
      printf("DELETE: %s\n", zFile);
      db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile);
    }else{
      sqlite3_int64 mtime;
      char *zFull = mprintf("%/%/", g.zLocalRoot, zFile);
      undo_save(zFile);
      blob_write_to_file(&record, zFull);
      file_setexe(zFull, isExe);
      printf("REVERTED: %s\n", zFile);
      mtime = file_mtime(zFull);
      db_multi_exec(
         "UPDATE vfile"
         "   SET mtime=%lld, chnged=0, deleted=0, isexe=%d,"
         "       pathname=coalesce(origname,pathname), origname=NULL"     
         " WHERE pathname=%Q",
         mtime, isExe, zFile
      );
      free(zFull);
    }
    blob_reset(&record);
    free(zFull);
  }
  db_finalize(&q);
  undo_finish();
  db_end_transaction(0);
}