~jan0sch/darcs-book

Showing details for patch 0cc1496d05c44151386f669d19dd4f689cf654d2.
2018-07-05 (Thu), 8:25 PM - - 0cc1496d05c44151386f669d19dd4f689cf654d2

section on weak hashes in chapter 5

Summary of changes
1 files modified with 65 lines added and 0 lines removed
  • en/05-a-little-help-from-my-friends.md with 65 added and 0 removed lines
diff -rN -u old-darcs-book/en/05-a-little-help-from-my-friends.md new-darcs-book/en/05-a-little-help-from-my-friends.md
--- old-darcs-book/en/05-a-little-help-from-my-friends.md	2024-11-24 00:02:15.979223027 +0000
+++ new-darcs-book/en/05-a-little-help-from-my-friends.md	2024-11-24 00:02:15.979223027 +0000
@@ -243,6 +243,71 @@
 `pull`. This saves us from memorizing all the remote repositories we are working
 with and thus makes life a little easier for us.
 
+Weak Hashes
+-----------
+
+There is something else that is interesting in the `darcs show repo` output.
+Namely the **weak hash**. What in tarnation does that mean and why is it useful?
+Basically it's useful to communicate if your repository has the same state as
+someone else's. Let me explain. When we first got to know `darcs` we've learned
+that a repository's state is defined by a set of changes, and therefore the
+order in which one has acquired these changes does not matter. So if I were to
+work on a project with my friend gimbar and they would pull in patches in a
+different order than I, how would we know that our repositories are actually in
+the same state? Well, as you might have guessed, that's what the **weak hash**
+is for. In chapter 3 we have learned that every patch can be identified by a
+**hash**, the **weak hash** is generated from the hashes of all the patches in a
+repository in a way that does not care about their order. So if two repositories
+are in the same state, meaning they have the same set of changes, and each patch
+has a hash that is supposed to be unique to that hash, they are bound to have
+the same **weak hash**. Take a look.
+
+```
+$ darcs log
+patch 1ae0f2d1bd00c9d72ac21eef7a26736ed76c27c8
+Author: raichoo@googlemail.com
+Date:   Thu Jul  5 21:36:46 CEST 2018
+  * A
+
+patch 6f9774a3038e1226d0df9518b163cab517b29f27
+Author: raichoo@googlemail.com
+Date:   Thu Jul  5 21:37:03 CEST 2018
+  * B
+$ darcs show repo
+         Format: hashed, darcs-2
+           Root: /tmp/darcs/X
+   PristineType: HashedPristine
+          Cache: thisrepo:/tmp/darcs/X, cache:/home/raichoo/.cache/darcs
+     PatchIndex: enabled, but not yet created
+    Num Patches: 2
+      Weak Hash: 75778672be8edbf1fa1d8bf7cb45b9dbc0deb8ef
+```
+
+```
+patch 6f9774a3038e1226d0df9518b163cab517b29f27
+Author: raichoo@googlemail.com
+Date:   Thu Jul  5 21:37:03 CEST 2018
+  * B
+
+patch 1ae0f2d1bd00c9d72ac21eef7a26736ed76c27c8
+Author: raichoo@googlemail.com
+Date:   Thu Jul  5 21:36:46 CEST 2018
+  * A
+$ darcs show repo
+         Format: hashed, darcs-2
+           Root: /tmp/darcs/Y
+   PristineType: HashedPristine
+          Cache: thisrepo:/tmp/darcs/Y, cache:/home/raichoo/.cache/darcs
+     PatchIndex: enabled, but not yet created
+ Default Remote: /tmp/darcs/X
+    Num Patches: 2
+      Weak Hash: 75778672be8edbf1fa1d8bf7cb45b9dbc0deb8ef
+```
+
+Even though these two example repositories have patch `A` and `B` applied in a
+different order, they do have the same **weak hash** meaning they are in the
+same state.
+
 Traveling without moving
 ------------------------