D6596: unshelve: make unshelve accept files (issue6162)

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

INLINE COMMENTS

> shelve.py:842
>  repo.setparents(tmpwctx.node(), nodemod.nullid)
>  newnode = repo.commit(text=shelvectx.description(),
>extra=shelvectx.extra(),

We can do filtering of files to unshelve here.

Before this `repo.commit` we have all the changes, we first commit which are 
needed to be unshelve, then create a shelve of rest of the changes.

REPOSITORY
  rHG Mercurial

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

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

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


D6588: abort: added support for merge

2019-07-06 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15783.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6588?vs=15770=15783

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  mercurial/state.py
  tests/test-commit-unresolved.t
  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
@@ -724,15 +724,20 @@
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
+
+#if abortflag
+  $ hg unshelve --abort
+  abort: no unshelve in progress
+  [255]
+#else
   $ hg abort
-  abort: no unshelve in progress (abortflag !)
-  abort: merge does not support 'hg abort' (abortcommand !)
-  (use 'hg commit' or 'hg merge --abort') (abortcommand !)
-  abort: merge does not support 'hg abort' (phasebased !)
-  (use 'hg commit' or 'hg merge --abort') (phasebased !)
-  abort: merge does not support 'hg abort' (stripbased !)
-  (use 'hg commit' or 'hg merge --abort') (stripbased !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3 (abortcommand !)
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved 
(abortcommand !)
+  aborting the merge, updating back to 9451eaa6eee3 (phasebased !)
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved 
(phasebased !)
+  aborting the merge, updating back to 9451eaa6eee3 (stripbased !)
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved 
(stripbased !)
+#endif
   $ cd ..
 
 Unshelve respects --keep even if user intervention is needed
diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t
--- a/tests/test-commit-unresolved.t
+++ b/tests/test-commit-unresolved.t
@@ -1,3 +1,11 @@
+#testcases abortcommand abortflag
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = merge --abort
+  > EOF
+#endif
+
   $ addcommit () {
   > echo $1 > $1
   > hg add $1
@@ -36,9 +44,11 @@
 
 Testing the abort functionality first in case of conflicts
 
-  $ hg merge --abort
-  abort: no merge in progress
+  $ hg abort
+  abort: no merge in progress (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
+
   $ hg merge
   merging A
   warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
@@ -53,7 +63,22 @@
   abort: cannot specify both --rev and --abort
   [255]
 
-  $ hg merge --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  merge in progress, will be aborted
+
+when in no-backup mode
+  $ hg abort --no-backup
+  abort: aborting merge does not support no-backup flag
+  [255]
+
+when dry-run mode is used with no backup
+  $ hg abort --dry-run --no-backup
+  merge in progress, will be aborted
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +156,7 @@
   abort: cannot specify --preview with --abort
   [255]
 
-  $ hg merge --abort
+  $ hg abort
   aborting the merge, updating back to 68352a18a7c4
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -205,13 +205,6 @@
  'To mark the changeset bad: hg bisect --bad\n'
  'To abort:  hg bisect --reset\n')
 )
-addunfinished(
-'merge', fname=None, clearable=True, allowcommit=True,
-cmdmsg=_('outstanding uncommitted merge'),
-statushint=_('To continue:hg commit\n'
- 'To abort:   hg merge --abort'),
-cmdhint=_("use 'hg commit' or 'hg merge --abort'")
-)
 
 def getrepostate(repo):
 # experimental config: commands.status.skipstates
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -956,23 +956,11 @@
   abort=False):
 """Branch merge with node, resolving changes. Return true if any
 unresolved conflicts."""
-if not abort:
-stats = mergemod.update(repo, node, branchmerge=True, force=force,
-mergeforce=mergeforce, labels=labels)
-else:
-ms = mergemod.mergestate.read(repo)
-if ms.active():
-# there were conflicts
-node = ms.localctx.hex()
-else:
-# there were no conficts, mergestate was not stored
-node = repo['.'].hex()
-
-repo.ui.status(_("aborting the merge, updating back to"
- " %s\n") % node[:12])
-stats = mergemod.update(repo, node, branchmerge=False, force=True,
-labels=labels)
-
+if abort:
+return abortmerge(repo.ui, repo, labels=labels)
+
+stats = mergemod.update(repo, node, branchmerge=True, force=force,
+  

D6579: abort: added support for unshelve

2019-07-06 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15781.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6579?vs=15768=15781

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/shelve.py
  mercurial/state.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
@@ -1,4 +1,4 @@
-#testcases stripbased phasebased
+#testcases stripbased phasebased abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +19,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +292,23 @@
   >>> working-copy: aef214a5229c - shelve: changes to: commit stuff
   $ cat f.orig
   g
-  $ hg unshelve --abort
+
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  unshelve in progress, will be aborted
+
+when in no-backup mode
+  $ hg abort --no-backup
+  abort: aborting unshelve does not support no-backup flag
+  [255]
+
+when dry-run mode is used with no backup
+  $ hg abort --dry-run --no-backup
+  unshelve in progress, will be aborted
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,14 +718,20 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   could not read shelved state file, your working copy may be in an unexpected 
state
   please update to some commit
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
-  $ hg unshelve --abort
-  abort: no unshelve in progress
+  $ hg abort
+  abort: no unshelve in progress (abortflag !)
+  abort: merge does not support 'hg abort' (abortcommand !)
+  (use 'hg commit' or 'hg merge --abort') (abortcommand !)
+  abort: merge does not support 'hg abort' (phasebased !)
+  (use 'hg commit' or 'hg merge --abort') (phasebased !)
+  abort: merge does not support 'hg abort' (stripbased !)
+  (use 'hg commit' or 'hg merge --abort') (stripbased !)
   [255]
   $ cd ..
 
@@ -822,7 +851,7 @@
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
   [1]
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 Unshelve without .shelve metadata (can happen when upgrading a repository with 
old shelve)
@@ -841,7 +870,7 @@
   [1]
   $ cat .hg/shelved/default.shelve
   node=82e0cb9893247d12667017593ce1e5655860f1ac
-  $ hg unshelve --abort
+  $ hg abort
   unshelve of 'default' aborted
 
 #endif
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -194,10 +194,6 @@
 _unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
-'unshelve', fname='shelvedstate', continueflag=True,
-cmdmsg=_('unshelve already in progress')
-)
-addunfinished(
 'update', fname='updatestate', clearable=True,
 cmdmsg=_('last update was interrupted'),
 cmdhint=_("use 'hg update' to get a consistent checkout"),
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -26,6 +26,7 @@
 import errno
 import itertools
 import stat
+import sys
 
 from .i18n import _
 from . import (
@@ -624,9 +625,40 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, continuef=False, abortf=False, **opts):
+try:
+state = shelvedstate.load(repo)
+if opts.get('keep') is None:
+opts['keep'] = state.keep
+except IOError as err:
+if err.errno != errno.ENOENT:
+raise
+cmdutil.wrongtooltocontinue(repo, _('unshelve'))
+except error.CorruptedState as err:
+ui.debug(pycompat.bytestr(err) + '\n')
+if continuef:
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif abortf:
+msg = _('could not read shelved state file, your working copy '
+'may be in an unexpected state\nplease update to some '
+'commit\n')
+ui.warn(msg)
+shelvedstate.clear(repo)
+sys.exit()
+return (state, opts)
+
+def unshelveabort(ui, repo, state=None, **opts):
 """subcommand that abort an in-progress unshelve"""
-with repo.lock():
+if opts.get('no_backup'):
+raise error.Abort(_("aborting unshelve does not support no-backup"
+" flag"))
+if not state:
+statetuple = 

D6582: abort: added support for histedit

2019-07-06 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15782.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6582?vs=15769=15782

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

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

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-arguments.t
  tests/test-histedit-no-backup.t
  tests/test-histedit-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -1,3 +1,12 @@
+#testcases abortcommand abortflag
+
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = histedit --abort
+  > EOF
+#endif
+
   $ . "$TESTDIR/histedit-helpers.sh"
 
 Enable obsolete
@@ -522,7 +531,17 @@
   (hg histedit --continue to resume)
   [1]
 
-  $ hg histedit --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  histedit in progress, will be aborted
+
+when dry-run mode is used with no backup
+  $ hg abort --dry-run --no-backup
+  histedit in progress, will be aborted
+#endif
+
+  $ hg abort
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to 
$TESTTMP/abort/.hg/strip-backup/4dc06258baa6-dff4ef05-backup.hg
 
diff --git a/tests/test-histedit-no-backup.t b/tests/test-histedit-no-backup.t
--- a/tests/test-histedit-no-backup.t
+++ b/tests/test-histedit-no-backup.t
@@ -1,3 +1,12 @@
+#testcases abortcommand abortflag
+
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = histedit --abort
+  > EOF
+#endif
+
   $ . "$TESTDIR/histedit-helpers.sh"
 
 Enable extension used by this test
@@ -44,17 +53,19 @@
   Editing (7d5187087c79), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
-  $ hg histedit --abort
+  $ hg abort
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to 
$TESTTMP/foo/.hg/strip-backup/1d8f701c7b35-cf7be322-backup.hg
   saved backup bundle to 
$TESTTMP/foo/.hg/strip-backup/5c0056670bce-b54b65d0-backup.hg
 
 Test when `backup-bundle` config option is not enabled
 Enable config option:
+#if abortflag
   $ cat >>$HGRCPATH < [rewrite]
   > backup-bundle = False
   > EOF
+#endif
 
   $ hg histedit -r '36b4bdd91f5b' --commands - << EOF
   > pick 36b4bdd91f5b 0 one
@@ -66,5 +77,10 @@
   Editing (7d5187087c79), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
+#if abortflag
   $ hg histedit --abort
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#else
+  $ hg abort --no-backup
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#endif
diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -1,3 +1,12 @@
+#testcases abortcommand abortflag
+
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = histedit --abort
+  > EOF
+#endif
+
 Test argument handling and various data parsing
 ==
 
@@ -47,8 +56,9 @@
   $ hg histedit --continue
   abort: no histedit in progress
   [255]
-  $ hg histedit --abort
-  abort: no histedit in progress
+  $ hg abort
+  abort: no histedit in progress (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
 
 Run a dummy edit to make sure we get tip^^ correctly via revsingle.
@@ -358,7 +368,7 @@
 Corrupt histedit state file
   $ sed 's/8fda0c726bf2/123456789012/' .hg/histedit-state > ../corrupt-histedit
   $ mv ../corrupt-histedit .hg/histedit-state
-  $ hg histedit --abort
+  $ hg abort
   warning: encountered an exception during histedit --abort; the repository 
may not have been completely cleaned up
   abort: $TESTTMP/foo/.hg/strip-backup/*-histedit.hg: $ENOENT$ (glob) (windows 
!)
   abort: $ENOENT$: '$TESTTMP/foo/.hg/strip-backup/*-histedit.hg' (glob) 
(no-windows !)
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1919,6 +1919,16 @@
 finally:
 state.clear()
 
+def hgaborthistedit(ui, repo, **opts):
+state = histeditstate(repo)
+nobackup = False
+if opts.get('no_backup'):
+nobackup = True
+with repo.wlock() as wlock, repo.lock() as lock:
+state.wlock = wlock
+state.lock = lock
+_aborthistedit(ui, repo, state, nobackup=nobackup)
+
 def _edithisteditplan(ui, repo, state, rules):
 state.read()
 if not rules:
@@ -2314,5 +2324,5 @@
 def extsetup(ui):
 cmdutil.summaryhooks.add('histedit', summaryhook)
 statemod.addunfinished('histedit', fname='histedit-state', 
allowcommit=True,
-continueflag=True)
-
+continueflag=True, abortfunc=hgaborthistedit)
+



To: taapas1128, durin42, #hg-reviewers
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing 

D6567: abort: added support for graft

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6567?vs=15766=15779

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

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

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

CHANGE DETAILS

diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1,9 +1,18 @@
+#testcases abortcommand abortflag
+
   $ cat >> $HGRCPATH < [extdiff]
   > # for portability:
   > pdiff = sh "$RUNTESTDIR/pdiff"
   > EOF
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = graft --abort
+  > EOF
+#endif
+
 Create a repo with some stuff in it:
 
   $ hg init a
@@ -1986,8 +1995,9 @@
   $ hg up 9150fe93bec6
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
-  $ hg graft --abort
-  abort: no interrupted graft to abort
+  $ hg abort
+  abort: no interrupted graft to abort (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
 
 when stripping is required
@@ -2016,7 +2026,22 @@
   abort: cannot specify any other flag with '--abort'
   [255]
 
-  $ hg graft --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  graft in progress, will be aborted
+
+when in no-backup mode
+  $ hg abort --no-backup
+  abort: aborting graft does not support no-backup flag
+  [255]
+
+when dry-run mode is used with no backup
+  $ hg abort --dry-run --no-backup
+  graft in progress, will be aborted
+#endif
+
+  $ hg abort
   graft aborted
   working directory is now at 9150fe93bec6
   $ hg log -GT "{rev}:{node|short} {desc}"
@@ -2041,7 +2066,7 @@
   (use 'hg resolve' and 'hg graft --continue')
   [255]
 
-  $ hg graft --abort
+  $ hg abort
   graft aborted
   working directory is now at 9150fe93bec6
   $ hg log -GT "{rev}:{node|short} {desc}"
@@ -2085,7 +2110,7 @@
   
   $ hg phase -r 6 --public
 
-  $ hg graft --abort
+  $ hg abort
   cannot clean up public changesets 6ec71c037d94
   graft aborted
   working directory is now at 6ec71c037d94
@@ -2162,7 +2187,7 @@
   new changesets 311dfc6cf3bf (1 drafts)
   (run 'hg heads .' to see heads, 'hg merge' to merge)
 
-  $ hg graft --abort
+  $ hg abort
   new changesets detected on destination branch, can't strip
   graft aborted
   working directory is now at 6b98ff0062dd
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -194,11 +194,6 @@
 _unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
-'graft', fname='graftstate', clearable=True, stopflag=True,
-continueflag=True,
-cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
-)
-addunfinished(
 'unshelve', fname='shelvedstate', continueflag=True,
 cmdmsg=_('unshelve already in progress')
 )
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2686,6 +2686,12 @@
 ui.status(_("working directory is now at %s\n") % pctx.hex()[:12])
 return 0
 
+statemod.addunfinished(
+'graft', fname='graftstate', clearable=True, stopflag=True,
+continueflag=True, abortfunc=cmdutil.hgabortgraft,
+cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
+)
+
 @command('grep',
 [('0', 'print0', None, _('end fields with NUL')),
 ('', 'all', None, _('print all revisions that match (DEPRECATED) ')),
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3411,3 +3411,10 @@
 nodes = repo.vfs.read('graftstate').splitlines()
 return {'nodes': nodes}
 
+def hgabortgraft(ui, repo, **opts):
+""" abort logic for aborting graft using 'hg abort'"""
+if opts.get('no_backup'):
+raise error.Abort(_("aborting graft does not support no-backup flag"))
+with repo.wlock():
+graftstate = statemod.cmdstate(repo, 'graftstate')
+return _abortgraft(ui, repo, graftstate)



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


D6608: graft: moved abortgraft and readgraft to cmdutil

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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -53,7 +53,6 @@
 pycompat,
 rcutil,
 registrar,
-repair,
 revsetlang,
 rewriteutil,
 scmutil,
@@ -2499,14 +2498,14 @@
 opts.get('currentuser'), opts.get('rev'))):
 raise error.Abort(_("cannot specify any other flag with 
'--abort'"))
 
-return _abortgraft(ui, repo, graftstate)
+return cmdutil._abortgraft(ui, repo, graftstate)
 elif opts.get('continue'):
 cont = True
 if revs:
 raise error.Abort(_("can't specify --continue and revisions"))
 # read in unfinished revisions
 if graftstate.exists():
-statedata = _readgraftstate(repo, graftstate)
+statedata = cmdutil._readgraftstate(repo, graftstate)
 if statedata.get('date'):
 opts['date'] = statedata['date']
 if statedata.get('user'):
@@ -2676,69 +2675,6 @@
 
 return 0
 
-def _abortgraft(ui, repo, graftstate):
-"""abort the interrupted graft and rollbacks to the state before 
interrupted
-graft"""
-if not graftstate.exists():
-raise error.Abort(_("no interrupted graft to abort"))
-statedata = _readgraftstate(repo, graftstate)
-newnodes = statedata.get('newnodes')
-if newnodes is None:
-# and old graft state which does not have all the data required to 
abort
-# the graft
-raise error.Abort(_("cannot abort using an old graftstate"))
-
-# changeset from which graft operation was started
-if len(newnodes) > 0:
-startctx = repo[newnodes[0]].p1()
-else:
-startctx = repo['.']
-# whether to strip or not
-cleanup = False
-if newnodes:
-newnodes = [repo[r].rev() for r in newnodes]
-cleanup = True
-# checking that none of the newnodes turned public or is public
-immutable = [c for c in newnodes if not repo[c].mutable()]
-if immutable:
-repo.ui.warn(_("cannot clean up public changesets %s\n")
- % ', '.join(bytes(repo[r]) for r in immutable),
- hint=_("see 'hg help phases' for details"))
-cleanup = False
-
-# checking that no new nodes are created on top of grafted revs
-desc = set(repo.changelog.descendants(newnodes))
-if desc - set(newnodes):
-repo.ui.warn(_("new changesets detected on destination "
-   "branch, can't strip\n"))
-cleanup = False
-
-if cleanup:
-with repo.wlock(), repo.lock():
-hg.updaterepo(repo, startctx.node(), overwrite=True)
-# stripping the new nodes created
-strippoints = [c.node() for c in repo.set("roots(%ld)",
-  newnodes)]
-repair.strip(repo.ui, repo, strippoints, backup=False)
-
-if not cleanup:
-# we don't update to the startnode if we can't strip
-startctx = repo['.']
-hg.updaterepo(repo, startctx.node(), overwrite=True)
-
-ui.status(_("graft aborted\n"))
-ui.status(_("working directory is now at %s\n") % startctx.hex()[:12])
-graftstate.delete()
-return 0
-
-def _readgraftstate(repo, graftstate):
-"""read the graft state file and return a dict of the data stored in it"""
-try:
-return graftstate.read()
-except error.CorruptedState:
-nodes = repo.vfs.read('graftstate').splitlines()
-return {'nodes': nodes}
-
 def _stopgraft(ui, repo, graftstate):
 """stop the interrupted graft"""
 if not graftstate.exists():
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -38,6 +38,7 @@
 pathutil,
 phases,
 pycompat,
+repair,
 revlog,
 rewriteutil,
 scmutil,
@@ -3345,3 +3346,68 @@
 if after[1]:
 hint = after[0]
 raise error.Abort(_('no %s in progress') % task, hint=hint)
+
+def _abortgraft(ui, repo, graftstate):
+"""abort the interrupted graft and rollbacks to the state before 
interrupted
+graft"""
+if not graftstate.exists():
+raise error.Abort(_("no interrupted graft to abort"))
+statedata = _readgraftstate(repo, graftstate)
+newnodes = statedata.get('newnodes')
+if newnodes is None:
+# and old graft state which does not have all the data required to 
abort
+# the graft
+raise error.Abort(_("cannot abort using an old graftstate"))
+
+# changeset from which graft operation was started
+if len(newnodes) > 0:
+   

D6566: abort: added logic for of hg abort

2019-07-06 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15777.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6566?vs=15775=15777

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/state.py
  tests/test-blackbox.t
  tests/test-completion.t
  tests/test-help.t
  tests/test-hgweb-json.t

CHANGE DETAILS

diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -1875,6 +1875,10 @@
   {
 "earlycommands": [
   {
+"summary": "abort an unfinished operation(EXPERIMENTAL)",
+"topic": "abort"
+  },
+  {
 "summary": "add the specified files on the next commit",
 "topic": "add"
   },
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -402,6 +402,7 @@
   
   basic commands:
   
+   abort abort an unfinished operation(EXPERIMENTAL)
add   add the specified files on the next commit
annotate, blame
  show changeset information by line for each file
@@ -2353,6 +2354,13 @@
   Main 
Commands
   
   
+  
+  abort
+  
+  
+  abort an unfinished operation(EXPERIMENTAL)
+  
+  
   
   add
   
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -1,5 +1,6 @@
 Show all commands except debug commands
   $ hg debugcomplete
+  abort
   add
   addremove
   annotate
@@ -59,6 +60,7 @@
 
 Show all commands that start with "a"
   $ hg debugcomplete a
+  abort
   add
   addremove
   annotate
@@ -235,6 +237,7 @@
 
 Show all commands + options
   $ hg debugcommands
+  abort: no-backup, dry-run
   add: include, exclude, subrepos, dry-run
   addremove: similarity, subrepos, include, exclude, dry-run
   annotate: rev, follow, no-follow, text, user, file, date, number, changeset, 
line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, 
ignore-space-at-eol, include, exclude, template
diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -7,7 +7,7 @@
   > @command(b'crash', [], b'hg crash')
   > def crash(ui, *args, **kwargs):
   > raise Exception("oops")
-  > @command(b'abort', [], b'hg abort')
+  > @command(b'abortcmd', [], b'hg abortcmd')
   > def abort(ui, *args, **kwargs):
   > raise error.Abort(b"oops")
   > EOF
@@ -52,10 +52,10 @@
 
 abort exit code
   $ rm ./.hg/blackbox.log
-  $ hg abort 2> /dev/null
+  $ hg abortcmd 2> /dev/null
   [255]
   $ hg blackbox -l 2
-  1970/01/01 00:00:00 bob @ (5000)> 
abort exited 255 after * seconds (glob)
+  1970/01/01 00:00:00 bob @ (5000)> 
abortcmd exited 255 after * seconds (glob)
   1970/01/01 00:00:00 bob @ (5000)> 
blackbox -l 2
 
 unhandled exception
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -98,7 +98,8 @@
 """
 
 def __init__(self, opname, fname, clearable, allowcommit, reportonly,
- continueflag, stopflag, cmdmsg, cmdhint, statushint):
+ continueflag, stopflag, cmdmsg, cmdhint, statushint,
+ abortfunc):
 self._opname = opname
 self._fname = fname
 self._clearable = clearable
@@ -109,6 +110,7 @@
 self._cmdmsg = cmdmsg
 self._cmdhint = cmdhint
 self._statushint = statushint
+self.abortfunc = abortfunc
 
 def statusmsg(self):
 """returns the hint message corresponding to the command for
@@ -157,7 +159,7 @@
 
 def addunfinished(opname, fname, clearable=False, allowcommit=False,
   reportonly=False, continueflag=False, stopflag=False,
-  cmdmsg="", cmdhint="", statushint=""):
+  cmdmsg="", cmdhint="", statushint="", abortfunc=None):
 """this registers a new command or operation to unfinishedstates
 opname is the name the command or operation
 fname is the file name in which data should be stored in .hg directory.
@@ -181,10 +183,11 @@
 statushint is used to pass a different status message in case standard
 message of the format ('To continue:hg cmdname --continue'
 'To abort:   hg cmdname --abort') is not desired
+abortfunc stores the function required to abort an unfinished state.
 """
 statecheckobj = _statecheck(opname, fname, clearable, allowcommit,
 reportonly, continueflag, stopflag, cmdmsg,
-cmdhint, statushint)
+cmdhint, statushint, abortfunc)
 if opname == 'merge':
 _unfinishedstates.append(statecheckobj)
 else:
diff --git a/mercurial/commands.py 

D6568: abort: added support for rebase

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6568?vs=15767=15780

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

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-abort.t

CHANGE DETAILS

diff --git a/tests/test-rebase-abort.t b/tests/test-rebase-abort.t
--- a/tests/test-rebase-abort.t
+++ b/tests/test-rebase-abort.t
@@ -1,3 +1,5 @@
+#testcases abortcommand abortflag
+
   $ cat >> $HGRCPATH < [extensions]
   > rebase=
@@ -9,6 +11,12 @@
   > tglog = log -G --template "{rev}:{phase} '{desc}' {branches}\n"
   > EOF
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = rebase --abort
+  > EOF
+#endif
 
   $ hg init a
   $ cd a
@@ -114,7 +122,22 @@
 
 Abort (should clear out unsupported merge state):
 
-  $ hg rebase --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  rebase in progress, will be aborted
+
+when in no-backup mode
+  $ hg abort --no-backup
+  abort: aborting rebase does not support no-backup flag
+  [255]
+
+when dry-run mode is used with no backup
+  $ hg abort --dry-run --no-backup
+  rebase in progress, will be aborted
+#endif
+
+  $ hg abort
   saved backup bundle to 
$TESTTMP/a/.hg/strip-backup/3e046f2ecedb-6beef7d5-backup.hg
   rebase aborted
   $ hg debugmergestate
@@ -154,7 +177,7 @@
   [255]
   $ hg summary | grep '^rebase: '
   rebase: (use "hg rebase --abort" to clear broken state)
-  $ hg rebase --abort
+  $ hg abort
   rebase aborted (no revision is removed, only broken state is cleared)
 
   $ cd ..
@@ -271,7 +294,7 @@
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
-  $ hg rebase --abort
+  $ hg abort
   rebase aborted
   $ hg log -G --template "{rev} {desc} {bookmarks}"
   @  3 C foo
@@ -324,7 +347,7 @@
 
   $ cat a
   new
-  $ hg rebase --abort
+  $ hg abort
   rebase aborted
   $ cat a
   new
@@ -405,7 +428,7 @@
   (use 'hg rebase --continue' or 'hg rebase --abort')
   [255]
 
-  $ hg rebase --abort
+  $ hg abort
   saved backup bundle to 
$TESTTMP/interrupted/.hg/strip-backup/3d8812cf300d-93041a90-backup.hg
   rebase aborted
   $ hg log -G --template "{rev} {desc} {bookmarks}"
@@ -456,7 +479,7 @@
   rebasing 2:e4ea5cdc9789 "conflicting 1"
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
-  $ hg rebase --abort
+  $ hg abort
   rebase aborted
   $ hg summary
   parent: 3:b16646383533 tip
@@ -497,7 +520,7 @@
   warning: conflicts while merging root! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
-  $ hg rebase --abort
-  rebase aborted
-  $ cd ..
-
+  $ hg abort
+  rebase aborted
+  $ cd ..
+
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1923,6 +1923,14 @@
 obsoleteextinctsuccessors,
 )
 
+def abortrebase(ui, repo, **opts):
+if opts.get('no_backup'):
+raise error.Abort(_("aborting rebase does not support no-backup flag"))
+with repo.wlock(), repo.lock():
+rbsrt = rebaseruntime(repo, ui)
+rbsrt._prepareabortorcontinue(isabort=True, backup=True,
+  suppwarns=False)
+
 def summaryhook(ui, repo):
 if not repo.vfs.exists('rebasestate'):
 return
@@ -1951,4 +1959,4 @@
  _("specify merge tool for rebase")))
 cmdutil.summaryhooks.add('rebase', summaryhook)
 statemod.addunfinished('rebase', fname='rebasestate', stopflag=True,
-continueflag=True)
+continueflag=True, abortfunc=abortrebase)



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


Re: [PATCH evolve-ext v2] py3: broad pass for python3 compatibility

2019-07-06 Thread Martin von Zweigbergk via Mercurial-devel
On Thu, Jul 4, 2019, 16:59 Ludovic Chabant  wrote:

>
> >
> > Should opts[x], opts.get(x), etc really use bytes? They usually get
> passed as **opts, which means their keys are str, I think.
> >
>
> Sounds OK to me -- there's probably a whole bunch of places that might
> need to be excluded. It might be worth exploring doing the opposite
> approach, i.e. manually adding byte strings until things work.
>


I've spent a few hours on that and it feels like I'm making good progress.
I'll spend a few more when I get back from vacation (Monday). I'll let you
know how it goes.

>
___
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