##// END OF EJS Templates
revert: fix the inconsistency of status msgs in --interactive mode...
Sushil khanchi -
r39442:cb70501d default
parent child Browse files
Show More
@@ -3019,8 +3019,9 b' def revert(ui, repo, ctx, parents, *pats'
3019 3019 util.copyfile(target, bakname)
3020 3020 else:
3021 3021 util.rename(target, bakname)
3022 if ui.verbose or not exact:
3023 ui.status(msg % rel)
3022 if opts.get('dry_run'):
3023 if ui.verbose or not exact:
3024 ui.status(msg % rel)
3024 3025 elif exact:
3025 3026 ui.warn(msg % rel)
3026 3027 break
@@ -3033,7 +3034,8 b' def revert(ui, repo, ctx, parents, *pats'
3033 3034 prefetch(repo, [ctx.rev()],
3034 3035 matchfiles(repo,
3035 3036 [f for sublist in oplist for f in sublist]))
3036 _performrevert(repo, parents, ctx, actions, interactive, tobackup)
3037 _performrevert(repo, parents, ctx, names, actions, interactive,
3038 tobackup)
3037 3039
3038 3040 if targetsubs:
3039 3041 # Revert the subrepos on the revert list
@@ -3045,7 +3047,7 b' def revert(ui, repo, ctx, parents, *pats'
3045 3047 raise error.Abort("subrepository '%s' does not exist in %s!"
3046 3048 % (sub, short(ctx.node())))
3047 3049
3048 def _performrevert(repo, parents, ctx, actions, interactive=False,
3050 def _performrevert(repo, parents, ctx, names, actions, interactive=False,
3049 3051 tobackup=None):
3050 3052 """function that actually perform all the actions computed for revert
3051 3053
@@ -3070,16 +3072,23 b' def _performrevert(repo, parents, ctx, a'
3070 3072 pass
3071 3073 repo.dirstate.remove(f)
3072 3074
3075 def prntstatusmsg(action, f):
3076 rel, exact = names[f]
3077 if repo.ui.verbose or not exact:
3078 repo.ui.status(actions[action][1] % rel)
3079
3073 3080 audit_path = pathutil.pathauditor(repo.root, cached=True)
3074 3081 for f in actions['forget'][0]:
3075 3082 if interactive:
3076 3083 choice = repo.ui.promptchoice(
3077 3084 _("forget added file %s (Yn)?$$ &Yes $$ &No") % f)
3078 3085 if choice == 0:
3086 prntstatusmsg('forget', f)
3079 3087 repo.dirstate.drop(f)
3080 3088 else:
3081 3089 excluded_files.append(f)
3082 3090 else:
3091 prntstatusmsg('forget', f)
3083 3092 repo.dirstate.drop(f)
3084 3093 for f in actions['remove'][0]:
3085 3094 audit_path(f)
@@ -3087,13 +3096,16 b' def _performrevert(repo, parents, ctx, a'
3087 3096 choice = repo.ui.promptchoice(
3088 3097 _("remove added file %s (Yn)?$$ &Yes $$ &No") % f)
3089 3098 if choice == 0:
3099 prntstatusmsg('remove', f)
3090 3100 doremove(f)
3091 3101 else:
3092 3102 excluded_files.append(f)
3093 3103 else:
3104 prntstatusmsg('remove', f)
3094 3105 doremove(f)
3095 3106 for f in actions['drop'][0]:
3096 3107 audit_path(f)
3108 prntstatusmsg('drop', f)
3097 3109 repo.dirstate.remove(f)
3098 3110
3099 3111 normal = None
@@ -3140,14 +3152,21 b' def _performrevert(repo, parents, ctx, a'
3140 3152 tobackup = set()
3141 3153 # Apply changes
3142 3154 fp = stringio()
3155 # `fnames` keeps track of filenames for which we have initiated changes,
3156 # to make sure that we print status msg only once per file.
3157 fnames = set()
3143 3158 for c in chunks:
3144 # Create a backup file only if this hunk should be backed up
3145 if ishunk(c) and c.header.filename() in tobackup:
3159 if ishunk(c):
3146 3160 abs = c.header.filename()
3147 target = repo.wjoin(abs)
3148 bakname = scmutil.origpath(repo.ui, repo, m.rel(abs))
3149 util.copyfile(target, bakname)
3150 tobackup.remove(abs)
3161 if abs not in fnames:
3162 fnames.add(abs)
3163 prntstatusmsg('revert', abs)
3164 # Create a backup file only if this hunk should be backed up
3165 if c.header.filename() in tobackup:
3166 target = repo.wjoin(abs)
3167 bakname = scmutil.origpath(repo.ui, repo, m.rel(abs))
3168 util.copyfile(target, bakname)
3169 tobackup.remove(abs)
3151 3170 c.write(fp)
3152 3171 dopatch = fp.tell()
3153 3172 fp.seek(0)
@@ -3159,6 +3178,7 b' def _performrevert(repo, parents, ctx, a'
3159 3178 del fp
3160 3179 else:
3161 3180 for f in actions['revert'][0]:
3181 prntstatusmsg('revert', f)
3162 3182 checkout(f)
3163 3183 if normal:
3164 3184 normal(f)
@@ -3166,6 +3186,7 b' def _performrevert(repo, parents, ctx, a'
3166 3186 for f in actions['add'][0]:
3167 3187 # Don't checkout modified files, they are already created by the diff
3168 3188 if f not in newlyaddedandmodifiedfiles:
3189 prntstatusmsg('add', f)
3169 3190 checkout(f)
3170 3191 repo.dirstate.add(f)
3171 3192
@@ -3173,6 +3194,7 b' def _performrevert(repo, parents, ctx, a'
3173 3194 if node == parent and p2 == nullid:
3174 3195 normal = repo.dirstate.normal
3175 3196 for f in actions['undelete'][0]:
3197 prntstatusmsg('undelete', f)
3176 3198 checkout(f)
3177 3199 normal(f)
3178 3200
@@ -147,8 +147,8 b' transaction: in-memory dirstate changes '
147 147 $ hg debugstate --nodates
148 148 n 644 12 set c
149 149 $ hg backout -d '6 0' -m 'to be rollback-ed soon' -r .
150 removing c
150 151 adding b
151 removing c
152 152 changeset 6:4bfec048029d backs out changeset 5:fac0b729a654
153 153 $ hg rollback -q
154 154 $ hg status -A
@@ -14,8 +14,8 b' Should show a removed and b added:'
14 14 R a
15 15
16 16 $ hg revert --all
17 forgetting b
17 18 undeleting a
18 forgetting b
19 19
20 20 Should show b unknown and a back to normal:
21 21
@@ -66,8 +66,8 b' Revert should fail:'
66 66 Revert should be ok now:
67 67
68 68 $ hg revert -r2 --all
69 forgetting b
69 70 undeleting a
70 forgetting b
71 71
72 72 Should show b unknown and a marked modified (merged):
73 73
@@ -187,11 +187,11 b' Test revert'
187 187 undeleting missing_content2_missing-untracked
188 188
189 189 $ hg revert 'set:deleted()'
190 forgetting content1_missing_missing-tracked
191 forgetting missing_missing_missing-tracked
190 192 reverting content1_content1_missing-tracked
191 193 reverting content1_content2_missing-tracked
192 forgetting content1_missing_missing-tracked
193 194 reverting missing_content2_missing-tracked
194 forgetting missing_missing_missing-tracked
195 195
196 196 $ hg revert 'set:unknown()'
197 197
@@ -615,8 +615,8 b' Renames and strip'
615 615 Prefix with strip, renames, creates etc
616 616
617 617 $ hg revert -aC
618 forgetting b
618 619 undeleting a
619 forgetting b
620 620 $ rm b
621 621 $ mkdir -p dir/dir2
622 622 $ echo b > dir/dir2/b
@@ -715,10 +715,10 b' Renames, similarity and git diff'
715 715
716 716 $ hg revert -aC
717 717 forgetting dir/a
718 forgetting dir/dir2/b2
719 reverting dir/dir2/c
718 720 undeleting dir/d
719 721 undeleting dir/dir2/b
720 forgetting dir/dir2/b2
721 reverting dir/dir2/c
722 722 $ rm dir/a dir/dir2/b2
723 723 $ hg import --similarity 90 --no-commit - <<EOF
724 724 > diff --git a/a b/b
@@ -1014,8 +1014,8 b' test import with similarity and git and '
1014 1014 a
1015 1015 R a
1016 1016 $ hg revert -a
1017 forgetting b
1017 1018 undeleting a
1018 forgetting b
1019 1019 $ cat b
1020 1020 mod b
1021 1021 $ rm b
@@ -66,9 +66,9 b' Revert reintroducing shadow - should fai'
66 66 Revert all - should succeed:
67 67
68 68 $ hg revert --all
69 undeleting a
70 69 forgetting a/a
71 70 forgetting b
71 undeleting a
72 72 undeleting b/b
73 73
74 74 $ hg st
@@ -1135,8 +1135,8 b' Move (and then undo) a directory move wi'
1135 1135 ? large.orig
1136 1136
1137 1137 $ hg revert --all
1138 forgetting .hglf/dir/subdir2/large.bin
1138 1139 undeleting .hglf/dir/subdir/large.bin
1139 forgetting .hglf/dir/subdir2/large.bin
1140 1140 reverting subrepo no-largefiles
1141 1141
1142 1142 $ hg status -C
@@ -1214,8 +1214,8 b' Start from scratch, and rename something'
1214 1214 large
1215 1215
1216 1216 $ hg revert --all
1217 forgetting .hglf/dir2/subdir/large.bin
1217 1218 undeleting .hglf/dir/subdir/large.bin
1218 forgetting .hglf/dir2/subdir/large.bin
1219 1219 reverting subrepo no-largefiles
1220 1220
1221 1221 $ hg status -C
@@ -1513,9 +1513,9 b' Test hg remove removes empty largefiles '
1513 1513 $ cat sub/large4
1514 1514 large4-modified
1515 1515 $ hg revert -a --no-backup
1516 undeleting .hglf/sub2/large6
1517 1516 forgetting .hglf/sub2/large8
1518 1517 reverting normal3
1518 undeleting .hglf/sub2/large6
1519 1519 $ hg status
1520 1520 ? sub/large4.orig
1521 1521 ? sub/normal4.orig
@@ -694,10 +694,6 b' Revert will prefetch blobs in a group'
694 694 $ rm *
695 695 $ hg revert --all -r 1 --debug
696 696 http auth: user foo, password ***
697 adding a
698 reverting b
699 reverting c
700 reverting d
701 697 http auth: user foo, password ***
702 698 Status: 200
703 699 Content-Length: 905 (git-server !)
@@ -778,9 +774,13 b' Revert will prefetch blobs in a group'
778 774 lfs: adding d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 to the usercache
779 775 lfs: processed: d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998
780 776 lfs: downloaded 3 files (51 bytes)
777 reverting b
781 778 lfs: found 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b in the local lfs store
779 reverting c
782 780 lfs: found d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 in the local lfs store
781 reverting d
783 782 lfs: found 37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19 in the local lfs store
783 adding a
784 784 lfs: found 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b in the local lfs store
785 785
786 786 Check error message when the remote missed a blob:
@@ -69,8 +69,8 b' Reverting foo1 and bar:'
69 69
70 70 $ hg revert -vr . foo1 bar
71 71 saving current version of bar as bar.orig
72 saving current version of foo1 as foo1.orig
72 73 reverting bar
73 saving current version of foo1 as foo1.orig
74 74 reverting foo1
75 75
76 76 $ hg debugstate --nodates
@@ -51,11 +51,8 b' 10 run the same test than 8 from within '
51 51 > n
52 52 > n
53 53 > EOF
54 reverting f
55 reverting folder1/g
54 remove added file folder1/i (Yn)? y
56 55 removing folder1/i
57 reverting folder2/h
58 remove added file folder1/i (Yn)? y
59 56 diff --git a/f b/f
60 57 2 hunks, 2 lines changed
61 58 examine changes to 'f'? [Ynesfdaq?] y
@@ -115,6 +112,8 b' 10 run the same test than 8 from within '
115 112 2 hunks, 2 lines changed
116 113 examine changes to 'folder2/h'? [Ynesfdaq?] n
117 114
115 reverting folder1/g
116 reverting f
118 117 $ cat f
119 118 1
120 119 2
@@ -140,8 +139,6 b' 10 run the same test than 8 from within '
140 139 Test that --interactive lift the need for --all
141 140
142 141 $ echo q | hg revert -i -r 2
143 reverting folder1/g
144 reverting folder2/h
145 142 diff --git a/folder1/g b/folder1/g
146 143 1 hunks, 1 lines changed
147 144 examine changes to 'folder1/g'? [Ynesfdaq?] q
@@ -197,10 +194,6 b' Test --no-backup'
197 194 > n
198 195 > n
199 196 > EOF
200 reverting f
201 reverting folder1/g
202 removing folder1/i
203 reverting folder2/h
204 197 remove added file folder1/i (Yn)? n
205 198 diff --git a/f b/f
206 199 2 hunks, 2 lines changed
@@ -250,6 +243,8 b' Test --no-backup'
250 243 2 hunks, 2 lines changed
251 244 examine changes to 'folder2/h'? [Ynesfdaq?] n
252 245
246 reverting folder1/g
247 reverting f
253 248 $ cat f
254 249 1
255 250 2
@@ -354,7 +349,6 b' 3) Use interactive revert with editing ('
354 349 > y
355 350 > e
356 351 > EOF
357 reverting k
358 352 diff --git a/k b/k
359 353 1 hunks, 2 lines changed
360 354 examine changes to 'k'? [Ynesfdaq?] y
@@ -365,6 +359,7 b' 3) Use interactive revert with editing ('
365 359 +2
366 360 discard this change to 'k'? [Ynesfdaq?] e
367 361
362 reverting k
368 363 $ cat k
369 364 42
370 365
@@ -378,15 +373,14 b' 3) Use interactive revert with editing ('
378 373 $ hg revert -i <<EOF
379 374 > n
380 375 > EOF
381 forgetting newfile
382 376 forget added file newfile (Yn)? n
383 377 $ hg status
384 378 A newfile
385 379 $ hg revert -i <<EOF
386 380 > y
387 381 > EOF
382 forget added file newfile (Yn)? y
388 383 forgetting newfile
389 forget added file newfile (Yn)? y
390 384 $ hg status
391 385 ? newfile
392 386
@@ -406,7 +400,6 b' When a line without EOL is selected duri'
406 400 > y
407 401 > y
408 402 > EOF
409 reverting a
410 403 diff --git a/a b/a
411 404 1 hunks, 1 lines changed
412 405 examine changes to 'a'? [Ynesfdaq?] y
@@ -417,6 +410,7 b' When a line without EOL is selected duri'
417 410 \ No newline at end of file
418 411 apply this change to 'a'? [Ynesfdaq?] y
419 412
413 reverting a
420 414 $ cat a
421 415 0
422 416
@@ -129,9 +129,9 b' revert to another revision (--rev)'
129 129 ----------------------------------
130 130
131 131 $ hg revert --all -r0
132 adding a
132 forgetting z
133 133 removing d
134 forgetting z
134 adding a
135 135
136 136 revert explicitly to parent (--rev)
137 137 -----------------------------------
@@ -283,8 +283,8 b' Issue332: confusing message when reverti'
283 283 $ echo foo > newdir/newfile
284 284 $ hg add newdir/newfile
285 285 $ hg revert b newdir
286 forgetting newdir/newfile
286 287 reverting b/b
287 forgetting newdir/newfile
288 288 $ echo foobar > b/b
289 289 $ hg revert .
290 290 reverting b/b
@@ -368,9 +368,9 b' copies and renames, you have no chance t'
368 368 $ hg update '.^'
369 369 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
370 370 $ hg revert -rtip -a
371 removing ignored
371 372 adding allyour
372 373 adding base
373 removing ignored
374 374 $ hg status -C
375 375 A allyour
376 376 ignored
@@ -790,28 +790,28 b' Test revert --all to parent content'
790 790 check revert output
791 791
792 792 $ hg revert --all
793 undeleting content1_content1_content1-untracked
794 reverting content1_content1_content3-tracked
795 undeleting content1_content1_content3-untracked
796 reverting content1_content1_missing-tracked
797 undeleting content1_content1_missing-untracked
798 reverting content1_content2_content1-tracked
799 undeleting content1_content2_content1-untracked
800 undeleting content1_content2_content2-untracked
801 reverting content1_content2_content3-tracked
802 undeleting content1_content2_content3-untracked
803 reverting content1_content2_missing-tracked
804 undeleting content1_content2_missing-untracked
805 793 forgetting content1_missing_content1-tracked
806 794 forgetting content1_missing_content3-tracked
807 795 forgetting content1_missing_missing-tracked
808 undeleting missing_content2_content2-untracked
809 reverting missing_content2_content3-tracked
810 undeleting missing_content2_content3-untracked
811 reverting missing_content2_missing-tracked
812 undeleting missing_content2_missing-untracked
813 796 forgetting missing_missing_content3-tracked
814 797 forgetting missing_missing_missing-tracked
798 reverting content1_content1_content3-tracked
799 reverting content1_content1_missing-tracked
800 reverting content1_content2_content1-tracked
801 reverting content1_content2_content3-tracked
802 reverting content1_content2_missing-tracked
803 reverting missing_content2_content3-tracked
804 reverting missing_content2_missing-tracked
805 undeleting content1_content1_content1-untracked
806 undeleting content1_content1_content3-untracked
807 undeleting content1_content1_missing-untracked
808 undeleting content1_content2_content1-untracked
809 undeleting content1_content2_content2-untracked
810 undeleting content1_content2_content3-untracked
811 undeleting content1_content2_missing-untracked
812 undeleting missing_content2_content2-untracked
813 undeleting missing_content2_content3-untracked
814 undeleting missing_content2_missing-untracked
815 815
816 816 Compare resulting directory with revert target.
817 817
@@ -847,28 +847,28 b' Test revert --all to "base" content'
847 847 check revert output
848 848
849 849 $ hg revert --all --rev 'desc(base)'
850 undeleting content1_content1_content1-untracked
851 reverting content1_content1_content3-tracked
852 undeleting content1_content1_content3-untracked
853 reverting content1_content1_missing-tracked
854 undeleting content1_content1_missing-untracked
855 undeleting content1_content2_content1-untracked
856 reverting content1_content2_content2-tracked
857 undeleting content1_content2_content2-untracked
858 reverting content1_content2_content3-tracked
859 undeleting content1_content2_content3-untracked
860 reverting content1_content2_missing-tracked
861 undeleting content1_content2_missing-untracked
862 adding content1_missing_content1-untracked
863 reverting content1_missing_content3-tracked
864 adding content1_missing_content3-untracked
865 reverting content1_missing_missing-tracked
866 adding content1_missing_missing-untracked
850 forgetting missing_missing_content3-tracked
851 forgetting missing_missing_missing-tracked
867 852 removing missing_content2_content2-tracked
868 853 removing missing_content2_content3-tracked
869 854 removing missing_content2_missing-tracked
870 forgetting missing_missing_content3-tracked
871 forgetting missing_missing_missing-tracked
855 reverting content1_content1_content3-tracked
856 reverting content1_content1_missing-tracked
857 reverting content1_content2_content2-tracked
858 reverting content1_content2_content3-tracked
859 reverting content1_content2_missing-tracked
860 reverting content1_missing_content3-tracked
861 reverting content1_missing_missing-tracked
862 adding content1_missing_content1-untracked
863 adding content1_missing_content3-untracked
864 adding content1_missing_missing-untracked
865 undeleting content1_content1_content1-untracked
866 undeleting content1_content1_content3-untracked
867 undeleting content1_content1_missing-untracked
868 undeleting content1_content2_content1-untracked
869 undeleting content1_content2_content2-untracked
870 undeleting content1_content2_content3-untracked
871 undeleting content1_content2_missing-untracked
872 872
873 873 Compare resulting directory with revert target.
874 874
@@ -1120,8 +1120,8 b' actual tests: reverting to something els'
1120 1120 M A
1121 1121 A B
1122 1122 $ hg revert --rev 1 --all
1123 removing B
1123 1124 reverting A
1124 removing B
1125 1125 $ hg status --rev 1
1126 1126
1127 1127 From the other parents
@@ -1140,8 +1140,8 b' From the other parents'
1140 1140 M A
1141 1141 A B
1142 1142 $ hg revert --rev 1 --all
1143 removing B
1143 1144 reverting A
1144 removing B
1145 1145 $ hg status --rev 1
1146 1146
1147 1147 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now