D6607: merge: disallow merge abort in case of an unfinished operation(issue6160)

2021-10-21 Thread ryancoop987 (ryan cooper)
Herald added a subscriber: mercurial-patches.
ryancoop987 added a comment.


  This is the latest online this play euchre free  card 
game i am exited to all time see it

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6607/new/

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

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


D6607: merge: disallow merge abort in case of an unfinished operation(issue6160)

2019-07-09 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHGb8d54f4625cb: merge: disallow merge abort in case of an 
unfinished operation (issue6160) (authored by taapas1128).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6607?vs=15814=15829#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6607?vs=15814=15829

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6607/new/

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  relnotes/next
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -847,3 +847,38 @@
 #endif
 
   $ cd ..
+
+Block merge abort when unshelve in progress(issue6160)
+--
+
+  $ hg init a
+  $ cd a
+  $ echo foo > a ; hg commit -qAm "initial commit"
+  $ echo bar > a
+  $ hg shelve
+  shelved as default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo foobar > a
+  $ hg unshelve
+  unshelving change 'default'
+  temporarily committing pending changes (restore with 'hg unshelve --abort')
+  rebasing shelved changes
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
+  [1]
+
+  $ hg log --template '{desc|firstline}  {author}  {date|isodate} \n' -r .
+  pending changes temporary commit  shelve@localhost  1970-01-01 00:00 + 
+  $ hg merge --abort
+  abort: cannot abort merge with unshelve in progress
+  (use 'hg unshelve --continue' or 'hg unshelve --abort')
+  [255]
+
+  $ hg unshelve --abort
+  unshelve of 'default' aborted
+
+  $ hg log -G --template '{desc|firstline}  {author}  {date|isodate} \n' -r .
+  @  initial commit  test  1970-01-01 00:00 +
+  
+  $ cd ..
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -81,6 +81,10 @@
 
  * `cmdutil.checkunfinished()` now includes detection for merge too.
 
+ * merge abort has been disallowed in case an operation of higher
+   precedence is in progress to avoid cases of partial abort of
+   operations.
+
  * We used to automatically attempt to make extensions compatible with
Python 3 (by translating their source code while loading it). We no
longer do that.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3952,6 +3952,10 @@
 if abort and repo.dirstate.p2() == nullid:
 cmdutil.wrongtooltocontinue(repo, _('merge'))
 if abort:
+state = cmdutil.getunfinishedstate(repo)
+if state and state._opname != 'merge':
+raise error.Abort(_('cannot abort merge with %s in progress') %
+(state._opname), hint=state.hint())
 if node:
 raise error.Abort(_("cannot specify a node with --abort"))
 if opts.get('rev'):
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3297,6 +3297,14 @@
 if s._clearable and s.isunfinished(repo):
 util.unlink(repo.vfs.join(s._fname))
 
+def getunfinishedstate(repo):
+''' Checks for unfinished operations and returns statecheck object
+for it'''
+for state in statemod._unfinishedstates:
+if state.isunfinished(repo):
+return state
+return None
+
 def howtocontinue(repo):
 '''Check for an unfinished operation and return the command to finish
 it.



To: taapas1128, #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


D6607: merge: disallow merge abort in case of an unfinished operation(issue6160)

2019-07-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.
taapas1128 marked an inline comment as done.


  added the entry in relnotes.

INLINE COMMENTS

> pulkit wrote in commands.py:4020
> state can be `None` here.

My bad I really shouldn't have missed that.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6607/new/

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

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


D6607: merge: disallow merge abort in case of an unfinished operation(issue6160)

2019-07-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15814.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6607?vs=15801=15814

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6607/new/

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  relnotes/next
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -847,3 +847,38 @@
 #endif
 
   $ cd ..
+
+Block merge abort when unshelve in progress(issue6160)
+--
+
+  $ hg init a
+  $ cd a
+  $ echo foo > a ; hg commit -qAm "initial commit"
+  $ echo bar > a
+  $ hg shelve
+  shelved as default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo foobar > a
+  $ hg unshelve
+  unshelving change 'default'
+  temporarily committing pending changes (restore with 'hg unshelve --abort')
+  rebasing shelved changes
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
+  [1]
+
+  $ hg log --template '{desc|firstline}  {author}  {date|isodate} \n' -r .
+  pending changes temporary commit  shelve@localhost  1970-01-01 00:00 + 
+  $ hg merge --abort
+  abort: cannot abort merge with unshelve in progress
+  (use 'hg unshelve --continue' or 'hg unshelve --abort')
+  [255]
+
+  $ hg unshelve --abort
+  unshelve of 'default' aborted
+
+  $ hg log -G --template '{desc|firstline}  {author}  {date|isodate} \n' -r .
+  @  initial commit  test  1970-01-01 00:00 +
+  
+  $ cd ..
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -70,3 +70,7 @@
`addunfinished()` in `state` module.
 
  * `cmdutil.checkunfinished()` now includes detection for merge too.
+
+ * merge abort has been disallowed in case an operation of higher
+   precedence is in progress to avoid cases of partial abort of
+   operations.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4016,6 +4016,10 @@
 if abort and repo.dirstate.p2() == nullid:
 cmdutil.wrongtooltocontinue(repo, _('merge'))
 if abort:
+state = cmdutil.getunfinishedstate(repo)
+if state and state._opname != 'merge':
+raise error.Abort(_('cannot abort merge with %s in progress') %
+(state._opname), hint=state.hint())
 if node:
 raise error.Abort(_("cannot specify a node with --abort"))
 if opts.get('rev'):
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3296,6 +3296,14 @@
 if s._clearable and s.isunfinished(repo):
 util.unlink(repo.vfs.join(s._fname))
 
+def getunfinishedstate(repo):
+''' Checks for unfinished operations and returns statecheck object
+for it'''
+for state in statemod._unfinishedstates:
+if state.isunfinished(repo):
+return state
+return None
+
 def howtocontinue(repo):
 '''Check for an unfinished operation and return the command to finish
 it.



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


D6607: merge: disallow merge abort in case of an unfinished operation(issue6160)

2019-07-08 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  Also, can you add an entry about this to relnotes/next?

INLINE COMMENTS

> commands.py:4020
> +state = cmdutil.getunfinishedstate(repo)
> +if state._opname != 'merge':
> +raise error.Abort(_('cannot abort merge with %s in progress') %

state can be `None` here.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6607/new/

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

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


D6607: merge: disallow merge abort in case of an unfinished operation(issue6160)

2019-07-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 edited the summary of this revision.
taapas1128 updated this revision to Diff 15801.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6607?vs=15793=15801

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6607/new/

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -847,3 +847,38 @@
 #endif
 
   $ cd ..
+
+Block merge abort when unshelve in progress(issue6160)
+--
+
+  $ hg init a
+  $ cd a
+  $ echo foo > a ; hg commit -qAm "initial commit"
+  $ echo bar > a
+  $ hg shelve
+  shelved as default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo foobar > a
+  $ hg unshelve
+  unshelving change 'default'
+  temporarily committing pending changes (restore with 'hg unshelve --abort')
+  rebasing shelved changes
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
+  [1]
+
+  $ hg log --template '{desc|firstline}  {author}  {date|isodate} \n' -r .
+  pending changes temporary commit  shelve@localhost  1970-01-01 00:00 + 
+  $ hg merge --abort
+  abort: cannot abort merge with unshelve in progress
+  (use 'hg unshelve --continue' or 'hg unshelve --abort')
+  [255]
+
+  $ hg unshelve --abort
+  unshelve of 'default' aborted
+
+  $ hg log -G --template '{desc|firstline}  {author}  {date|isodate} \n' -r .
+  @  initial commit  test  1970-01-01 00:00 +
+  
+  $ cd ..
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4016,6 +4016,10 @@
 if abort and repo.dirstate.p2() == nullid:
 cmdutil.wrongtooltocontinue(repo, _('merge'))
 if abort:
+state = cmdutil.getunfinishedstate(repo)
+if state._opname != 'merge':
+raise error.Abort(_('cannot abort merge with %s in progress') %
+(state._opname), hint=state.hint())
 if node:
 raise error.Abort(_("cannot specify a node with --abort"))
 if opts.get('rev'):
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3296,6 +3296,14 @@
 if s._clearable and s.isunfinished(repo):
 util.unlink(repo.vfs.join(s._fname))
 
+def getunfinishedstate(repo):
+''' Checks for unfinished operations and returns statecheck object
+for it'''
+for state in statemod._unfinishedstates:
+if state.isunfinished(repo):
+return state
+return None
+
 def howtocontinue(repo):
 '''Check for an unfinished operation and return the command to finish
 it.



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


D6607: merge: disallow merge abort in case of an unfinished operation(issue6160)

2019-07-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.


  okay I will create that in `cmdutil.py`.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6607/new/

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

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


D6607: merge: disallow merge abort in case of an unfinished operation(issue6160)

2019-07-08 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> commands.py:4019
>  if abort:
> +for state in statemod._unfinishedstates:
> +if state.isunfinished(repo) and state._opname != 'merge':

We are performing the same loop in https://phab.mercurial-scm.org/D6566. How 
about having a utility function which will return the unfinished state, 
something like `getunfinishedstate`

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6607/new/

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

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


D6607: merge: disallow merge abort in case of an unfinished operation(issue6160)

2019-07-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15793.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6607?vs=15776=15793

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6607/new/

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -847,3 +847,38 @@
 #endif
 
   $ cd ..
+
+Block merge abort when unshelve in progress(issue6160)
+--
+
+  $ hg init a
+  $ cd a
+  $ echo foo > a ; hg commit -qAm "initial commit"
+  $ echo bar > a
+  $ hg shelve
+  shelved as default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo foobar > a
+  $ hg unshelve
+  unshelving change 'default'
+  temporarily committing pending changes (restore with 'hg unshelve --abort')
+  rebasing shelved changes
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
+  [1]
+
+  $ hg log --template '{desc|firstline}  {author}  {date|isodate} \n' -r .
+  pending changes temporary commit  shelve@localhost  1970-01-01 00:00 + 
+  $ hg merge --abort
+  abort: cannot abort merge with unshelve in progress
+  (use 'hg unshelve --continue' or 'hg unshelve --abort')
+  [255]
+
+  $ hg unshelve --abort
+  unshelve of 'default' aborted
+
+  $ hg log -G --template '{desc|firstline}  {author}  {date|isodate} \n' -r .
+  @  initial commit  test  1970-01-01 00:00 +
+  
+  $ cd ..
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4016,6 +4016,10 @@
 if abort and repo.dirstate.p2() == nullid:
 cmdutil.wrongtooltocontinue(repo, _('merge'))
 if abort:
+for state in statemod._unfinishedstates:
+if state.isunfinished(repo) and state._opname != 'merge':
+raise error.Abort(_('cannot abort merge with %s in progress') %
+(state._opname), hint=state.hint())
 if node:
 raise error.Abort(_("cannot specify a node with --abort"))
 if opts.get('rev'):



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


D6607: merge: disallow merge abort in case of an unfinished operation(issue6160)

2019-07-08 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> commands.py:4017
> +unfinishedstate = None
> +for state in statemod._unfinishedstates:
> +if state.isunfinished(repo):

We should first check `if abort` before performing this loop instead of 
checking later.

> commands.py:4019
> +if state.isunfinished(repo):
> +unfinishedstate = state
> +if abort and unfinishedstate._opname != 'merge':

we don't need to create a new variable. We can operate on `state` below.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6607/new/

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

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


D6607: merge: disallow merge abort in case of an unfinished operation(issue6160)

2019-07-06 Thread taapas1128 (Taapas Agrawal)
taapas1128 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch disallows `hg merge --abort` in case an operation of higher
  precedence i.e unshelve, rebase, histedit are in unfinished states.
  
  This is done so as to avoid partial abort of these operations in case
  merge abort is called at an interrupted step.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -847,3 +847,38 @@
 #endif
 
   $ cd ..
+
+Block merge abort when unshelve in progress(issue6160)
+--
+
+  $ hg init a
+  $ cd a
+  $ echo foo > a ; hg commit -qAm "initial commit"
+  $ echo bar > a
+  $ hg shelve
+  shelved as default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo foobar > a
+  $ hg unshelve
+  unshelving change 'default'
+  temporarily committing pending changes (restore with 'hg unshelve --abort')
+  rebasing shelved changes
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
+  [1]
+
+  $ hg log --template '{desc|firstline}  {author}  {date|isodate} \n' -r .
+  pending changes temporary commit  shelve@localhost  1970-01-01 00:00 + 
+  $ hg merge --abort
+  abort: cannot abort merge with unshelve in progress
+  (use 'hg unshelve --continue' or 'hg unshelve --abort')
+  [255]
+
+  $ hg unshelve --abort
+  unshelve of 'default' aborted
+
+  $ hg log -G --template '{desc|firstline}  {author}  {date|isodate} \n' -r .
+  @  initial commit  test  1970-01-01 00:00 +
+  
+  $ cd ..
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4013,6 +4013,14 @@
 
 opts = pycompat.byteskwargs(opts)
 abort = opts.get('abort')
+unfinishedstate = None
+for state in statemod._unfinishedstates:
+if state.isunfinished(repo):
+unfinishedstate = state
+if abort and unfinishedstate._opname != 'merge':
+raise error.Abort(_('cannot abort merge with %s in progress') %
+(unfinishedstate._opname),
+hint=unfinishedstate.hint())
 if abort and repo.dirstate.p2() == nullid:
 cmdutil.wrongtooltocontinue(repo, _('merge'))
 if abort:



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