Show More
@@ -0,0 +1,203 | |||||
|
1 | Revert interactive tests | |||
|
2 | 1 add and commit file f | |||
|
3 | 2 add commit file folder1/g | |||
|
4 | 3 add and commit file folder2/h | |||
|
5 | 4 add and commit file folder1/i | |||
|
6 | 5 commit change to file f | |||
|
7 | 6 commit changes to files folder1/g folder2/h | |||
|
8 | 7 commit changes to files folder1/g folder2/h | |||
|
9 | 8 revert interactive to commit id 2 (line 3 above), check that folder1/i is removed and | |||
|
10 | 9 make workdir match 7 | |||
|
11 | 10 run the same test than 8 from within folder1 and check same expectations | |||
|
12 | ||||
|
13 | $ cat <<EOF >> $HGRCPATH | |||
|
14 | > [ui] | |||
|
15 | > interactive = true | |||
|
16 | > [extensions] | |||
|
17 | > record = | |||
|
18 | > EOF | |||
|
19 | ||||
|
20 | ||||
|
21 | $ mkdir -p a/{folder1,folder2} | |||
|
22 | $ cd a | |||
|
23 | $ hg init | |||
|
24 | $ seq 1 5 > f ; hg add f ; hg commit -m "adding f" | |||
|
25 | $ seq 1 5 > folder1/g ; hg add folder1/g ; hg commit -m "adding folder1/g" | |||
|
26 | $ seq 1 5 > folder2/h ; hg add folder2/h ; hg commit -m "adding folder2/h" | |||
|
27 | $ seq 1 5 > folder1/i ; hg add folder1/i ; hg commit -m "adding folder1/i" | |||
|
28 | $ echo "a" > f ; seq 1 5 >> f ; echo "b" >> f ; hg commit -m "modifying f" | |||
|
29 | $ echo "c" > folder1/g ; seq 1 5 >> folder1/g ; echo "d" >> folder1/g ; hg commit -m "modifying folder1/g" | |||
|
30 | $ echo "e" > folder2/h ; seq 1 5 >> folder2/h ; echo "f" >> folder2/h ; hg commit -m "modifying folder2/h" | |||
|
31 | $ hg tip | |||
|
32 | changeset: 6:59dd6e4ab63a | |||
|
33 | tag: tip | |||
|
34 | user: test | |||
|
35 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
36 | summary: modifying folder2/h | |||
|
37 | ||||
|
38 | $ hg revert -i -r 2 --all -- << EOF | |||
|
39 | > y | |||
|
40 | > y | |||
|
41 | > y | |||
|
42 | > y | |||
|
43 | > y | |||
|
44 | > n | |||
|
45 | > n | |||
|
46 | > EOF | |||
|
47 | reverting f | |||
|
48 | reverting folder1/g (glob) | |||
|
49 | removing folder1/i (glob) | |||
|
50 | reverting folder2/h (glob) | |||
|
51 | diff -r 89ac3d72e4a4 f | |||
|
52 | 2 hunks, 2 lines changed | |||
|
53 | examine changes to 'f'? [Ynesfdaq?] y | |||
|
54 | ||||
|
55 | @@ -1,6 +1,5 @@ | |||
|
56 | -a | |||
|
57 | 1 | |||
|
58 | 2 | |||
|
59 | 3 | |||
|
60 | 4 | |||
|
61 | 5 | |||
|
62 | record change 1/6 to 'f'? [Ynesfdaq?] y | |||
|
63 | ||||
|
64 | @@ -2,6 +1,5 @@ | |||
|
65 | 1 | |||
|
66 | 2 | |||
|
67 | 3 | |||
|
68 | 4 | |||
|
69 | 5 | |||
|
70 | -b | |||
|
71 | record change 2/6 to 'f'? [Ynesfdaq?] y | |||
|
72 | ||||
|
73 | diff -r 89ac3d72e4a4 folder1/g | |||
|
74 | 2 hunks, 2 lines changed | |||
|
75 | examine changes to 'folder1/g'? [Ynesfdaq?] y | |||
|
76 | ||||
|
77 | @@ -1,6 +1,5 @@ | |||
|
78 | -c | |||
|
79 | 1 | |||
|
80 | 2 | |||
|
81 | 3 | |||
|
82 | 4 | |||
|
83 | 5 | |||
|
84 | record change 3/6 to 'folder1/g'? [Ynesfdaq?] y | |||
|
85 | ||||
|
86 | @@ -2,6 +1,5 @@ | |||
|
87 | 1 | |||
|
88 | 2 | |||
|
89 | 3 | |||
|
90 | 4 | |||
|
91 | 5 | |||
|
92 | -d | |||
|
93 | record change 4/6 to 'folder1/g'? [Ynesfdaq?] n | |||
|
94 | ||||
|
95 | diff -r 89ac3d72e4a4 folder2/h | |||
|
96 | 2 hunks, 2 lines changed | |||
|
97 | examine changes to 'folder2/h'? [Ynesfdaq?] n | |||
|
98 | ||||
|
99 | $ cat f | |||
|
100 | 1 | |||
|
101 | 2 | |||
|
102 | 3 | |||
|
103 | 4 | |||
|
104 | 5 | |||
|
105 | $ cat folder1/g | |||
|
106 | 1 | |||
|
107 | 2 | |||
|
108 | 3 | |||
|
109 | 4 | |||
|
110 | 5 | |||
|
111 | d | |||
|
112 | $ cat folder2/h | |||
|
113 | e | |||
|
114 | 1 | |||
|
115 | 2 | |||
|
116 | 3 | |||
|
117 | 4 | |||
|
118 | 5 | |||
|
119 | f | |||
|
120 | $ hg update -C 6 | |||
|
121 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
122 | $ hg revert -i -r 2 --all -- << EOF | |||
|
123 | > y | |||
|
124 | > y | |||
|
125 | > y | |||
|
126 | > y | |||
|
127 | > y | |||
|
128 | > n | |||
|
129 | > n | |||
|
130 | > EOF | |||
|
131 | reverting f | |||
|
132 | reverting folder1/g (glob) | |||
|
133 | removing folder1/i (glob) | |||
|
134 | reverting folder2/h (glob) | |||
|
135 | diff -r 89ac3d72e4a4 f | |||
|
136 | 2 hunks, 2 lines changed | |||
|
137 | examine changes to 'f'? [Ynesfdaq?] y | |||
|
138 | ||||
|
139 | @@ -1,6 +1,5 @@ | |||
|
140 | -a | |||
|
141 | 1 | |||
|
142 | 2 | |||
|
143 | 3 | |||
|
144 | 4 | |||
|
145 | 5 | |||
|
146 | record change 1/6 to 'f'? [Ynesfdaq?] y | |||
|
147 | ||||
|
148 | @@ -2,6 +1,5 @@ | |||
|
149 | 1 | |||
|
150 | 2 | |||
|
151 | 3 | |||
|
152 | 4 | |||
|
153 | 5 | |||
|
154 | -b | |||
|
155 | record change 2/6 to 'f'? [Ynesfdaq?] y | |||
|
156 | ||||
|
157 | diff -r 89ac3d72e4a4 folder1/g | |||
|
158 | 2 hunks, 2 lines changed | |||
|
159 | examine changes to 'folder1/g'? [Ynesfdaq?] y | |||
|
160 | ||||
|
161 | @@ -1,6 +1,5 @@ | |||
|
162 | -c | |||
|
163 | 1 | |||
|
164 | 2 | |||
|
165 | 3 | |||
|
166 | 4 | |||
|
167 | 5 | |||
|
168 | record change 3/6 to 'folder1/g'? [Ynesfdaq?] y | |||
|
169 | ||||
|
170 | @@ -2,6 +1,5 @@ | |||
|
171 | 1 | |||
|
172 | 2 | |||
|
173 | 3 | |||
|
174 | 4 | |||
|
175 | 5 | |||
|
176 | -d | |||
|
177 | record change 4/6 to 'folder1/g'? [Ynesfdaq?] n | |||
|
178 | ||||
|
179 | diff -r 89ac3d72e4a4 folder2/h | |||
|
180 | 2 hunks, 2 lines changed | |||
|
181 | examine changes to 'folder2/h'? [Ynesfdaq?] n | |||
|
182 | ||||
|
183 | $ cat f | |||
|
184 | 1 | |||
|
185 | 2 | |||
|
186 | 3 | |||
|
187 | 4 | |||
|
188 | 5 | |||
|
189 | $ cat folder1/g | |||
|
190 | 1 | |||
|
191 | 2 | |||
|
192 | 3 | |||
|
193 | 4 | |||
|
194 | 5 | |||
|
195 | d | |||
|
196 | $ cat folder2/h | |||
|
197 | e | |||
|
198 | 1 | |||
|
199 | 2 | |||
|
200 | 3 | |||
|
201 | 4 | |||
|
202 | 5 | |||
|
203 | f |
@@ -3018,8 +3018,8 def revert(ui, repo, ctx, parents, *pats | |||||
3018 | if not opts.get('dry_run'): |
|
3018 | if not opts.get('dry_run'): | |
3019 | needdata = ('revert', 'add', 'undelete') |
|
3019 | needdata = ('revert', 'add', 'undelete') | |
3020 | _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata]) |
|
3020 | _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata]) | |
3021 |
|
3021 | interactive = opts.get('interactive', False) | ||
3022 | _performrevert(repo, parents, ctx, actions) |
|
3022 | _performrevert(repo, parents, ctx, actions, interactive) | |
3023 |
|
3023 | |||
3024 | # get the list of subrepos that must be reverted |
|
3024 | # get the list of subrepos that must be reverted | |
3025 | subrepomatch = scmutil.match(ctx, pats, opts) |
|
3025 | subrepomatch = scmutil.match(ctx, pats, opts) | |
@@ -3036,7 +3036,7 def _revertprefetch(repo, ctx, *files): | |||||
3036 | """Let extension changing the storage layer prefetch content""" |
|
3036 | """Let extension changing the storage layer prefetch content""" | |
3037 | pass |
|
3037 | pass | |
3038 |
|
3038 | |||
3039 | def _performrevert(repo, parents, ctx, actions): |
|
3039 | def _performrevert(repo, parents, ctx, actions, interactive=False): | |
3040 | """function that actually perform all the actions computed for revert |
|
3040 | """function that actually perform all the actions computed for revert | |
3041 |
|
3041 | |||
3042 | This is an independent function to let extension to plug in and react to |
|
3042 | This is an independent function to let extension to plug in and react to | |
@@ -3070,10 +3070,40 def _performrevert(repo, parents, ctx, a | |||||
3070 | normal = repo.dirstate.normallookup |
|
3070 | normal = repo.dirstate.normallookup | |
3071 | else: |
|
3071 | else: | |
3072 | normal = repo.dirstate.normal |
|
3072 | normal = repo.dirstate.normal | |
3073 | for f in actions['revert'][0]: |
|
3073 | ||
3074 | checkout(f) |
|
3074 | if interactive: | |
3075 | if normal: |
|
3075 | # Prompt the user for changes to revert | |
3076 | normal(f) |
|
3076 | torevert = [repo.wjoin(f) for f in actions['revert'][0]] | |
|
3077 | m = scmutil.match(ctx, torevert, {}) | |||
|
3078 | diff = patch.diff(repo, None, ctx.node(), m) | |||
|
3079 | originalchunks = patch.parsepatch(diff) | |||
|
3080 | try: | |||
|
3081 | chunks = recordfilter(repo.ui, originalchunks) | |||
|
3082 | except patch.PatchError, err: | |||
|
3083 | raise util.Abort(_('error parsing patch: %s') % err) | |||
|
3084 | ||||
|
3085 | # Apply changes | |||
|
3086 | fp = cStringIO.StringIO() | |||
|
3087 | for c in chunks: | |||
|
3088 | c.write(fp) | |||
|
3089 | dopatch = fp.tell() | |||
|
3090 | fp.seek(0) | |||
|
3091 | if dopatch: | |||
|
3092 | try: | |||
|
3093 | patch.internalpatch(repo.ui, repo, fp, 1, eolmode=None) | |||
|
3094 | except patch.PatchError, err: | |||
|
3095 | raise util.Abort(str(err)) | |||
|
3096 | del fp | |||
|
3097 | ||||
|
3098 | for f in actions['revert'][0]: | |||
|
3099 | if normal: | |||
|
3100 | normal(f) | |||
|
3101 | ||||
|
3102 | else: | |||
|
3103 | for f in actions['revert'][0]: | |||
|
3104 | checkout(f) | |||
|
3105 | if normal: | |||
|
3106 | normal(f) | |||
3077 |
|
3107 | |||
3078 | for f in actions['add'][0]: |
|
3108 | for f in actions['add'][0]: | |
3079 | checkout(f) |
|
3109 | checkout(f) |
@@ -5375,6 +5375,7 def resolve(ui, repo, *pats, **opts): | |||||
5375 | ('d', 'date', '', _('tipmost revision matching date'), _('DATE')), |
|
5375 | ('d', 'date', '', _('tipmost revision matching date'), _('DATE')), | |
5376 | ('r', 'rev', '', _('revert to the specified revision'), _('REV')), |
|
5376 | ('r', 'rev', '', _('revert to the specified revision'), _('REV')), | |
5377 | ('C', 'no-backup', None, _('do not save backup copies of files')), |
|
5377 | ('C', 'no-backup', None, _('do not save backup copies of files')), | |
|
5378 | ('i', 'interactive', None, _('interactively select the changes')), | |||
5378 | ] + walkopts + dryrunopts, |
|
5379 | ] + walkopts + dryrunopts, | |
5379 | _('[OPTION]... [-r REV] [NAME]...')) |
|
5380 | _('[OPTION]... [-r REV] [NAME]...')) | |
5380 | def revert(ui, repo, *pats, **opts): |
|
5381 | def revert(ui, repo, *pats, **opts): |
@@ -279,7 +279,7 Show all commands + options | |||||
279 | recover: |
|
279 | recover: | |
280 | rename: after, force, include, exclude, dry-run |
|
280 | rename: after, force, include, exclude, dry-run | |
281 | resolve: all, list, mark, unmark, no-status, tool, include, exclude, template |
|
281 | resolve: all, list, mark, unmark, no-status, tool, include, exclude, template | |
282 | revert: all, date, rev, no-backup, include, exclude, dry-run |
|
282 | revert: all, date, rev, no-backup, interactive, include, exclude, dry-run | |
283 | rollback: dry-run, force |
|
283 | rollback: dry-run, force | |
284 | root: |
|
284 | root: | |
285 | tag: force, local, rev, remove, edit, message, date, user |
|
285 | tag: force, local, rev, remove, edit, message, date, user |
General Comments 0
You need to be logged in to leave comments.
Login now