| @@ -223,37 +223,29 @@ |
| 223 | 223 | // Remove temp upload files |
| 224 | 224 | rmSync(tmpDir, { recursive: true, force: true }); |
| 225 | 225 | |
| 226 | | // Set up Sapling working copy by cloning from Grove |
| 226 | // Set up Sapling working copy: init, configure, pull, checkout |
| 227 | 227 | const s3 = spinner(); |
| 228 | 228 | s3.start("Setting up Sapling working copy"); |
| 229 | | const cloneTmp = join(dir, "..", `.grove-clone-${name}-${Date.now()}`); |
| 230 | 229 | try { |
| 231 | | // Clone into a temp dir, then move .sl into the working dir |
| 232 | | // Pass selectivepulldefault so sl clone pulls the right bookmark (default is "master") |
| 233 | | execSync(`sl clone --config remotenames.selectivepulldefault=${gitBranch} slapi:${name} "${cloneTmp}"`, { stdio: "pipe" }); |
| 234 | | |
| 235 | | // Remove .git and replace with .sl |
| 230 | // Remove .git and init Sapling in place |
| 236 | 231 | rmSync(join(dir, ".git"), { recursive: true, force: true }); |
| 237 | | renameSync(join(cloneTmp, ".sl"), join(dir, ".sl")); |
| 232 | execSync(`sl init --config init.prefer-git=false --config format.use-remotefilelog=true "${dir}"`, { stdio: "pipe" }); |
| 238 | 233 | |
| 239 | | // Write config with correct remote settings |
| 234 | // Write config with correct remote and auth settings |
| 240 | 235 | const config = buildSlConfig({ ...repo, default_branch: gitBranch }, hub); |
| 241 | 236 | writeFileSync(join(dir, ".sl", "config"), config); |
| 242 | 237 | |
| 243 | | // Reset dirstate to match existing working copy files |
| 244 | | execSync(`sl goto ${gitBranch} --clean`, { cwd: dir, stdio: "pipe" }); |
| 238 | // Pull commits and checkout (pull may warn about "master" prefetch, which is non-fatal) |
| 239 | try { execSync(`sl pull`, { cwd: dir, stdio: "pipe" }); } catch {} |
| 240 | execSync(`sl goto ${gitBranch}`, { cwd: dir, stdio: "pipe" }); |
| 245 | 241 | |
| 246 | 242 | s3.stop("Sapling working copy ready"); |
| 247 | 243 | } catch (e: any) { |
| 248 | | s3.stop("Clone failed"); |
| 244 | s3.stop("Failed to set up working copy"); |
| 249 | 245 | log.error(e.stderr?.toString() || e.message); |
| 250 | | rmSync(cloneTmp, { recursive: true, force: true }); |
| 251 | 246 | process.exit(1); |
| 252 | 247 | } |
| 253 | 248 | |
| 254 | | // Clean up clone temp dir |
| 255 | | rmSync(cloneTmp, { recursive: true, force: true }); |
| 256 | | |
| 257 | 249 | outro(`Imported ${ownerName}/${name} with full git history`); |
| 258 | 250 | } |
| 259 | 251 | |
| 260 | 252 | |