summaryrefslogtreecommitdiff
path: root/vrsite/jj.go
diff options
context:
space:
mode:
Diffstat (limited to 'vrsite/jj.go')
-rw-r--r--vrsite/jj.go27
1 files changed, 16 insertions, 11 deletions
diff --git a/vrsite/jj.go b/vrsite/jj.go
index bb95d83..0b5cbdf 100644
--- a/vrsite/jj.go
+++ b/vrsite/jj.go
@@ -1,9 +1,8 @@
// jj.go — every read of the repository goes through here.
//
-// Two rules hold everywhere: the repo is never modified (no edit, no new, no
-// checkout; --ignore-working-copy on every call so we never even snapshot),
-// and nothing is written to disk — templates are passed inline with -T, so a
-// query leaves no trace behind, it just renders once and is sent to the page.
+// These helpers never modify project history or its working copy
+// (--ignore-working-copy means they never even snapshot it). Sidecar mutation
+// is isolated in the shared sidecar package.
package main
import (
@@ -72,21 +71,27 @@ func checkRevset(r string) error {
}
func resolveChange(repo, rev string) (string, error) {
+ change, _, err := resolveRevision(repo, rev)
+ return change, err
+}
+
+func resolveRevision(repo, rev string) (change, commit string, err error) {
if rev == "" {
rev = "@"
}
if err := checkRevset(rev); err != nil {
- return "", err
+ return "", "", err
}
- out, err := jjRun(repo, "log", "-r", rev, "--no-graph", "-n", "1", "-T", "change_id")
+ out, err := jjRun(repo, "log", "-r", "exactly(("+rev+"), 1)", "--no-graph",
+ "-T", "change_id ++ \"\\n\" ++ commit_id ++ \"\\n\"")
if err != nil {
- return "", err
+ return "", "", err
}
- id := strings.TrimSpace(string(out))
- if id == "" {
- return "", fmt.Errorf("revset %q matches no change", rev)
+ ids := strings.Fields(string(out))
+ if len(ids) != 2 {
+ return "", "", fmt.Errorf("revset %q did not resolve to one change and commit", rev)
}
- return id, nil
+ return ids[0], ids[1], nil
}
// changeBrief resolves a revset to the one change it names, with everything a