Fossil SCM
Add support for the "--nested" option to the clone subcommand, so the new clone/open in 1 step usage can be use insde a checkout.
Commit
f3d115d9884944932247c030d3eb0db0a812edbd37d2b995900071b77262eabb
Parent
c7dcf38c5b89ccc…
1 file changed
+28
-13
+28
-13
| --- src/clone.c | ||
| +++ src/clone.c | ||
| @@ -123,10 +123,11 @@ | ||
| 123 | 123 | ** the -A|--admin-user parameter. |
| 124 | 124 | ** |
| 125 | 125 | ** Options: |
| 126 | 126 | ** --admin-user|-A USERNAME Make USERNAME the administrator |
| 127 | 127 | ** --httpauth|-B USER:PASS Add HTTP Basic Authorization to requests |
| 128 | +** --nested Allow opening a repository inside an opened checkout | |
| 128 | 129 | ** --nocompress Omit extra delta compression |
| 129 | 130 | ** --no-open Clone only. Do not open a check-out. |
| 130 | 131 | ** --once Don't remember the URI. |
| 131 | 132 | ** --private Also clone private branches |
| 132 | 133 | ** --save-http-password Remember the HTTP password without asking |
| @@ -145,12 +146,13 @@ | ||
| 145 | 146 | int nErr = 0; |
| 146 | 147 | int urlFlags = URL_PROMPT_PW | URL_REMEMBER; |
| 147 | 148 | int syncFlags = SYNC_CLONE; |
| 148 | 149 | int noCompress = find_option("nocompress",0,0)!=0; |
| 149 | 150 | int noOpen = find_option("no-open",0,0)!=0; |
| 151 | + int allowNested = find_option("nested",0,0)!=0; /* Used by open */ | |
| 150 | 152 | const char *zRepo = 0; /* Name of the new local repository file */ |
| 151 | - const char *zWorkDir = 0; /* Open in this director, if not zero */ | |
| 153 | + const char *zWorkDir = 0; /* Open in this directory, if not zero */ | |
| 152 | 154 | |
| 153 | 155 | |
| 154 | 156 | /* Also clone private branches */ |
| 155 | 157 | if( find_option("private",0,0)!=0 ) syncFlags |= SYNC_PRIVATE; |
| 156 | 158 | if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER; |
| @@ -189,10 +191,16 @@ | ||
| 189 | 191 | } |
| 190 | 192 | fossil_free(zBase); |
| 191 | 193 | } |
| 192 | 194 | if( -1 != file_size(zRepo, ExtFILE) ){ |
| 193 | 195 | fossil_fatal("file already exists: %s", zRepo); |
| 196 | + } | |
| 197 | + /* Fail before clone if open will fail because inside an open checkout */ | |
| 198 | + if( zWorkDir!=0 && zWorkDir[0]!=0 && !noOpen ){ | |
| 199 | + if( db_open_local_v2(0, allowNested) ){ | |
| 200 | + fossil_fatal("there is already an open tree at %s", g.zLocalRoot); | |
| 201 | + } | |
| 194 | 202 | } |
| 195 | 203 | url_parse(g.argv[2], urlFlags); |
| 196 | 204 | if( zDefaultUser==0 && g.url.user!=0 ) zDefaultUser = g.url.user; |
| 197 | 205 | if( g.url.isFile ){ |
| 198 | 206 | file_copy(g.url.name, zRepo); |
| @@ -277,22 +285,29 @@ | ||
| 277 | 285 | fossil_print("\nproject-id: %s\n", db_get("project-code", 0)); |
| 278 | 286 | fossil_print("server-id: %s\n", db_get("server-code", 0)); |
| 279 | 287 | zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); |
| 280 | 288 | fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword); |
| 281 | 289 | if( zWorkDir!=0 && zWorkDir[0]!=0 && !noOpen ){ |
| 282 | - char *azNew[6]; | |
| 283 | - fossil_print("opening the new %s repository in directory %s...\n", | |
| 284 | - zRepo, zWorkDir); | |
| 285 | - azNew[0] = g.argv[0]; | |
| 286 | - azNew[1] = "open"; | |
| 287 | - azNew[2] = (char*)zRepo; | |
| 288 | - azNew[3] = "--workdir"; | |
| 289 | - azNew[4] = (char*)zWorkDir; | |
| 290 | - azNew[5] = 0; | |
| 291 | - g.argv = azNew; | |
| 292 | - g.argc = 5; | |
| 293 | - cmd_open(); | |
| 290 | + char *azNew[7]; | |
| 291 | + int nargs = 5; | |
| 292 | + fossil_print("opening the new %s repository in directory %s...\n", | |
| 293 | + zRepo, zWorkDir); | |
| 294 | + azNew[0] = g.argv[0]; | |
| 295 | + azNew[1] = "open"; | |
| 296 | + azNew[2] = (char*)zRepo; | |
| 297 | + azNew[3] = "--workdir"; | |
| 298 | + azNew[4] = (char*)zWorkDir; | |
| 299 | + if( allowNested ){ | |
| 300 | + azNew[5] = "--nested"; | |
| 301 | + nargs++; | |
| 302 | + }else{ | |
| 303 | + azNew[5] = 0; | |
| 304 | + } | |
| 305 | + azNew[6] = 0; | |
| 306 | + g.argv = azNew; | |
| 307 | + g.argc = nargs; | |
| 308 | + cmd_open(); | |
| 294 | 309 | } |
| 295 | 310 | } |
| 296 | 311 | |
| 297 | 312 | /* |
| 298 | 313 | ** If user chooses to use HTTP Authentication over unencrypted HTTP, |
| 299 | 314 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -123,10 +123,11 @@ | |
| 123 | ** the -A|--admin-user parameter. |
| 124 | ** |
| 125 | ** Options: |
| 126 | ** --admin-user|-A USERNAME Make USERNAME the administrator |
| 127 | ** --httpauth|-B USER:PASS Add HTTP Basic Authorization to requests |
| 128 | ** --nocompress Omit extra delta compression |
| 129 | ** --no-open Clone only. Do not open a check-out. |
| 130 | ** --once Don't remember the URI. |
| 131 | ** --private Also clone private branches |
| 132 | ** --save-http-password Remember the HTTP password without asking |
| @@ -145,12 +146,13 @@ | |
| 145 | int nErr = 0; |
| 146 | int urlFlags = URL_PROMPT_PW | URL_REMEMBER; |
| 147 | int syncFlags = SYNC_CLONE; |
| 148 | int noCompress = find_option("nocompress",0,0)!=0; |
| 149 | int noOpen = find_option("no-open",0,0)!=0; |
| 150 | const char *zRepo = 0; /* Name of the new local repository file */ |
| 151 | const char *zWorkDir = 0; /* Open in this director, if not zero */ |
| 152 | |
| 153 | |
| 154 | /* Also clone private branches */ |
| 155 | if( find_option("private",0,0)!=0 ) syncFlags |= SYNC_PRIVATE; |
| 156 | if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER; |
| @@ -189,10 +191,16 @@ | |
| 189 | } |
| 190 | fossil_free(zBase); |
| 191 | } |
| 192 | if( -1 != file_size(zRepo, ExtFILE) ){ |
| 193 | fossil_fatal("file already exists: %s", zRepo); |
| 194 | } |
| 195 | url_parse(g.argv[2], urlFlags); |
| 196 | if( zDefaultUser==0 && g.url.user!=0 ) zDefaultUser = g.url.user; |
| 197 | if( g.url.isFile ){ |
| 198 | file_copy(g.url.name, zRepo); |
| @@ -277,22 +285,29 @@ | |
| 277 | fossil_print("\nproject-id: %s\n", db_get("project-code", 0)); |
| 278 | fossil_print("server-id: %s\n", db_get("server-code", 0)); |
| 279 | zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); |
| 280 | fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword); |
| 281 | if( zWorkDir!=0 && zWorkDir[0]!=0 && !noOpen ){ |
| 282 | char *azNew[6]; |
| 283 | fossil_print("opening the new %s repository in directory %s...\n", |
| 284 | zRepo, zWorkDir); |
| 285 | azNew[0] = g.argv[0]; |
| 286 | azNew[1] = "open"; |
| 287 | azNew[2] = (char*)zRepo; |
| 288 | azNew[3] = "--workdir"; |
| 289 | azNew[4] = (char*)zWorkDir; |
| 290 | azNew[5] = 0; |
| 291 | g.argv = azNew; |
| 292 | g.argc = 5; |
| 293 | cmd_open(); |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | /* |
| 298 | ** If user chooses to use HTTP Authentication over unencrypted HTTP, |
| 299 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -123,10 +123,11 @@ | |
| 123 | ** the -A|--admin-user parameter. |
| 124 | ** |
| 125 | ** Options: |
| 126 | ** --admin-user|-A USERNAME Make USERNAME the administrator |
| 127 | ** --httpauth|-B USER:PASS Add HTTP Basic Authorization to requests |
| 128 | ** --nested Allow opening a repository inside an opened checkout |
| 129 | ** --nocompress Omit extra delta compression |
| 130 | ** --no-open Clone only. Do not open a check-out. |
| 131 | ** --once Don't remember the URI. |
| 132 | ** --private Also clone private branches |
| 133 | ** --save-http-password Remember the HTTP password without asking |
| @@ -145,12 +146,13 @@ | |
| 146 | int nErr = 0; |
| 147 | int urlFlags = URL_PROMPT_PW | URL_REMEMBER; |
| 148 | int syncFlags = SYNC_CLONE; |
| 149 | int noCompress = find_option("nocompress",0,0)!=0; |
| 150 | int noOpen = find_option("no-open",0,0)!=0; |
| 151 | int allowNested = find_option("nested",0,0)!=0; /* Used by open */ |
| 152 | const char *zRepo = 0; /* Name of the new local repository file */ |
| 153 | const char *zWorkDir = 0; /* Open in this directory, if not zero */ |
| 154 | |
| 155 | |
| 156 | /* Also clone private branches */ |
| 157 | if( find_option("private",0,0)!=0 ) syncFlags |= SYNC_PRIVATE; |
| 158 | if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER; |
| @@ -189,10 +191,16 @@ | |
| 191 | } |
| 192 | fossil_free(zBase); |
| 193 | } |
| 194 | if( -1 != file_size(zRepo, ExtFILE) ){ |
| 195 | fossil_fatal("file already exists: %s", zRepo); |
| 196 | } |
| 197 | /* Fail before clone if open will fail because inside an open checkout */ |
| 198 | if( zWorkDir!=0 && zWorkDir[0]!=0 && !noOpen ){ |
| 199 | if( db_open_local_v2(0, allowNested) ){ |
| 200 | fossil_fatal("there is already an open tree at %s", g.zLocalRoot); |
| 201 | } |
| 202 | } |
| 203 | url_parse(g.argv[2], urlFlags); |
| 204 | if( zDefaultUser==0 && g.url.user!=0 ) zDefaultUser = g.url.user; |
| 205 | if( g.url.isFile ){ |
| 206 | file_copy(g.url.name, zRepo); |
| @@ -277,22 +285,29 @@ | |
| 285 | fossil_print("\nproject-id: %s\n", db_get("project-code", 0)); |
| 286 | fossil_print("server-id: %s\n", db_get("server-code", 0)); |
| 287 | zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); |
| 288 | fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword); |
| 289 | if( zWorkDir!=0 && zWorkDir[0]!=0 && !noOpen ){ |
| 290 | char *azNew[7]; |
| 291 | int nargs = 5; |
| 292 | fossil_print("opening the new %s repository in directory %s...\n", |
| 293 | zRepo, zWorkDir); |
| 294 | azNew[0] = g.argv[0]; |
| 295 | azNew[1] = "open"; |
| 296 | azNew[2] = (char*)zRepo; |
| 297 | azNew[3] = "--workdir"; |
| 298 | azNew[4] = (char*)zWorkDir; |
| 299 | if( allowNested ){ |
| 300 | azNew[5] = "--nested"; |
| 301 | nargs++; |
| 302 | }else{ |
| 303 | azNew[5] = 0; |
| 304 | } |
| 305 | azNew[6] = 0; |
| 306 | g.argv = azNew; |
| 307 | g.argc = nargs; |
| 308 | cmd_open(); |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | /* |
| 313 | ** If user chooses to use HTTP Authentication over unencrypted HTTP, |
| 314 |