#!/bin/bash STASH_NAME="stash-$(date +'%d-%m-%y-%H-%M-%S')" STASH_PATCH=$STASH_NAME.dpatch mkdir repo cd repo darcs init echo testing > file darcs add file darcs record -a -m 'Add file' echo -e "with\nsome\nlines" >> file darcs wh # unique prefixes are allowed in darcs - wh(atsnew) # Let's stash! darcs rec -am $STASH_NAME # In recent darcs (>2.5 I think), you can say this: darcs obliterate --last 1 -a -o $STASH_PATCH # -o creates a dpatch in current dir with given name, and -a says accept "all" # chosen patches # To get back to our old state: darcs apply $STASH_PATCH darcs unrecord --last 1 -a rm $STASH_PATCH ########### NEWER DARCS (> 2.5) GO NO FURTHER! ########### # For older darcs without -o option to obliterate: # First, get back to our full recorded state of two patches darcs rec -am $STASH_NAME # Need to do some juggling to generate the dpatch file, by setting up a target # repo to "darcs send" to. cd .. mkdir send-target cd send-target darcs init darcs pull ../repo -p 'Add file' -a cd ../repo # Now, we can "send" our patch to the new repo, and output into a file. darcs send -a -o $STASH_PATCH --no-edit ../send-target darcs ob --last 1 -a # Again, to get back where we were darcs apply $STASH_PATCH darcs unrecord --last 1 -a