150 If no files are specified, the commit will be pruned, unless --keep is |
150 If no files are specified, the commit will be pruned, unless --keep is |
151 given. |
151 given. |
152 """ |
152 """ |
153 cmdutil.check_note_size(opts) |
153 cmdutil.check_note_size(opts) |
154 cmdutil.resolve_commit_options(ui, opts) |
154 cmdutil.resolve_commit_options(ui, opts) |
155 opts = pycompat.byteskwargs(opts) |
|
156 |
155 |
157 with repo.wlock(), repo.lock(): |
156 with repo.wlock(), repo.lock(): |
158 |
157 |
159 st = repo.status() |
158 st = repo.status() |
160 m, a, r, d = st.modified, st.added, st.removed, st.deleted |
159 m, a, r, d = st.modified, st.added, st.removed, st.deleted |
161 isdirtypath = any(set(m + a + r + d) & set(pats)) |
160 isdirtypath = any(set(m + a + r + d) & set(pats)) |
162 allowdirtywcopy = opts[ |
161 allowdirtywcopy = opts[ |
163 b'allow_dirty_working_copy' |
162 'allow_dirty_working_copy' |
164 ] or repo.ui.configbool(b'experimental', b'uncommitondirtywdir') |
163 ] or repo.ui.configbool(b'experimental', b'uncommitondirtywdir') |
165 if not allowdirtywcopy and (not pats or isdirtypath): |
164 if not allowdirtywcopy and (not pats or isdirtypath): |
166 cmdutil.bailifchanged( |
165 cmdutil.bailifchanged( |
167 repo, |
166 repo, |
168 hint=_(b'requires --allow-dirty-working-copy to uncommit'), |
167 hint=_(b'requires --allow-dirty-working-copy to uncommit'), |
170 old = repo[b'.'] |
169 old = repo[b'.'] |
171 rewriteutil.precheck(repo, [old.rev()], b'uncommit') |
170 rewriteutil.precheck(repo, [old.rev()], b'uncommit') |
172 if len(old.parents()) > 1: |
171 if len(old.parents()) > 1: |
173 raise error.InputError(_(b"cannot uncommit merge changeset")) |
172 raise error.InputError(_(b"cannot uncommit merge changeset")) |
174 |
173 |
175 match = scmutil.match(old, pats, opts) |
174 match = scmutil.match(old, pats, pycompat.byteskwargs(opts)) |
176 |
175 |
177 # Check all explicitly given files; abort if there's a problem. |
176 # Check all explicitly given files; abort if there's a problem. |
178 if match.files(): |
177 if match.files(): |
179 s = old.status(old.p1(), match, listclean=True) |
178 s = old.status(old.p1(), match, listclean=True) |
180 eligible = set(s.added) | set(s.modified) | set(s.removed) |
179 eligible = set(s.added) | set(s.modified) | set(s.removed) |
201 _(b'cannot uncommit "%s"') % scmutil.getuipathfn(repo)(f), |
200 _(b'cannot uncommit "%s"') % scmutil.getuipathfn(repo)(f), |
202 hint=hint, |
201 hint=hint, |
203 ) |
202 ) |
204 |
203 |
205 with repo.transaction(b'uncommit'): |
204 with repo.transaction(b'uncommit'): |
206 if not (opts[b'message'] or opts[b'logfile']): |
205 if not (opts['message'] or opts['logfile']): |
207 opts[b'message'] = old.description() |
206 opts['message'] = old.description() |
208 message = cmdutil.logmessage(ui, opts) |
207 message = cmdutil.logmessage(ui, pycompat.byteskwargs(opts)) |
209 |
208 |
210 keepcommit = pats |
209 keepcommit = pats |
211 if not keepcommit: |
210 if not keepcommit: |
212 if opts.get(b'keep') is not None: |
211 if opts.get('keep') is not None: |
213 keepcommit = opts.get(b'keep') |
212 keepcommit = opts.get('keep') |
214 else: |
213 else: |
215 keepcommit = ui.configbool( |
214 keepcommit = ui.configbool( |
216 b'experimental', b'uncommit.keep' |
215 b'experimental', b'uncommit.keep' |
217 ) |
216 ) |
218 newid = _commitfiltered( |
217 newid = _commitfiltered( |
219 repo, |
218 repo, |
220 old, |
219 old, |
221 match, |
220 match, |
222 keepcommit, |
221 keepcommit, |
223 message=message, |
222 message=message, |
224 user=opts.get(b'user'), |
223 user=opts.get('user'), |
225 date=opts.get(b'date'), |
224 date=opts.get('date'), |
226 ) |
225 ) |
227 if newid is None: |
226 if newid is None: |
228 ui.status(_(b"nothing to uncommit\n")) |
227 ui.status(_(b"nothing to uncommit\n")) |
229 return 1 |
228 return 1 |
230 |
229 |