sapling/tests/test-mq-qfold
Steve Losh eea597d740 mq: add parent node IDs to MQ patches on qrefresh/qnew
The goal of this patch is to add the IDs of the parents of applied MQ patches
into the patch file headers whenever qnew or qrefresh are run.

This will serve as a reminder of when the patches last applied cleanly and
will let us do more intelligent things in the future, such as:

    * Resolve conflicts found when qpushing to a new location by merging
      instead of simply showing rejects.

    * Display better diffs of versioned MQ patches because we can tell how the
      patched files have changed in the meantime.

Here are the new rules this patch introduces.  They are checked in this order:

    * If a patch currently has old, plain-style patch headers ("From:" and
      "Date:") do not change the style or add any new headers.

    * If the 'mq.plain' configuration setting is true, only plain-style
      headers will be used for all MQ patches.

    * qnew will initialize new patches with HG-style headers and fill in the
      "# Parent" header with the appropriate parent node.

    * qrefresh will refresh the "# Parent" header with the current parent of
      the current patch.
2010-02-07 10:47:54 -05:00

67 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
echo "[extensions]" >> $HGRCPATH
echo "mq=" >> $HGRCPATH
echo "[mq]" >> $HGRCPATH
echo "git=keep" >> $HGRCPATH
filterdiff()
{
grep -v diff | \
sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
}
filterpatch()
{
sed -e "s/\(# Parent \).*/\1/"
}
echo '% init'
hg init repo
cd repo
echo a > a
hg ci -Am adda
echo a >> a
hg qnew -f p1
echo b >> a
hg qnew -f p2
echo c >> a
hg qnew -f p3
echo '% fold in the middle of the queue'
hg qpop p1
hg qdiff | filterdiff
hg qfold p2
grep git .hg/patches/p1 && echo 'git patch found!'
hg qser
hg qdiff | filterdiff
echo '% fold with local changes'
echo d >> a
hg qfold p3
hg diff -c . | filterdiff
hg revert -a --no-backup
echo '% fold git patch into a regular patch, expect git patch'
echo a >> a
hg qnew -f regular
hg cp a aa
hg qnew --git -f git
hg qpop
hg qfold git
cat .hg/patches/regular | filterpatch
hg qpop
hg qdel regular
echo '% fold regular patch into a git patch, expect git patch'
hg cp a aa
hg qnew --git -f git
echo b >> aa
hg qnew -f regular
hg qpop
hg qfold regular
cat .hg/patches/git | filterpatch
cd ..