|
|
… |
297 unchanged lines |
| 298 |
298 |
|
{ |
| 299 |
299 |
|
return fail(format!("{url} has no branch {branch:?}")); |
| 300 |
300 |
|
} |
| 301 |
|
- |
self.import_git_commits(&mirror, branch, &format!("oxy git fetch {url} {branch}")) |
|
301 |
+ |
self.import_git_commits( |
|
302 |
+ |
&mirror, |
|
303 |
+ |
branch, |
|
304 |
+ |
&format!("oxy git fetch {url} {branch}"), |
|
305 |
+ |
&mut |_| {}, |
|
306 |
+ |
) |
| 302 |
307 |
|
} |
| 303 |
308 |
|
|
| 304 |
309 |
|
/// Export the bookmark to `branch` of the Git repository at `url` |
|
|
… |
252 unchanged lines |
| 557 |
562 |
|
/// edits the difference between the union of its parents' states and its |
| 558 |
563 |
|
/// tree, so merge commits become resolutions. Submodules are skipped. |
| 559 |
564 |
|
pub fn import_git(&self, git_dir: &Path, branch: &str) -> Result<GitImportReport> { |
|
565 |
+ |
self.import_git_with(git_dir, branch, &mut |_| {}) |
|
566 |
+ |
} |
|
567 |
+ |
|
|
568 |
+ |
/// `import_git`, telling `progress` where it is every few hundred |
|
569 |
+ |
/// commits: the count so far, the merges, and the commit in hand, so a |
|
570 |
+ |
/// long import is never silent and a run that dies says where. |
|
571 |
+ |
pub fn import_git_with( |
|
572 |
+ |
&self, |
|
573 |
+ |
git_dir: &Path, |
|
574 |
+ |
branch: &str, |
|
575 |
+ |
progress: crate::store::Progress<'_>, |
|
576 |
+ |
) -> Result<GitImportReport> { |
| 560 |
577 |
|
if !self.bookmark_heads()?.is_empty() { |
| 561 |
578 |
|
return fail("git import needs an empty bookmark; import into a fresh repository"); |
| 562 |
579 |
|
} |
|
|
… |
1 unchanged lines |
| 564 |
581 |
|
git_dir, |
| 565 |
582 |
|
branch, |
| 566 |
583 |
|
&format!("oxy git import {} {branch}", git_dir.display()), |
|
584 |
+ |
progress, |
| 567 |
585 |
|
) |
| 568 |
586 |
|
} |
| 569 |
587 |
|
|
|
|
… |
4 unchanged lines |
| 574 |
592 |
|
git_dir: &Path, |
| 575 |
593 |
|
branch: &str, |
| 576 |
594 |
|
command: &str, |
|
595 |
+ |
progress: crate::store::Progress<'_>, |
| 577 |
596 |
|
) -> Result<GitImportReport> { |
| 578 |
597 |
|
let batch = self.store.begin_batch()?; |
| 579 |
|
- |
let result = self.import_git_commits_batched(git_dir, branch, command); |
|
598 |
+ |
let result = self.import_git_commits_batched(git_dir, branch, command, progress); |
| 580 |
599 |
|
batch.finish()?; |
| 581 |
600 |
|
result |
| 582 |
601 |
|
} |
|
|
… |
3 unchanged lines |
| 586 |
605 |
|
git_dir: &Path, |
| 587 |
606 |
|
branch: &str, |
| 588 |
607 |
|
command: &str, |
|
608 |
+ |
progress: crate::store::Progress<'_>, |
| 589 |
609 |
|
) -> Result<GitImportReport> { |
| 590 |
610 |
|
let commits = list_commits(git_dir, branch)?; |
| 591 |
611 |
|
let mut cat = CatFile::start(git_dir)?; |
|
|
… |
7 unchanged lines |
| 599 |
619 |
|
let mut blob_cache: HashMap<String, Vec<u8>> = HashMap::new(); |
| 600 |
620 |
|
let mut cache_bytes: usize = 0; |
| 601 |
621 |
|
|
| 602 |
|
- |
for gc in &commits { |
|
622 |
+ |
let total = commits.len(); |
|
623 |
+ |
for (index, gc) in commits.iter().enumerate() { |
| 603 |
624 |
|
if known.imported.contains_key(&gc.sha) || known.exported.contains_key(&gc.sha) { |
| 604 |
625 |
|
continue; |
|
626 |
+ |
} |
|
627 |
+ |
if index % 500 == 0 { |
|
628 |
+ |
progress(&format!( |
|
629 |
+ |
"{index} of {total} commits, {} merges; at {} {}", |
|
630 |
+ |
report.merges, |
|
631 |
+ |
&gc.sha[..12.min(gc.sha.len())], |
|
632 |
+ |
gc.message |
|
633 |
+ |
.lines() |
|
634 |
+ |
.next() |
|
635 |
+ |
.unwrap_or("") |
|
636 |
+ |
.chars() |
|
637 |
+ |
.take(60) |
|
638 |
+ |
.collect::<String>() |
|
639 |
+ |
)); |
| 605 |
640 |
|
} |
| 606 |
641 |
|
// Base: union of every parent's state. |
| 607 |
642 |
|
let mut base = match (&gc.parents.first(), &last) { |
|
|
… |
324 unchanged lines |