Patchwork [v3] rollback: add a config knob for entirely disabling the command

login
register
mail settings
Submitter Augie Fackler
Date May 4, 2016, 3:03 p.m.
Message ID <689b8a0a3c5e32e8c7b1.1462374189@imladris.local>
Download mbox | patch
Permalink /patch/14881/
State Superseded
Headers show

Comments

Augie Fackler - May 4, 2016, 3:03 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1462307605 14400
#      Tue May 03 16:33:25 2016 -0400
# Node ID 689b8a0a3c5e32e8c7b1358b51fd87d69207973c
# Parent  8eba4cdcfd810d80785c94d770a442c5bd1f9d0f
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`.
Adrian Buehlmann - May 4, 2016, 4:53 p.m.
On 2016-05-04 17:03, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1462307605 14400
> #      Tue May 03 16:33:25 2016 -0400
> # Node ID 689b8a0a3c5e32e8c7b1358b51fd87d69207973c
> # Parent  8eba4cdcfd810d80785c94d770a442c5bd1f9d0f
> 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`.
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -6377,6 +6377,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 using the
> +      ``ui.norollback`` configuration setting. If you're here because
> +      you want to use rollback and it's disabled, you can re-enable
> +      the command by setting ``ui.norollback`` 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
> @@ -6386,6 +6391,9 @@ def rollback(ui, repo, **opts):
>  
>      Returns 0 on success, 1 if no rollback data is available.
>      """
> +    if ui.configbool('ui', 'norollback', False):
> +        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]
> +  > norollback = true
> +  > 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]

I don't really care that much myself, but why don't you add

   ui.rollback

with a default value of True?

Users who want to disable that command could then specify

   [ui]
   rollback = false

In a future release, the default could be changed to False.
Augie Fackler - May 4, 2016, 4:55 p.m.
(+ a couple of people that seem to be reliable UX oracles)
> On May 4, 2016, at 12:53, Adrian Buehlmann <adrian@cadifra.com> wrote:
> 
> On 2016-05-04 17:03, Augie Fackler wrote:
>> # HG changeset patch
>> # User Augie Fackler <augie@google.com>
>> # Date 1462307605 14400
>> #      Tue May 03 16:33:25 2016 -0400
>> # Node ID 689b8a0a3c5e32e8c7b1358b51fd87d69207973c
>> # Parent  8eba4cdcfd810d80785c94d770a442c5bd1f9d0f
>> 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 blackout`.

[snip]

>> +  [255]
> 
> I don't really care that much myself, but why don't you add
> 
>   ui.rollback
> 
> with a default value of True?
> 
> Users who want to disable that command could then specify
> 
>   [ui]
>   rollback = false
> 
> In a future release, the default could be changed to False.

Ooh, nice. That avoids the slightly confusing double-negative as well. If I don't hear any objections in the next couple of hours, I'll roll a v4 with that version of things.

Thanks!

> 
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Sean Farley - May 4, 2016, 9:50 p.m.
Augie Fackler <raf@durin42.com> writes:

> (+ a couple of people that seem to be reliable UX oracles)
>> On May 4, 2016, at 12:53, Adrian Buehlmann <adrian@cadifra.com> wrote:
>> 
>> On 2016-05-04 17:03, Augie Fackler wrote:
>>> # HG changeset patch
>>> # User Augie Fackler <augie@google.com>
>>> # Date 1462307605 14400
>>> #      Tue May 03 16:33:25 2016 -0400
>>> # Node ID 689b8a0a3c5e32e8c7b1358b51fd87d69207973c
>>> # Parent  8eba4cdcfd810d80785c94d770a442c5bd1f9d0f
>>> 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 blackout`.
>
> [snip]
>
>>> +  [255]
>> 
>> I don't really care that much myself, but why don't you add
>> 
>>   ui.rollback
>> 
>> with a default value of True?
>> 
>> Users who want to disable that command could then specify
>> 
>>   [ui]
>>   rollback = false
>> 
>> In a future release, the default could be changed to False.
>
> Ooh, nice. That avoids the slightly confusing double-negative as well. If I don't hear any objections in the next couple of hours, I'll roll a v4 with that version of things.

I like this suggestion (double negatives are really confusing to me and
maybe foreign speakers).

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6377,6 +6377,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 using the
+      ``ui.norollback`` configuration setting. If you're here because
+      you want to use rollback and it's disabled, you can re-enable
+      the command by setting ``ui.norollback`` 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
@@ -6386,6 +6391,9 @@  def rollback(ui, repo, **opts):
 
     Returns 0 on success, 1 if no rollback data is available.
     """
+    if ui.configbool('ui', 'norollback', False):
+        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]
+  > norollback = true
+  > 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]