isomorphic-jj 1.1.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/dist/index.cjs +327 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +327 -156
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/repository.js +246 -150
- package/src/core/bookmark-store.js +16 -4
- package/src/core/revset-engine.js +18 -0
- package/src/core/user-config.js +47 -2
- package/src/types.d.ts +165 -2
package/README.md
CHANGED
|
@@ -202,6 +202,54 @@ await jj.amend();
|
|
|
202
202
|
await jj.undo();
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
+
### Understanding Working Copy vs Parent
|
|
206
|
+
|
|
207
|
+
A common source of confusion: **the working copy and its parent are different changes**.
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
// After init, you have a working copy change (with changeId)
|
|
211
|
+
const status1 = await jj.status();
|
|
212
|
+
console.log(status1.workingCopy.changeId); // e.g., "abc123..."
|
|
213
|
+
console.log(status1.workingCopy.description); // "(no description set)"
|
|
214
|
+
|
|
215
|
+
// When you describe(), you're updating the PARENT change
|
|
216
|
+
await jj.describe({ message: 'Add feature' });
|
|
217
|
+
|
|
218
|
+
// The working copy changeId is STILL the same!
|
|
219
|
+
const status2 = await jj.status();
|
|
220
|
+
console.log(status2.workingCopy.changeId); // SAME: "abc123..."
|
|
221
|
+
console.log(status2.workingCopy.description); // UPDATED: "Add feature"
|
|
222
|
+
|
|
223
|
+
// When you new(), you create a NEW working copy
|
|
224
|
+
await jj.new({ message: 'Next change' });
|
|
225
|
+
|
|
226
|
+
const status3 = await jj.status();
|
|
227
|
+
console.log(status3.workingCopy.changeId); // DIFFERENT: "def456..."
|
|
228
|
+
console.log(status3.workingCopy.description); // "Next change"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Key points:**
|
|
232
|
+
- **Working copy IS a change** with its own `changeId` (always `@` in revsets)
|
|
233
|
+
- **`describe()`** updates the parent's description, not the working copy's changeId
|
|
234
|
+
- **`status()`** returns the working copy changeId (which may or may not have a description)
|
|
235
|
+
- **`new()`** creates a new working copy change and makes the previous one the parent
|
|
236
|
+
- **Reading metadata immediately after write** shows working copy state, not parent state
|
|
237
|
+
|
|
238
|
+
**Common pattern:**
|
|
239
|
+
```javascript
|
|
240
|
+
// 1. Edit files
|
|
241
|
+
await jj.write({ path: 'file.js', data: 'content' });
|
|
242
|
+
|
|
243
|
+
// 2. Describe the change (updates parent)
|
|
244
|
+
await jj.describe({ message: 'Add file' });
|
|
245
|
+
|
|
246
|
+
// 3. Create new working copy for next change
|
|
247
|
+
await jj.new({ message: 'Next feature' });
|
|
248
|
+
|
|
249
|
+
// Or use commit() to combine describe() + new()
|
|
250
|
+
await jj.commit({ message: 'Add file', nextMessage: 'Next feature' });
|
|
251
|
+
```
|
|
252
|
+
|
|
205
253
|
---
|
|
206
254
|
|
|
207
255
|
## Features
|