refactor design: part 2

- Add a code browsing test
- Update design doc, mainly Code Browsing and Diff.
- Simplify `Directory`.
- Remove `Tree` and `Forest`, and `SystemType`.
- Use `Rev` in `diff()`.

Signed-off-by: Han Xu <keepsimple@gmail.com>
This commit is contained in:
Han Xu
2022-10-17 19:57:20 -07:00
parent 0cec6b5997
commit c3d9a2bdc5
15 changed files with 417 additions and 1730 deletions
+5 -3
View File
@@ -144,12 +144,14 @@ pub struct Commits {
///
/// Will return [`Error`] if the project doesn't exist or the surf interaction
/// fails.
pub fn commit(repo: &RepositoryRef, sha1: Oid) -> Result<Commit, Error> {
pub fn commit(repo: &RepositoryRef, rev: &Rev) -> Result<Commit, Error> {
let sha1 = repo.rev_oid(rev)?;
let commit = repo.get_commit(sha1)?;
let diff = if let Some(parent) = commit.parents.first() {
repo.diff(*parent, sha1)?
let parent_rev = (*parent).into();
repo.diff(&parent_rev, rev)?
} else {
repo.initial_diff(sha1)?
repo.initial_diff(rev)?
};
let mut deletions = 0;