fix init: use sl init+pull instead of sl clone for gitimported repos

sl clone uses a different protocol path (getbundle) that doesn't work for
repos populated via gitimport. Using sl init + write config + sl pull + sl goto
correctly pulls commits via the EdenAPI changelog path.
Anton Kaminsky28d ago56f671e7b40bparent 6d52207
1 file changed+8-16
cli/src/commands/init.ts
@@ -223,37 +223,29 @@
223223 // Remove temp upload files
224224 rmSync(tmpDir, { recursive: true, force: true });
225225
226 // Set up Sapling working copy by cloning from Grove
226 // Set up Sapling working copy: init, configure, pull, checkout
227227 const s3 = spinner();
228228 s3.start("Setting up Sapling working copy");
229 const cloneTmp = join(dir, "..", `.grove-clone-${name}-${Date.now()}`);
230229 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
236231 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" });
238233
239 // Write config with correct remote settings
234 // Write config with correct remote and auth settings
240235 const config = buildSlConfig({ ...repo, default_branch: gitBranch }, hub);
241236 writeFileSync(join(dir, ".sl", "config"), config);
242237
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" });
245241
246242 s3.stop("Sapling working copy ready");
247243 } catch (e: any) {
248 s3.stop("Clone failed");
244 s3.stop("Failed to set up working copy");
249245 log.error(e.stderr?.toString() || e.message);
250 rmSync(cloneTmp, { recursive: true, force: true });
251246 process.exit(1);
252247 }
253248
254 // Clean up clone temp dir
255 rmSync(cloneTmp, { recursive: true, force: true });
256
257249 outro(`Imported ${ownerName}/${name} with full git history`);
258250}
259251
260252