[PATCH] qrefresh += --amend (#933)

Alexis S. L. Carvalho alexis at cecm.usp.br
Fri Jan 18 16:38:45 CST 2008


Thus spake Kirill Smelkov:
> # HG changeset patch
> # User Kirill Smelkov <kirr at mns.spb.ru>
> # Date 1200685207 -10800
> # Node ID 48fa1430786a31d4e31d80832c4d9215268e25e4
> # Parent  fb93c774dffff3601835102fdb57417428307cba
> qrefresh += --amend  (#933)
> 
> It would be handy to say 'hg qrefresh file.txt' to add changes made to file.txt
> to current patch.
> 
> Unfortunately this is not qrefresh behaviour -- it just excludes everything but
> file.txt from refreshed patch. We discussed this on irc, and it seems people
> are against changing this behaviour becuase of backward compatibility.
> 
> So here it comes 'hg qrefresh --amend ...' for folks like me who wants just to
> incrementally refresh their patches.

On IRC I understood something different from what your patch does (and I
still do when I read this description...).
 
I thought you wanted something like "keep the patch exactly as is (even
if some file touched by the patch was modified again in the working dir)
and add the changes to file.txt".
 
But your patch does something like "the patch is updated, but contains 
only the files that were already in the patch and file.txt".

This is very close to what "qrefresh --short" does.  And since it 
ignores any files passed on the command line, how about just extending 
it instead of adding a new option?

> diff --git a/tests/test-mq-qrefresh b/tests/test-mq-qrefresh
> --- a/tests/test-mq-qrefresh
> +++ b/tests/test-mq-qrefresh
> @@ -82,3 +82,17 @@
>  cat .hg/patches/mqbase | \
>  sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
>      -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
> +
> +echo % qrefresh --amend
> +hg qrefresh 1/base
> +hg qrefresh --amend 2/base

You'll want to change some other file before the qrefreshes, to test 
that it won't be included in the patch.

> +
> +echo % qdiff
> +hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
> +               -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
> +
> +echo % patch file contents
> +cat .hg/patches/mqbase | \
> +sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
> +    -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"

And you'll want a "hg diff" somewhere to make sure this other file 
wasn't committed.

Alexis


More information about the Mercurial-devel mailing list