tests/test-mq-qnew.t
changeset 21234 b9a16ed5acec
parent 20859 e259d4c462b5
child 21266 19d6fec60b81
equal deleted inserted replaced
21233:213fd1a99cd9 21234:b9a16ed5acec
   245   >     class commitfailure(repo.__class__):
   245   >     class commitfailure(repo.__class__):
   246   >         def commit(self, *args, **kwargs):
   246   >         def commit(self, *args, **kwargs):
   247   >             raise util.Abort('emulating unexpected abort')
   247   >             raise util.Abort('emulating unexpected abort')
   248   >     repo.__class__ = commitfailure
   248   >     repo.__class__ = commitfailure
   249   > EOF
   249   > EOF
   250   $ cat > .hg/hgrc <<EOF
   250   $ cat >> .hg/hgrc <<EOF
   251   > [extensions]
   251   > [extensions]
       
   252   > # this failure occurs before editor invocation
   252   > commitfailure = $TESTTMP/commitfailure.py
   253   > commitfailure = $TESTTMP/commitfailure.py
   253   > EOF
   254   > EOF
   254 
   255 
   255   $ cat > $TESTTMP/editor.sh << EOF
   256   $ cat > $TESTTMP/editor.sh << EOF
   256   > echo "==== before editing"
   257   > echo "==== before editing"
   257   > cat \$1
   258   > cat \$1
   258   > echo "===="
   259   > echo "===="
   259   > echo "test saving last-message.txt" >> \$1
   260   > echo "test saving last-message.txt" >> \$1
   260   > EOF
   261   > EOF
   261 
   262 
       
   263 (test that editor is not invoked before transaction starting)
       
   264 
       
   265   $ rm -f .hg/last-message.txt
       
   266   $ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e patch
       
   267   abort: emulating unexpected abort
       
   268   [255]
       
   269   $ cat .hg/last-message.txt
       
   270   cat: .hg/last-message.txt: No such file or directory
       
   271   [1]
       
   272 
       
   273 (test that editor is invoked and commit message is saved into
       
   274 "last-message.txt")
       
   275 
       
   276   $ cat >> .hg/hgrc <<EOF
       
   277   > [extensions]
       
   278   > commitfailure = !
       
   279   > [hooks]
       
   280   > # this failure occurs after editor invocation
       
   281   > pretxncommit.unexpectedabort = false
       
   282   > EOF
       
   283 
   262   $ rm -f .hg/last-message.txt
   284   $ rm -f .hg/last-message.txt
   263   $ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e patch
   285   $ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e patch
   264   ==== before editing
   286   ==== before editing
       
   287   
   265   ====
   288   ====
   266   abort: emulating unexpected abort
   289   transaction abort!
       
   290   rollback completed
       
   291   note: commit message saved in .hg/last-message.txt
       
   292   abort: pretxncommit.unexpectedabort hook exited with status 1
   267   [255]
   293   [255]
   268   $ cat .hg/last-message.txt
   294   $ cat .hg/last-message.txt
       
   295   
   269   test saving last-message.txt
   296   test saving last-message.txt
   270 
   297 
       
   298   $ cat >> .hg/hgrc <<EOF
       
   299   > [hooks]
       
   300   > pretxncommit.unexpectedabort =
       
   301   > EOF
       
   302 
       
   303 Test handling default message with the patch filename with tail whitespaces
       
   304 
       
   305   $ cat > $TESTTMP/editor.sh << EOF
       
   306   > echo "==== before editing"
       
   307   > cat \$1
       
   308   > echo "===="
       
   309   > echo "[mq]: patch        " > \$1
       
   310   > EOF
       
   311 
       
   312   $ rm -f .hg/last-message.txt
       
   313   $ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e "patch "
       
   314   ==== before editing
       
   315   
       
   316   ====
       
   317   $ cat ".hg/patches/patch "
       
   318   # HG changeset patch
       
   319   # Parent 0000000000000000000000000000000000000000
       
   320 
   271   $ cd ..
   321   $ cd ..