~jan0sch/darcs-book

Showing details for patch 98c0bda2017ce5bc233f72a8a5e1026646a3c4b8.
2018-07-03 (Tue), 7:10 PM - - 98c0bda2017ce5bc233f72a8a5e1026646a3c4b8

additional content for chapter 3

Summary of changes
1 files modified with 159 lines added and 3 lines removed
  • en/03-working-locally.md with 159 added and 3 removed lines
diff -rN -u old-darcs-book/en/03-working-locally.md new-darcs-book/en/03-working-locally.md
--- old-darcs-book/en/03-working-locally.md	2024-11-24 01:33:00.708315858 +0000
+++ new-darcs-book/en/03-working-locally.md	2024-11-24 01:33:00.708315858 +0000
@@ -141,8 +141,9 @@
 patch. The first one is that we simply want to add the `Main.hs` file the we
 created. The type of this change is `addfile`. The second change it asks us
 about adds the content to the file, this change type is what we call a `hunk`.
-This `hunk` just adds our single line program as line 1 to `Main.hs` (indicated by
-the `+` in front of the line).
+This `hunk` just adds our single line program as line 1 to `Main.hs` (indicated
+by the `+` in front of the line). We will look at different types of changes
+later in this chapter.
 
 `darcs log` will now show us our first recorded patch!
 
@@ -383,10 +384,165 @@
 No changes!
 ```
 
-
 The boring file is a plain text file so you can simply edit it with your
 favorite text editor.
 
+If you want `darcs` to use a different file as your **boring** file you can use
+`darcs setpref FILENAME` which will create a special kind of change called
+`changepref`.
+
+Different types of changes
+--------------------------
+
+We have seen a few different types of changes throughout this chapter, maybe
+it's time to look at them a little more, so this section summarizes all of the
+different types of changes that exist. As we have seen before, a patch is made
+up of changes so far we have met a couple of them.
+
+* `adddir`
+
+  `darcs` unlike some other version control systems is aware of directories and
+  has its own type of change to track them. This change is created by performing
+  `add` on a directory.
+
+  ```
+  $ mkdir directory
+  $ darcs add directory
+  Adding 'directory'
+  $ darcs whatsnew
+  adddir ./directory
+  ```
+
+* `addfile`
+
+  This change we have seen before, but for the sake of completeness let's have a
+  look at it again. To keep track of a file we can perform `add` on it and
+  `darcs` will create an `addfile` change. Adding a file will not `record` its
+  content, this is what `hunk` changes are for, it will merely inform `darcs` of
+  the file's existence.
+
+  ```
+  $ touch file
+  $ darcs add file
+  Adding 'file'
+  $ darcs whatsnew
+  addfile ./file
+  ```
+
+* `binary`
+
+  Binary files can be a bit of a hassle, especially when it comes to tracking
+  how they change throughout the lifetime of the project. `darcs` simply stores
+  them in their entirety by creating a `binary` change. If `darcs` does not
+  recognize a binary file as such you can inform it by adding its name to
+  `_darcs/prefs/binaries` which works exactly like the `boring` file we have
+  looked at in the previous section.
+
+  ```
+  $ ghc Main.hs
+  $ darcs add Main
+  Adding 'Main'
+  $ darcs whatsnew
+  binary ./Main
+  ```
+
+* `changepref`
+
+  This kind of change is somewhat advanced and allow you to `record` preference
+  changes of your repository and distribute them to others. To create such a
+  change one utilizes the `setpref` command. These changes should be handled
+  with extreme care since they also allow you to specify a shell command for the
+  `darcs test` command. You should never blindly execute commands from
+  strangers, so be a bit careful with these changes. We will talk about `test`
+  in a later chapter. For now it is sufficient to know that you can change your
+  `boring` file as well as your **binaries** file with it.
+
+  ```
+  $ touch myboring
+  $ darcs setpref boringfile myboring
+  $ darcs whatsnew
+  changepref boringfile
+
+  myboring
+  ```
+
+* `hunk`
+
+  When working with plain text files you will see this kind of change the most.
+  A `hunk` is used to track line-wise changes in a file. As we have seen in the
+  previous sections a `hunk` looks like this and is created by editing a tracked
+  file.
+
+  ```
+  $ darcs whatsnew
+  hunk ./Hello.hs 1
+  -main = putStrLn "Hello World!"
+  +main = putStrLn "Hello Everyone!"
+  ```
+
+  The `hunk` change states the file it is modifying as well as the line number
+  it affects, in this case that would be line 1 in the file `Hello.hs`. Line
+  removals are indicated by a `-` symbol in front of the line while line
+  additions are indicated by a `+` symbol.
+
+* `move`
+
+  `move` changes keep track of file and directory movements alike. Imagine you
+  have a file called `from` and want to rename it to `to`. This is how you
+  should go about doing that.
+
+  ```
+  $ darcs move from to
+  Moved: from to: to
+  $ darcs whatsnew
+  move ./from ./to
+  ```
+
+  Using this kind of change gives `darcs` more context then just removing the
+  file and adding it as a new one. For example, someone wrote a patch that
+  changes the contents of a file `A` and someone else moves file `A` to `B`
+  `darcs` can commute these changes. That means that for `darcs` is does not
+  matter if you first change the content of the file and then `move` it, or the
+  other way around.
+
+* `replace`
+
+  If we want to be a little bit more fine grained than a `hunk` when if comes to
+  text changes we can use `replace` changes. They play a lot better with other
+  changes than the line-wise of a `hunk`.
+
+  ```
+  $ darcs replace World Everyone Hello.hs
+  M ./Hello.hs r1
+  $ darcs whatsnew
+  replace ./Hello.hs [A-Za-z_0-9] World Everyone
+  ```
+
+  This type of change gives us a bit more freedom when collaborating with other
+  people. We are going to talk about the benefits of `replace` in chapter 6.
+
+* `rmdir`
+
+  This type is change unsurprisingly tracks the removal of a directory, it's
+  created by simply removing a directory.
+
+  ```
+  $ rmdir directory
+  $ darcs whatsnew
+  rmdir ./directory
+  ```
+
+* `rmfile`
+
+  Like `rmdir` the `rmfile` track a removal but in this case it's the removal of
+  a file.
+
+  ```
+  $ rm file
+  $ darcs whatsnew
+  rmfile ./file
+  ```
+
 Revisiting history
 ------------------