History

Make Requests Processes and create process hierarchy. Associate OpenRepository with context. (#17125)

This PR registers requests with the process manager and manages hierarchy within the processes. Git repos are then associated with a context, (usually the request's context) - with sub commands using this context as their base context.

zeripath committed 4 years ago

Commit 01087e91 parent d894c9066 files · +591 −306Browse files

Showing the changes to services/gitdiff/gitdiff.go (1 of 66 files). Show all

Unified · Split

services/gitdiff/gitdiff.go+3−5
@@ -1303,8 +1303,9 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff · 1302 unmodified lines
1303 return nil, err1303 return nil, err
1304 }1304 }
1305 1305
1306 ctx, cancel := context.WithTimeout(git.DefaultContext, time.Duration(setting.Git.Timeout.Default)*time.Second)1306 timeout := time.Duration(setting.Git.Timeout.Default) * time.Second
1307 defer cancel()1307 ctx, _, finished := process.GetManager().AddContextTimeout(gitRepo.Ctx, timeout, fmt.Sprintf("GetDiffRange [repo_path: %s]", repoPath))
1308 defer finished()
1308 1309
1309 argsLength := 61310 argsLength := 6
1310 if len(opts.WhitespaceBehavior) > 0 {1311 if len(opts.WhitespaceBehavior) > 0 {
@@ -1369,9 +1370,6 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff · 58 unmodified lines
1369 return nil, fmt.Errorf("error during Start: %w", err)1370 return nil, fmt.Errorf("error during Start: %w", err)
1370 }1371 }
1371 1372
1372 pid := process.GetManager().Add(fmt.Sprintf("GetDiffRange [repo_path: %s]", repoPath), cancel)
1373 defer process.GetManager().Remove(pid)
1374
1375 diff, err := ParsePatch(opts.MaxLines, opts.MaxLineCharacters, opts.MaxFiles, stdout, parsePatchSkipToFile)1373 diff, err := ParsePatch(opts.MaxLines, opts.MaxLineCharacters, opts.MaxFiles, stdout, parsePatchSkipToFile)
1376 if err != nil {1374 if err != nil {
1377 return nil, fmt.Errorf("unable to ParsePatch: %w", err)1375 return nil, fmt.Errorf("unable to ParsePatch: %w", err)