Show More
@@ -47,6 +47,9 b' configitem = registrar.configitem(config' | |||||
47 | configitem('experimental', 'uncommitondirtywdir', |
|
47 | configitem('experimental', 'uncommitondirtywdir', | |
48 | default=False, |
|
48 | default=False, | |
49 | ) |
|
49 | ) | |
|
50 | configitem('experimental', 'uncommit.keep', | |||
|
51 | default=False, | |||
|
52 | ) | |||
50 |
|
53 | |||
51 | stringio = util.stringio |
|
54 | stringio = util.stringio | |
52 |
|
55 | |||
@@ -240,7 +243,7 b' def _uncommitdirstate(repo, oldctx, matc' | |||||
240 |
|
243 | |||
241 | @command('uncommit', |
|
244 | @command('uncommit', | |
242 | [('i', 'interactive', False, _('interactive mode to uncommit')), |
|
245 | [('i', 'interactive', False, _('interactive mode to uncommit')), | |
243 |
('', 'keep', |
|
246 | ('', 'keep', None, _('allow an empty commit after uncommiting')), | |
244 | ] + commands.walkopts, |
|
247 | ] + commands.walkopts, | |
245 | _('[OPTION]... [FILE]...'), |
|
248 | _('[OPTION]... [FILE]...'), | |
246 | helpcategory=command.CATEGORY_CHANGE_MANAGEMENT) |
|
249 | helpcategory=command.CATEGORY_CHANGE_MANAGEMENT) | |
@@ -270,7 +273,12 b' def uncommit(ui, repo, *pats, **opts):' | |||||
270 |
|
273 | |||
271 | with repo.transaction('uncommit'): |
|
274 | with repo.transaction('uncommit'): | |
272 | match = scmutil.match(old, pats, opts) |
|
275 | match = scmutil.match(old, pats, opts) | |
273 |
keepcommit = |
|
276 | keepcommit = pats | |
|
277 | if not keepcommit: | |||
|
278 | if opts.get('keep') is not None: | |||
|
279 | keepcommit = opts.get('keep') | |||
|
280 | else: | |||
|
281 | keepcommit = ui.configbool('experimental', 'uncommit.keep') | |||
274 | newid = _commitfiltered(repo, old, match, keepcommit) |
|
282 | newid = _commitfiltered(repo, old, match, keepcommit) | |
275 | if interactive: |
|
283 | if interactive: | |
276 | match = scmutil.match(old, pats, opts) |
|
284 | match = scmutil.match(old, pats, opts) |
@@ -308,7 +308,7 b' Partial uncommit with public parent' | |||||
308 | $ hg phase -r ".^" |
|
308 | $ hg phase -r ".^" | |
309 | 12: public |
|
309 | 12: public | |
310 |
|
310 | |||
311 | Uncommit leaving an empty changeset |
|
311 | Uncommit with --keep or experimental.uncommit.keep leaves an empty changeset | |
312 |
|
312 | |||
313 | $ cd $TESTTMP |
|
313 | $ cd $TESTTMP | |
314 | $ hg init repo1 |
|
314 | $ hg init repo1 | |
@@ -328,9 +328,31 b' Uncommit leaving an empty changeset' | |||||
328 | |/ |
|
328 | |/ | |
329 | o P FILES: P |
|
329 | o P FILES: P | |
330 |
|
330 | |||
|
331 | $ cat >> .hg/hgrc <<EOF | |||
|
332 | > [experimental] | |||
|
333 | > uncommit.keep=True | |||
|
334 | > EOF | |||
|
335 | $ hg ci --amend | |||
|
336 | $ hg uncommit | |||
|
337 | note: keeping empty commit | |||
|
338 | $ hg log -G -T '{desc} FILES: {files}' | |||
|
339 | @ Q FILES: | |||
|
340 | | | |||
|
341 | | x Q FILES: Q | |||
|
342 | |/ | |||
|
343 | o P FILES: P | |||
|
344 | ||||
331 | $ hg status |
|
345 | $ hg status | |
332 | A Q |
|
346 | A Q | |
333 |
|
347 | $ hg ci --amend | ||
|
348 | $ hg uncommit --no-keep | |||
|
349 | $ hg log -G -T '{desc} FILES: {files}' | |||
|
350 | x Q FILES: Q | |||
|
351 | | | |||
|
352 | @ P FILES: P | |||
|
353 | ||||
|
354 | $ hg status | |||
|
355 | A Q | |||
334 | $ cd .. |
|
356 | $ cd .. | |
335 | $ rm -rf repo1 |
|
357 | $ rm -rf repo1 | |
336 |
|
358 |
General Comments 0
You need to be logged in to leave comments.
Login now