Diff
Not logged in

Differences From Artifact [24593c59e3]:

To Artifact [bf8e9beb01]:


41
42
43
44
45
46
47






























48
49
50
51
52
53
54
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  db_must_be_within_tree();
  vid = db_lget_int("checkout",0);
  if( vid==0 ) return 2;
  vfile_check_signature(vid);
  return db_exists("SELECT 1 FROM vfile WHERE chnged"
                   " OR coalesce(origname!=pathname,0)");
}

/*
** Check to see if the requested co is in fact "checkout-able"
** Return values:
**   0: Not checkout-able (does not exist, or is not an on-disk artifact)
**   1: Is checkout-able.
*/
int checkoutable(const char *zName){
  int rc=1; /* assuming is checkout-able */
  Blob uuid;
  const char *rid=(char *)NULL;
  Stmt q; // db query
  char *zSQL; //build-up sql

  //  zSQL = mprintf();

  // [create sql statement]
  // db_prepare(&q,sqlstmt);

  blob_init(&uuid, zName, -1);
  if( name_to_uuid(&uuid, 1) ){
    fossil_panic(g.zErrMsg);
  }

  /*  nParent=db_text(0,"select rid from blob where uuid=%s",uuid.nameofobj); */

  /*  int nParent = db_column_int(q, somenum); */
  return rc;
}


/*
** Undo the current check-out.  Unlink all files from the disk.
** Clear the VFILE table.
*/
void uncheckout(int vid){
  if( vid==0 ) return;
155
156
157
158
159
160
161



162
163
164
165
166
167
168
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201







+
+
+







  db_begin_transaction();
  forceFlag = find_option("force","f",0)!=0;
  noWrite = find_option("dontwrite",0,0)!=0;
  if( g.argc!=3 ) usage("?--force? VERSION");
  if( !forceFlag && unsaved_changes()==1 ){
    fossil_fatal("there are unsaved changes in the current checkout");
  }
  if(!checkoutable()){
    fossil_fatal("the VERSION you requested is not a checkout-able artifact");
  }
  if( forceFlag ){
    db_multi_exec("DELETE FROM vfile");
    prior = 0;
  }else{
    prior = db_lget_int("checkout",0);
  }
  vid = load_vfile(g.argv[2]);