Skip to content

Instantly share code, notes, and snippets.

@sebfisch
Last active December 14, 2015 19:29

Revisions

  1. sebfisch revised this gist Mar 11, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions DarcsDialog.markdown
    Original file line number Diff line number Diff line change
    @@ -100,8 +100,8 @@ to `Utilities`. There is no split command but we can do it by hand.
    Fred: Now we have a clone containing only the first two patches and
    can remove the second because nothing depends on it?

    Lisa: Right. We will use `unrecord` so Darcs knows that the patch was
    once there. Then we record two patches, splitting your changes.
    Lisa: Right. We can use unrecord for that. Then we record two patches,
    splitting your changes.

    # echo yny | darcs unrecord
    # echo nnyy | darcs record -m "added database helper"
  2. sebfisch revised this gist Mar 11, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion DarcsDialog.markdown
    Original file line number Diff line number Diff line change
    @@ -204,4 +204,4 @@ Lisa: Right. That would complicate things again. Seems like there
    should be a merge command. Or can splitting and merging be implemented
    using [rebase for Darcs](http://darcs.net/Ideas/RebaseDesign)?

    Fred: Good question.
    Fred: Well, you said *you* know Darcs!
  3. sebfisch revised this gist Mar 11, 2013. 1 changed file with 83 additions and 27 deletions.
    110 changes: 83 additions & 27 deletions DarcsDialog.markdown
    Original file line number Diff line number Diff line change
    @@ -1,56 +1,56 @@
    # A Dialog on How to Manage Patches with Darcs

    Lisa: So, you know Darcs?
    Fred: So, you know Darcs?

    Fred: Sure.
    Lisa: Sure.

    Lisa: I heard it is quite flexible in managing patches. Wanna show me?
    Fred: I heard it is quite flexible in managing patches. Wanna show me?

    Fred: Ok, let's make a new repository for some imaginary project.
    Lisa: Ok, let's make a new repository for some imaginary project.

    # mkdir project; cd project; darcs init

    Lisa: Ok, now add these files. A `Main` module using some helper
    Fred: Ok, now add these files. A `Main` module using some helper
    function from a `Utilities` module.

    # echo define helperFunction > Utilities
    # echo import Utilities > Main
    # echo use helperFunction >> Main

    Fred: Let's make a patch including all these changes.
    Lisa: Let's make a patch including all these changes.

    # darcs -lam "added initial Main and Utilities"

    Lisa: I want to add database access. I make a new module and use it in
    Fred: I want to add database access. I make a new module and use it in
    Main.

    # echo define access > Database
    # echo use Database.access >> Main

    Lisa: I also add a helper to `Utilities` and use it in `Database`.
    Fred: I also add a helper to `Utilities` and use it in `Database`.

    # echo define dbHelper >> Utilities
    # echo use dbHelper >> Database

    Fred: Here is a patch for that.
    Lisa: Here is a patch for that.

    # darcs record -lam "added database access with helper"

    Fred: I add a GUI and use your database helper for that.
    Lisa: I add a GUI and use your database helper for that.

    # echo import Utilities > GUI
    # echo use dbHelper >> GUI

    Fred: I also add another helper function and use it.
    Lisa: I also add another helper function and use it.

    # echo define guiHelper >> Utilities
    # echo use guiHelper >> GUI

    Lisa: By now, I know how to make a patch.
    Fred: By now, I know how to make a patch.

    # darcs record -lam "added GUI with helper and using DB helper"

    Fred: Let's see what we have until now.
    Lisa: Let's see what we have until now.

    # yes | darcs changes --reverse

    @@ -82,44 +82,44 @@ Fred: Let's see what we have until now.
    hunk ./Utilities 3
    +define guiHelper

    Lisa: Ok, I see which files were added by which patch and hunks seem
    Fred: Ok, I see which files were added by which patch and hunks seem
    to be changes to the contents of files.

    Fred: Right. Now I want to remove database access but keep the GUI.
    Lisa: Right. Now I want to remove database access but keep the GUI.

    Lisa: You can't remove the database patch because the GUI patch
    Fred: You can't remove the database patch because the GUI patch
    depends on it adding the `dbHelper`.

    Fred: It would be nice, if Darcs would let me split your patch, so I
    Lisa: It would be nice, if Darcs would let me split your patch, so I
    can remove your changes to `Database` and `Main` but keep your changes
    to `Utilities`. There is no split command but we can do it by hand.

    # cd ..; mkdir clone; cd clone; darcs init
    # echo yyny | darcs pull ../project

    Lisa: Now we have a clone containing only the first two patches and
    Fred: Now we have a clone containing only the first two patches and
    can remove the second because nothing depends on it?

    Fred: Right. We will use `unrecord` so Darcs knows that the patch was
    Lisa: Right. We will use `unrecord` so Darcs knows that the patch was
    once there. Then we record two patches, splitting your changes.

    # echo yny | darcs unrecord
    # echo nnyy | darcs record -m "added database helper"
    # yes | darcs record -m "added database access"

    Fred: Now we can pull the remaining changes. This will also include
    Lisa: Now we can pull the remaining changes. This will also include
    the original big patch adding database access and the helper function.

    # yes | darcs pull project

    Lisa: So now we are back where we started?
    Fred: So now we are back where we started?

    Fred: But we can now obliterate the big database patch as well as the
    Lisa: But we can now obliterate the big database patch as well as the
    small one that I don't need for the GUI.

    # echo nyyy | darcs obliterate

    Lisa: Let's see what we have now.
    Fred: Let's see what we have now.

    # yes | darcs changes --reverse

    @@ -145,7 +145,63 @@ Lisa: Let's see what we have now.
    hunk ./Utilities 3
    +define guiHelper

    Lisa: Ok, but that sure was complicated. And the Darcs Manual
    explicitly advises against unrecording changes that you want to
    re-record or that others have in their repositories. Isn't there a
    better way? What about rollback?
    Fred: Ok, but that sure was complicated. There should be a split
    command that does what you just did by hand. Can we now pull back the
    changes from the clone into our project?

    # cd ../project; darcs pull ../clone

    darcs: bug at src/Darcs/Patch/Depends.hs:322
    Failed to commute common patches:
    * added GUI with helper and using DB helper
    * added database access with helper

    Lisa: Oops! Let's just work in the clone.

    Fred: I know how to drastically simplify your GUI implementation. I
    don't need the `guiHelper` and just delete it from `GUI` and
    `Utilities`.

    # sed -i "$ d" Utilities
    # sed -i "$ d" GUI

    Fred: Let's record that.

    # darcs record -am "simplified GUI"

    Lisa: There are now two patches for adding the GUI.

    # yes | darcs changes --reverse --last=2

    [added GUI with helper and using DB helper]
    addfile ./GUI
    hunk ./GUI 1
    +import Utilities
    +use dbHelper
    +use guiHelper
    hunk ./Utilities 3
    +define guiHelper

    [simplified GUI]
    hunk ./GUI 3
    -use guiHelper
    hunk ./Utilities 3
    -define guiHelper

    Fred: Hmm, I wish I could merge them into a single patch that just
    adds the `GUI` file without using `guiHelper`.

    Lisa: Then you should have used amend-record instead of recording a
    new patch. Now you can still unrecord and then amend the changes.

    # echo yny | darcs unrecord
    # yes | darcs amend-record

    Fred: But unrecording would not work if there were already other
    patches depending on the simplified GUI.

    Lisa: Right. That would complicate things again. Seems like there
    should be a merge command. Or can splitting and merging be implemented
    using [rebase for Darcs](http://darcs.net/Ideas/RebaseDesign)?

    Fred: Good question.
  4. sebfisch revised this gist Mar 11, 2013. 1 changed file with 77 additions and 17 deletions.
    94 changes: 77 additions & 17 deletions DarcsDialog.markdown
    Original file line number Diff line number Diff line change
    @@ -1,56 +1,56 @@
    # A Dialog on How to Manage Patches with Darcs

    Fred: So, you know Darcs?
    Lisa: So, you know Darcs?

    Lisa: Sure.
    Fred: Sure.

    Fred: I heard it is quite flexible in managing patches. Wanna show me?
    Lisa: I heard it is quite flexible in managing patches. Wanna show me?

    Lisa: Ok, let's make a new repository for some imaginary project.
    Fred: Ok, let's make a new repository for some imaginary project.

    # mkdir project; cd project; darcs init

    Fred: Ok, now add these files. A `Main` module using some helper
    Lisa: Ok, now add these files. A `Main` module using some helper
    function from a `Utilities` module.

    # echo define helperFunction > Utilities
    # echo import Utilities > Main
    # echo use helperFunction >> Main

    Lisa: Let's make a patch including all these changes.
    Fred: Let's make a patch including all these changes.

    # darcs -lam "added initial Main and Utilities"

    Fred: I want to add database access. I make a new module and use it in
    Lisa: I want to add database access. I make a new module and use it in
    Main.

    # echo define access > Database
    # echo use Database.access >> Main

    Fred: I also add a helper to `Utilities` and use it in `Database`.
    Lisa: I also add a helper to `Utilities` and use it in `Database`.

    # echo define dbHelper >> Utilities
    # echo use dbHelper >> Database

    Lisa: Here is a patch for that.
    Fred: Here is a patch for that.

    # darcs record -lam "added database access with helper"

    Lisa: I add a GUI and use your database helper for that.
    Fred: I add a GUI and use your database helper for that.

    # echo import Utilities > GUI
    # echo use dbHelper >> GUI

    Lisa: I also add another helper function and use it.
    Fred: I also add another helper function and use it.

    # echo define guiHelper >> Utilities
    # echo use guiHelper >> GUI

    Fred: By now, I know how to make a patch.
    Lisa: By now, I know how to make a patch.

    # darcs record -lam "added GUI with helper and using DB helper"

    Lisa: Let's see what we have until now.
    Fred: Let's see what we have until now.

    # yes | darcs changes --reverse

    @@ -82,10 +82,70 @@ Lisa: Let's see what we have until now.
    hunk ./Utilities 3
    +define guiHelper

    Fred: Ok, I see which files were added by which patch and hunks seem
    Lisa: Ok, I see which files were added by which patch and hunks seem
    to be changes to the contents of files.

    Lisa: Right. Now I want to remove database access but keep the GUI.
    Fred: Right. Now I want to remove database access but keep the GUI.

    Fred: You can't remove the database patch because the GUI patch
    depends on it adding the `dbHelper`.
    Lisa: You can't remove the database patch because the GUI patch
    depends on it adding the `dbHelper`.

    Fred: It would be nice, if Darcs would let me split your patch, so I
    can remove your changes to `Database` and `Main` but keep your changes
    to `Utilities`. There is no split command but we can do it by hand.

    # cd ..; mkdir clone; cd clone; darcs init
    # echo yyny | darcs pull ../project

    Lisa: Now we have a clone containing only the first two patches and
    can remove the second because nothing depends on it?

    Fred: Right. We will use `unrecord` so Darcs knows that the patch was
    once there. Then we record two patches, splitting your changes.

    # echo yny | darcs unrecord
    # echo nnyy | darcs record -m "added database helper"
    # yes | darcs record -m "added database access"

    Fred: Now we can pull the remaining changes. This will also include
    the original big patch adding database access and the helper function.

    # yes | darcs pull project

    Lisa: So now we are back where we started?

    Fred: But we can now obliterate the big database patch as well as the
    small one that I don't need for the GUI.

    # echo nyyy | darcs obliterate

    Lisa: Let's see what we have now.

    # yes | darcs changes --reverse

    [added initial Main and Utilities]
    addfile ./Main
    hunk ./Main 1
    +import Utilities
    +use helperFuntion
    addfile ./Utilities
    hunk ./Utilities 1
    +define helperFunction

    [added database helper]
    hunk ./Utilities 2
    +define dbHelper

    [added GUI with helper and using DB helper]
    addfile ./GUI
    hunk ./GUI 1
    +import Utilities
    +use dbHelper
    +use guiHelper
    hunk ./Utilities 3
    +define guiHelper

    Lisa: Ok, but that sure was complicated. And the Darcs Manual
    explicitly advises against unrecording changes that you want to
    re-record or that others have in their repositories. Isn't there a
    better way? What about rollback?
  5. sebfisch revised this gist Mar 11, 2013. 1 changed file with 40 additions and 0 deletions.
    40 changes: 40 additions & 0 deletions DarcsDialog.markdown
    Original file line number Diff line number Diff line change
    @@ -49,3 +49,43 @@ Lisa: I also add another helper function and use it.
    Fred: By now, I know how to make a patch.

    # darcs record -lam "added GUI with helper and using DB helper"

    Lisa: Let's see what we have until now.

    # yes | darcs changes --reverse

    [added initial Main and Utilities]
    addfile ./Main
    hunk ./Main 1
    +import Utilities
    +use helperFuntion
    addfile ./Utilities
    hunk ./Utilities 1
    +define helperFunction

    [added database access with helper]
    addfile ./Database
    hunk ./Database 1
    +define access
    +use dbHelper
    hunk ./Main 3
    +use Database.access
    hunk ./Utilities 2
    +define dbHelper

    [added GUI with helper and using DB helper]
    addfile ./GUI
    hunk ./GUI 1
    +import Utilities
    +use dbHelper
    +use guiHelper
    hunk ./Utilities 3
    +define guiHelper

    Fred: Ok, I see which files were added by which patch and hunks seem
    to be changes to the contents of files.

    Lisa: Right. Now I want to remove database access but keep the GUI.

    Fred: You can't remove the database patch because the GUI patch
    depends on it adding the `dbHelper`.
  6. sebfisch revised this gist Mar 11, 2013. 1 changed file with 35 additions and 6 deletions.
    41 changes: 35 additions & 6 deletions DarcsDialog.markdown
    Original file line number Diff line number Diff line change
    @@ -8,15 +8,44 @@ Fred: I heard it is quite flexible in managing patches. Wanna show me?

    Lisa: Ok, let's make a new repository for some imaginary project.

    sh# mkdir project; cd project; darcs init
    # mkdir project; cd project; darcs init

    Fred: Ok, now add these files. A `Main` module using some helper
    function from a `Utilities` module.

    sh# echo define helperFunction > Utilities
    sh# echo import Utilities > Main
    sh# echo use helperFunction >> Main
    # echo define helperFunction > Utilities
    # echo import Utilities > Main
    # echo use helperFunction >> Main

    Lisa: Now let's make a patch including all these changes.
    Lisa: Let's make a patch including all these changes.

    sh# darcs -lam "added initial Main and Utilities"
    # darcs -lam "added initial Main and Utilities"

    Fred: I want to add database access. I make a new module and use it in
    Main.

    # echo define access > Database
    # echo use Database.access >> Main

    Fred: I also add a helper to `Utilities` and use it in `Database`.

    # echo define dbHelper >> Utilities
    # echo use dbHelper >> Database

    Lisa: Here is a patch for that.

    # darcs record -lam "added database access with helper"

    Lisa: I add a GUI and use your database helper for that.

    # echo import Utilities > GUI
    # echo use dbHelper >> GUI

    Lisa: I also add another helper function and use it.

    # echo define guiHelper >> Utilities
    # echo use guiHelper >> GUI

    Fred: By now, I know how to make a patch.

    # darcs record -lam "added GUI with helper and using DB helper"
  7. sebfisch revised this gist Mar 11, 2013. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions DarcsDialog.markdown
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,13 @@ Lisa: Ok, let's make a new repository for some imaginary project.

    sh# mkdir project; cd project; darcs init

    Fred: Ok, now add these files. A `Main` module using some helper
    function from a `Utilities` module.

    sh# echo define helperFunction > Utilities
    sh# echo import Utilities > Main
    sh# echo use helperFunction >> Main

    Lisa: Now let's make a patch including all these changes.

    sh# darcs -lam "added initial Main and Utilities"
  8. sebfisch revised this gist Mar 11, 2013. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion DarcsDialog.markdown
    Original file line number Diff line number Diff line change
    @@ -1 +1,13 @@
    # A Dialog on How to Manage Patches with Darcs
    # A Dialog on How to Manage Patches with Darcs

    Fred: So, you know Darcs?

    Lisa: Sure.

    Fred: I heard it is quite flexible in managing patches. Wanna show me?

    Lisa: Ok, let's make a new repository for some imaginary project.

    sh# mkdir project; cd project; darcs init


  9. Sebastian Fischer created this gist Mar 11, 2013.
    1 change: 1 addition & 0 deletions DarcsDialog.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    # A Dialog on How to Manage Patches with Darcs