changeset 7113:f7fc5f5ecd62

mq: Allow qrefresh --silent to take parameters 'hg qrefresh --short file.txt' now adds changes made to file.txt to current patch. This builds on a patch for implementing --amend by Kirill Smelkov as discussed in issue933. FIXME: Why do mq refresh have two matchers if we only need one?
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 17 Oct 2008 21:26:39 +0200
parents c9b88695d894
children 30e49d54c537
files hgext/mq.py tests/test-mq-qrefresh tests/test-mq-qrefresh.out
diffstat 3 files changed, 72 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Sat Oct 18 03:53:54 2008 -0500
+++ b/hgext/mq.py	Fri Oct 17 21:26:39 2008 +0200
@@ -1073,7 +1073,9 @@
                 man = repo.manifest.read(changes[0])
                 aaa = aa[:]
                 if opts.get('short'):
-                    match = cmdutil.matchfiles(repo, mm + aa + dd)
+                    # if amending a patch, we always match already-in-patch files
+                    match = cmdutil.matchfiles(repo, mm + aa + dd + matchfn.files())
+                    matchfn = match # FIXME: Why have two matchers if we only need one?
                 else:
                     match = cmdutil.matchall(repo)
                 m, a, r, d = repo.status(match=match)[:4]
@@ -1750,6 +1752,9 @@
     the modifications that match those patterns; the remaining modifications
     will remain in the working directory.
 
+    If --short is specified, files currently included in the patch will 
+    be refreshed just like matched files and remain in the patch.
+
     hg add/remove/copy/rename work as usual, though you might want to use
     git-style patches (--git or [diff] git=1) to track copies and renames.
     """
@@ -2411,7 +2416,7 @@
         (refresh,
          [('e', 'edit', None, _('edit commit message')),
           ('g', 'git', None, _('use git extended diff format')),
-          ('s', 'short', None, _('refresh only files already in the patch')),
+          ('s', 'short', None, _('refresh only files already in the patch and specified files')),
           ('U', 'currentuser', None, _('add/update "From: <current user>" in patch')),
           ('u', 'user', '', _('add/update "From: <given user>" in patch')),
           ('D', 'currentdate', None, _('update "Date: <current date>" in patch (if present)')),
--- a/tests/test-mq-qrefresh	Sat Oct 18 03:53:54 2008 -0500
+++ b/tests/test-mq-qrefresh	Fri Oct 17 21:26:39 2008 +0200
@@ -82,6 +82,29 @@
 cat .hg/patches/mqbase | \
 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
     -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
+
+echo % qrefresh --short
+echo 'orphan' > orphanchild
+hg add orphanchild
+hg qrefresh nonexistingfilename
+hg qrefresh --short 1/base
+hg qrefresh --short 2/base
+
+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/"
+
+echo % diff shows orphan ...
+hg st
+hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
+              -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" \
+              -e "s/^\(diff\).*/\1/"
+
 cd ..
 
 
--- a/tests/test-mq-qrefresh.out	Sat Oct 18 03:53:54 2008 -0500
+++ b/tests/test-mq-qrefresh.out	Fri Oct 17 21:26:39 2008 +0200
@@ -159,6 +159,48 @@
 @@ -1,1 +1,1 @@
 -base
 +patched
+% qrefresh --short
+% qdiff
+diff -r b55ecdccb5cf 1/base
+--- a/1/base
++++ b/1/base
+@@ -1,1 +1,1 @@
+-base
++patched
+diff -r b55ecdccb5cf 2/base
+--- a/2/base
++++ b/2/base
+@@ -1,1 +1,1 @@
+-base
++patched
+diff -r b55ecdccb5cf orphanchild
+--- /dev/null
++++ b/orphanchild
+@@ -0,0 +1,1 @@
++orphan
+% patch file contents
+mqbase
+
+diff -r b55ecdccb5cf 1/base
+--- a/1/base
++++ b/1/base
+@@ -1,1 +1,1 @@
+-base
++patched
+diff -r b55ecdccb5cf 2/base
+--- a/2/base
++++ b/2/base
+@@ -1,1 +1,1 @@
+-base
++patched
+% diff shows orphan ...
+A orphanchild
+? base
+diff
+--- /dev/null
++++ b/orphanchild
+@@ -0,0 +1,1 @@
++orphan
 % create test repo
 adding a
 % capture changes