Advertisement
Guest User

Recipe for stashing in darcs

a guest
Oct 31st, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.29 KB | None | 0 0
  1.  #!/bin/bash
  2.  
  3. STASH_NAME="stash-$(date +'%d-%m-%y-%H-%M-%S')"
  4. STASH_PATCH=$STASH_NAME.dpatch
  5.  
  6. mkdir repo
  7. cd repo
  8. darcs init
  9.  
  10. echo testing > file
  11. darcs add file
  12. darcs record -a -m 'Add file'
  13.  
  14. echo -e "with\nsome\nlines" >> file
  15.  
  16. darcs wh # unique prefixes are allowed in darcs - wh(atsnew)
  17.  
  18. # Let's stash!
  19. darcs rec -am $STASH_NAME
  20.  
  21. # In recent darcs (>2.5 I think), you can say this:
  22. darcs obliterate --last 1 -a -o $STASH_PATCH
  23. # -o creates a dpatch in current dir with given name, and -a says accept "all"
  24. # chosen patches
  25.  
  26. # To get back to our old state:
  27. darcs apply $STASH_PATCH
  28. darcs unrecord --last 1 -a
  29. rm $STASH_PATCH
  30.  
  31. ########### NEWER DARCS (> 2.5) GO NO FURTHER! ###########
  32. # For older darcs without -o option to obliterate:
  33.  
  34. # First, get back to our full recorded state of two patches
  35. darcs rec -am $STASH_NAME
  36.  
  37. # Need to do some juggling to generate the dpatch file, by setting up a target
  38. # repo to "darcs send" to.
  39. cd ..
  40. mkdir send-target
  41. cd send-target
  42. darcs init
  43. darcs pull ../repo -p 'Add file' -a
  44. cd ../repo
  45.  
  46. # Now, we can "send" our patch to the new repo, and output into a file.
  47. darcs send -a -o $STASH_PATCH --no-edit ../send-target
  48. darcs ob --last 1 -a
  49.  
  50. # Again, to get back where we were
  51. darcs apply $STASH_PATCH
  52. darcs unrecord --last 1 -a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement