D3988: resolve: add confirm config option

2018-08-03 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> martinvonz wrote in configitems.py:193
> Is this name too generic? It's specifically for confirming re-resolve with 
> `--all`. I can imagine having confirmation for marking files as resolved and 
> I'm not sure we'd want to share the config option if we ever added such a 
> feature. It might also make the name clearer if it was something like 
> `resolve.confirmreresolve` or `resolve.confirmredo` or 
> `resolve.confirmoverwrite`.

For now, yes the name is generic. My plan with @khanchi97 on this is to respect 
this option with other flags too. Like `hg resolve -m` will ask before marking 
as resolve if this config option is set.

Once we are done with other flags too, this won't sound generic.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3988

To: khanchi97, #hg-reviewers, pulkit
Cc: martinvonz, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3988: resolve: add confirm config option

2018-08-03 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> configitems.py:193
>  )
> +coreconfigitem('commands', 'resolve.confirm',
> +default=False,

Is this name too generic? It's specifically for confirming re-resolve with 
`--all`. I can imagine having confirmation for marking files as resolved and 
I'm not sure we'd want to share the config option if we ever added such a 
feature. It might also make the name clearer if it was something like 
`resolve.confirmreresolve` or `resolve.confirmredo` or 
`resolve.confirmoverwrite`.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3988

To: khanchi97, #hg-reviewers, pulkit
Cc: martinvonz, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3988: resolve: add confirm config option

2018-08-03 Thread khanchi97 (Sushil khanchi)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf8732e33bcbc: resolve: add confirm config option (authored 
by khanchi97, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D3988?vs=9816=9823#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3988?vs=9816=9823

REVISION DETAIL
  https://phab.mercurial-scm.org/D3988

AFFECTED FILES
  mercurial/commands.py
  mercurial/configitems.py
  mercurial/help/config.txt
  tests/test-resolve.t

CHANGE DETAILS

diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -423,3 +423,92 @@
   R file2
 
   $ cd ..
+
+==
+Test 'hg resolve' confirm config option functionality |
+==
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > rebase=
+  > EOF
+
+  $ hg init repo2
+  $ cd repo2
+
+  $ echo boss > boss
+  $ hg ci -Am "add boss"
+  adding boss
+
+  $ for emp in emp1 emp2 emp3; do echo work > $emp; done;
+  $ hg ci -Aqm "added emp1 emp2 emp3"
+
+  $ hg up 0
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+
+  $ for emp in emp1 emp2 emp3; do echo nowork > $emp; done;
+  $ hg ci -Aqm "added lazy emp1 emp2 emp3"
+
+  $ hg log -GT "{rev} {node|short} {firstline(desc)}\n"
+  @  2 0acfd4a49af0 added lazy emp1 emp2 emp3
+  |
+  | o  1 f30f98a8181f added emp1 emp2 emp3
+  |/
+  o  0 88660038d466 add boss
+  
+  $ hg rebase -s 1 -d 2
+  rebasing 1:f30f98a8181f "added emp1 emp2 emp3"
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+
+Test when commands.resolve.confirm config option is not set:
+===
+  $ hg resolve --all
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  [1]
+
+Test when config option is set:
+==
+  $ cat >> $HGRCPATH << EOF
+  > [ui]
+  > interactive = True
+  > [commands]
+  > resolve.confirm = True
+  > EOF
+
+  $ hg resolve
+  abort: no files or directories specified
+  (use --all to re-merge all unresolved files)
+  [255]
+  $ hg resolve --all << EOF
+  > n
+  > EOF
+  re-merge all unresolved files (yn)? n
+  abort: user quit
+  [255]
+
+  $ hg resolve --all << EOF
+  > y
+  > EOF
+  re-merge all unresolved files (yn)? y
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  [1]
+
+  $ hg rebase --abort
+  rebase aborted
+  $ cd ..
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -438,6 +438,11 @@
 ``commands``
 
 
+``resolve.confirm``
+Confirm before re-merging all unresolved files when running
+:hg:`resolve --all`.
+(default: False)
+
 ``status.relative``
 Make paths in :hg:`status` output relative to the current directory.
 (default: False)
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -190,6 +190,9 @@
 coreconfigitem('commands', 'grep.all-files',
 default=False,
 )
+coreconfigitem('commands', 'resolve.confirm',
+default=False,
+)
 coreconfigitem('commands', 'show.aliasprefix',
 default=list,
 )
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4529,10 +4529,16 @@
 """
 
 opts = pycompat.byteskwargs(opts)
+confirm = ui.configbool('commands', 'resolve.confirm')
 flaglist = 'all mark unmark list no_status'.split()
 all, mark, unmark, show, nostatus = \
 [opts.get(o) for o in flaglist]
 
+if all and confirm:
+if ui.promptchoice(_(b're-merge all unresolved files (yn)?'
+ b'$$  $$ ')):
+raise error.Abort(_('user quit'))
+
 if (show and (mark or unmark)) or (mark and unmark):
 raise error.Abort(_("too many options specified"))
 if pats and all:



To: khanchi97, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D3988: resolve: add confirm config option

2018-08-03 Thread khanchi97 (Sushil khanchi)
khanchi97 updated this revision to Diff 9816.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3988?vs=9785=9816

REVISION DETAIL
  https://phab.mercurial-scm.org/D3988

AFFECTED FILES
  mercurial/commands.py
  mercurial/configitems.py
  mercurial/help/config.txt
  tests/test-resolve.t

CHANGE DETAILS

diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -374,3 +374,92 @@
   $ hg resolve -l
 
   $ cd ..
+
+==
+Test 'hg resolve' confirm config option functionality |
+==
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > rebase=
+  > EOF
+
+  $ hg init repo2
+  $ cd repo2
+
+  $ echo boss > boss
+  $ hg ci -Am "add boss"
+  adding boss
+
+  $ for emp in emp1 emp2 emp3; do echo work > $emp; done;
+  $ hg ci -Aqm "added emp1 emp2 emp3"
+
+  $ hg up 0
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+
+  $ for emp in emp1 emp2 emp3; do echo nowork > $emp; done;
+  $ hg ci -Aqm "added lazy emp1 emp2 emp3"
+
+  $ hg log -GT "{rev} {node|short} {firstline(desc)}\n"
+  @  2 0acfd4a49af0 added lazy emp1 emp2 emp3
+  |
+  | o  1 f30f98a8181f added emp1 emp2 emp3
+  |/
+  o  0 88660038d466 add boss
+  
+  $ hg rebase -s 1 -d 2
+  rebasing 1:f30f98a8181f "added emp1 emp2 emp3"
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+
+Test when commands.resolve.confirm config option is not set:
+===
+  $ hg resolve --all
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  [1]
+
+Test when config option is set:
+==
+  $ cat >> $HGRCPATH << EOF
+  > [ui]
+  > interactive = True
+  > [commands]
+  > resolve.confirm = True
+  > EOF
+
+  $ hg resolve
+  abort: no files or directories specified
+  (use --all to re-merge all unresolved files)
+  [255]
+  $ hg resolve --all << EOF
+  > n
+  > EOF
+  re-merge all unresolved files (yn)? n
+  abort: user quit
+  [255]
+
+  $ hg resolve --all << EOF
+  > y
+  > EOF
+  re-merge all unresolved files (yn)? y
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  [1]
+
+  $ hg rebase --abort
+  rebase aborted
+  $ cd ..
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -438,6 +438,11 @@
 ``commands``
 
 
+``resolve.confirm``
+Confirm before re-merging all unresolved files when running
+:hg:`resolve --all`.
+(default: False)
+
 ``status.relative``
 Make paths in :hg:`status` output relative to the current directory.
 (default: False)
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -190,6 +190,9 @@
 coreconfigitem('commands', 'grep.all-files',
 default=False,
 )
+coreconfigitem('commands', 'resolve.confirm',
+default=False,
+)
 coreconfigitem('commands', 'show.aliasprefix',
 default=list,
 )
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4528,10 +4528,16 @@
 """
 
 opts = pycompat.byteskwargs(opts)
+confirm = ui.configbool('commands', 'resolve.confirm')
 flaglist = 'all mark unmark list no_status'.split()
 all, mark, unmark, show, nostatus = \
 [opts.get(o) for o in flaglist]
 
+if all and confirm:
+if ui.promptchoice(_(b're-merge all unresolved files (yn)?'
+ b'$$  $$ ')):
+raise error.Abort(_('user quit'))
+
 if (show and (mark or unmark)) or (mark and unmark):
 raise error.Abort(_("too many options specified"))
 if pats and all:



To: khanchi97, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3988: resolve: add confirm config option

2018-08-02 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> commands.py:4539
> + b'$$  $$ ')):
> +return
> +

This should be an abort with message 'user quit' instead of just a return.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3988

To: khanchi97, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3988: resolve: add confirm config option

2018-08-02 Thread khanchi97 (Sushil khanchi)
khanchi97 updated this revision to Diff 9785.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3988?vs=9678=9785

REVISION DETAIL
  https://phab.mercurial-scm.org/D3988

AFFECTED FILES
  mercurial/commands.py
  mercurial/configitems.py
  mercurial/help/config.txt
  tests/test-resolve.t

CHANGE DETAILS

diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -374,3 +374,90 @@
   $ hg resolve -l
 
   $ cd ..
+
+==
+Test 'hg resolve' confirm config option functionality |
+==
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > rebase=
+  > EOF
+
+  $ hg init repo2
+  $ cd repo2
+
+  $ echo boss > boss
+  $ hg ci -Am "add boss"
+  adding boss
+
+  $ for emp in emp1 emp2 emp3; do echo work > $emp; done;
+  $ hg ci -Aqm "added emp1 emp2 emp3"
+
+  $ hg up 0
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+
+  $ for emp in emp1 emp2 emp3; do echo nowork > $emp; done;
+  $ hg ci -Aqm "added lazy emp1 emp2 emp3"
+
+  $ hg log -GT "{rev} {node|short} {firstline(desc)}\n"
+  @  2 0acfd4a49af0 added lazy emp1 emp2 emp3
+  |
+  | o  1 f30f98a8181f added emp1 emp2 emp3
+  |/
+  o  0 88660038d466 add boss
+  
+  $ hg rebase -s 1 -d 2
+  rebasing 1:f30f98a8181f "added emp1 emp2 emp3"
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+
+Test when commands.resolve.confirm config option is not set:
+===
+  $ hg resolve --all
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  [1]
+
+Test when config option is set:
+==
+  $ cat >> $HGRCPATH << EOF
+  > [ui]
+  > interactive = True
+  > [commands]
+  > resolve.confirm = True
+  > EOF
+
+  $ hg resolve
+  abort: no files or directories specified
+  (use --all to re-merge all unresolved files)
+  [255]
+  $ hg resolve --all << EOF
+  > n
+  > EOF
+  re-merge all unresolved files (yn)? n
+
+  $ hg resolve --all << EOF
+  > y
+  > EOF
+  re-merge all unresolved files (yn)? y
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  [1]
+
+  $ hg rebase --abort
+  rebase aborted
+  $ cd ..
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -438,6 +438,11 @@
 ``commands``
 
 
+``resolve.confirm``
+Confirm before re-merging all unresolved files when running
+:hg:`resolve --all`.
+(default: False)
+
 ``status.relative``
 Make paths in :hg:`status` output relative to the current directory.
 (default: False)
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -190,6 +190,9 @@
 coreconfigitem('commands', 'grep.all-files',
 default=False,
 )
+coreconfigitem('commands', 'resolve.confirm',
+default=False,
+)
 coreconfigitem('commands', 'show.aliasprefix',
 default=list,
 )
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4528,10 +4528,16 @@
 """
 
 opts = pycompat.byteskwargs(opts)
+confirm = ui.configbool('commands', 'resolve.confirm')
 flaglist = 'all mark unmark list no_status'.split()
 all, mark, unmark, show, nostatus = \
 [opts.get(o) for o in flaglist]
 
+if all and confirm:
+if ui.promptchoice(_(b're-merge all unresolved files (yn)?'
+ b'$$  $$ ')):
+return
+
 if (show and (mark or unmark)) or (mark and unmark):
 raise error.Abort(_("too many options specified"))
 if pats and all:



To: khanchi97, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3988: resolve: add confirm config option

2018-08-01 Thread pulkit (Pulkit Goyal)
pulkit requested changes to this revision.
pulkit added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> commands.py:4536
>  
> +if all and confirm and ui.promptchoice(_(b're-merge all unresolved files'
> + b' (yn)?$$  $$ ')):

please break this down into two if's. First one `if all and confirm` and the 
promptchoice in another one.

> configitems.py:193
>  )
> +coreconfigitem('commands', 'resolve.confirm',
> +default=False,

You need to document this config option. You can have a look at where other 
options are documented and do something similar.

> test-resolve.t:449
> +  abort: no files or directories specified
> +  (use --all to re-merge all unresolved files)
> +  [255]

this should be user quit rather than this abort.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3988

To: khanchi97, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3988: resolve: add confirm config option

2018-08-01 Thread khanchi97 (Sushil khanchi)
khanchi97 updated this revision to Diff 9678.
khanchi97 edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3988?vs=9676=9678

REVISION DETAIL
  https://phab.mercurial-scm.org/D3988

AFFECTED FILES
  mercurial/commands.py
  mercurial/configitems.py
  tests/test-resolve.t

CHANGE DETAILS

diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -374,3 +374,93 @@
   $ hg resolve -l
 
   $ cd ..
+
+==
+Test 'hg resolve' confirm config option functionality |
+==
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > rebase=
+  > EOF
+
+  $ hg init repo2
+  $ cd repo2
+
+  $ echo boss > boss
+  $ hg ci -Am "add boss"
+  adding boss
+
+  $ for emp in emp1 emp2 emp3; do echo work > $emp; done;
+  $ hg ci -Aqm "added emp1 emp2 emp3"
+
+  $ hg up 0
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+
+  $ for emp in emp1 emp2 emp3; do echo nowork > $emp; done;
+  $ hg ci -Aqm "added lazy emp1 emp2 emp3"
+
+  $ hg log -GT "{rev} {node|short} {firstline(desc)}\n"
+  @  2 0acfd4a49af0 added lazy emp1 emp2 emp3
+  |
+  | o  1 f30f98a8181f added emp1 emp2 emp3
+  |/
+  o  0 88660038d466 add boss
+  
+  $ hg rebase -s 1 -d 2
+  rebasing 1:f30f98a8181f "added emp1 emp2 emp3"
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+
+Test when commands.resolve.confirm config option is not set:
+===
+  $ hg resolve --all
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  [1]
+
+Test when config option is set:
+==
+  $ cat >> $HGRCPATH << EOF
+  > [ui]
+  > interactive = True
+  > [commands]
+  > resolve.confirm = True
+  > EOF
+
+  $ hg resolve
+  abort: no files or directories specified
+  (use --all to re-merge all unresolved files)
+  [255]
+  $ hg resolve --all << EOF
+  > n
+  > EOF
+  re-merge all unresolved files (yn)? n
+  abort: no files or directories specified
+  (use --all to re-merge all unresolved files)
+  [255]
+
+  $ hg resolve --all << EOF
+  > y
+  > EOF
+  re-merge all unresolved files (yn)? y
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  [1]
+
+  $ hg rebase --abort
+  rebase aborted
+  $ cd ..
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -190,6 +190,9 @@
 coreconfigitem('commands', 'grep.all-files',
 default=False,
 )
+coreconfigitem('commands', 'resolve.confirm',
+default=False,
+)
 coreconfigitem('commands', 'show.aliasprefix',
 default=list,
 )
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4528,10 +4528,15 @@
 """
 
 opts = pycompat.byteskwargs(opts)
+confirm = ui.configbool('commands', 'resolve.confirm')
 flaglist = 'all mark unmark list no_status'.split()
 all, mark, unmark, show, nostatus = \
 [opts.get(o) for o in flaglist]
 
+if all and confirm and ui.promptchoice(_(b're-merge all unresolved files'
+ b' (yn)?$$  $$ ')):
+all = False
+
 if (show and (mark or unmark)) or (mark and unmark):
 raise error.Abort(_("too many options specified"))
 if pats and all:



To: khanchi97, #hg-reviewers
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3988: resolve: add confirm config option

2018-08-01 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> commands.py:4536
>  
> +if confirm and not ui.promptchoice(_(b're-merge all unresolved files 
> (yn)?'
> + b'$$  $$ ')):

I missed that we need --all, so make this prompt only when `--all` is passed.

> configitems.py:1159
>  )
> +coreconfigitem('ui', 'resolve.confirm',
> +default=False,

commands.resolve.confirm sounds a better place.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3988

To: khanchi97, #hg-reviewers
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3988: resolve: add confirm config option

2018-07-31 Thread khanchi97 (Sushil khanchi)
khanchi97 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This config setting gives a functionality to confirm before
  it re-merge all unresolved files. If this config is enabled,
  when you run 'hg resolve' it will prompt with a msg
  "re-merge all unresolved files (yn)?"
  
  To enable this functionality:
  [ui]
  resolve.confirm = True

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3988

AFFECTED FILES
  mercurial/commands.py
  mercurial/configitems.py
  tests/test-resolve.t

CHANGE DETAILS

diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -374,3 +374,84 @@
   $ hg resolve -l
 
   $ cd ..
+
+==
+Test 'hg resolve' confirm config option functionality |
+==
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > rebase=
+  > EOF
+
+  $ hg init repo2
+  $ cd repo2
+
+  $ echo boss > boss
+  $ hg ci -Am "add boss"
+  adding boss
+
+  $ for emp in emp1 emp2 emp3; do echo work > $emp; done;
+  $ hg ci -Aqm "added emp1 emp2 emp3"
+
+  $ hg up 0
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+
+  $ for emp in emp1 emp2 emp3; do echo nowork > $emp; done;
+  $ hg ci -Aqm "added lazy emp1 emp2 emp3"
+
+  $ hg log -GT "{rev} {node|short} {firstline(desc)}\n"
+  @  2 0acfd4a49af0 added lazy emp1 emp2 emp3
+  |
+  | o  1 f30f98a8181f added emp1 emp2 emp3
+  |/
+  o  0 88660038d466 add boss
+  
+  $ hg rebase -s 1 -d 2
+  rebasing 1:f30f98a8181f "added emp1 emp2 emp3"
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+
+Test when ui.resolve.confirm config option is not set:
+=
+  $ hg resolve
+  abort: no files or directories specified
+  (use --all to re-merge all unresolved files)
+  [255]
+
+Test when config option is set:
+==
+  $ cat >> $HGRCPATH << EOF
+  > [ui]
+  > interactive = True
+  > resolve.confirm = True
+  > EOF
+
+  $ hg resolve << EOF
+  > n
+  > EOF
+  re-merge all unresolved files (yn)? n
+  abort: no files or directories specified
+  (use --all to re-merge all unresolved files)
+  [255]
+
+  $ hg resolve << EOF
+  > y
+  > EOF
+  re-merge all unresolved files (yn)? y
+  merging emp1
+  merging emp2
+  merging emp3
+  warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
+  [1]
+
+  $ hg rebase --abort
+  rebase aborted
+  $ cd ..
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1156,6 +1156,9 @@
 coreconfigitem('ui', 'remotecmd',
 default='hg',
 )
+coreconfigitem('ui', 'resolve.confirm',
+default=False,
+)
 coreconfigitem('ui', 'report_untrusted',
 default=True,
 )
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4528,10 +4528,15 @@
 """
 
 opts = pycompat.byteskwargs(opts)
+confirm = ui.configbool('ui', 'resolve.confirm')
 flaglist = 'all mark unmark list no_status'.split()
 all, mark, unmark, show, nostatus = \
 [opts.get(o) for o in flaglist]
 
+if confirm and not ui.promptchoice(_(b're-merge all unresolved files (yn)?'
+ b'$$  $$ ')):
+all = True
+
 if (show and (mark or unmark)) or (mark and unmark):
 raise error.Abort(_("too many options specified"))
 if pats and all:



To: khanchi97, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel