comparison tests/test-mq-qrefresh @ 10397:8cb81d75730c

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.
author Steve Losh <steve@stevelosh.com>
date Sun, 07 Feb 2010 10:47:54 -0500
parents f05e0d54f424
children
comparison
equal deleted inserted replaced
10396:65a90c8e11ee 10397:8cb81d75730c
1 #!/bin/sh 1 #!/bin/sh
2 2
3 echo "[extensions]" >> $HGRCPATH 3 echo "[extensions]" >> $HGRCPATH
4 echo "mq=" >> $HGRCPATH 4 echo "mq=" >> $HGRCPATH
5
6 catpatch() {
7 cat $1 | sed -e "s/^\(# Parent \).*/\1/"
8 }
5 9
6 echo % init 10 echo % init
7 hg init a 11 hg init a
8 cd a 12 cd a
9 13
28 echo % qdiff dirname 32 echo % qdiff dirname
29 hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ 33 hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
30 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" 34 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
31 35
32 echo % patch file contents 36 echo % patch file contents
33 cat .hg/patches/mqbase | \ 37 catpatch .hg/patches/mqbase | \
34 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ 38 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
35 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" 39 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
36 40
37 echo % qrefresh 1 41 echo % qrefresh 1
38 echo 'patched again' > base 42 echo 'patched again' > base
45 echo % qdiff dirname 49 echo % qdiff dirname
46 hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ 50 hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
47 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" 51 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
48 52
49 echo % patch file contents 53 echo % patch file contents
50 cat .hg/patches/mqbase | \ 54 catpatch .hg/patches/mqbase | \
51 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ 55 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
52 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" 56 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
53 57
54 echo % qrefresh . in subdir 58 echo % qrefresh . in subdir
55 ( cd 1 ; hg qrefresh . ) 59 ( cd 1 ; hg qrefresh . )
61 echo % qdiff dirname 65 echo % qdiff dirname
62 hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ 66 hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
63 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" 67 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
64 68
65 echo % patch file contents 69 echo % patch file contents
66 cat .hg/patches/mqbase | \ 70 catpatch .hg/patches/mqbase | \
67 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ 71 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
68 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" 72 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
69 73
70 echo % qrefresh in hg-root again 74 echo % qrefresh in hg-root again
71 hg qrefresh 75 hg qrefresh
77 echo % qdiff dirname 81 echo % qdiff dirname
78 hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ 82 hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
79 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" 83 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
80 84
81 echo % patch file contents 85 echo % patch file contents
82 cat .hg/patches/mqbase | \ 86 catpatch .hg/patches/mqbase | \
83 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ 87 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
84 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" 88 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
85 89
86 echo 90 echo
87 echo % qrefresh --short tests: 91 echo % qrefresh --short tests:
96 echo % -- qdiff output 100 echo % -- qdiff output
97 hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ 101 hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
98 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" 102 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
99 103
100 echo % -- patch file content 104 echo % -- patch file content
101 cat .hg/patches/mqbase | \ 105 catpatch .hg/patches/mqbase | \
102 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ 106 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
103 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" 107 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
104 hg st 108 hg st
105 109
106 echo % -- diff shows what is not in patch 110 echo % -- diff shows what is not in patch
174 echo '% status after refresh' 178 echo '% status after refresh'
175 hg st 179 hg st
176 echo '% b after refresh' 180 echo '% b after refresh'
177 cat b 181 cat b
178 echo '% patch file after refresh' 182 echo '% patch file after refresh'
179 cat .hg/patches/patch 183 catpatch .hg/patches/patch
180 cd .. 184 cd ..
181 185
182 186
183 echo % issue1441 with git patches 187 echo % issue1441 with git patches
184 hg init repo-1441-git 188 hg init repo-1441-git