@@ -201,7 +201,8 @@ def setupwrapcolorwrite(ui):
setattr(ui, 'write', wrap)
return oldwrite
-def filterchunks(ui, originalhunks, usecurses, testfile, operation=None):
+def filterchunks(ui, originalhunks, usecurses, testfile, match,
+ operation=None):
try:
if usecurses:
if testfile:
@@ -216,9 +217,9 @@ def filterchunks(ui, originalhunks, usec
ui.warn('%s\n' % e.message)
ui.warn(_('falling back to text mode\n'))
- return patch.filterpatch(ui, originalhunks, operation)
-
-def recordfilter(ui, originalhunks, operation=None):
+ return patch.filterpatch(ui, originalhunks, match, operation)
+
+def recordfilter(ui, originalhunks, match, operation=None):
""" Prompts the user to filter the originalhunks and return a list of
selected hunks.
*operation* is used for to build ui messages to indicate the user what
@@ -230,7 +231,7 @@ def recordfilter(ui, originalhunks, oper
oldwrite = setupwrapcolorwrite(ui)
try:
newchunks, newopts = filterchunks(ui, originalhunks, usecurses,
- testfile, operation)
+ testfile, match, operation)
finally:
ui.write = oldwrite
return newchunks, newopts
@@ -312,10 +313,11 @@ def dorecord(ui, repo, commitfunc, cmdsu
diffopts.showfunc = True
originaldiff = patch.diff(repo, changes=status, opts=diffopts)
originalchunks = patch.parsepatch(originaldiff)
+ match = scmutil.match(repo[None], pats)
# 1. filter patch, since we are intending to apply subset of it
try:
- chunks, newopts = filterfn(ui, originalchunks)
+ chunks, newopts = filterfn(ui, originalchunks, match)
except error.PatchError as err:
raise error.Abort(_('error parsing patch: %s') % err)
opts.update(newopts)
@@ -3082,8 +3084,9 @@ def revert(ui, repo, ctx, parents, *pats
prefetch(repo, [ctx.rev()],
matchfiles(repo,
[f for sublist in oplist for f in sublist]))
+ match = scmutil.match(repo[None], pats)
_performrevert(repo, parents, ctx, names, uipathfn, actions,
- interactive, tobackup)
+ match, interactive, tobackup)
if targetsubs:
# Revert the subrepos on the revert list
@@ -3096,7 +3099,7 @@ def revert(ui, repo, ctx, parents, *pats
% (sub, short(ctx.node())))
def _performrevert(repo, parents, ctx, names, uipathfn, actions,
- interactive=False, tobackup=None):
+ match, interactive=False, tobackup=None):
"""function that actually perform all the actions computed for revert
This is an independent function to let extension to plug in and react to
@@ -3192,7 +3195,7 @@ def _performrevert(repo, parents, ctx, n
try:
- chunks, opts = recordfilter(repo.ui, originalchunks,
+ chunks, opts = recordfilter(repo.ui, originalchunks, match,
operation=operation)
if operation == 'discard':
chunks = patch.reversehunks(chunks)
@@ -1065,7 +1065,7 @@ def getmessages():
}
}
-def filterpatch(ui, headers, operation=None):
+def filterpatch(ui, headers, match, operation=None):
"""Interactively filter patch chunks into applied-only chunks"""
messages = getmessages()
@@ -1182,9 +1182,13 @@ the hunk is left unchanged.
seen.add(hdr)
if skipall is None:
h.pretty(ui)
+ files = h.files()
msg = (_('examine changes to %s?') %
- _(' and ').join("'%s'" % f for f in h.files()))
- r, skipfile, skipall, np = prompt(skipfile, skipall, msg, None)
+ _(' and ').join("'%s'" % f for f in files))
+ if all(match.exact(f) for f in files):
+ r, skipall, np = True, None, None
+ else:
+ r, skipfile, skipall, np = prompt(skipfile, skipall, msg, None)
if not r:
continue
applied[h.filename()] = [h]
@@ -26,10 +26,8 @@ Select no files
> EOF
diff --git a/empty-rw b/empty-rw
new file mode 100644
- examine changes to 'empty-rw'? [Ynesfdaq?] n
-
- no changes to record
- [1]
+ abort: empty commit message
+ [255]
$ hg tip -p
changeset: -1:000000000000
@@ -47,8 +45,6 @@ Select files but no hunks
> EOF
diff --git a/empty-rw b/empty-rw
new file mode 100644
- examine changes to 'empty-rw'? [Ynesfdaq?] y
-
abort: empty commit message
[255]
@@ -72,12 +68,9 @@ Record empty file
$ hg commit -i -d '0 0' -m empty empty-rw<<EOF
> y
- > y
> EOF
diff --git a/empty-rw b/empty-rw
new file mode 100644
- examine changes to 'empty-rw'? [Ynesfdaq?] y
-
$ hg tip -p
changeset: 0:c0708cf4e46e
@@ -249,8 +242,6 @@ Add plain file
> EOF
diff --git a/plain b/plain
new file mode 100644
- examine changes to 'plain'? [Ynesfdaq?] y
-
@@ -0,0 +1,10 @@
+1
+2
@@ -306,8 +297,6 @@ Modify end of plain file, also test that
> EOF
diff --git a/plain b/plain
1 hunks, 1 lines changed
- examine changes to 'plain'? [Ynesfdaq?] y
-
@@ -8,3 +8,4 @@ 7
8
9
@@ -325,8 +314,6 @@ Modify end of plain file, no EOL
> EOF
diff --git a/plain b/plain
1 hunks, 1 lines changed
- examine changes to 'plain'? [Ynesfdaq?] y
-
@@ -9,3 +9,4 @@ 8
9
10
@@ -467,8 +454,6 @@ Modify end of plain file, add EOL
> EOF
diff --git a/plain b/plain
1 hunks, 1 lines changed
- examine changes to 'plain'? [Ynesfdaq?] y
-
@@ -9,4 +9,4 @@ 8
9
10
@@ -480,8 +465,6 @@ Modify end of plain file, add EOL
diff --git a/plain2 b/plain2
new file mode 100644
- examine changes to 'plain2'? [Ynesfdaq?] y
-
@@ -0,0 +1,1 @@
+1
record change 2/2 to 'plain2'? [Ynesfdaq?] y
@@ -504,8 +487,6 @@ changes numbering
> EOF
diff --git a/plain b/plain
2 hunks, 3 lines changed
- examine changes to 'plain'? [Ynesfdaq?] y
-
@@ -1,4 +1,4 @@
-1
+2
@@ -524,8 +505,6 @@ changes numbering
diff --git a/plain2 b/plain2
1 hunks, 1 lines changed
- examine changes to 'plain2'? [Ynesfdaq?] y
-
@@ -1,1 +1,2 @@
1
+2
@@ -572,14 +551,11 @@ Trim beginning, modify end
Record end
$ hg commit -i -d '11 0' -m end-only plain <<EOF
- > y
> n
> y
> EOF
diff --git a/plain b/plain
2 hunks, 4 lines changed
- examine changes to 'plain'? [Ynesfdaq?] y
-
@@ -1,9 +1,6 @@
-2
-2
@@ -630,8 +606,6 @@ Record beginning
> EOF
diff --git a/plain b/plain
1 hunks, 3 lines changed
- examine changes to 'plain'? [Ynesfdaq?] y
-
@@ -1,6 +1,3 @@
-2
-2
@@ -671,14 +645,11 @@ Add to beginning, trim from end
Record end
$ hg commit -i --traceback -d '13 0' -m end-again plain<<EOF
- > y
> n
> y
> EOF
diff --git a/plain b/plain
2 hunks, 4 lines changed
- examine changes to 'plain'? [Ynesfdaq?] y
-
@@ -1,6 +1,9 @@
+1
+2
@@ -714,13 +685,10 @@ Record beginning, middle, and test that
$ hg commit -i --config diff.noprefix=True -d '14 0' -m middle-only plain <<EOF
> y
> y
- > y
> n
> EOF
diff --git a/plain b/plain
3 hunks, 7 lines changed
- examine changes to 'plain'? [Ynesfdaq?] y
-
@@ -1,2 +1,5 @@
+1
+2
@@ -781,8 +749,6 @@ Record end
> EOF
diff --git a/plain b/plain
1 hunks, 2 lines changed
- examine changes to 'plain'? [Ynesfdaq?] y
-
@@ -9,3 +9,5 @@ 6
7
8
@@ -823,8 +789,6 @@ Record end
> EOF
diff --git a/subdir/a b/subdir/a
1 hunks, 1 lines changed
- examine changes to 'subdir/a'? [Ynesfdaq?] y
-
@@ -1,1 +1,2 @@
a
+a
@@ -879,6 +843,35 @@ Help, quit
abort: user quit
[255]
+Patterns
+
+ $ hg commit -i 'glob:f*' << EOF
+ > y
+ > n
+ > y
+ > n
+ > EOF
+ diff --git a/subdir/f1 b/subdir/f1
+ 1 hunks, 1 lines changed
+ examine changes to 'subdir/f1'? [Ynesfdaq?] y
+
+ @@ -1,1 +1,2 @@
+ a
+ +a
+ record change 1/2 to 'subdir/f1'? [Ynesfdaq?] n
+
+ diff --git a/subdir/f2 b/subdir/f2
+ 1 hunks, 1 lines changed
+ examine changes to 'subdir/f2'? [Ynesfdaq?] y
+
+ @@ -1,1 +1,2 @@
+ b
+ +b
+ record change 2/2 to 'subdir/f2'? [Ynesfdaq?] n
+
+ no changes to record
+ [1]
+
#if gettext
Test translated help message
@@ -157,14 +157,11 @@ record
$ chmod +x a
$ hg record -m moda a <<EOF
> y
- > y
> EOF
\x1b[0;1mdiff --git a/a b/a\x1b[0m (esc)
\x1b[0;36;1mold mode 100644\x1b[0m (esc)
\x1b[0;36;1mnew mode 100755\x1b[0m (esc)
1 hunks, 1 lines changed
- \x1b[0;33mexamine changes to 'a'? [Ynesfdaq?]\x1b[0m y (esc)
-
\x1b[0;35m@@ -2,7 +2,7 @@ c\x1b[0m (esc)
c
a
@@ -383,13 +383,10 @@ record chunk
>>> open('a', 'wb').writelines(lines)
$ hg record -d '10 1' -m rectest a<<EOF
> y
- > y
> n
> EOF
diff --git a/a b/a
2 hunks, 2 lines changed
- examine changes to 'a'? [Ynesfdaq?] y
-
@@ -1,3 +1,4 @@
expand $Id$
+foo
@@ -448,8 +445,6 @@ Record all chunks in file a
> EOF
diff --git a/a b/a
2 hunks, 2 lines changed
- examine changes to 'a'? [Ynesfdaq?] y
-
@@ -1,3 +1,4 @@
expand $Id$
+foo
@@ -519,8 +514,6 @@ record added file alone
> EOF
diff --git a/r b/r
new file mode 100644
- examine changes to 'r'? [Ynesfdaq?] y
-
@@ -0,0 +1,1 @@
+$Id$
record this change to 'r'? [Ynesfdaq?] y
@@ -76,10 +76,8 @@ Select no files
> EOF
diff --git a/empty-rw b/empty-rw
new file mode 100644
- examine changes to 'empty-rw'? [Ynesfdaq?] n
-
- no changes to record
- [1]
+ abort: empty commit message
+ [255]
$ hg tip -p
changeset: -1:000000000000
@@ -149,11 +149,9 @@ Test that --interactive lift the need fo
g
Test that a noop revert doesn't do an unnecessary backup
- $ (echo y; echo n) | hg revert -i -r 2 folder1/g
+ $ (echo n) | hg revert -i -r 2 folder1/g
diff --git a/folder1/g b/folder1/g
1 hunks, 1 lines changed
- examine changes to 'folder1/g'? [Ynesfdaq?] y
-
@@ -3,4 +3,3 @@
3
4
@@ -165,11 +163,9 @@ Test that a noop revert doesn't do an un
g
Test --no-backup
- $ (echo y; echo y) | hg revert -i -C -r 2 folder1/g
+ $ (echo y) | hg revert -i -C -r 2 folder1/g
diff --git a/folder1/g b/folder1/g
1 hunks, 1 lines changed
- examine changes to 'folder1/g'? [Ynesfdaq?] y
-
@@ -3,4 +3,3 @@
3
4
@@ -270,7 +266,6 @@ Test --no-backup
M f
M folder1/g
$ hg revert --interactive f << EOF
- > y
> ?
> y
> n
@@ -278,8 +273,6 @@ Test --no-backup
> EOF
diff --git a/f b/f
2 hunks, 2 lines changed
- examine changes to 'f'? [Ynesfdaq?] y
-
@@ -1,6 +1,5 @@
-a
1
@@ -327,6 +320,25 @@ Test --no-backup
4
5
$ rm f.orig
+
+Patterns
+
+ $ hg revert -i 'glob:f*' << EOF
+ > y
+ > n
+ > EOF
+ diff --git a/f b/f
+ 1 hunks, 1 lines changed
+ examine changes to 'f'? [Ynesfdaq?] y
+
+ @@ -4,4 +4,3 @@
+ 3
+ 4
+ 5
+ -b
+ discard this change to 'f'? [Ynesfdaq?] n
+
+
$ hg update -C .
2 files updated, 0 files merged, 0 files removed, 0 files unresolved