Fossil SCM
Make [/help?cmd=open|fossil open] and [/help?cmd=checkout|fossil checkout] aware of missing content too.
Commit
941ead2f9ad6f9ca3f3b5a0d2502c2ecc0d7460a
Parent
16da1b6dff02f50…
2 files changed
+10
-5
+11
-5
+10
-5
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -54,11 +54,11 @@ | ||
| 54 | 54 | ** Given the abbreviated UUID name of a version, load the content of that |
| 55 | 55 | ** version in the VFILE table. Return the VID for the version. |
| 56 | 56 | ** |
| 57 | 57 | ** If anything goes wrong, panic. |
| 58 | 58 | */ |
| 59 | -int load_vfile(const char *zName){ | |
| 59 | +int load_vfile(const char *zName, int forceMissingFlag){ | |
| 60 | 60 | Blob uuid; |
| 61 | 61 | int vid; |
| 62 | 62 | |
| 63 | 63 | blob_init(&uuid, zName, -1); |
| 64 | 64 | if( name_to_uuid(&uuid, 1, "ci") ){ |
| @@ -69,11 +69,13 @@ | ||
| 69 | 69 | fossil_fatal("no such check-in: %s", g.argv[2]); |
| 70 | 70 | } |
| 71 | 71 | if( !is_a_version(vid) ){ |
| 72 | 72 | fossil_fatal("object [%.10s] is not a check-in", blob_str(&uuid)); |
| 73 | 73 | } |
| 74 | - load_vfile_from_rid(vid); | |
| 74 | + if( load_vfile_from_rid(vid) && !forceMissingFlag ){ | |
| 75 | + fossil_fatal("missing content, unable to checkout"); | |
| 76 | + }; | |
| 75 | 77 | return vid; |
| 76 | 78 | } |
| 77 | 79 | |
| 78 | 80 | /* |
| 79 | 81 | ** Set or clear the vfile.isexe flag for a file. |
| @@ -176,17 +178,19 @@ | ||
| 176 | 178 | ** |
| 177 | 179 | ** The --latest flag can be used in place of VERSION to checkout the |
| 178 | 180 | ** latest version in the repository. |
| 179 | 181 | ** |
| 180 | 182 | ** 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 | |
| 183 | 186 | ** |
| 184 | 187 | ** See also: update |
| 185 | 188 | */ |
| 186 | 189 | void checkout_cmd(void){ |
| 187 | 190 | int forceFlag; /* Force checkout even if edits exist */ |
| 191 | + int forceMissingFlag; /* Force checkout even if missing content */ | |
| 188 | 192 | int keepFlag; /* Do not change any files on disk */ |
| 189 | 193 | int latestFlag; /* Checkout the latest version */ |
| 190 | 194 | char *zVers; /* Version to checkout */ |
| 191 | 195 | int promptFlag; /* True to prompt before overwriting */ |
| 192 | 196 | int vid, prior; |
| @@ -193,10 +197,11 @@ | ||
| 193 | 197 | Blob cksum1, cksum1b, cksum2; |
| 194 | 198 | |
| 195 | 199 | db_must_be_within_tree(); |
| 196 | 200 | db_begin_transaction(); |
| 197 | 201 | forceFlag = find_option("force","f",0)!=0; |
| 202 | + forceMissingFlag = find_option("force-missing",0,0)!=0; | |
| 198 | 203 | keepFlag = find_option("keep",0,0)!=0; |
| 199 | 204 | latestFlag = find_option("latest",0,0)!=0; |
| 200 | 205 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 201 | 206 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| 202 | 207 | usage("VERSION|--latest ?--force? ?--keep?"); |
| @@ -224,11 +229,11 @@ | ||
| 224 | 229 | return; |
| 225 | 230 | } |
| 226 | 231 | }else{ |
| 227 | 232 | zVers = g.argv[2]; |
| 228 | 233 | } |
| 229 | - vid = load_vfile(zVers); | |
| 234 | + vid = load_vfile(zVers, forceMissingFlag); | |
| 230 | 235 | if( prior==vid ){ |
| 231 | 236 | return; |
| 232 | 237 | } |
| 233 | 238 | if( !keepFlag ){ |
| 234 | 239 | uncheckout(prior); |
| 235 | 240 |
| --- 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 |
M
src/db.c
+11
-5
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1985,29 +1985,32 @@ | ||
| 1985 | 1985 | ** If VERSION is specified then that version is checked out. Otherwise |
| 1986 | 1986 | ** the latest version is checked out. No files other than "manifest" |
| 1987 | 1987 | ** and "manifest.uuid" are modified if the --keep option is present. |
| 1988 | 1988 | ** |
| 1989 | 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 | |
| 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 | |
| 1995 | 1996 | ** |
| 1996 | 1997 | ** See also: close |
| 1997 | 1998 | */ |
| 1998 | 1999 | void cmd_open(void){ |
| 1999 | 2000 | int emptyFlag; |
| 2000 | 2001 | int keepFlag; |
| 2002 | + int forceMissingFlag; | |
| 2001 | 2003 | int allowNested; |
| 2002 | 2004 | char **oldArgv; |
| 2003 | 2005 | int oldArgc; |
| 2004 | 2006 | static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0 }; |
| 2005 | 2007 | |
| 2006 | 2008 | url_proxy_options(); |
| 2007 | 2009 | emptyFlag = find_option("empty",0,0)!=0; |
| 2008 | 2010 | keepFlag = find_option("keep",0,0)!=0; |
| 2011 | + forceMissingFlag = find_option("force-missing",0,0)!=0; | |
| 2009 | 2012 | allowNested = find_option("nested",0,0)!=0; |
| 2010 | 2013 | if( g.argc!=3 && g.argc!=4 ){ |
| 2011 | 2014 | usage("REPOSITORY-FILENAME ?VERSION?"); |
| 2012 | 2015 | } |
| 2013 | 2016 | if( !allowNested && db_open_local(0) ){ |
| @@ -2043,10 +2046,13 @@ | ||
| 2043 | 2046 | azNewArgv[g.argc-1] = db_get("main-branch", "trunk"); |
| 2044 | 2047 | } |
| 2045 | 2048 | if( keepFlag ){ |
| 2046 | 2049 | azNewArgv[g.argc++] = "--keep"; |
| 2047 | 2050 | } |
| 2051 | + if( forceMissingFlag ){ | |
| 2052 | + azNewArgv[g.argc++] = "--force-missing"; | |
| 2053 | + } | |
| 2048 | 2054 | checkout_cmd(); |
| 2049 | 2055 | } |
| 2050 | 2056 | g.argc = 2; |
| 2051 | 2057 | info_cmd(); |
| 2052 | 2058 | } |
| 2053 | 2059 |
| --- 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 |