Skip to content

Commit bba7bcf

Browse files
committed
Simplify rendering.
I realized I can set colors on in trycmd: I don't mind the output being a bit garbled, the point is to check if things have changed. By doing this, I don't need to render things again, and that also means that the line numbers for the inclusion can actually match the numbers in the file, which is SO NICE.
1 parent 6817b57 commit bba7bcf

File tree

9 files changed

+187
-244
lines changed

9 files changed

+187
-244
lines changed

.github/workflows/deploy.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@ jobs:
2222
mkdir mdbook
2323
curl -sSL $url | tar -xz --directory=./mdbook
2424
echo `pwd`/mdbook >> $GITHUB_PATH
25-
- uses: baptiste0928/cargo-install@v3
26-
with:
27-
crate: jj-cli
28-
version: "=0.27.0"
25+
- name: Build jj
26+
run: |
27+
cargo build
2928
- name: Configure jj
3029
run: |
31-
jj config set --user user.name "Steve Klabnik"
32-
jj config set --user user.email "steve@steveklabnik.com"
30+
cargo run --bin jj -- config set --user user.name "Steve Klabnik"
31+
cargo run --bin jj -- config set --user user.email "steve@steveklabnik.com"
3332
- name: Build Book
3433
run: |
35-
cargo build && PATH=$PATH:target/debug/ mdbook build book
34+
PATH=$PATH:target/debug/ mdbook build book
3635
- name: Setup Pages
3736
uses: actions/configure-pages@v5
3837
- name: Upload artifact

.vscode/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
{
22
"cSpell.words": [
3+
"abbb",
34
"DVCS",
45
"hljs",
56
"kozrnusy",
7+
"mdiff",
8+
"mfde",
9+
"mfed",
10+
"mgit",
11+
"mgoodbye",
12+
"mindex",
13+
"mmznvnuw",
14+
"mnmounps",
15+
"mpqvmvrn",
16+
"mquwwlss",
17+
"msrc",
18+
"mtrqnyzv",
19+
"mtrunk",
620
"mtuyzlkn",
21+
"mvnlxpxw",
22+
"mzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz",
723
"nmounps",
824
"noreport",
925
"nvnlxpxw",

book/src/core-concepts/changes-commits-and-revisions.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ one, it will refuse unless you pass `--ignore-immutable` as an argument.
8080

8181
Let's look at `jj log`:
8282

83-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:63:70}}
83+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:68:75}}
8484

8585
We have the green `@`, but its parent instead has a ``. This change
8686
is mutable. But what about `p`? It has a ``. This change is immutable.
@@ -103,7 +103,7 @@ to us right now.
103103
We can use `jj show` to show information about changes. The root change
104104
has a change ID of all `z`s, let's check it out:
105105

106-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:73:81}}
106+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:78:84}}
107107

108108
Pretty fun. Wait, what's that `Commit ID` doing there? Okay, let's
109109
talk about commits.
@@ -117,7 +117,7 @@ So we've been talking about how changes are different than `git`'s commits...
117117
but `jj` also has commits. Let me explain. Let's use `jj st` to look at our
118118
current change:
119119

120-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:83:87}}
120+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:88:91}}
121121

122122
Do you see how we have four identifiers there?
123123

@@ -134,7 +134,7 @@ the contents of the commit, when you create a new git commit, you're also going
134134
to get a different ID. Here, let's give it a try: modify `src/main.rs`, in any
135135
way that you'd like. Then we'll run `jj st` again:
136136

137-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:92:97}}
137+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:99:103}}
138138

139139
`o` used to have a commit ID of `95d5c471`, but now it's `c920ae70`. Our change
140140
ID remains stable, but the commit ID will change over time.
@@ -143,7 +143,7 @@ This is very powerful! Part 4 of the tutorial is titled "Fixing Problems," and
143143
a lot of the stuff we will talk about there is powered by commits. We can
144144
use `jj evolog`, the "evolution log," to see how a change has evolved over time:
145145

146-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:99:106}}
146+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:106:111}}
147147

148148
There are a lot of flags to control `jj evolog`'s output. I've chosen the
149149
`summary` flag here to show which files we changed.

book/src/core-concepts/throwing-away-changes-and-jj-undo.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Getting rid of changes is very easy in `jj`: we can do it with `jj abandon`.
77

88
If you remember, we're in the middle of some stuff:
99

10-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:107:112}}
10+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:114:118}}
1111

1212
If you are coming to this section fresh, just type `jj new` a few times to
1313
give yourself some good changes. Done? Great. Let's throw them away.
@@ -17,25 +17,25 @@ give yourself some good changes. Done? Great. Let's throw them away.
1717
Let's say we don't like that "hello and goodbye world" stuff. We're not going
1818
to pursue that further. Getting rid of it is as easy as:
1919

20-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:114:118}}
20+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:128:132}}
2121

2222
By default, `jj restore` takes changes from your parent change, and puts them
2323
into `@`. But there's `--from` and even `--into` flags you can pass as well.
2424
Let's grab the diff from our first commit, and apply it to `@`:
2525

26-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:121:125}}
26+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:128:132}}
2727

2828
As you can see we aren't empty any more. Well, what does our code look like?
2929
Let's use `jj diff` to see:
3030

31-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:128:132}}
31+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:135:139}}
3232

3333
This format is different than `git`'s: we have red and green to indicate
3434
what's changed, for example.
3535

3636
If you want to get a `git` style diff instead, that is easy as well:
3737

38-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:135:144}}
38+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:142:151}}
3939

4040
We only had one file that was changed, so we didn't *need* to pass the path to
4141
`jj restore`, but `jj restore` is mostly used with individual paths. If we
@@ -50,7 +50,7 @@ But what if we want to delete a change entirely?
5050
At any time, you can get rid of a change with `jj abandon`. It's tons of fun!
5151
Let's try it:
5252

53-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:147:151}}
53+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:154:158}}
5454

5555
This throws away our current change. We abandoned `opqvmvrn`, and since that
5656
was the same as `@`, `jj` makes a new change for us, in this case, called
@@ -59,11 +59,11 @@ was the same as `@`, `jj` makes a new change for us, in this case, called
5959
But what if we abandon something that's not `@`? Like, let's say, `t`, the
6060
change that we're currently on top of. What's the worst that could happen?
6161

62-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:154:160}}
62+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:161:167}}
6363

6464
So what happened here?
6565

66-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:163:169}}
66+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:170:175}}
6767

6868
As you can see, because we got rid of the commit we were standing on, instead of throwing
6969
us away too, `jj` just re-parented us onto the abandoned commit's parent. We're still on
@@ -78,11 +78,11 @@ I have good news.
7878

7979
There's a really useful subcommand that goes by `jj undo`:
8080

81-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:171:175}}
81+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:178:182}}
8282

8383
That's it! We're good again:
8484

85-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:178:185}}
85+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:185:192}}
8686

8787
Everything is back to where we put it. We can always `jj undo` to undo
8888
*any* of our last operations, and `jj` will make things right again.
@@ -95,7 +95,7 @@ though. What do you think would happen if we `jj undo`'d again right now?
9595

9696
Make your guess, and then give it a try:
9797

98-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:188:195}}
98+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:195:201}}
9999

100100
That's right: the last thing you did was an `undo`, so an `undo` just
101101
`undo`es that `undo`. Hilarious, but kind of frustrating. There's a
@@ -105,7 +105,7 @@ a bit trickier than it sounds.
105105
Regardless, we can fix this: there's no problem with `jj undo` that you
106106
can't solve by throwing more `jj undo`s at it:
107107

108-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:197:203}}
108+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:204:210}}
109109

110110
Whew. That's enough of that.
111111

@@ -114,24 +114,24 @@ Whew. That's enough of that.
114114
Having an empty change with no description is fine to have if it's
115115
`@`, or if it has children. Here's a fun party trick:
116116

117-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:206:210}}
117+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:213:217}}
118118

119119
That's right: `jj new` can take `--before` or `--after` flags to
120120
squish a change in between others. (Yes, we're trying to make squish happen.)
121121
And `--no-edit` means that we don't want to move our working copy
122122
to the new change: `@` stays right where it is:
123123

124-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:213:222}}
124+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:220:229}}
125125

126126
So that change is fine. But what if we move away from these changes?
127127
Let's make a new change on top of `trunk`:
128128

129-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:225:228}}
129+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:232:235}}
130130

131131
We had two empty commits on top of `goodbye-world` before, but
132132
what about now?
133133

134-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:230:239}}
134+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:238:247}}
135135

136136
Our empty change `nvnlxpxw` was discarded, automatically. You don't have to
137137
worry about `jj new` littering up your repository, empty changes will end up

book/src/getting-started/cloning-a-repository.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ of your own.
1212
Next, let's clone down our fork. Go to the directory where you'd like to create
1313
your clone, in my case, that's `~/src`. And then type this:
1414

15-
```bash
15+
```nohighlight
1616
$ jj git clone --colocate git@github.com:<YOUR USERNAME>/hello-world
1717
Fetching into new repo in "/home/<YOUR USERNAME>/src/hello-world"
1818
bookmark: trunk@origin [new] untracked
@@ -30,7 +30,7 @@ command, `--colocate`. `jj` supports two different kinds of repositories:
3030
colocated, and non-colocated. What's the difference? Well, let's take a look
3131
at our repository:
3232

33-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:12:19}}
33+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:15:22}}
3434

3535
We have both a `.jj` and a `.git` directory at the top level. This means both
3636
jj's information as git's information are co-located: they're next to each
@@ -44,7 +44,7 @@ at the root of the repository will still work.
4444

4545
Let's see what our repository's history looks like:
4646

47-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:22:27}}
47+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:26:31}}
4848

4949
This looks a bit different than `git log`, but it's the same general idea: we
5050
can see where we our in our history.

book/src/getting-started/interacting-with-github.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ would make it harder to understand.
88

99
Let's look at that `jj log` output again:
1010

11-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:49:56}}
11+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:54:61}}
1212

1313
Do you see that little `trunk` over on the right there? That is a *bookmark*
1414
in `jj`, and it's how `jj` understands git branches. `trunk` is the name of
@@ -24,7 +24,7 @@ locally, but when we interact with GitHub, it needs a branch name.
2424

2525
To create a bookmark, we can use `jj bookmark`:
2626

27-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:59:61}}
27+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:64:65}}
2828

2929
`jj bookmark create` takes a name for the bookmark, and then we also pass a `-r` flag.
3030
This is short for "revision," which is a sort of catch-all name for the various kinds
@@ -33,7 +33,7 @@ the change ID. In this case, we pass `@-`, which means "the parent of `@`."
3333

3434
Let's look at our log:
3535

36-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:63:70}}
36+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:68:75}}
3737

3838
We can now see `goodbye-world` listed on the right. Great! Let's push that up
3939
to GitHub. But before we do, a warning:

book/src/getting-started/making-a-new-change.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ simplest possible workflow. If you're a fan of building up small commits via the
77
If you remember from the end of the last section, we're on an empty change.
88
You can double check with `jj status` (or `jj st`):
99

10-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:29:32}}
10+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:34:37}}
1111

1212
So what is a change, anyway? It is the core primitive you'll be working with in
1313
`jj`. We'll talk about that actually means in Part 2. For now, you can think of
@@ -35,7 +35,7 @@ fn main() {
3535

3636
A bit fatalistic, but it works. Let's run `jj st` again:
3737

38-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:37:42}}
38+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:42:46}}
3939

4040
We can see we've modified `src/main.rs`. Whenever we run a `jj` command, `jj`
4141
will snapshot all of the changes that we've made to any files in our repository
@@ -51,14 +51,14 @@ but now I love it.
5151
Let's say we're happy with the contents of this change. We're done, and we want
5252
to start working on something else. To do that, we can use `jj commit`:
5353

54-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:44:46}}
54+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:49:51}}
5555

5656
Easy enough! Our working copy is now on a fresh new change, and its parent
5757
is our "Goodbye, world!" change that we just committed.
5858

5959
To see our changes in context, let's look at `jj log` again:
6060

61-
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:49:56}}
61+
{{#trycmdinclude tests/tests/cmd/getting-started.trycmd:54:61}}
6262

6363
You can see that we're currently working on an empty change. It has `x` as a
6464
change ID, but there's also a little `@` there: `@` is an alias for the working

0 commit comments

Comments
 (0)