Fossil SCM

Make [/help?cmd=open|fossil open] and [/help?cmd=checkout|fossil checkout] aware of missing content too.

andybradford 2014-05-22 04:39 trunk
Commit 941ead2f9ad6f9ca3f3b5a0d2502c2ecc0d7460a
2 files changed +10 -5 +11 -5
+10 -5
--- src/checkout.c
+++ src/checkout.c
@@ -54,11 +54,11 @@
5454
** Given the abbreviated UUID name of a version, load the content of that
5555
** version in the VFILE table. Return the VID for the version.
5656
**
5757
** If anything goes wrong, panic.
5858
*/
59
-int load_vfile(const char *zName){
59
+int load_vfile(const char *zName, int forceMissingFlag){
6060
Blob uuid;
6161
int vid;
6262
6363
blob_init(&uuid, zName, -1);
6464
if( name_to_uuid(&uuid, 1, "ci") ){
@@ -69,11 +69,13 @@
6969
fossil_fatal("no such check-in: %s", g.argv[2]);
7070
}
7171
if( !is_a_version(vid) ){
7272
fossil_fatal("object [%.10s] is not a check-in", blob_str(&uuid));
7373
}
74
- load_vfile_from_rid(vid);
74
+ if( load_vfile_from_rid(vid) && !forceMissingFlag ){
75
+ fossil_fatal("missing content, unable to checkout");
76
+ };
7577
return vid;
7678
}
7779
7880
/*
7981
** Set or clear the vfile.isexe flag for a file.
@@ -176,17 +178,19 @@
176178
**
177179
** The --latest flag can be used in place of VERSION to checkout the
178180
** latest version in the repository.
179181
**
180182
** Options:
181
-** --force Ignore edited files in the current checkout
182
-** --keep Only update the manifest and manifest.uuid files
183
+** --force Ignore edited files in the current checkout
184
+** --keep Only update the manifest and manifest.uuid files
185
+** --force-missing Force checkout even if content is missing
183186
**
184187
** See also: update
185188
*/
186189
void checkout_cmd(void){
187190
int forceFlag; /* Force checkout even if edits exist */
191
+ int forceMissingFlag; /* Force checkout even if missing content */
188192
int keepFlag; /* Do not change any files on disk */
189193
int latestFlag; /* Checkout the latest version */
190194
char *zVers; /* Version to checkout */
191195
int promptFlag; /* True to prompt before overwriting */
192196
int vid, prior;
@@ -193,10 +197,11 @@
193197
Blob cksum1, cksum1b, cksum2;
194198
195199
db_must_be_within_tree();
196200
db_begin_transaction();
197201
forceFlag = find_option("force","f",0)!=0;
202
+ forceMissingFlag = find_option("force-missing",0,0)!=0;
198203
keepFlag = find_option("keep",0,0)!=0;
199204
latestFlag = find_option("latest",0,0)!=0;
200205
promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0;
201206
if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){
202207
usage("VERSION|--latest ?--force? ?--keep?");
@@ -224,11 +229,11 @@
224229
return;
225230
}
226231
}else{
227232
zVers = g.argv[2];
228233
}
229
- vid = load_vfile(zVers);
234
+ vid = load_vfile(zVers, forceMissingFlag);
230235
if( prior==vid ){
231236
return;
232237
}
233238
if( !keepFlag ){
234239
uncheckout(prior);
235240
--- src/checkout.c
+++ src/checkout.c
@@ -54,11 +54,11 @@
54 ** Given the abbreviated UUID name of a version, load the content of that
55 ** version in the VFILE table. Return the VID for the version.
56 **
57 ** If anything goes wrong, panic.
58 */
59 int load_vfile(const char *zName){
60 Blob uuid;
61 int vid;
62
63 blob_init(&uuid, zName, -1);
64 if( name_to_uuid(&uuid, 1, "ci") ){
@@ -69,11 +69,13 @@
69 fossil_fatal("no such check-in: %s", g.argv[2]);
70 }
71 if( !is_a_version(vid) ){
72 fossil_fatal("object [%.10s] is not a check-in", blob_str(&uuid));
73 }
74 load_vfile_from_rid(vid);
 
 
75 return vid;
76 }
77
78 /*
79 ** Set or clear the vfile.isexe flag for a file.
@@ -176,17 +178,19 @@
176 **
177 ** The --latest flag can be used in place of VERSION to checkout the
178 ** latest version in the repository.
179 **
180 ** Options:
181 ** --force Ignore edited files in the current checkout
182 ** --keep Only update the manifest and manifest.uuid files
 
183 **
184 ** See also: update
185 */
186 void checkout_cmd(void){
187 int forceFlag; /* Force checkout even if edits exist */
 
188 int keepFlag; /* Do not change any files on disk */
189 int latestFlag; /* Checkout the latest version */
190 char *zVers; /* Version to checkout */
191 int promptFlag; /* True to prompt before overwriting */
192 int vid, prior;
@@ -193,10 +197,11 @@
193 Blob cksum1, cksum1b, cksum2;
194
195 db_must_be_within_tree();
196 db_begin_transaction();
197 forceFlag = find_option("force","f",0)!=0;
 
198 keepFlag = find_option("keep",0,0)!=0;
199 latestFlag = find_option("latest",0,0)!=0;
200 promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0;
201 if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){
202 usage("VERSION|--latest ?--force? ?--keep?");
@@ -224,11 +229,11 @@
224 return;
225 }
226 }else{
227 zVers = g.argv[2];
228 }
229 vid = load_vfile(zVers);
230 if( prior==vid ){
231 return;
232 }
233 if( !keepFlag ){
234 uncheckout(prior);
235
--- src/checkout.c
+++ src/checkout.c
@@ -54,11 +54,11 @@
54 ** Given the abbreviated UUID name of a version, load the content of that
55 ** version in the VFILE table. Return the VID for the version.
56 **
57 ** If anything goes wrong, panic.
58 */
59 int load_vfile(const char *zName, int forceMissingFlag){
60 Blob uuid;
61 int vid;
62
63 blob_init(&uuid, zName, -1);
64 if( name_to_uuid(&uuid, 1, "ci") ){
@@ -69,11 +69,13 @@
69 fossil_fatal("no such check-in: %s", g.argv[2]);
70 }
71 if( !is_a_version(vid) ){
72 fossil_fatal("object [%.10s] is not a check-in", blob_str(&uuid));
73 }
74 if( load_vfile_from_rid(vid) && !forceMissingFlag ){
75 fossil_fatal("missing content, unable to checkout");
76 };
77 return vid;
78 }
79
80 /*
81 ** Set or clear the vfile.isexe flag for a file.
@@ -176,17 +178,19 @@
178 **
179 ** The --latest flag can be used in place of VERSION to checkout the
180 ** latest version in the repository.
181 **
182 ** Options:
183 ** --force Ignore edited files in the current checkout
184 ** --keep Only update the manifest and manifest.uuid files
185 ** --force-missing Force checkout even if content is missing
186 **
187 ** See also: update
188 */
189 void checkout_cmd(void){
190 int forceFlag; /* Force checkout even if edits exist */
191 int forceMissingFlag; /* Force checkout even if missing content */
192 int keepFlag; /* Do not change any files on disk */
193 int latestFlag; /* Checkout the latest version */
194 char *zVers; /* Version to checkout */
195 int promptFlag; /* True to prompt before overwriting */
196 int vid, prior;
@@ -193,10 +197,11 @@
197 Blob cksum1, cksum1b, cksum2;
198
199 db_must_be_within_tree();
200 db_begin_transaction();
201 forceFlag = find_option("force","f",0)!=0;
202 forceMissingFlag = find_option("force-missing",0,0)!=0;
203 keepFlag = find_option("keep",0,0)!=0;
204 latestFlag = find_option("latest",0,0)!=0;
205 promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0;
206 if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){
207 usage("VERSION|--latest ?--force? ?--keep?");
@@ -224,11 +229,11 @@
229 return;
230 }
231 }else{
232 zVers = g.argv[2];
233 }
234 vid = load_vfile(zVers, forceMissingFlag);
235 if( prior==vid ){
236 return;
237 }
238 if( !keepFlag ){
239 uncheckout(prior);
240
+11 -5
--- src/db.c
+++ src/db.c
@@ -1985,29 +1985,32 @@
19851985
** If VERSION is specified then that version is checked out. Otherwise
19861986
** the latest version is checked out. No files other than "manifest"
19871987
** and "manifest.uuid" are modified if the --keep option is present.
19881988
**
19891989
** Options:
1990
-** --empty Initialize checkout as being empty, but still connected
1991
-** with the local repository. If you commit this checkout,
1992
-** it will become a new "initial" commit in the repository.
1993
-** --keep Only modify the manifest and manifest.uuid files
1994
-** --nested Allow opening a repository inside an opened checkout
1990
+** --empty Initialize checkout as being empty, but still connected
1991
+** with the local repository. If you commit this checkout,
1992
+** it will become a new "initial" commit in the repository.
1993
+** --keep Only modify the manifest and manifest.uuid files
1994
+** --nested Allow opening a repository inside an opened checkout
1995
+** --force-missing Force opening a repository with missing content
19951996
**
19961997
** See also: close
19971998
*/
19981999
void cmd_open(void){
19992000
int emptyFlag;
20002001
int keepFlag;
2002
+ int forceMissingFlag;
20012003
int allowNested;
20022004
char **oldArgv;
20032005
int oldArgc;
20042006
static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0 };
20052007
20062008
url_proxy_options();
20072009
emptyFlag = find_option("empty",0,0)!=0;
20082010
keepFlag = find_option("keep",0,0)!=0;
2011
+ forceMissingFlag = find_option("force-missing",0,0)!=0;
20092012
allowNested = find_option("nested",0,0)!=0;
20102013
if( g.argc!=3 && g.argc!=4 ){
20112014
usage("REPOSITORY-FILENAME ?VERSION?");
20122015
}
20132016
if( !allowNested && db_open_local(0) ){
@@ -2043,10 +2046,13 @@
20432046
azNewArgv[g.argc-1] = db_get("main-branch", "trunk");
20442047
}
20452048
if( keepFlag ){
20462049
azNewArgv[g.argc++] = "--keep";
20472050
}
2051
+ if( forceMissingFlag ){
2052
+ azNewArgv[g.argc++] = "--force-missing";
2053
+ }
20482054
checkout_cmd();
20492055
}
20502056
g.argc = 2;
20512057
info_cmd();
20522058
}
20532059
--- src/db.c
+++ src/db.c
@@ -1985,29 +1985,32 @@
1985 ** If VERSION is specified then that version is checked out. Otherwise
1986 ** the latest version is checked out. No files other than "manifest"
1987 ** and "manifest.uuid" are modified if the --keep option is present.
1988 **
1989 ** Options:
1990 ** --empty Initialize checkout as being empty, but still connected
1991 ** with the local repository. If you commit this checkout,
1992 ** it will become a new "initial" commit in the repository.
1993 ** --keep Only modify the manifest and manifest.uuid files
1994 ** --nested Allow opening a repository inside an opened checkout
 
1995 **
1996 ** See also: close
1997 */
1998 void cmd_open(void){
1999 int emptyFlag;
2000 int keepFlag;
 
2001 int allowNested;
2002 char **oldArgv;
2003 int oldArgc;
2004 static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0 };
2005
2006 url_proxy_options();
2007 emptyFlag = find_option("empty",0,0)!=0;
2008 keepFlag = find_option("keep",0,0)!=0;
 
2009 allowNested = find_option("nested",0,0)!=0;
2010 if( g.argc!=3 && g.argc!=4 ){
2011 usage("REPOSITORY-FILENAME ?VERSION?");
2012 }
2013 if( !allowNested && db_open_local(0) ){
@@ -2043,10 +2046,13 @@
2043 azNewArgv[g.argc-1] = db_get("main-branch", "trunk");
2044 }
2045 if( keepFlag ){
2046 azNewArgv[g.argc++] = "--keep";
2047 }
 
 
 
2048 checkout_cmd();
2049 }
2050 g.argc = 2;
2051 info_cmd();
2052 }
2053
--- src/db.c
+++ src/db.c
@@ -1985,29 +1985,32 @@
1985 ** If VERSION is specified then that version is checked out. Otherwise
1986 ** the latest version is checked out. No files other than "manifest"
1987 ** and "manifest.uuid" are modified if the --keep option is present.
1988 **
1989 ** Options:
1990 ** --empty Initialize checkout as being empty, but still connected
1991 ** with the local repository. If you commit this checkout,
1992 ** it will become a new "initial" commit in the repository.
1993 ** --keep Only modify the manifest and manifest.uuid files
1994 ** --nested Allow opening a repository inside an opened checkout
1995 ** --force-missing Force opening a repository with missing content
1996 **
1997 ** See also: close
1998 */
1999 void cmd_open(void){
2000 int emptyFlag;
2001 int keepFlag;
2002 int forceMissingFlag;
2003 int allowNested;
2004 char **oldArgv;
2005 int oldArgc;
2006 static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0 };
2007
2008 url_proxy_options();
2009 emptyFlag = find_option("empty",0,0)!=0;
2010 keepFlag = find_option("keep",0,0)!=0;
2011 forceMissingFlag = find_option("force-missing",0,0)!=0;
2012 allowNested = find_option("nested",0,0)!=0;
2013 if( g.argc!=3 && g.argc!=4 ){
2014 usage("REPOSITORY-FILENAME ?VERSION?");
2015 }
2016 if( !allowNested && db_open_local(0) ){
@@ -2043,10 +2046,13 @@
2046 azNewArgv[g.argc-1] = db_get("main-branch", "trunk");
2047 }
2048 if( keepFlag ){
2049 azNewArgv[g.argc++] = "--keep";
2050 }
2051 if( forceMissingFlag ){
2052 azNewArgv[g.argc++] = "--force-missing";
2053 }
2054 checkout_cmd();
2055 }
2056 g.argc = 2;
2057 info_cmd();
2058 }
2059

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button