Cached builds

Source units now point to their previous revision if the unit isn't changed, and those units aren't rebuilt during the `make` step.

Just to clarify, changedFilesFromCurrentRev only returns the files that
have changed between fromRev and HEAD. I hadn't thought of the case
where srclib is building uncommitted code, and I think
changedFilesFromCurrentRev should diff with the current working
directory to be consistent with srclib's current behavior.

Let me fix up the name, though.

Quinn Slack writes:

>> @@ -95,6 +95,32 @@ func resolveWorkingTreeRevision(vcsType string, dir string) (string, error) {
>>  	return strings.TrimSuffix(string(bytes.TrimSpace(out)), "+"), nil
>>  }
>>  
>> +func listRevisions(vcsType string, dir string) ([]string, error) {
>> +	if vcsType != "git" {
>> +		return nil, fmt.Errorf("listRevisions: unsupported vcs type: %q", vcsType)
>> +	}
>> +	cmd := exec.Command("git", "rev-list", "--max-count=5", "HEAD")
>> +	cmd.Dir = dir
>> +	out, err := cmd.CombinedOutput()
>> +	if err != nil {
>> +		return nil, err
>> +	}
>> +	return strings.Split(string(bytes.TrimSpace(out)), "\n"), nil
>> +}
>> +
>> +func changedFilesFromCurrentRev(vcsType string, dir string, fromRev string) ([]string, error) {
>
> "Current revision" is ambiguous. It could imply that it finds the files that changed between fromRev and the HEAD commit. But this command also gets files that have changed in the index (i.e., files that haven't yet been committed). The existing behavior is a bit weird, in that it'll process the index and store it in the `.srclib-cache/COMMITID` dir for the commit, but we should try to be explicit about that. So, what about calling this func `filesChangedFromRevToHEAD`?
>
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/sourcegraph/srclib/pull/97/files#r22396171

-- 
    Samer