The sound distributed version control system

#15 Diff shows different change than the change I made

Closed on November 9, 2020
lambda on November 6, 2020

After cloning anu, despite seeming to have the fixes from #11 and #5, I still have newlines missing from my Cargo.toml files, so cargo build doesn’t work.

Once I add those newlines in again myself and use anu diff to see my changes, I see a diff that looks very different than the change I actually made:

$ anu diff libanu/Cargo.toml 
message = ''
timestamp = '2020-11-06T23:36:56.053801176Z'
authors = []

# Dependencies
[2] SL52FT2SJFQMOA2H25WXCYJBY4Z4ATQOAEIGDQULLLNZGLTIL3IAC
[3]+Y67GBRYQ6WCAKFJKZJYNCSON7AMN2KRH5T745MQ3OMZCUA2SM5UAC
[4]+HYNHP3MNRNAAS5VJNBWP664PE5OTL7IT5WN7WDTN4KHCSI2URIYAC

# Changes

1. Replacement in libanu/Cargo.toml:3 3.803852
  :D, 2.291 -> 2.291:314/2, 2.314 -> 4.121:168/2, 3.803903 -> 4.121:168/4
  up 2.291, new 0:71, down 2.315
- version = "1.0.0-alpha"
- repository = "https://nest.anu.dev/anu/libanu"
- repository = "https://nest.anu.dev/anu/libanu"
+ version = "1.0.0-alpha"
+ repository = "https://nest.anu.dev/anu/libanu"
+

2. Replacement in libanu/Cargo.toml:6 3.803852
  :D, 2.356 -> 2.356:408/2, 2.408 -> 3.803956:803973/2, 3.803956 -> 3.803956:803973/3
  up 2.356, new 72:142, down 4.209
- authors = ["Pierre-Étienne Meunier <pe@pijul.org>"]
- edition = "2018"
- edition = "2018"
+ authors = ["Pierre-Étienne Meunier <pe@pijul.org>"]
+ edition = "2018"
+

3. Replacement in libanu/Cargo.toml:103 3.803852
  :D, 2.430 -> 2.430:445/2, 2.445 -> 3.804519:804541/2, 3.804519 -> 3.804519:804541/3
  up 2.430, new 143:181, down 3.804541
- bincode = "1.3"
- data-encoding = "2.3"
- data-encoding = "2.3"
+ bincode = "1.3"
+ data-encoding = "2.3"
+

Here is a session showing steps, along with a manual backup of the file and diff using diff:

$ anu clone 51.210.158.166:22/anu/anu
$ anu diff libanu/Cargo.toml

# ... edit in my editor ...

$ diff -u libanu/Cargo.toml{.bak,}
--- libanu/Cargo.toml.bak	2020-11-06 18:45:57.805823045 -0500
+++ libanu/Cargo.toml	2020-11-06 18:46:48.880560170 -0500
@@ -1,9 +1,11 @@
 [package]
 name = "libanu"
 description = "Core library of Anu, a distributed version control system based on a sound theory of collaborative work."
-version = "1.0.0-alpha"repository = "https://nest.anu.dev/anu/libanu"
+version = "1.0.0-alpha"
+repository = "https://nest.anu.dev/anu/libanu"
 documentation = "https://docs.rs/libanu"
-authors = ["Pierre-Étienne Meunier <pe@pijul.org>"]edition = "2018"
+authors = ["Pierre-Étienne Meunier <pe@pijul.org>"]
+edition = "2018"
 license = "GPL-2.0"
 include = [
 "Cargo.toml",
@@ -99,7 +101,8 @@
 blake3 = "0.3"
 chrono = { version = "0.4", features = ["serde"] }
 anu-macros = "0.1.0"
-bincode = "1.3"data-encoding = "2.3"
+bincode = "1.3"
+data-encoding = "2.3"
 lru-cache = "0.1"
 diffs = "0.4"
 tempfile = "3.1"

$ anu diff libanu/Cargo.toml
message = ''
timestamp = '2020-11-06T23:46:58.699276658Z'
authors = []

# Dependencies
[2] SL52FT2SJFQMOA2H25WXCYJBY4Z4ATQOAEIGDQULLLNZGLTIL3IAC
[3]+Y67GBRYQ6WCAKFJKZJYNCSON7AMN2KRH5T745MQ3OMZCUA2SM5UAC
[4]+HYNHP3MNRNAAS5VJNBWP664PE5OTL7IT5WN7WDTN4KHCSI2URIYAC

# Changes

1. Replacement in libanu/Cargo.toml:3 3.803852
  :D, 2.291 -> 2.291:314/2, 2.314 -> 4.121:168/2, 3.803903 -> 4.121:168/4
  up 2.291, new 0:71, down 2.315
- version = "1.0.0-alpha"
- repository = "https://nest.anu.dev/anu/libanu"
- repository = "https://nest.anu.dev/anu/libanu"
+ version = "1.0.0-alpha"
+ repository = "https://nest.anu.dev/anu/libanu"
+

2. Replacement in libanu/Cargo.toml:6 3.803852
  :D, 2.356 -> 2.356:408/2, 2.408 -> 3.803956:803973/2, 3.803956 -> 3.803956:803973/3
  up 2.356, new 72:142, down 4.209
- authors = ["Pierre-Étienne Meunier <pe@pijul.org>"]
- edition = "2018"
- edition = "2018"
+ authors = ["Pierre-Étienne Meunier <pe@pijul.org>"]
+ edition = "2018"
+

3. Replacement in libanu/Cargo.toml:103 3.803852
  :D, 2.430 -> 2.430:445/2, 2.445 -> 3.804519:804541/2, 3.804519 -> 3.804519:804541/3
  up 2.430, new 143:181, down 3.804541
- bincode = "1.3"
- data-encoding = "2.3"
- data-encoding = "2.3"
+ bincode = "1.3"
+ data-encoding = "2.3"
+

So for some reason, the diff shows three predecessor lines, when there was only one line in the actual file in my working directory, and it shows 3 new lines, two of which match the predecessor lines and one of which is a blank line at the end that I did not add; I added a newline in between the two other lines, to break up the two lines which had gotten merged together somehow.

fabian on November 6, 2020

Refer to #13

pmeunier on November 7, 2020

This is due to the trickiest part of libanu: change parsing. The internal representation of changes is tricky, and Pijul used to provide an interactive sequence of questions to make a change. I believe this new scheme offers much more flexibility, but requires (1) a stable text format to describe the changes (the binary format itself is stable), and (2) a parser for it.

Unfortunately, only real-world usage can tell if the text format is good enough. And since I don’t actuvely work on any other project at the moment, Anu itself is a good test case, even if that means going through some of these UI hiccups for the first release.

pmeunier on November 9, 2020

This particular problem with newlines is fixed in #3EAIT2277UKYK2SGAWNR4GRP3IIJGMH6ANJ3JGBZMKNYRW7OOCVQC.

I have explained in the following blog post how the whole thing works: https://pijul.org/posts/2020-11-07-towards-1.0/

In particular, deleted lines are not part of the change, they’re mostly a decoration here. The only things that matter for deletions are the lines of the form :D, 2.291 -> 2.291:314/2, 2.314 -> 4.121:168/2, 3.803903 -> 4.121:168/4.

pmeunier closed this discussion on November 9, 2020