Mercurial > hg-stable
comparison hgext/uncommit.py @ 35253:98f97eb20597
rewriteutil: use precheck() in uncommit and amend commands
Differential Revision: https://phab.mercurial-scm.org/D1526
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Tue, 28 Nov 2017 05:50:45 +0530 |
parents | 9e339c97fabb |
children | 8a0cac20a1ad |
comparison
equal
deleted
inserted
replaced
35252:490df753894d | 35253:98f97eb20597 |
---|---|
26 commands, | 26 commands, |
27 context, | 27 context, |
28 copies, | 28 copies, |
29 error, | 29 error, |
30 node, | 30 node, |
31 obsolete, | |
32 obsutil, | 31 obsutil, |
33 pycompat, | 32 pycompat, |
34 registrar, | 33 registrar, |
34 rewriteutil, | |
35 scmutil, | 35 scmutil, |
36 ) | 36 ) |
37 | 37 |
38 cmdtable = {} | 38 cmdtable = {} |
39 command = registrar.command(cmdtable) | 39 command = registrar.command(cmdtable) |
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: |