##// END OF EJS Templates
uncommit: add config option to keep commit by default...
Martin von Zweigbergk -
r41916:1040d54e default
parent child Browse files
Show More
@@ -44,6 +44,9 b' configitem = registrar.configitem(config'
44 configitem('experimental', 'uncommitondirtywdir',
44 configitem('experimental', 'uncommitondirtywdir',
45 default=False,
45 default=False,
46 )
46 )
47 configitem('experimental', 'uncommit.keep',
48 default=False,
49 )
47
50
48 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
51 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
49 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
52 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
@@ -136,7 +139,7 b' def _fixdirstate(repo, oldctx, newctx, m'
136 ds.copy(src, dst)
139 ds.copy(src, dst)
137
140
138 @command('uncommit',
141 @command('uncommit',
139 [('', 'keep', False, _('allow an empty commit after uncommiting')),
142 [('', 'keep', None, _('allow an empty commit after uncommiting')),
140 ] + commands.walkopts,
143 ] + commands.walkopts,
141 _('[OPTION]... [FILE]...'),
144 _('[OPTION]... [FILE]...'),
142 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
145 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
@@ -165,7 +168,12 b' def uncommit(ui, repo, *pats, **opts):'
165
168
166 with repo.transaction('uncommit'):
169 with repo.transaction('uncommit'):
167 match = scmutil.match(old, pats, opts)
170 match = scmutil.match(old, pats, opts)
168 keepcommit = opts.get('keep') or pats
171 keepcommit = pats
172 if not keepcommit:
173 if opts.get('keep') is not None:
174 keepcommit = opts.get('keep')
175 else:
176 keepcommit = ui.configbool('experimental', 'uncommit.keep')
169 newid = _commitfiltered(repo, old, match, keepcommit)
177 newid = _commitfiltered(repo, old, match, keepcommit)
170 if newid is None:
178 if newid is None:
171 ui.status(_("nothing to uncommit\n"))
179 ui.status(_("nothing to uncommit\n"))
@@ -307,7 +307,7 b' Partial uncommit with public parent'
307 $ hg phase -r ".^"
307 $ hg phase -r ".^"
308 12: public
308 12: public
309
309
310 Uncommit leaving an empty changeset
310 Uncommit with --keep or experimental.uncommit.keep leaves an empty changeset
311
311
312 $ cd $TESTTMP
312 $ cd $TESTTMP
313 $ hg init repo1
313 $ hg init repo1
@@ -327,9 +327,31 b' Uncommit leaving an empty changeset'
327 |/
327 |/
328 o P FILES: P
328 o P FILES: P
329
329
330 $ cat >> .hg/hgrc <<EOF
331 > [experimental]
332 > uncommit.keep=True
333 > EOF
334 $ hg ci --amend
335 $ hg uncommit
336 note: keeping empty commit
337 $ hg log -G -T '{desc} FILES: {files}'
338 @ Q FILES:
339 |
340 | x Q FILES: Q
341 |/
342 o P FILES: P
343
330 $ hg status
344 $ hg status
331 A Q
345 A Q
346 $ hg ci --amend
347 $ hg uncommit --no-keep
348 $ hg log -G -T '{desc} FILES: {files}'
349 x Q FILES: Q
350 |
351 @ P FILES: P
332
352
353 $ hg status
354 A Q
333 $ cd ..
355 $ cd ..
334 $ rm -rf repo1
356 $ rm -rf repo1
335
357
General Comments 0
You need to be logged in to leave comments. Login now