##// END OF EJS Templates
amend: update .hgsubstate before committing a memctx (issue5677)...
Yuya Nishihara -
r35019:691524f0 stable
parent child Browse files
Show More
@@ -3153,6 +3153,18 b' def amend(ui, repo, old, extra, pats, op'
3153 raise error.Abort(
3153 raise error.Abort(
3154 _("failed to mark all new/missing files as added/removed"))
3154 _("failed to mark all new/missing files as added/removed"))
3155
3155
3156 # Check subrepos. This depends on in-place wctx._status update in
3157 # subrepo.precommit(). To minimize the risk of this hack, we do
3158 # nothing if .hgsub does not exist.
3159 if '.hgsub' in wctx or '.hgsub' in old:
3160 from . import subrepo # avoid cycle: cmdutil -> subrepo -> cmdutil
3161 subs, commitsubs, newsubstate = subrepo.precommit(
3162 ui, wctx, wctx._status, matcher)
3163 # amend should abort if commitsubrepos is enabled
3164 assert not commitsubs
3165 if subs:
3166 subrepo.writestate(repo, newsubstate)
3167
3156 filestoamend = set(f for f in wctx.files() if matcher(f))
3168 filestoamend = set(f for f in wctx.files() if matcher(f))
3157
3169
3158 changes = (len(filestoamend) > 0)
3170 changes = (len(filestoamend) > 0)
@@ -31,28 +31,18 b' Link first subrepo'
31
31
32 amend without .hgsub
32 amend without .hgsub
33
33
34 BROKEN: should say "can't commit subrepos without .hgsub"
35 $ hg amend s
34 $ hg amend s
36 nothing changed
35 abort: can't commit subrepos without .hgsub
37 [1]
36 [255]
38
37
39 amend with subrepo
38 amend with subrepo
40
39
41 BROKEN: should update .hgsubstate
42 $ hg amend
40 $ hg amend
43 saved backup bundle to * (glob) (obsstore-off !)
41 saved backup bundle to * (glob) (obsstore-off !)
44 $ hg status --change .
42 $ hg status --change .
45 A .hgsub
43 A .hgsub
44 A .hgsubstate
46 A a
45 A a
47
48 FIX UP .hgsubstate
49
50 $ hg ci -mfix
51 $ hg rollback -q
52 $ hg add .hgsubstate
53 $ hg amend
54 saved backup bundle to * (glob) (obsstore-off !)
55
56 $ cat .hgsubstate
46 $ cat .hgsubstate
57 0000000000000000000000000000000000000000 s
47 0000000000000000000000000000000000000000 s
58
48
@@ -69,46 +59,27 b' amend with dirty subrepo'
69 $ echo a >> s/a
59 $ echo a >> s/a
70 $ hg add -R s
60 $ hg add -R s
71 adding s/a
61 adding s/a
72 BROKEN: should say "uncommitted changes in subrepository"
73 $ hg amend
62 $ hg amend
74 nothing changed
63 abort: uncommitted changes in subrepository "s"
75 [1]
64 (use --subrepos for recursive commit)
65 [255]
76
66
77 amend with modified subrepo
67 amend with modified subrepo
78
68
79 $ hg ci -R s -m0
69 $ hg ci -R s -m0
80 BROKEN: should update .hgsubstate
81 $ hg amend
82 nothing changed
83 [1]
84 $ hg status --change .
85 M a
86
87 FIX UP .hgsubstate
88
89 $ hg ci -mfix
90 $ hg rollback -q
91 $ hg amend
70 $ hg amend
92 saved backup bundle to * (glob) (obsstore-off !)
71 saved backup bundle to * (glob) (obsstore-off !)
93
72 $ hg status --change .
73 M .hgsubstate
74 M a
94 $ cat .hgsubstate
75 $ cat .hgsubstate
95 f7b1eb17ad24730a1651fccd46c43826d1bbc2ac s
76 f7b1eb17ad24730a1651fccd46c43826d1bbc2ac s
96
77
97 revert subrepo change
78 revert subrepo change
98
79
99 $ hg up -R s -q null
80 $ hg up -R s -q null
100 BROKEN: should update .hgsubstate
101 $ hg amend
102 nothing changed
103 [1]
104
105 FIX UP .hgsubstate
106
107 $ hg ci -mfix
108 $ hg rollback -q
109 $ hg amend
81 $ hg amend
110 saved backup bundle to * (glob) (obsstore-off !)
82 saved backup bundle to * (glob) (obsstore-off !)
111
112 $ hg status --change .
83 $ hg status --change .
113 M a
84 M a
114
85
@@ -131,21 +102,13 b' amend with another subrepo'
131 $ hg ci -R t -Am0
102 $ hg ci -R t -Am0
132 adding b
103 adding b
133 $ echo 't = t' >> .hgsub
104 $ echo 't = t' >> .hgsub
134 BROKEN: should update .hgsubstate
135 $ hg amend
105 $ hg amend
136 saved backup bundle to * (glob) (obsstore-off !)
106 saved backup bundle to * (glob) (obsstore-off !)
137 $ hg status --change .
107 $ hg status --change .
138 M .hgsub
108 M .hgsub
109 M .hgsubstate
139 M a
110 M a
140 A b
111 A b
141
142 FIX UP .hgsubstate
143
144 $ hg ci -mfix
145 $ hg rollback -q
146 $ hg amend
147 saved backup bundle to * (glob) (obsstore-off !)
148
149 $ cat .hgsubstate
112 $ cat .hgsubstate
150 0000000000000000000000000000000000000000 s
113 0000000000000000000000000000000000000000 s
151 bfb1a4fb358498a9533dabf4f2043d94162f1fcd t
114 bfb1a4fb358498a9533dabf4f2043d94162f1fcd t
@@ -161,23 +124,12 b' add new commit to be amended'
161 amend with one subrepo dropped
124 amend with one subrepo dropped
162
125
163 $ echo 't = t' > .hgsub
126 $ echo 't = t' > .hgsub
164 BROKEN: should update .hgsubstate
165 $ hg amend
127 $ hg amend
166 saved backup bundle to * (glob) (obsstore-off !)
128 saved backup bundle to * (glob) (obsstore-off !)
167 $ hg status --change .
129 $ hg status --change .
168 M .hgsub
130 M .hgsub
131 M .hgsubstate
169 M a
132 M a
170
171 FIX UP .hgsubstate
172
173 $ echo 's = s' > .hgsub
174 $ hg amend -q
175 $ echo 't = t' > .hgsub
176 $ hg ci -mfix
177 $ hg rollback -q
178 $ hg amend
179 saved backup bundle to * (glob) (obsstore-off !)
180
181 $ cat .hgsubstate
133 $ cat .hgsubstate
182 bfb1a4fb358498a9533dabf4f2043d94162f1fcd t
134 bfb1a4fb358498a9533dabf4f2043d94162f1fcd t
183
135
@@ -192,22 +144,11 b' add new commit to be amended'
192 amend with .hgsub removed
144 amend with .hgsub removed
193
145
194 $ hg rm .hgsub
146 $ hg rm .hgsub
195 BROKEN: should update .hgsubstate
196 $ hg amend
147 $ hg amend
197 saved backup bundle to * (glob) (obsstore-off !)
148 saved backup bundle to * (glob) (obsstore-off !)
198 $ hg status --change .
149 $ hg status --change .
199 M a
150 M a
200 R .hgsub
151 R .hgsub
201
202 FIX UP .hgsubstate
203
204 $ hg forget .hgsubstate
205 $ hg amend
206 saved backup bundle to * (glob) (obsstore-off !)
207
208 $ hg status --change .
209 M a
210 R .hgsub
211 R .hgsubstate
152 R .hgsubstate
212
153
213 $ cd ..
154 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now