2019-12-10 02:24:31 +03:00
|
|
|
#chg-compatible
|
|
|
|
|
2015-03-17 02:33:59 +03:00
|
|
|
Revert interactive tests
|
|
|
|
1 add and commit file f
|
|
|
|
2 add commit file folder1/g
|
|
|
|
3 add and commit file folder2/h
|
|
|
|
4 add and commit file folder1/i
|
|
|
|
5 commit change to file f
|
|
|
|
6 commit changes to files folder1/g folder2/h
|
|
|
|
7 commit changes to files folder1/g folder2/h
|
|
|
|
8 revert interactive to commit id 2 (line 3 above), check that folder1/i is removed and
|
|
|
|
9 make workdir match 7
|
|
|
|
10 run the same test than 8 from within folder1 and check same expectations
|
|
|
|
|
2020-01-20 13:42:49 +03:00
|
|
|
$ setconfig ui.interactive=true
|
2015-03-17 02:33:59 +03:00
|
|
|
|
|
|
|
|
2015-03-19 18:22:37 +03:00
|
|
|
$ mkdir -p a/folder1 a/folder2
|
2015-03-17 02:33:59 +03:00
|
|
|
$ cd a
|
|
|
|
$ hg init
|
2020-07-14 06:53:04 +03:00
|
|
|
>>> _ = open('f', 'wb').write(b"1\n2\n3\n4\n5\n")
|
2015-03-21 18:56:43 +03:00
|
|
|
$ hg add f ; hg commit -m "adding f"
|
2015-03-18 04:47:47 +03:00
|
|
|
$ cat f > folder1/g ; hg add folder1/g ; hg commit -m "adding folder1/g"
|
|
|
|
$ cat f > folder2/h ; hg add folder2/h ; hg commit -m "adding folder2/h"
|
|
|
|
$ cat f > folder1/i ; hg add folder1/i ; hg commit -m "adding folder1/i"
|
2020-07-14 06:53:04 +03:00
|
|
|
>>> _ = open('f', 'wb').write(b"a\n1\n2\n3\n4\n5\nb\n")
|
2015-03-21 18:56:43 +03:00
|
|
|
$ hg commit -m "modifying f"
|
2020-07-14 06:53:04 +03:00
|
|
|
>>> _ = open('folder1/g', 'wb').write(b"c\n1\n2\n3\n4\n5\nd\n")
|
2015-03-21 18:56:43 +03:00
|
|
|
$ hg commit -m "modifying folder1/g"
|
2020-07-14 06:53:04 +03:00
|
|
|
>>> _ = open('folder2/h', 'wb').write(b"e\n1\n2\n3\n4\n5\nf\n")
|
2015-03-21 18:56:43 +03:00
|
|
|
$ hg commit -m "modifying folder2/h"
|
2015-03-17 02:33:59 +03:00
|
|
|
$ hg tip
|
2020-07-21 03:23:52 +03:00
|
|
|
commit: 59dd6e4ab63a
|
2015-03-17 02:33:59 +03:00
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: modifying folder2/h
|
|
|
|
|
2020-10-08 21:06:31 +03:00
|
|
|
$ hg revert -i -r 89ac3d72e4a40dddb2b309da933c539e8c7d1d4d --all -- << EOF
|
2015-03-17 02:33:59 +03:00
|
|
|
> y
|
|
|
|
> y
|
|
|
|
> y
|
|
|
|
> y
|
|
|
|
> y
|
2017-04-24 18:13:24 +03:00
|
|
|
> ?
|
2016-11-25 11:10:30 +03:00
|
|
|
> y
|
2015-03-17 02:33:59 +03:00
|
|
|
> n
|
|
|
|
> n
|
|
|
|
> EOF
|
|
|
|
reverting f
|
2017-12-11 06:50:57 +03:00
|
|
|
reverting folder1/g
|
|
|
|
removing folder1/i
|
|
|
|
reverting folder2/h
|
2016-11-25 11:10:30 +03:00
|
|
|
remove added file folder1/i (Yn)? y
|
2015-05-22 00:25:57 +03:00
|
|
|
diff --git a/f b/f
|
2015-03-17 02:33:59 +03:00
|
|
|
2 hunks, 2 lines changed
|
|
|
|
examine changes to 'f'? [Ynesfdaq?] y
|
|
|
|
|
2017-11-03 16:47:37 +03:00
|
|
|
@@ -1,6 +1,5 @@
|
|
|
|
-a
|
2015-03-17 02:33:59 +03:00
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2017-11-03 16:47:37 +03:00
|
|
|
apply change 1/6 to 'f'? [Ynesfdaq?] y
|
2015-03-17 02:33:59 +03:00
|
|
|
|
2017-11-03 16:47:37 +03:00
|
|
|
@@ -2,6 +1,5 @@
|
2015-03-17 02:33:59 +03:00
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2017-11-03 16:47:37 +03:00
|
|
|
-b
|
|
|
|
apply change 2/6 to 'f'? [Ynesfdaq?] y
|
2015-03-17 02:33:59 +03:00
|
|
|
|
2015-05-22 00:25:57 +03:00
|
|
|
diff --git a/folder1/g b/folder1/g
|
2015-03-17 02:33:59 +03:00
|
|
|
2 hunks, 2 lines changed
|
|
|
|
examine changes to 'folder1/g'? [Ynesfdaq?] y
|
|
|
|
|
2017-11-03 16:47:37 +03:00
|
|
|
@@ -1,6 +1,5 @@
|
|
|
|
-c
|
2015-03-17 02:33:59 +03:00
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2017-11-03 16:47:37 +03:00
|
|
|
apply change 3/6 to 'folder1/g'? [Ynesfdaq?] ?
|
2017-04-24 18:13:24 +03:00
|
|
|
|
2017-11-03 16:47:37 +03:00
|
|
|
y - yes, apply this change
|
2017-04-24 18:13:24 +03:00
|
|
|
n - no, skip this change
|
|
|
|
e - edit this change manually
|
|
|
|
s - skip remaining changes to this file
|
2017-11-03 16:47:37 +03:00
|
|
|
f - apply remaining changes to this file
|
2017-04-24 18:13:24 +03:00
|
|
|
d - done, skip remaining changes and files
|
2017-11-03 16:47:37 +03:00
|
|
|
a - apply all changes to all remaining files
|
|
|
|
q - quit, applying no changes
|
2017-04-24 18:13:24 +03:00
|
|
|
? - ? (display help)
|
2017-11-03 16:47:37 +03:00
|
|
|
apply change 3/6 to 'folder1/g'? [Ynesfdaq?] y
|
2015-03-17 02:33:59 +03:00
|
|
|
|
2017-11-03 16:47:37 +03:00
|
|
|
@@ -2,6 +1,5 @@
|
2015-03-17 02:33:59 +03:00
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2017-11-03 16:47:37 +03:00
|
|
|
-d
|
|
|
|
apply change 4/6 to 'folder1/g'? [Ynesfdaq?] n
|
2015-03-17 02:33:59 +03:00
|
|
|
|
2015-05-22 00:25:57 +03:00
|
|
|
diff --git a/folder2/h b/folder2/h
|
2015-03-17 02:33:59 +03:00
|
|
|
2 hunks, 2 lines changed
|
|
|
|
examine changes to 'folder2/h'? [Ynesfdaq?] n
|
|
|
|
|
|
|
|
$ cat f
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
$ cat folder1/g
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
d
|
|
|
|
$ cat folder2/h
|
|
|
|
e
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
f
|
2015-04-11 19:26:54 +03:00
|
|
|
|
|
|
|
Test that --interactive lift the need for --all
|
|
|
|
|
2020-10-08 21:06:31 +03:00
|
|
|
$ echo q | hg revert -i -r 89ac3d72e4a40dddb2b309da933c539e8c7d1d4d
|
2017-12-11 06:50:57 +03:00
|
|
|
reverting folder1/g
|
|
|
|
reverting folder2/h
|
2015-05-22 00:25:57 +03:00
|
|
|
diff --git a/folder1/g b/folder1/g
|
2015-04-11 19:26:54 +03:00
|
|
|
1 hunks, 1 lines changed
|
|
|
|
examine changes to 'folder1/g'? [Ynesfdaq?] q
|
|
|
|
|
|
|
|
abort: user quit
|
|
|
|
[255]
|
2016-06-30 18:38:19 +03:00
|
|
|
$ ls folder1/
|
|
|
|
g
|
|
|
|
|
2016-10-18 00:16:55 +03:00
|
|
|
Test that a noop revert doesn't do an unnecessary backup
|
2020-10-08 21:06:31 +03:00
|
|
|
$ (echo y; echo n) | hg revert -i -r 89ac3d72e4a40dddb2b309da933c539e8c7d1d4d folder1/g
|
2016-06-30 18:38:19 +03:00
|
|
|
diff --git a/folder1/g b/folder1/g
|
|
|
|
1 hunks, 1 lines changed
|
|
|
|
examine changes to 'folder1/g'? [Ynesfdaq?] y
|
|
|
|
|
2017-11-03 16:47:37 +03:00
|
|
|
@@ -3,4 +3,3 @@
|
2016-06-30 18:38:19 +03:00
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2017-11-03 16:47:37 +03:00
|
|
|
-d
|
|
|
|
apply this change to 'folder1/g'? [Ynesfdaq?] n
|
2016-06-30 18:38:19 +03:00
|
|
|
|
|
|
|
$ ls folder1/
|
|
|
|
g
|
|
|
|
|
|
|
|
Test --no-backup
|
2020-10-08 21:06:31 +03:00
|
|
|
$ (echo y; echo y) | hg revert -i -C -r 89ac3d72e4a40dddb2b309da933c539e8c7d1d4d folder1/g
|
2016-06-30 18:38:19 +03:00
|
|
|
diff --git a/folder1/g b/folder1/g
|
|
|
|
1 hunks, 1 lines changed
|
|
|
|
examine changes to 'folder1/g'? [Ynesfdaq?] y
|
|
|
|
|
2017-11-03 16:47:37 +03:00
|
|
|
@@ -3,4 +3,3 @@
|
2016-06-30 18:38:19 +03:00
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2017-11-03 16:47:37 +03:00
|
|
|
-d
|
|
|
|
apply this change to 'folder1/g'? [Ynesfdaq?] y
|
2016-06-30 18:38:19 +03:00
|
|
|
|
|
|
|
$ ls folder1/
|
|
|
|
g
|
2020-07-14 06:53:04 +03:00
|
|
|
>>> _ = open('folder1/g', 'wb').write(b"1\n2\n3\n4\n5\nd\n")
|
2015-04-11 19:26:54 +03:00
|
|
|
|
|
|
|
|
2020-10-08 21:06:31 +03:00
|
|
|
$ hg update -C 'max(desc(modifying))'
|
2015-03-17 02:33:59 +03:00
|
|
|
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
2020-10-08 21:06:31 +03:00
|
|
|
$ hg revert -i -r 89ac3d72e4a40dddb2b309da933c539e8c7d1d4d --all -- << EOF
|
2016-11-25 11:10:30 +03:00
|
|
|
> n
|
2015-03-17 02:33:59 +03:00
|
|
|
> y
|
|
|
|
> y
|
|
|
|
> y
|
|
|
|
> y
|
|
|
|
> y
|
|
|
|
> n
|
|
|
|
> n
|
|
|
|
> EOF
|
|
|
|
reverting f
|
2017-12-11 06:50:57 +03:00
|
|
|
reverting folder1/g
|
|
|
|
removing folder1/i
|
|
|
|
reverting folder2/h
|
2016-11-25 11:10:30 +03:00
|
|
|
remove added file folder1/i (Yn)? n
|
2015-05-22 00:25:57 +03:00
|
|
|
diff --git a/f b/f
|
2015-03-17 02:33:59 +03:00
|
|
|
2 hunks, 2 lines changed
|
|
|
|
examine changes to 'f'? [Ynesfdaq?] y
|
|
|
|
|
2017-11-03 16:47:37 +03:00
|
|
|
@@ -1,6 +1,5 @@
|
|
|
|
-a
|
2015-03-17 02:33:59 +03:00
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2017-11-03 16:47:37 +03:00
|
|
|
apply change 1/6 to 'f'? [Ynesfdaq?] y
|
2015-03-17 02:33:59 +03:00
|
|
|
|
2017-11-03 16:47:37 +03:00
|
|
|
@@ -2,6 +1,5 @@
|
2015-03-17 02:33:59 +03:00
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2017-11-03 16:47:37 +03:00
|
|
|
-b
|
|
|
|
apply change 2/6 to 'f'? [Ynesfdaq?] y
|
2015-03-17 02:33:59 +03:00
|
|
|
|
2015-05-22 00:25:57 +03:00
|
|
|
diff --git a/folder1/g b/folder1/g
|
2015-03-17 02:33:59 +03:00
|
|
|
2 hunks, 2 lines changed
|
|
|
|
examine changes to 'folder1/g'? [Ynesfdaq?] y
|
|
|
|
|
2017-11-03 16:47:37 +03:00
|
|
|
@@ -1,6 +1,5 @@
|
|
|
|
-c
|
2015-03-17 02:33:59 +03:00
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2017-11-03 16:47:37 +03:00
|
|
|
apply change 3/6 to 'folder1/g'? [Ynesfdaq?] y
|
2015-03-17 02:33:59 +03:00
|
|
|
|
2017-11-03 16:47:37 +03:00
|
|
|
@@ -2,6 +1,5 @@
|
2015-03-17 02:33:59 +03:00
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2017-11-03 16:47:37 +03:00
|
|
|
-d
|
|
|
|
apply change 4/6 to 'folder1/g'? [Ynesfdaq?] n
|
2015-03-17 02:33:59 +03:00
|
|
|
|
2015-05-22 00:25:57 +03:00
|
|
|
diff --git a/folder2/h b/folder2/h
|
2015-03-17 02:33:59 +03:00
|
|
|
2 hunks, 2 lines changed
|
|
|
|
examine changes to 'folder2/h'? [Ynesfdaq?] n
|
|
|
|
|
|
|
|
$ cat f
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
$ cat folder1/g
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
d
|
|
|
|
$ cat folder2/h
|
|
|
|
e
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
f
|
2015-03-26 00:01:14 +03:00
|
|
|
$ hg st
|
|
|
|
M f
|
|
|
|
M folder1/g
|
|
|
|
$ hg revert --interactive f << EOF
|
|
|
|
> y
|
2017-04-24 18:13:24 +03:00
|
|
|
> ?
|
2015-03-26 00:01:14 +03:00
|
|
|
> y
|
|
|
|
> n
|
|
|
|
> n
|
|
|
|
> EOF
|
2015-05-22 00:25:57 +03:00
|
|
|
diff --git a/f b/f
|
2015-03-26 00:01:14 +03:00
|
|
|
2 hunks, 2 lines changed
|
|
|
|
examine changes to 'f'? [Ynesfdaq?] y
|
|
|
|
|
2015-06-24 00:28:15 +03:00
|
|
|
@@ -1,6 +1,5 @@
|
|
|
|
-a
|
2015-03-26 00:01:14 +03:00
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2017-04-24 18:13:24 +03:00
|
|
|
discard change 1/2 to 'f'? [Ynesfdaq?] ?
|
|
|
|
|
|
|
|
y - yes, discard this change
|
|
|
|
n - no, skip this change
|
|
|
|
e - edit this change manually
|
|
|
|
s - skip remaining changes to this file
|
|
|
|
f - discard remaining changes to this file
|
|
|
|
d - done, skip remaining changes and files
|
|
|
|
a - discard all changes to all remaining files
|
|
|
|
q - quit, discarding no changes
|
|
|
|
? - ? (display help)
|
2016-06-03 16:55:07 +03:00
|
|
|
discard change 1/2 to 'f'? [Ynesfdaq?] y
|
2015-03-26 00:01:14 +03:00
|
|
|
|
2015-06-24 00:28:15 +03:00
|
|
|
@@ -2,6 +1,5 @@
|
2015-03-26 00:01:14 +03:00
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2015-06-24 00:28:15 +03:00
|
|
|
-b
|
2016-06-03 16:55:07 +03:00
|
|
|
discard change 2/2 to 'f'? [Ynesfdaq?] n
|
2015-03-26 00:01:14 +03:00
|
|
|
|
|
|
|
$ hg st
|
|
|
|
M f
|
|
|
|
M folder1/g
|
|
|
|
? f.orig
|
|
|
|
$ cat f
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
$ cat f.orig
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
2015-05-22 00:34:24 +03:00
|
|
|
$ rm f.orig
|
|
|
|
$ hg update -C .
|
2016-11-25 11:10:30 +03:00
|
|
|
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
2015-05-22 00:34:24 +03:00
|
|
|
|
|
|
|
Check editing files newly added by a revert
|
|
|
|
|
|
|
|
1) Create a dummy editor changing 1 to 42
|
|
|
|
$ cat > $TESTTMP/editor.sh << '__EOF__'
|
|
|
|
> cat "$1" | sed "s/1/42/g" > tt
|
|
|
|
> mv tt "$1"
|
|
|
|
> __EOF__
|
|
|
|
|
2015-06-23 23:46:58 +03:00
|
|
|
2) Add k
|
|
|
|
$ printf "1\n" > k
|
|
|
|
$ hg add k
|
2015-05-22 00:34:24 +03:00
|
|
|
$ hg commit -m "add k"
|
|
|
|
|
2015-06-23 23:46:58 +03:00
|
|
|
3) Use interactive revert with editing (replacing +1 with +42):
|
|
|
|
$ printf "0\n2\n" > k
|
|
|
|
$ HGEDITOR="\"sh\" \"${TESTTMP}/editor.sh\"" hg revert -i <<EOF
|
2015-05-22 00:34:24 +03:00
|
|
|
> y
|
|
|
|
> e
|
|
|
|
> EOF
|
2015-06-23 23:46:58 +03:00
|
|
|
reverting k
|
|
|
|
diff --git a/k b/k
|
|
|
|
1 hunks, 2 lines changed
|
|
|
|
examine changes to 'k'? [Ynesfdaq?] y
|
2015-05-22 00:34:24 +03:00
|
|
|
|
2015-06-24 00:28:15 +03:00
|
|
|
@@ -1,1 +1,2 @@
|
|
|
|
-1
|
|
|
|
+0
|
|
|
|
+2
|
2016-06-03 16:55:07 +03:00
|
|
|
discard this change to 'k'? [Ynesfdaq?] e
|
2015-05-22 00:34:24 +03:00
|
|
|
|
2015-06-23 23:46:58 +03:00
|
|
|
$ cat k
|
2015-05-22 00:34:24 +03:00
|
|
|
42
|
2015-05-29 23:11:52 +03:00
|
|
|
|
2016-02-05 17:18:40 +03:00
|
|
|
$ hg update -C .
|
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ hg purge
|
|
|
|
$ touch newfile
|
|
|
|
$ hg add newfile
|
|
|
|
$ hg status
|
|
|
|
A newfile
|
|
|
|
$ hg revert -i <<EOF
|
|
|
|
> n
|
|
|
|
> EOF
|
|
|
|
forgetting newfile
|
2016-11-25 11:09:31 +03:00
|
|
|
forget added file newfile (Yn)? n
|
2016-02-05 17:18:40 +03:00
|
|
|
$ hg status
|
|
|
|
A newfile
|
|
|
|
$ hg revert -i <<EOF
|
|
|
|
> y
|
|
|
|
> EOF
|
|
|
|
forgetting newfile
|
2016-11-25 11:09:31 +03:00
|
|
|
forget added file newfile (Yn)? y
|
2016-02-05 17:18:40 +03:00
|
|
|
$ hg status
|
|
|
|
? newfile
|
2017-08-27 23:39:17 +03:00
|
|
|
|
|
|
|
When a line without EOL is selected during "revert -i" (issue5651)
|
|
|
|
|
|
|
|
$ hg init $TESTTMP/revert-i-eol
|
|
|
|
$ cd $TESTTMP/revert-i-eol
|
|
|
|
$ echo 0 > a
|
|
|
|
$ hg ci -qAm 0
|
|
|
|
$ printf 1 >> a
|
|
|
|
$ hg ci -qAm 1
|
|
|
|
$ cat a
|
|
|
|
0
|
|
|
|
1 (no-eol)
|
|
|
|
|
|
|
|
$ hg revert -ir'.^' <<EOF
|
|
|
|
> y
|
|
|
|
> y
|
|
|
|
> EOF
|
|
|
|
reverting a
|
|
|
|
diff --git a/a b/a
|
|
|
|
1 hunks, 1 lines changed
|
|
|
|
examine changes to 'a'? [Ynesfdaq?] y
|
|
|
|
|
2017-11-03 16:47:37 +03:00
|
|
|
@@ -1,2 +1,1 @@
|
2017-08-27 23:39:17 +03:00
|
|
|
0
|
2017-11-03 16:47:37 +03:00
|
|
|
-1
|
2017-08-27 23:39:17 +03:00
|
|
|
\ No newline at end of file
|
2017-11-03 16:47:37 +03:00
|
|
|
apply this change to 'a'? [Ynesfdaq?] y
|
2017-08-27 23:39:17 +03:00
|
|
|
|
|
|
|
$ cat a
|
|
|
|
0
|
|
|
|
|
|
|
|
$ cd ..
|