153 modified in the working directory. |
153 modified in the working directory. |
154 """ |
154 """ |
155 opts = pycompat.byteskwargs(opts) |
155 opts = pycompat.byteskwargs(opts) |
156 |
156 |
157 with repo.wlock(), repo.lock(): |
157 with repo.wlock(), repo.lock(): |
158 wctx = repo[None] |
|
159 |
158 |
160 if not pats and not repo.ui.configbool('experimental', |
159 if not pats and not repo.ui.configbool('experimental', |
161 'uncommitondirtywdir'): |
160 'uncommitondirtywdir'): |
162 cmdutil.bailifchanged(repo) |
161 cmdutil.bailifchanged(repo) |
163 if wctx.parents()[0].node() == node.nullid: |
|
164 raise error.Abort(_("cannot uncommit null changeset")) |
|
165 if len(wctx.parents()) > 1: |
|
166 raise error.Abort(_("cannot uncommit while merging")) |
|
167 old = repo['.'] |
162 old = repo['.'] |
168 if not old.mutable(): |
163 rewriteutil.precheck(repo, [old.rev()], 'uncommit') |
169 raise error.Abort(_('cannot uncommit public changesets')) |
|
170 if len(old.parents()) > 1: |
164 if len(old.parents()) > 1: |
171 raise error.Abort(_("cannot uncommit merge changeset")) |
165 raise error.Abort(_("cannot uncommit merge changeset")) |
172 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt) |
|
173 if not allowunstable and old.children(): |
|
174 raise error.Abort(_('cannot uncommit changeset with children')) |
|
175 |
166 |
176 with repo.transaction('uncommit'): |
167 with repo.transaction('uncommit'): |
177 match = scmutil.match(old, pats, opts) |
168 match = scmutil.match(old, pats, opts) |
178 newid = _commitfiltered(repo, old, match, opts.get('keep')) |
169 newid = _commitfiltered(repo, old, match, opts.get('keep')) |
179 if newid is None: |
170 if newid is None: |