[PATCH] mq: Allow qrefresh --silent to take parameters

Mads Kiilerich mads at kiilerich.com
Fri Oct 17 14:27:23 CDT 2008


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1224271599 -7200
# Node ID 7af6928686760f3889bc18e2ef0439e1aac3c387
# Parent  4674706b5b95b2a0446538195c62297c990cd65a
mq: Allow qrefresh --silent to take parameters

'hg qrefresh --silent 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?

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -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)')),
diff --git a/tests/test-mq-qrefresh b/tests/test-mq-qrefresh
--- a/tests/test-mq-qrefresh
+++ b/tests/test-mq-qrefresh
@@ -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 ..
 
 
diff --git a/tests/test-mq-qrefresh.out b/tests/test-mq-qrefresh.out
--- a/tests/test-mq-qrefresh.out
+++ b/tests/test-mq-qrefresh.out
@@ -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


More information about the Mercurial-devel mailing list