##// END OF EJS Templates
rewriteutil: use precheck() in uncommit and amend commands...
Pulkit Goyal -
r35244:98f97eb2 default
parent child Browse files
Show More
@@ -28,10 +28,10 b' from mercurial import ('
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
@@ -155,23 +155,14 b' def uncommit(ui, repo, *pats, **opts):'
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)
@@ -49,6 +49,7 b' from . import ('
49 rcutil,
49 rcutil,
50 registrar,
50 registrar,
51 revsetlang,
51 revsetlang,
52 rewriteutil,
52 scmutil,
53 scmutil,
53 server,
54 server,
54 sshserver,
55 sshserver,
@@ -1541,13 +1542,7 b' def _docommit(ui, repo, *pats, **opts):'
1541 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1542 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1542
1543
1543 old = repo['.']
1544 old = repo['.']
1544 if not old.mutable():
1545 rewriteutil.precheck(repo, [old.rev()], 'amend')
1545 raise error.Abort(_('cannot amend public changesets'))
1546 if len(repo[None].parents()) > 1:
1547 raise error.Abort(_('cannot amend while merging'))
1548 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1549 if not allowunstable and old.children():
1550 raise error.Abort(_('cannot amend changeset with children'))
1551
1546
1552 # Currently histedit gets confused if an amend happens while histedit
1547 # Currently histedit gets confused if an amend happens while histedit
1553 # is in progress. Since we have a checkunfinished command, we are
1548 # is in progress. Since we have a checkunfinished command, we are
@@ -213,6 +213,7 b' Cannot amend public changeset'
213 $ hg update -C -q A
213 $ hg update -C -q A
214 $ hg amend -m AMEND
214 $ hg amend -m AMEND
215 abort: cannot amend public changesets
215 abort: cannot amend public changesets
216 (see 'hg help phases' for details)
216 [255]
217 [255]
217
218
218 Amend a merge changeset
219 Amend a merge changeset
@@ -16,6 +16,7 b' Refuse to amend public csets:'
16 $ hg phase -r . -p
16 $ hg phase -r . -p
17 $ hg ci --amend
17 $ hg ci --amend
18 abort: cannot amend public changesets
18 abort: cannot amend public changesets
19 (see 'hg help phases' for details)
19 [255]
20 [255]
20 $ hg phase -r . -f -d
21 $ hg phase -r . -f -d
21
22
@@ -41,6 +41,7 b' Uncommit with no commits should fail'
41
41
42 $ hg uncommit
42 $ hg uncommit
43 abort: cannot uncommit null changeset
43 abort: cannot uncommit null changeset
44 (no changeset checked out)
44 [255]
45 [255]
45
46
46 Create some commits
47 Create some commits
General Comments 0
You need to be logged in to leave comments. Login now