Submitter | Augie Fackler |
---|---|
Date | May 5, 2016, 3:42 a.m. |
Message ID | <62ae5d974b76b3e61749.1462419745@139.17.16.172.in-addr.arpa> |
Download | mbox | patch |
Permalink | /patch/14892/ |
State | Accepted |
Headers | show |
Comments
Augie Fackler <raf@durin42.com> writes: > # HG changeset patch > # User Augie Fackler <augie@google.com> > # Date 1462307605 14400 > # Tue May 03 16:33:25 2016 -0400 > # Node ID 62ae5d974b76b3e61749fe89f11ae3bb176f487b > # Parent 906a1c8a75fd8a18e43e8545eedcbe5222f84647 > rollback: add a config knob for entirely disabling the command > > This is of pretty high value for organizations that used to use p4 (as > an example), since `p4 rollback` is what we call `hg backout`. Looks good to me.
On 05/06/2016 06:22 AM, Kevin Bullock wrote: >> On May 4, 2016, at 22:42, Augie Fackler <raf@durin42.com> wrote: >> >> # HG changeset patch >> # User Augie Fackler <augie@google.com> >> # Date 1462307605 14400 >> # Tue May 03 16:33:25 2016 -0400 >> # Node ID 62ae5d974b76b3e61749fe89f11ae3bb176f487b >> # Parent 906a1c8a75fd8a18e43e8545eedcbe5222f84647 >> rollback: add a config knob for entirely disabling the command > Probably should've been done years ago. Pushed to -committed! Hooray for having the flag. While keeping in mind than "deprecated" does not mean "flagged for removal" it might still be a good idea to eventually disable 'hg rollback'. As Greg pointed, it can lead to unrecoverable data loss and as Sean pointed out, we did it in the past for small thing like 'hg strip -b'. An extra element to take in account is that the actual result of 'hg rollback' have been shifting a lot in the past years as more and more things are using transaction. So scripting using 'hg rollback' might have already broke multiple times (especially if they do a lot of local operation, pull should be fine, push is not). I'm not saying we should do it, but I think there might be some room to think about it if someone is willing to make a full analysis. In all case, getting this flag was a necessary first step.
Patch
diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -6380,6 +6380,11 @@ def rollback(ui, repo, **opts): commit transaction if it isn't checked out. Use --force to override this protection. + The rollback command can be entirely disabled by setting the + ``ui.rollback`` configuration setting to false. If you're here + because you want to use rollback and it's disabled, you can + re-enable the command by setting ``ui.rollback`` to true. + This command is not intended for use on public repositories. Once changes are visible for pull by other users, rolling a transaction back locally is ineffective (someone else may already have pulled @@ -6389,6 +6394,9 @@ def rollback(ui, repo, **opts): Returns 0 on success, 1 if no rollback data is available. """ + if not ui.configbool('ui', 'rollback', True): + raise error.Abort(_('rollback is disabled because it is unsafe'), + hint=('see `hg help -v rollback` for information')) return repo.rollback(dryrun=opts.get('dry_run'), force=opts.get('force')) diff --git a/tests/test-rollback.t b/tests/test-rollback.t --- a/tests/test-rollback.t +++ b/tests/test-rollback.t @@ -196,3 +196,15 @@ corrupt journal test checking files 1 files, 2 changesets, 2 total revisions +rollback disabled by config + $ cat >> $HGRCPATH <<EOF + > [ui] + > rollback = false + > EOF + $ echo narf >> pinky-sayings.txt + $ hg add pinky-sayings.txt + $ hg ci -m 'First one.' + $ hg rollback + abort: rollback is disabled because it is unsafe + (see `hg help -v rollback` for information) + [255]