comparison hgext/uncommit.py @ 41860:aa284d9a33ca

uncommit: add flag --allow-dirty-working-copy This adds a flag `--allow-dirty-working-copy` as an alias for the experimental config option `experimental.uncommitondirtydir`. Differential Revision: https://phab.mercurial-scm.org/D6069
author Navaneeth Suresh <navaneeths1998@gmail.com>
date Mon, 04 Mar 2019 20:18:13 +0530
parents bf22e370ae9a
children bf72e4c39f0b
comparison
equal deleted inserted replaced
41859:bf22e370ae9a 41860:aa284d9a33ca
138 src = None 138 src = None
139 ds.copy(src, dst) 139 ds.copy(src, dst)
140 140
141 @command('uncommit', 141 @command('uncommit',
142 [('', 'keep', None, _('allow an empty commit after uncommiting')), 142 [('', 'keep', None, _('allow an empty commit after uncommiting')),
143 ('', 'allow-dirty-working-copy', False,
144 _('allow uncommit with outstanding changes'))
143 ] + commands.walkopts, 145 ] + commands.walkopts,
144 _('[OPTION]... [FILE]...'), 146 _('[OPTION]... [FILE]...'),
145 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT) 147 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
146 def uncommit(ui, repo, *pats, **opts): 148 def uncommit(ui, repo, *pats, **opts):
147 """uncommit part or all of a local changeset 149 """uncommit part or all of a local changeset
158 160
159 with repo.wlock(), repo.lock(): 161 with repo.wlock(), repo.lock():
160 162
161 m, a, r, d = repo.status()[:4] 163 m, a, r, d = repo.status()[:4]
162 isdirtypath = any(set(m + a + r + d) & set(pats)) 164 isdirtypath = any(set(m + a + r + d) & set(pats))
163 if (not repo.ui.configbool('experimental', 'uncommitondirtywdir') and 165 allowdirtywcopy = (opts['allow_dirty_working_copy'] or
164 (not pats or isdirtypath)): 166 repo.ui.configbool('experimental', 'uncommitondirtywdir'))
167 if not allowdirtywcopy and (not pats or isdirtypath):
165 cmdutil.bailifchanged(repo, hint=_('requires ' 168 cmdutil.bailifchanged(repo, hint=_('requires '
166 'experimental.uncommitondirtywdir to uncommit')) 169 '--allow-dirty-working-copy to uncommit'))
167 old = repo['.'] 170 old = repo['.']
168 rewriteutil.precheck(repo, [old.rev()], 'uncommit') 171 rewriteutil.precheck(repo, [old.rev()], 'uncommit')
169 if len(old.parents()) > 1: 172 if len(old.parents()) > 1:
170 raise error.Abort(_("cannot uncommit merge changeset")) 173 raise error.Abort(_("cannot uncommit merge changeset"))
171 174