diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1073,7 +1073,9 @@ class queue: 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 @@ def refresh(ui, repo, *pats, **opts): 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 @@ cmdtable = { (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: " in patch')), ('u', 'user', '', _('add/update "From: " in patch')), ('D', 'currentdate', None, _('update "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 @@ echo % patch file contents 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 @@ diff -r b55ecdccb5cf 2/base @@ -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