D6665: continue: added support for graft

2019-10-04 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16792.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6665?vs=16173=16792

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

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

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

CHANGE DETAILS

diff --git a/tests/test-issue1175.t b/tests/test-issue1175.t
--- a/tests/test-issue1175.t
+++ b/tests/test-issue1175.t
@@ -1,3 +1,11 @@
+#testcases continueflag continuecommand
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 https://bz.mercurial-scm.org/1175
 
   $ hg init
@@ -80,7 +88,7 @@
   $ hg resolve --mark b
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:5974126fad84 "b1"
   warning: can't find ancestor for 'b' copied from 'a'!
   $ hg log -f b -T 'changeset:   {rev}:{node|short}\nsummary: {desc}\n\n'
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1,4 +1,4 @@
-#testcases abortcommand abortflag
+#testcases commandmode abortflag continueflag
 
   $ cat >> $HGRCPATH < [extdiff]
@@ -13,6 +13,13 @@
   > EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 Create a repo with some stuff in it:
 
   $ hg init a
@@ -92,9 +99,11 @@
 
   $ hg -q up -cr tip
   $ hg rm -q e
-  $ hg graft --continue
-  abort: no graft in progress
-  [255]
+  $ hg continue
+  abort: no graft in progress (continueflag !)
+  abort: no operation in progress (no-continueflag !)
+  [255]
+
   $ hg revert -r . -q e
 
 Need to specify a rev:
@@ -1697,7 +1706,13 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+
+#if commandmode
+  $ hg continue --dry-run
+  graft in progress, will be resumed
+#endif
+
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1754,7 +1769,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1803,7 +1818,7 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1843,7 +1858,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1997,7 +2012,7 @@
 
   $ hg abort
   abort: no interrupted graft to abort (abortflag !)
-  abort: no operation in progress (abortcommand !)
+  abort: no operation in progress (no-abortflag !)
   [255]
 
 when stripping is required
@@ -2026,7 +2041,7 @@
   abort: cannot specify any other flag with '--abort'
   [255]
 
-#if abortcommand
+#if commandmode
 when in dry-run mode
   $ hg abort --dry-run
   graft in progress, will be aborted
@@ -2273,7 +2288,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
@@ -2350,7 +2365,7 @@
   $ hg resolve --mark
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg diff
   diff -r 2aa9ad1006ff a
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2630,6 +2630,7 @@
 statemod.addunfinished(
 'graft', fname='graftstate', clearable=True, stopflag=True,
 continueflag=True, abortfunc=cmdutil.hgabortgraft,
+continuefunc=cmdutil.continuegraft,
 cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
 )
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3426,6 +3426,29 @@
 graftstate = statemod.cmdstate(repo, 'graftstate')
 return abortgraft(ui, repo, graftstate)
 
+def continuegraft(ui, repo):
+"""logic to resume interrupted graft using 'hg continue'"""
+with repo.wlock():
+graftstate = statemod.cmdstate(repo, 'graftstate')
+opts = {}
+statedata = {}
+cont = True
+basectx = None
+nodes, opts = updateopts(repo, graftstate, opts)
+revs = [repo[node].rev() for node in nodes]
+skipped = set()
+if basectx is None:
+# check for merges
+for rev in repo.revs('%ld and merge()', revs):
+ui.warn(_('skipping ungraftable merge revision %d\n') % rev)
+skipped.add(rev)
+revs = [r for r in revs if r not in 

D6659: graft: split graft code into seperate functions

2019-10-04 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16791.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6659?vs=16155=16791

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

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

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
@@ -2470,9 +2470,6 @@
 if not opts.get('date') and opts.get('currentdate'):
 opts['date'] = "%d %d" % dateutil.makedate()
 
-editor = cmdutil.getcommiteditor(editform='graft',
- **pycompat.strkwargs(opts))
-
 cont = False
 if opts.get('no_commit'):
 if opts.get('edit'):
@@ -2518,16 +2515,7 @@
 raise error.Abort(_("can't specify --continue and revisions"))
 # read in unfinished revisions
 if graftstate.exists():
-statedata = cmdutil.readgraftstate(repo, graftstate)
-if statedata.get('date'):
-opts['date'] = statedata['date']
-if statedata.get('user'):
-opts['user'] = statedata['user']
-if statedata.get('log'):
-opts['log'] = True
-if statedata.get('no_commit'):
-opts['no_commit'] = statedata.get('no_commit')
-nodes = statedata['nodes']
+nodes, opts = cmdutil.updateopts(repo, graftstate, opts)
 revs = [repo[node].rev() for node in nodes]
 else:
 cmdutil.wrongtooltocontinue(repo, _('graft'))
@@ -2619,69 +2607,9 @@
 
 if opts.get('no_commit'):
 statedata['no_commit'] = True
-for pos, ctx in enumerate(repo.set("%ld", revs)):
-desc = '%d:%s "%s"' % (ctx.rev(), ctx,
-   ctx.description().split('\n', 1)[0])
-names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
-if names:
-desc += ' (%s)' % ' '.join(names)
-ui.status(_('grafting %s\n') % desc)
-if opts.get('dry_run'):
-continue
-
-source = ctx.extra().get('source')
-extra = {}
-if source:
-extra['source'] = source
-extra['intermediate-source'] = ctx.hex()
-else:
-extra['source'] = ctx.hex()
-user = ctx.user()
-if opts.get('user'):
-user = opts['user']
-statedata['user'] = user
-date = ctx.date()
-if opts.get('date'):
-date = opts['date']
-statedata['date'] = date
-message = ctx.description()
-if opts.get('log'):
-message += '\n(grafted from %s)' % ctx.hex()
-statedata['log'] = True
-
-# we don't merge the first commit when continuing
-if not cont:
-# perform the graft merge with p1(rev) as 'ancestor'
-overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
-base = ctx.p1() if basectx is None else basectx
-with ui.configoverride(overrides, 'graft'):
-stats = mergemod.graft(repo, ctx, base, ['local', 'graft'])
-# report any conflicts
-if stats.unresolvedcount > 0:
-# write out state for --continue
-nodes = [repo[rev].hex() for rev in revs[pos:]]
-statedata['nodes'] = nodes
-stateversion = 1
-graftstate.save(stateversion, statedata)
-hint = _("use 'hg resolve' and 'hg graft --continue'")
-raise error.Abort(
-_("unresolved conflicts, can't continue"),
-hint=hint)
-else:
-cont = False
-
-# commit if --no-commit is false
-if not opts.get('no_commit'):
-node = repo.commit(text=message, user=user, date=date, extra=extra,
-   editor=editor)
-if node is None:
-ui.warn(
-_('note: graft of %d:%s created no changes to commit\n') %
-(ctx.rev(), ctx))
-# checking that newnodes exist because old state files won't have 
it
-elif statedata.get('newnodes') is not None:
-statedata['newnodes'].append(node)
-
+
+cmdutil.finishgraft(repo, ui, basectx, revs, statedata, cont, opts,
+graftstate)
 # remove state when we complete successfully
 if not opts.get('dry_run'):
 graftstate.delete()
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3425,3 +3425,87 @@
 with repo.wlock():
 graftstate = statemod.cmdstate(repo, 'graftstate')
 return abortgraft(ui, repo, graftstate)
+
+def finishgraft(repo, ui, basectx, revs, statedata, cont, opts,
+graftstate=None):
+"""logic to 

D6659: graft: split graft code into seperate functions

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


  @durin42 done.

REPOSITORY
  rHG Mercurial

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

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

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


D6735: update: added support for --abort flag(issue4404)

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


  @durin42 I don't think the subrepos are properly initialized in the tests. I 
would be updating them soon.

REPOSITORY
  rHG Mercurial

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

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

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


D6735: update: added support for --abort flag(issue4404)

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

INLINE COMMENTS

> mharbison72 wrote in test-merge-tools.t:2092
> When you add more tests, please include some with 1 dirty subrepo, and then 
> another where the first subrepo is already merged/resolved, and the second 
> subrepo is dirty and pending a merge/resolve.  If it simplifies the initial 
> implementation to detect a dirty subrepo and then abort the `--abort` before 
> it starts, that seems fine.

@mharbison72 Have a look. I have updated the diff.

REPOSITORY
  rHG Mercurial

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

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

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


D6735: update: added support for --abort flag(issue4404)

2019-08-22 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16294.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6735?vs=16262=16294

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  tests/test-update-abort.t

CHANGE DETAILS

diff --git a/tests/test-update-abort.t b/tests/test-update-abort.t
new file mode 100644
--- /dev/null
+++ b/tests/test-update-abort.t
@@ -0,0 +1,177 @@
+Tests for 'hg update --abort'
+
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > graphlog=
+  > EOF
+
+Basic test
+  $ hg init test
+  $ cd test
+  $ echo before > file
+  $ hg add file
+  $ hg commit -mbefore
+  $ echo after > file
+  $ hg commit -mafter
+  $ echo edited > file
+
+abort flag with no interrupted update
+  $ hg update --abort
+  abort: no update in progress
+  [255]
+
+Pre-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+  $ hg update 0
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+
+  $ hg update --abort
+  aborting the update, updating back to 47d1da7c1f80
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  update aborted
+  working directory is now at 47d1da7c1f80
+
+Post-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+
+Test when not all files are resolved
+  $ echo foo > foo
+  $ hg add foo
+  $ hg commit -m "added foo"
+  $ echo changed > file
+  $ echo bar > foo
+  $ hg update 0
+  file 'foo' was deleted in other [destination] but was modified in local 
[working copy].
+  You can use (c)hanged version, (d)elete, or leave (u)nresolved.
+  What do you want to do? u
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 2 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+  $ echo resolved > file
+  $ hg resolve --mark
+  (no more unresolved files)
+  $ cat file
+  resolved
+  $ hg update --abort
+  aborting the update, updating back to a2b94c20eadb
+  merging file
+  merging foo
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
+  update aborted
+  working directory is now at a2b94c20eadb
+  $ cat file
+  changed
+  $ cat foo
+  bar
+  $ cd ..
+
+Test with dirty subrepo
+  $ hg init repo
+  $ cd repo
+  $ echo foo > bar
+  $ hg add bar
+  $ hg commit -minitial
+  $ mkdir subrepo
+  $ cd subrepo
+  $ echo foo1 > bar1
+  $ hg add bar1
+  $ hg commit -m "initial subrepo"
+  $ echo edited > bar1
+  $ hg up 0
+  file 'subrepo/bar1' was deleted in other [destination] but was modified in 
local [working copy].
+  You can use (c)hanged version, (d)elete, or leave (u)nresolved.
+  What do you want to do? u
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+  $ hg update --abort
+  aborting the update, updating back to 4fa4579cc2b0
+  merging subrepo/bar1
+  warning: conflicts while merging subrepo/bar1! (edit, then use 'hg resolve 
--mark')
+  update aborted
+  working directory is now at 4fa4579cc2b0
+  $ cat bar1
+  edited
+  $ cd ..
+
+Test with not all subrepos resolved
+  $ mkdir subrepo2
+  $ cd subrepo2
+  $ echo foo2 > bar2
+  $ hg add bar2
+  $ hg commit -m "initial subrepo2"
+  $ echo bar > bar2
+  $ cd ..
+  $ cd subrepo
+  $ echo edited1 > bar1
+  $ cd ..
+  $ hg up 0
+  file 'subrepo/bar1' was deleted in other [destination] but was modified in 
local [working copy].
+  You can use (c)hanged version, (d)elete, or leave (u)nresolved.
+  What do you want to do? u
+  file 'subrepo2/bar2' was deleted in other [destination] but was modified in 
local [working copy].
+  You can use (c)hanged version, (d)elete, or leave (u)nresolved.
+  What do you want to do? u
+  0 files updated, 0 files merged, 0 files removed, 2 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+  $ cd subrepo2
+  $ echo resolved > bar2
+  $ cat bar2
+  resolved
+  $ hg resolve --mark
+  (no more unresolved 

D6735: update: added support for --abort flag(issue4404)

2019-08-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 marked an inline comment as done.
taapas1128 updated this revision to Diff 16262.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6735?vs=16261=16262

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  tests/test-update-abort.t

CHANGE DETAILS

diff --git a/tests/test-update-abort.t b/tests/test-update-abort.t
new file mode 100644
--- /dev/null
+++ b/tests/test-update-abort.t
@@ -0,0 +1,95 @@
+Tests for 'hg update --abort'
+
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > graphlog=
+  > EOF
+
+Basic test
+  $ hg init test
+  $ cd test
+  $ echo before > file
+  $ hg add file
+  $ hg commit -mbefore
+  $ echo after > file
+  $ hg commit -mafter
+  $ echo edited > file
+
+Pre-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+  $ hg update 0
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+
+  $ hg update --abort
+  aborting the update, updating back to 47d1da7c1f80
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  update aborted
+  working directory is now at 47d1da7c1f80
+
+Post-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+
+Test when not all files are resolved
+  $ echo foo > foo
+  $ hg add foo
+  $ hg commit -m "added foo"
+  $ echo changed > file
+  $ echo bar > foo
+  $ hg update 0
+  file 'foo' was deleted in other [destination] but was modified in local 
[working copy].
+  You can use (c)hanged version, (d)elete, or leave (u)nresolved.
+  What do you want to do? u
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 2 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+  $ echo resolved > file
+  $ cat file
+  resolved
+  $ hg update --abort
+  aborting the update, updating back to a2b94c20eadb
+  merging file
+  merging foo
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
+  update aborted
+  working directory is now at a2b94c20eadb
+  $ cat file
+  changed
+  $ cat foo
+  bar
+  $ cd ..
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -984,6 +984,34 @@
 _showstats(repo, stats)
 return stats.unresolvedcount > 0
 
+def _unmarkandresolvelocal(ui, repo , ms):
+"""Helper for abortupdate(). This unmarks partially resolved files and then
+resolves the update generated conflicts."""
+wctx = repo[None]
+for f in ms:
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
+try:
+overrides = {('ui', 'forcemerge'): ':local'}
+with ui.configoverride(overrides, 'resolve'):
+ms.preresolve(f, wctx)
+ms.resolve(f, wctx)
+finally:
+ms.commit()
+
+def abortupdate(ui, repo):
+"""logic to abort an conflicted update"""
+ms = mergemod.mergestate.read(repo)
+node = ms.localctx.hex()
+_unmarkandresolvelocal(ui, repo, ms)
+repo.ui.status(_("aborting the update, updating back to"
+ " %s\n") % node[:12])
+mergemod.update(repo, node, branchmerge=False, force=False)
+ms2 = mergemod.mergestate.read(repo)
+_unmarkandresolvelocal(ui, repo, ms2)
+ui.status(_("update aborted\n"))
+ui.status(_("working directory is now at %s\n") % node[:12])
+
 def _incoming(displaychlist, subreporecurse, ui, repo, source,
 opts, buffered=False):
 """
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6154,6 +6154,7 @@
 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
 ('c', 'check', None, _('require clean working directory')),
 ('m', 'merge', None, _('merge uncommitted changes')),
+('', 'abort', False, _('abort interrupted update')),
 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
 

D6735: update: added support for --abort flag(issue4404)

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

INLINE COMMENTS

> pulkit wrote in test-merge-tools.t:2092
> I suggest taking `update --abort` tests in a new file as we will need to 
> extensively test that.

I have created a separate file will add more tests.

REPOSITORY
  rHG Mercurial

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

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

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


D6735: update: added support for --abort flag(issue4404)

2019-08-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16261.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6735?vs=16251=16261

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  tests/test-update-abort.t

CHANGE DETAILS

diff --git a/tests/test-update-abort.t b/tests/test-update-abort.t
new file mode 100644
--- /dev/null
+++ b/tests/test-update-abort.t
@@ -0,0 +1,82 @@
+Tests for 'hg update --abort'
+
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > graphlog=
+  > EOF
+
+Basic test
+  $ hg init test
+  $ cd test
+  $ echo before > file
+  $ hg add file
+  $ hg commit -mbefore
+  $ echo after > file
+  $ hg commit -mafter
+  $ echo edited > file
+
+Pre-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+  $ hg update 0
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+
+  $ hg update --abort
+  aborting the update, updating back to 47d1da7c1f80
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  update aborted
+  working directory is now at 47d1da7c1f80
+
+Post-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+
+  $ hg update 0
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+  $ echo resolved > file
+  $ cat file
+  resolved
+  $ hg update --abort
+  aborting the update, updating back to 47d1da7c1f80
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  update aborted
+  working directory is now at 47d1da7c1f80
+  $ cat file
+  edited
+  $ cd ..
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -984,6 +984,34 @@
 _showstats(repo, stats)
 return stats.unresolvedcount > 0
 
+def _unmarkandresolvelocal(ui, repo , ms):
+"""Helper for abortupdate(). This unmarks partially resolved files and then
+resolves the update generated conflicts."""
+wctx = repo[None]
+for f in ms:
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
+try:
+overrides = {('ui', 'forcemerge'): ':local'}
+with ui.configoverride(overrides, 'resolve'):
+ms.preresolve(f, wctx)
+ms.resolve(f, wctx)
+finally:
+ms.commit()
+
+def abortupdate(ui, repo):
+"""logic to abort an conflicted update"""
+ms = mergemod.mergestate.read(repo)
+node = ms.localctx.hex()
+_unmarkandresolvelocal(ui, repo, ms)
+repo.ui.status(_("aborting the update, updating back to"
+ " %s\n") % node[:12])
+mergemod.update(repo, node, branchmerge=False, force=False)
+ms2 = mergemod.mergestate.read(repo)
+_unmarkandresolvelocal(ui, repo, ms2)
+ui.status(_("update aborted\n"))
+ui.status(_("working directory is now at %s\n") % node[:12])
+
 def _incoming(displaychlist, subreporecurse, ui, repo, source,
 opts, buffered=False):
 """
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6154,6 +6154,7 @@
 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
 ('c', 'check', None, _('require clean working directory')),
 ('m', 'merge', None, _('merge uncommitted changes')),
+('', 'abort', False, _('abort interrupted update')),
 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
 ('r', 'rev', '', _('revision'), _('REV'))
  ] + mergetoolopts,
@@ -6220,6 +6221,7 @@
 clean = opts.get(r'clean')
 check = opts.get(r'check')
 merge = opts.get(r'merge')
+abort = opts.get(r'abort')
 if rev and node:
 raise error.Abort(_("please specify just one revision"))
 
@@ -6245,6 +6247,8 @@
 updatecheck = 'none'
 
 with repo.wlock():
+if abort:
+return hg.abortupdate(ui, repo)
 cmdutil.clearunfinished(repo)
 

D6735: update: added support for --abort flag(issue4404)

2019-08-17 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16251.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6735?vs=16250=16251

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  tests/test-merge-tools.t

CHANGE DETAILS

diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -4,6 +4,8 @@
   $ cat >> $HGRCPATH << EOF
   > [ui]
   > merge=
+  > [extensions]
+  > graphlog=
   > EOF
   $ hg init repo
   $ cd repo
@@ -2086,3 +2088,63 @@
   f = false
 
   $ cd ..
+
+Test for 'hg update --abort'
+
+  $ hg init test
+  $ cd test
+  $ echo before > file
+  $ hg add file
+  $ hg commit -mbefore
+  $ echo after > file
+  $ hg commit -mafter
+  $ echo edited > file
+
+Pre-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+  $ hg update 0
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+
+  $ hg update --abort
+  aborting the update, updating back to 47d1da7c1f80
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  update aborted
+  working directory is now at 47d1da7c1f80
+
+Post-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+
+  $ cd ..
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -984,6 +984,34 @@
 _showstats(repo, stats)
 return stats.unresolvedcount > 0
 
+def _unmarkandresolvelocal(ui, repo , ms):
+"""Helper for abortupdate(). This unmarks partially resolved files and then
+resolves the update generated conflicts."""
+wctx = repo[None]
+for f in ms:
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
+try:
+overrides = {('ui', 'forcemerge'): ':local'}
+with ui.configoverride(overrides, 'resolve'):
+ms.preresolve(f, wctx)
+ms.resolve(f, wctx)
+finally:
+ms.commit()
+
+def abortupdate(ui, repo):
+"""logic to abort an conflicted update"""
+ms = mergemod.mergestate.read(repo)
+node = ms.localctx.hex()
+_unmarkandresolvelocal(ui, repo, ms)
+repo.ui.status(_("aborting the update, updating back to"
+ " %s\n") % node[:12])
+mergemod.update(repo, node, branchmerge=False, force=False)
+ms2 = mergemod.mergestate.read(repo)
+_unmarkandresolvelocal(ui, repo, ms2)
+ui.status(_("update aborted\n"))
+ui.status(_("working directory is now at %s\n") % node[:12])
+
 def _incoming(displaychlist, subreporecurse, ui, repo, source,
 opts, buffered=False):
 """
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6154,6 +6154,7 @@
 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
 ('c', 'check', None, _('require clean working directory')),
 ('m', 'merge', None, _('merge uncommitted changes')),
+('', 'abort', False, _('abort interrupted update')),
 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
 ('r', 'rev', '', _('revision'), _('REV'))
  ] + mergetoolopts,
@@ -6220,6 +6221,7 @@
 clean = opts.get(r'clean')
 check = opts.get(r'check')
 merge = opts.get(r'merge')
+abort = opts.get(r'abort')
 if rev and node:
 raise error.Abort(_("please specify just one revision"))
 
@@ -6245,6 +6247,8 @@
 updatecheck = 'none'
 
 with repo.wlock():
+if abort:
+return hg.abortupdate(ui, repo)
 cmdutil.clearunfinished(repo)
 if date:
 rev = cmdutil.finddate(ui, repo, date)



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


D6735: update: added support for --abort flag(issue4404)

2019-08-17 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16250.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6735?vs=16249=16250

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  tests/test-merge-tools.t

CHANGE DETAILS

diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -4,6 +4,8 @@
   $ cat >> $HGRCPATH << EOF
   > [ui]
   > merge=
+  > [extensions]
+  > graphlog=
   > EOF
   $ hg init repo
   $ cd repo
@@ -2086,3 +2088,63 @@
   f = false
 
   $ cd ..
+
+Test for 'hg update --abort'
+
+  $ hg init test
+  $ cd test
+  $ echo before > file
+  $ hg add file
+  $ hg commit -mbefore
+  $ echo after > file
+  $ hg commit -mafter
+  $ echo edited > file
+
+Pre-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+  $ hg update 0
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+
+  $ hg update --abort
+  aborting the update, updating back to 47d1da7c1f80
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  update aborted
+  working directory is now at 47d1da7c1f80
+
+Post-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+
+  $ cd ..
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -984,6 +984,34 @@
 _showstats(repo, stats)
 return stats.unresolvedcount > 0
 
+def _unmarkandresolvelocal(ui, repo , ms):
+"""Helper for abortupdate(). This unmarks partially resolved files and then
+resolves the update generated conflicts."""
+wctx = repo[None]
+for f in ms:
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
+try:
+overrides = {('ui', 'forcemerge'): ':local'}
+with ui.configoverride(overrides, 'resolve'):
+ms.preresolve(f, wctx)
+ms.resolve(f, wctx)
+finally:
+ms.commit()
+
+def abortupdate(ui, repo):
+"""logic to abort an conflicted update"""
+ms = mergemod.mergestate.read(repo)
+node = ms.localctx.hex()
+_unmarkandresolvelocal(ui, repo, ms)
+repo.ui.status(_("aborting the update, updating back to"
+ " %s\n") % node[:12])
+mergemod.update(repo, node, branchmerge=False, force=False)
+ms2 = mergemod.mergestate.read(repo)
+_unmarkandresolvelocal(ui, repo, ms)(ui, repo, ms2)
+ui.status(_("update aborted\n"))
+ui.status(_("working directory is now at %s\n") % node[:12])
+
 def _incoming(displaychlist, subreporecurse, ui, repo, source,
 opts, buffered=False):
 """
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6154,6 +6154,7 @@
 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
 ('c', 'check', None, _('require clean working directory')),
 ('m', 'merge', None, _('merge uncommitted changes')),
+('', 'abort', False, _('abort interrupted update')),
 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
 ('r', 'rev', '', _('revision'), _('REV'))
  ] + mergetoolopts,
@@ -6220,6 +6221,7 @@
 clean = opts.get(r'clean')
 check = opts.get(r'check')
 merge = opts.get(r'merge')
+abort = opts.get(r'abort')
 if rev and node:
 raise error.Abort(_("please specify just one revision"))
 
@@ -6245,6 +6247,8 @@
 updatecheck = 'none'
 
 with repo.wlock():
+if abort:
+return hg.abortupdate(ui, repo)
 cmdutil.clearunfinished(repo)
 if date:
 rev = cmdutil.finddate(ui, repo, date)



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


D6735: update: added support for --abort flag(issue4404)

2019-08-17 Thread taapas1128 (Taapas Agrawal)
taapas1128 created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch adds functionality to abort a conflicted
  update. A new function `hg.abortupdate()` is added for
  the purpose which has a helper function
  `hg._unmarkandresolvelocal()` which deals with the
  conflicts occured.
  
  Results are shown in tests.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/transplant.py
  mercurial/commands.py
  mercurial/hg.py
  tests/test-merge-tools.t

CHANGE DETAILS

diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -4,6 +4,8 @@
   $ cat >> $HGRCPATH << EOF
   > [ui]
   > merge=
+  > [extensions]
+  > graphlog=
   > EOF
   $ hg init repo
   $ cd repo
@@ -2086,3 +2088,63 @@
   f = false
 
   $ cd ..
+
+Test for 'hg update --abort'
+
+  $ hg init test
+  $ cd test
+  $ echo before > file
+  $ hg add file
+  $ hg commit -mbefore
+  $ echo after > file
+  $ hg commit -mafter
+  $ echo edited > file
+
+Pre-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+  $ hg update 0
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+
+  $ hg update --abort
+  aborting the update, updating back to 47d1da7c1f80
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  update aborted
+  working directory is now at 47d1da7c1f80
+
+Post-update log and file content
+  $ hg glog
+  @  changeset:   1:47d1da7c1f80
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: after
+  |
+  o  changeset:   0:dd67ebc4de84
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: before
+  
+
+  $ cat file
+  edited
+
+  $ cd ..
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -984,6 +984,34 @@
 _showstats(repo, stats)
 return stats.unresolvedcount > 0
 
+def _unmarkandresolvelocal(ui, repo , ms):
+"""Helper for abortupdate(). This unmarks partially resolved files and then
+resolves the update generated conflicts."""
+wctx = repo[None]
+for f in ms:
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED_PATH)
+ms.mark(f, mergemod.MERGE_RECORD_UNRESOLVED)
+try:
+overrides = {('ui', 'forcemerge'): ':local'}
+with ui.configoverride(overrides, 'resolve'):
+ms.preresolve(f, wctx)
+ms.resolve(f, wctx)
+finally:
+ms.commit()
+
+def abortupdate(ui, repo):
+"""logic to abort an conflicted update"""
+ms = mergemod.mergestate.read(repo)
+node = ms.localctx.hex()
+_unmarkandresolvelocal(ui, repo, ms)
+repo.ui.status(_("aborting the update, updating back to"
+ " %s\n") % node[:12])
+mergemod.update(repo, node, branchmerge=False, force=False)
+ms2 = mergemod.mergestate.read(repo)
+_unmarkandresolvelocal(ui, repo, ms)(ui, repo, ms2)
+ui.status(_("update aborted\n"))
+ui.status(_("working directory is now at %s\n") % node[:12])
+
 def _incoming(displaychlist, subreporecurse, ui, repo, source,
 opts, buffered=False):
 """
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6154,6 +6154,7 @@
 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
 ('c', 'check', None, _('require clean working directory')),
 ('m', 'merge', None, _('merge uncommitted changes')),
+('', 'abort', False, _('abort interrupted update')),
 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
 ('r', 'rev', '', _('revision'), _('REV'))
  ] + mergetoolopts,
@@ -6220,6 +6221,7 @@
 clean = opts.get(r'clean')
 check = opts.get(r'check')
 merge = opts.get(r'merge')
+abort = opts.get(r'abort')
 if rev and node:
 raise error.Abort(_("please specify just one revision"))
 
@@ -6245,6 +6247,8 @@
 updatecheck = 'none'
 
 with repo.wlock():
+if abort:
+return hg.abortupdate(ui, repo)
 cmdutil.clearunfinished(repo)
 if date:
 rev = cmdutil.finddate(ui, repo, date)
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -786,13 +786,27 @@
 return n and nodemod.hex(n) or ''
 
 

D6678: continue: added support for histedit

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


  @pulkit This one is ready too.

REPOSITORY
  rHG Mercurial

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

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

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


D6695: transplant: added support for --stop flag

2019-08-16 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG4d10aada6c3b: transplant: added support for --stop flag 
(authored by taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6695?vs=16215=16223

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

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -2,6 +2,7 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
+  > graphlog=
   > EOF
 
 #if continueflag
@@ -19,6 +20,9 @@
   $ hg transplant --continue --all
   abort: --continue is incompatible with --branch, --all and --merge
   [255]
+  $ hg transplant --stop --all
+  abort: --stop is incompatible with --branch, --all and --merge
+  [255]
   $ hg transplant --all tip
   abort: --all requires a branch revision
   [255]
@@ -376,7 +380,8 @@
   applying 722f4667af76
   722f4667af76 transplanted to 76e321915884
 
-transplant --continue
+
+transplant --continue and --stop behaviour
 
   $ hg init ../tc
   $ cd ../tc
@@ -416,6 +421,36 @@
   $ echo foobar > foo
   $ hg ci -mfoobar
   created new head
+
+Repo log before transplant
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
   $ hg transplant 1:3
   applying 46ae92138f3c
   patching file foo
@@ -425,6 +460,49 @@
   abort: fix up the working directory and run hg transplant --continue
   [255]
 
+  $ hg transplant --stop
+  stopped the interrupted transplant
+  working directory is now at e8643552fde5
+Repo log after abort
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
+  $ hg transplant 1:3
+  applying 46ae92138f3c
+  file added already exists
+  1 out of 1 hunks FAILED -- saving rejects to file added.rej
+  patching file foo
+  Hunk #1 FAILED at 0
+  1 out of 1 hunks FAILED -- saving rejects to file foo.rej
+  patch failed to apply
+  abort: fix up the working directory and run hg transplant --continue
+  [255]
+
 transplant -c shouldn't use an old changeset
 
   $ hg up -C
@@ -436,6 +514,9 @@
   abort: no transplant to continue (continueflag !)
   abort: no operation in progress (no-continueflag !)
   [255]
+  $ hg transplant --stop
+  abort: no interrupted transplant found
+  [255]
   $ hg transplant 1
   applying 46ae92138f3c
   patching file foo
@@ -489,23 +570,23 @@
   [255]
   $ hg transplant 1:3
   abort: transplant in progress
-  (use 'hg transplant --continue' or 'hg update' to abort)
+  (use 'hg transplant --continue' or 'hg transplant --stop')
   [255]
   $ hg status -v
   A bar
+  ? added.rej
   ? baz.rej
   ? foo.rej
   # The repository is in an unfinished *transplant* state.
   
   # To continue:hg transplant --continue
-  # To abort:   hg update
+  # To stop:hg transplant --stop
   
   $ echo fixed > baz
   $ hg continue
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
-
   $ cd ..
 
 Issue: Test transplant --merge
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -412,6 +412,17 @@
 # this is kept only to reduce changes in a patch.
 pass
 
+def stop(self, ui, repo):
+"""logic to stop an interrupted transplant"""
+if self.canresume():
+startctx = repo['.']
+

D6695: transplant: added support for --stop flag

2019-08-15 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16215.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6695?vs=16214=16215

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

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -2,6 +2,7 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
+  > graphlog=
   > EOF
 
 #if continueflag
@@ -19,6 +20,9 @@
   $ hg transplant --continue --all
   abort: --continue is incompatible with --branch, --all and --merge
   [255]
+  $ hg transplant --stop --all
+  abort: --stop is incompatible with --branch, --all and --merge
+  [255]
   $ hg transplant --all tip
   abort: --all requires a branch revision
   [255]
@@ -376,7 +380,8 @@
   applying 722f4667af76
   722f4667af76 transplanted to 76e321915884
 
-transplant --continue
+
+transplant --continue and --stop behaviour
 
   $ hg init ../tc
   $ cd ../tc
@@ -416,6 +421,36 @@
   $ echo foobar > foo
   $ hg ci -mfoobar
   created new head
+
+Repo log before transplant
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
   $ hg transplant 1:3
   applying 46ae92138f3c
   patching file foo
@@ -425,6 +460,49 @@
   abort: fix up the working directory and run hg transplant --continue
   [255]
 
+  $ hg transplant --stop
+  stopped the interrupted transplant
+  working directory is now at e8643552fde5
+Repo log after abort
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
+  $ hg transplant 1:3
+  applying 46ae92138f3c
+  file added already exists
+  1 out of 1 hunks FAILED -- saving rejects to file added.rej
+  patching file foo
+  Hunk #1 FAILED at 0
+  1 out of 1 hunks FAILED -- saving rejects to file foo.rej
+  patch failed to apply
+  abort: fix up the working directory and run hg transplant --continue
+  [255]
+
 transplant -c shouldn't use an old changeset
 
   $ hg up -C
@@ -436,6 +514,9 @@
   abort: no transplant to continue (continueflag !)
   abort: no operation in progress (no-continueflag !)
   [255]
+  $ hg transplant --stop
+  abort: no interrupted transplant found
+  [255]
   $ hg transplant 1
   applying 46ae92138f3c
   patching file foo
@@ -489,23 +570,23 @@
   [255]
   $ hg transplant 1:3
   abort: transplant in progress
-  (use 'hg transplant --continue' or 'hg update' to abort)
+  (use 'hg transplant --continue' or 'hg transplant --stop')
   [255]
   $ hg status -v
   A bar
+  ? added.rej
   ? baz.rej
   ? foo.rej
   # The repository is in an unfinished *transplant* state.
   
   # To continue:hg transplant --continue
-  # To abort:   hg update
+  # To stop:hg transplant --stop
   
   $ echo fixed > baz
   $ hg continue
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
-
   $ cd ..
 
 Issue: Test transplant --merge
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -412,6 +412,17 @@
 # this is kept only to reduce changes in a patch.
 pass
 
+def stop(self, ui, repo):
+"""logic to stop an interrupted transplant"""
+if self.canresume():
+startctx = repo['.']
+hg.updaterepo(repo, startctx.node(), overwrite=True)
+ui.status(_("stopped the interrupted transplant\n"))
+

D6695: transplant: added support for --stop flag

2019-08-15 Thread taapas1128 (Taapas Agrawal)
taapas1128 edited the summary of this revision.
taapas1128 retitled this revision from "transplant: added support for --abort 
flag" to "transplant: added support for --stop flag".
taapas1128 marked an inline comment as done.
taapas1128 updated this revision to Diff 16214.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6695?vs=16162=16214

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

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -2,6 +2,7 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
+  > graphlog=
   > EOF
 
 #if continueflag
@@ -19,6 +20,9 @@
   $ hg transplant --continue --all
   abort: --continue is incompatible with --branch, --all and --merge
   [255]
+  $ hg transplant --stop --all
+  abort: --stop is incompatible with --branch, --all and --merge
+  [255]
   $ hg transplant --all tip
   abort: --all requires a branch revision
   [255]
@@ -376,7 +380,8 @@
   applying 722f4667af76
   722f4667af76 transplanted to 76e321915884
 
-transplant --continue
+
+transplant --continue and --abort behaviour
 
   $ hg init ../tc
   $ cd ../tc
@@ -416,6 +421,36 @@
   $ echo foobar > foo
   $ hg ci -mfoobar
   created new head
+
+Repo log before transplant
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
   $ hg transplant 1:3
   applying 46ae92138f3c
   patching file foo
@@ -425,6 +460,49 @@
   abort: fix up the working directory and run hg transplant --continue
   [255]
 
+  $ hg transplant --stop
+  stopped the interrupted transplant
+  working directory is now at e8643552fde5
+Repo log after abort
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
+  $ hg transplant 1:3
+  applying 46ae92138f3c
+  file added already exists
+  1 out of 1 hunks FAILED -- saving rejects to file added.rej
+  patching file foo
+  Hunk #1 FAILED at 0
+  1 out of 1 hunks FAILED -- saving rejects to file foo.rej
+  patch failed to apply
+  abort: fix up the working directory and run hg transplant --continue
+  [255]
+
 transplant -c shouldn't use an old changeset
 
   $ hg up -C
@@ -436,6 +514,9 @@
   abort: no transplant to continue (continueflag !)
   abort: no operation in progress (no-continueflag !)
   [255]
+  $ hg transplant --stop
+  abort: no interrupted transplant found
+  [255]
   $ hg transplant 1
   applying 46ae92138f3c
   patching file foo
@@ -489,23 +570,23 @@
   [255]
   $ hg transplant 1:3
   abort: transplant in progress
-  (use 'hg transplant --continue' or 'hg update' to abort)
+  (use 'hg transplant --continue' or 'hg transplant --stop')
   [255]
   $ hg status -v
   A bar
+  ? added.rej
   ? baz.rej
   ? foo.rej
   # The repository is in an unfinished *transplant* state.
   
   # To continue:hg transplant --continue
-  # To abort:   hg update
+  # To stop:hg transplant --stop
   
   $ echo fixed > baz
   $ hg continue
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
-
   $ cd ..
 
 Issue: Test transplant --merge
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -412,6 +412,17 @@
 # this is kept only to reduce changes in a patch.
 pass
 
+def stop(self, ui, repo):
+"""logic to stop an interrupted 

D6665: continue: added support for graft

2019-08-12 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16173.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6665?vs=16156=16173

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

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

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

CHANGE DETAILS

diff --git a/tests/test-issue1175.t b/tests/test-issue1175.t
--- a/tests/test-issue1175.t
+++ b/tests/test-issue1175.t
@@ -1,3 +1,11 @@
+#testcases continueflag continuecommand
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 https://bz.mercurial-scm.org/1175
 
   $ hg init
@@ -80,7 +88,7 @@
   $ hg resolve --mark b
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:5974126fad84 "b1"
   warning: can't find ancestor for 'b' copied from 'a'!
   $ hg log -f b -T 'changeset:   {rev}:{node|short}\nsummary: {desc}\n\n'
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1,4 +1,4 @@
-#testcases abortcommand abortflag
+#testcases commandmode abortflag continueflag
 
   $ cat >> $HGRCPATH < [extdiff]
@@ -13,6 +13,13 @@
   > EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 Create a repo with some stuff in it:
 
   $ hg init a
@@ -92,9 +99,11 @@
 
   $ hg -q up -cr tip
   $ hg rm -q e
-  $ hg graft --continue
-  abort: no graft in progress
-  [255]
+  $ hg continue
+  abort: no graft in progress (continueflag !)
+  abort: no operation in progress (no-continueflag !)
+  [255]
+
   $ hg revert -r . -q e
 
 Need to specify a rev:
@@ -1697,7 +1706,13 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+
+#if commandmode
+  $ hg continue --dry-run
+  graft in progress, will be resumed
+#endif
+
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1754,7 +1769,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1803,7 +1818,7 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1843,7 +1858,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1997,7 +2012,7 @@
 
   $ hg abort
   abort: no interrupted graft to abort (abortflag !)
-  abort: no operation in progress (abortcommand !)
+  abort: no operation in progress (no-abortflag !)
   [255]
 
 when stripping is required
@@ -2026,7 +2041,7 @@
   abort: cannot specify any other flag with '--abort'
   [255]
 
-#if abortcommand
+#if commandmode
 when in dry-run mode
   $ hg abort --dry-run
   graft in progress, will be aborted
@@ -2273,7 +2288,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
@@ -2350,7 +2365,7 @@
   $ hg resolve --mark
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg diff
   diff -r 2aa9ad1006ff a
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2630,6 +2630,7 @@
 statemod.addunfinished(
 'graft', fname='graftstate', clearable=True, stopflag=True,
 continueflag=True, abortfunc=cmdutil.hgabortgraft,
+continuefunc=cmdutil.continuegraft,
 cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
 )
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3426,6 +3426,29 @@
 graftstate = statemod.cmdstate(repo, 'graftstate')
 return abortgraft(ui, repo, graftstate)
 
+def continuegraft(ui, repo):
+"""logic to resume interrupted graft using 'hg continue'"""
+with repo.wlock():
+graftstate = statemod.cmdstate(repo, 'graftstate')
+opts = {}
+statedata = {}
+cont = True
+basectx = None
+nodes, opts = updateopts(repo, graftstate, opts)
+revs = [repo[node].rev() for node in nodes]
+skipped = set()
+if basectx is None:
+# check for merges
+for rev in repo.revs('%ld and merge()', revs):
+ui.warn(_('skipping ungraftable merge revision %d\n') % rev)
+skipped.add(rev)
+revs = [r for r in revs if r not in 

D6689: continue: added support for transplant

2019-08-09 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG0a4303c77637: continue: added support for transplant 
(authored by taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6689?vs=16161=16169

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

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -1,8 +1,16 @@
+#testcases commandmode continueflag
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = transplant --continue
+  > EOF
+#endif
+
   $ hg init t
   $ cd t
   $ hg transplant
@@ -424,8 +432,9 @@
   updated to "e8643552fde5: foobar"
   1 other heads for branch "default"
   $ rm added
-  $ hg transplant --continue
-  abort: no transplant to continue
+  $ hg continue
+  abort: no transplant to continue (continueflag !)
+  abort: no operation in progress (no-continueflag !)
   [255]
   $ hg transplant 1
   applying 46ae92138f3c
@@ -492,7 +501,7 @@
   # To abort:   hg update
   
   $ echo fixed > baz
-  $ hg transplant --continue
+  $ hg continue
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
@@ -881,7 +890,7 @@
   [255]
   $ hg status
   ? b.rej
-  $ hg transplant --continue
+  $ hg continue
   645035761929 skipped due to empty diff
 
   $ cd ..
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -734,6 +734,13 @@
 if cleanupfn:
 cleanupfn()
 
+def continuecmd(ui, repo):
+"""logic to resume an interrupted transplant using
+'hg continue'"""
+with repo.wlock():
+tp = transplanter(ui, repo, {})
+return tp.resume(repo, repo, {})
+
 revsetpredicate = registrar.revsetpredicate()
 
 @revsetpredicate('transplanted([set])')
@@ -760,6 +767,7 @@
 def extsetup(ui):
 statemod.addunfinished (
 'transplant', fname='transplant/journal', clearable=True,
+continuefunc=continuecmd,
 statushint=_('To continue:hg transplant --continue\n'
  'To abort:   hg update'),
 cmdhint=_("use 'hg transplant --continue' or 'hg update' to abort")



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


D6695: transplant: added support for --abort flag

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6695?vs=16159=16162

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

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -2,6 +2,7 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
+  > graphlog=
   > EOF
 
 #if continueflag
@@ -19,6 +20,9 @@
   $ hg transplant --continue --all
   abort: --continue is incompatible with --branch, --all and --merge
   [255]
+  $ hg transplant --abort --all
+  abort: --abort is incompatible with --branch, --all and --merge
+  [255]
   $ hg transplant --all tip
   abort: --all requires a branch revision
   [255]
@@ -376,7 +380,8 @@
   applying 722f4667af76
   722f4667af76 transplanted to 76e321915884
 
-transplant --continue
+
+transplant --continue and --abort behaviour
 
   $ hg init ../tc
   $ cd ../tc
@@ -416,6 +421,36 @@
   $ echo foobar > foo
   $ hg ci -mfoobar
   created new head
+
+Repo log before transplant
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
   $ hg transplant 1:3
   applying 46ae92138f3c
   patching file foo
@@ -425,6 +460,49 @@
   abort: fix up the working directory and run hg transplant --continue
   [255]
 
+  $ hg transplant --abort
+  transplant aborted
+  working directory is now at e8643552fde5
+Repo log after abort
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
+  $ hg transplant 1:3
+  applying 46ae92138f3c
+  file added already exists
+  1 out of 1 hunks FAILED -- saving rejects to file added.rej
+  patching file foo
+  Hunk #1 FAILED at 0
+  1 out of 1 hunks FAILED -- saving rejects to file foo.rej
+  patch failed to apply
+  abort: fix up the working directory and run hg transplant --continue
+  [255]
+
 transplant -c shouldn't use an old changeset
 
   $ hg up -C
@@ -436,6 +514,9 @@
   abort: no transplant to continue (continueflag !)
   abort: no operation in progress (no-continueflag !)
   [255]
+  $ hg transplant --abort
+  abort: no transplant to abort
+  [255]
   $ hg transplant 1
   applying 46ae92138f3c
   patching file foo
@@ -489,23 +570,23 @@
   [255]
   $ hg transplant 1:3
   abort: transplant in progress
-  (use 'hg transplant --continue' or 'hg update' to abort)
+  (use 'hg transplant --continue' or 'hg transplant --abort')
   [255]
   $ hg status -v
   A bar
+  ? added.rej
   ? baz.rej
   ? foo.rej
   # The repository is in an unfinished *transplant* state.
   
   # To continue:hg transplant --continue
-  # To abort:   hg update
+  # To abort:   hg transplant --abort
   
   $ echo fixed > baz
   $ hg continue
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
-
   $ cd ..
 
 Issue: Test transplant --merge
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -412,6 +412,17 @@
 # this is kept only to reduce changes in a patch.
 pass
 
+def abort(self, ui, repo):
+"""logic to abort an interrupted transplant"""
+if self.canresume():
+startctx = repo['.']
+hg.updaterepo(repo, startctx.node(), overwrite=True)
+ui.status(_("transplant aborted\n"))
+ui.status(_("working directory is now at %s\n") 

D6689: continue: added support for transplant

2019-08-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 marked an inline comment as done.
taapas1128 updated this revision to Diff 16161.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6689?vs=16158=16161

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

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -1,8 +1,16 @@
+#testcases commandmode continueflag
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = transplant --continue
+  > EOF
+#endif
+
   $ hg init t
   $ cd t
   $ hg transplant
@@ -424,8 +432,9 @@
   updated to "e8643552fde5: foobar"
   1 other heads for branch "default"
   $ rm added
-  $ hg transplant --continue
-  abort: no transplant to continue
+  $ hg continue
+  abort: no transplant to continue (continueflag !)
+  abort: no operation in progress (no-continueflag !)
   [255]
   $ hg transplant 1
   applying 46ae92138f3c
@@ -492,7 +501,7 @@
   # To abort:   hg update
   
   $ echo fixed > baz
-  $ hg transplant --continue
+  $ hg continue
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
@@ -881,7 +890,7 @@
   [255]
   $ hg status
   ? b.rej
-  $ hg transplant --continue
+  $ hg continue
   645035761929 skipped due to empty diff
 
   $ cd ..
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -734,6 +734,13 @@
 if cleanupfn:
 cleanupfn()
 
+def continuecmd(ui, repo):
+"""logic to resume an interrupted transplant using
+'hg continue'"""
+with repo.wlock():
+tp = transplanter(ui, repo, {})
+return tp.resume(repo, repo, {})
+
 revsetpredicate = registrar.revsetpredicate()
 
 @revsetpredicate('transplanted([set])')
@@ -760,6 +767,7 @@
 def extsetup(ui):
 statemod.addunfinished (
 'transplant', fname='transplant/journal', clearable=True,
+continuefunc=continuecmd,
 statushint=_('To continue:hg transplant --continue\n'
  'To abort:   hg update'),
 cmdhint=_("use 'hg transplant --continue' or 'hg update' to abort")



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


D6659: graft: split graft code into seperate functions

2019-08-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 added inline comments.

INLINE COMMENTS

> pulkit wrote in cmdutil.py:3495
> the function name is not correct with respect to what it does, maybe 
> something like `getopts` or something. Also, we no longer update the `opts`, 
> so we can drop that as argument and also need to update the function 
> description.

I havent removed `opts` from argument yet.

REPOSITORY
  rHG Mercurial

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

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

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


D6665: continue: added support for graft

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6665?vs=16121=16156

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

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

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

CHANGE DETAILS

diff --git a/tests/test-issue1175.t b/tests/test-issue1175.t
--- a/tests/test-issue1175.t
+++ b/tests/test-issue1175.t
@@ -1,3 +1,11 @@
+#testcases continueflag continuecommand
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 https://bz.mercurial-scm.org/1175
 
   $ hg init
@@ -80,7 +88,7 @@
   $ hg resolve --mark b
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:5974126fad84 "b1"
   warning: can't find ancestor for 'b' copied from 'a'!
   $ hg log -f b -T 'changeset:   {rev}:{node|short}\nsummary: {desc}\n\n'
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1,4 +1,4 @@
-#testcases abortcommand abortflag
+#testcases commandmode abortflag continueflag
 
   $ cat >> $HGRCPATH < [extdiff]
@@ -13,6 +13,13 @@
   > EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 Create a repo with some stuff in it:
 
   $ hg init a
@@ -92,9 +99,11 @@
 
   $ hg -q up -cr tip
   $ hg rm -q e
-  $ hg graft --continue
-  abort: no graft in progress
-  [255]
+  $ hg continue
+  abort: no graft in progress (continueflag !)
+  abort: no operation in progress (no-continueflag !)
+  [255]
+
   $ hg revert -r . -q e
 
 Need to specify a rev:
@@ -1697,7 +1706,13 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+
+#if commandmode
+  $ hg continue --dry-run
+  graft in progress, will be resumed
+#endif
+
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1754,7 +1769,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1803,7 +1818,7 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1843,7 +1858,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1997,7 +2012,7 @@
 
   $ hg abort
   abort: no interrupted graft to abort (abortflag !)
-  abort: no operation in progress (abortcommand !)
+  abort: no operation in progress (no-abortflag !)
   [255]
 
 when stripping is required
@@ -2026,7 +2041,7 @@
   abort: cannot specify any other flag with '--abort'
   [255]
 
-#if abortcommand
+#if commandmode
 when in dry-run mode
   $ hg abort --dry-run
   graft in progress, will be aborted
@@ -2273,7 +2288,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
@@ -2350,7 +2365,7 @@
   $ hg resolve --mark
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg diff
   diff -r 2aa9ad1006ff a
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2630,6 +2630,7 @@
 statemod.addunfinished(
 'graft', fname='graftstate', clearable=True, stopflag=True,
 continueflag=True, abortfunc=cmdutil.hgabortgraft,
+continuefunc=cmdutil.continuegraft,
 cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
 )
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3426,6 +3426,29 @@
 graftstate = statemod.cmdstate(repo, 'graftstate')
 return abortgraft(ui, repo, graftstate)
 
+def continuegraft(ui, repo):
+"""logic to resume interrupted graft using 'hg continue'"""
+with repo.wlock():
+graftstate = statemod.cmdstate(repo, 'graftstate')
+opts = {}
+statedata = {}
+cont = True
+basectx = None
+nodes, opts = continuegraftstate(repo, graftstate, opts)
+revs = [repo[node].rev() for node in nodes]
+skipped = set()
+if basectx is None:
+# check for merges
+for rev in repo.revs('%ld and merge()', revs):
+ui.warn(_('skipping ungraftable merge revision %d\n') % rev)
+skipped.add(rev)
+revs = [r for r in revs if r not in 

D6659: graft: split graft code into seperate functions

2019-08-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 marked an inline comment as done.
taapas1128 updated this revision to Diff 16155.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6659?vs=16120=16155

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

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

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
@@ -2470,9 +2470,6 @@
 if not opts.get('date') and opts.get('currentdate'):
 opts['date'] = "%d %d" % dateutil.makedate()
 
-editor = cmdutil.getcommiteditor(editform='graft',
- **pycompat.strkwargs(opts))
-
 cont = False
 if opts.get('no_commit'):
 if opts.get('edit'):
@@ -2518,16 +2515,7 @@
 raise error.Abort(_("can't specify --continue and revisions"))
 # read in unfinished revisions
 if graftstate.exists():
-statedata = cmdutil.readgraftstate(repo, graftstate)
-if statedata.get('date'):
-opts['date'] = statedata['date']
-if statedata.get('user'):
-opts['user'] = statedata['user']
-if statedata.get('log'):
-opts['log'] = True
-if statedata.get('no_commit'):
-opts['no_commit'] = statedata.get('no_commit')
-nodes = statedata['nodes']
+nodes, opts = cmdutil.updateopts(repo, graftstate, opts)
 revs = [repo[node].rev() for node in nodes]
 else:
 cmdutil.wrongtooltocontinue(repo, _('graft'))
@@ -2619,69 +2607,9 @@
 
 if opts.get('no_commit'):
 statedata['no_commit'] = True
-for pos, ctx in enumerate(repo.set("%ld", revs)):
-desc = '%d:%s "%s"' % (ctx.rev(), ctx,
-   ctx.description().split('\n', 1)[0])
-names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
-if names:
-desc += ' (%s)' % ' '.join(names)
-ui.status(_('grafting %s\n') % desc)
-if opts.get('dry_run'):
-continue
-
-source = ctx.extra().get('source')
-extra = {}
-if source:
-extra['source'] = source
-extra['intermediate-source'] = ctx.hex()
-else:
-extra['source'] = ctx.hex()
-user = ctx.user()
-if opts.get('user'):
-user = opts['user']
-statedata['user'] = user
-date = ctx.date()
-if opts.get('date'):
-date = opts['date']
-statedata['date'] = date
-message = ctx.description()
-if opts.get('log'):
-message += '\n(grafted from %s)' % ctx.hex()
-statedata['log'] = True
-
-# we don't merge the first commit when continuing
-if not cont:
-# perform the graft merge with p1(rev) as 'ancestor'
-overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
-base = ctx.p1() if basectx is None else basectx
-with ui.configoverride(overrides, 'graft'):
-stats = mergemod.graft(repo, ctx, base, ['local', 'graft'])
-# report any conflicts
-if stats.unresolvedcount > 0:
-# write out state for --continue
-nodes = [repo[rev].hex() for rev in revs[pos:]]
-statedata['nodes'] = nodes
-stateversion = 1
-graftstate.save(stateversion, statedata)
-hint = _("use 'hg resolve' and 'hg graft --continue'")
-raise error.Abort(
-_("unresolved conflicts, can't continue"),
-hint=hint)
-else:
-cont = False
-
-# commit if --no-commit is false
-if not opts.get('no_commit'):
-node = repo.commit(text=message, user=user, date=date, extra=extra,
-   editor=editor)
-if node is None:
-ui.warn(
-_('note: graft of %d:%s created no changes to commit\n') %
-(ctx.rev(), ctx))
-# checking that newnodes exist because old state files won't have 
it
-elif statedata.get('newnodes') is not None:
-statedata['newnodes'].append(node)
-
+
+cmdutil.finishgraft(repo, ui, basectx, revs, statedata, cont, opts,
+graftstate)
 # remove state when we complete successfully
 if not opts.get('dry_run'):
 graftstate.delete()
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3425,3 +3425,86 @@
 with repo.wlock():
 graftstate = statemod.cmdstate(repo, 'graftstate')
 return abortgraft(ui, repo, graftstate)
+
+def finishgraft(repo, ui, basectx, revs, statedata, cont, opts,
+

D6696: abort: added support for transplant

2019-08-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 marked an inline comment as done.
taapas1128 updated this revision to Diff 16160.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6696?vs=16070=16160

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

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -1,10 +1,17 @@
-#testcases commandmode continueflag
+#testcases commandmode abortflag continueflag
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
   > graphlog=
   > EOF
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = transplant --abort
+  > EOF
+#endif
+
 #if continueflag
   $ cat >> $HGRCPATH < [alias]
@@ -460,7 +467,7 @@
   abort: fix up the working directory and run hg transplant --continue
   [255]
 
-  $ hg transplant --abort
+  $ hg abort
   transplant aborted
   working directory is now at e8643552fde5
 Repo log after abort
@@ -514,8 +521,9 @@
   abort: no transplant to continue (continueflag !)
   abort: no operation in progress (no-continueflag !)
   [255]
-  $ hg transplant --abort
-  abort: no transplant to abort
+  $ hg abort
+  abort: no transplant to abort (abortflag !)
+  abort: no operation in progress (no-abortflag !)
   [255]
   $ hg transplant 1
   applying 46ae92138f3c
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -762,6 +762,13 @@
 tp = transplanter(ui, repo, {})
 return tp.resume(repo, repo, {})
 
+def aborttransplant(ui, repo):
+"""logic to abort a transplnat in progress using
+'hg abort'"""
+with repo.wlock():
+tp = transplanter(ui, repo, {})
+return tp.abort(ui, repo)
+
 revsetpredicate = registrar.revsetpredicate()
 
 @revsetpredicate('transplanted([set])')
@@ -788,7 +795,7 @@
 def extsetup(ui):
 statemod.addunfinished (
 'transplant', fname='transplant/journal', clearable=True,
-continuefunc=continuetransplant,
+continuefunc=continuetransplant, abortfunc=aborttransplant,
 )
 
 # tell hggettext to extract docstrings from these functions:



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


D6695: transplant: added support for --abort flag

2019-08-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 marked 4 inline comments as done.
taapas1128 updated this revision to Diff 16159.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6695?vs=16069=16159

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

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -2,6 +2,7 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
+  > graphlog=
   > EOF
 
 #if continueflag
@@ -19,6 +20,9 @@
   $ hg transplant --continue --all
   abort: --continue is incompatible with --branch, --all and --merge
   [255]
+  $ hg transplant --abort --all
+  abort: --abort is incompatible with --branch, --all and --merge
+  [255]
   $ hg transplant --all tip
   abort: --all requires a branch revision
   [255]
@@ -376,7 +380,8 @@
   applying 722f4667af76
   722f4667af76 transplanted to 76e321915884
 
-transplant --continue
+
+transplant --continue and --abort behaviour
 
   $ hg init ../tc
   $ cd ../tc
@@ -416,6 +421,36 @@
   $ echo foobar > foo
   $ hg ci -mfoobar
   created new head
+
+Repo log before transplant
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
   $ hg transplant 1:3
   applying 46ae92138f3c
   patching file foo
@@ -425,6 +460,49 @@
   abort: fix up the working directory and run hg transplant --continue
   [255]
 
+  $ hg transplant --abort
+  transplant aborted
+  working directory is now at e8643552fde5
+Repo log after abort
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
+  $ hg transplant 1:3
+  applying 46ae92138f3c
+  file added already exists
+  1 out of 1 hunks FAILED -- saving rejects to file added.rej
+  patching file foo
+  Hunk #1 FAILED at 0
+  1 out of 1 hunks FAILED -- saving rejects to file foo.rej
+  patch failed to apply
+  abort: fix up the working directory and run hg transplant --continue
+  [255]
+
 transplant -c shouldn't use an old changeset
 
   $ hg up -C
@@ -436,6 +514,9 @@
   abort: no transplant to continue (continueflag !)
   abort: no operation in progress (no-continueflag !)
   [255]
+  $ hg transplant --abort
+  abort: no transplant to abort
+  [255]
   $ hg transplant 1
   applying 46ae92138f3c
   patching file foo
@@ -489,23 +570,23 @@
   [255]
   $ hg transplant 1:3
   abort: transplant in progress
-  (use 'hg transplant --continue' or 'hg update' to abort)
+  (use 'hg transplant --continue' or 'hg transplant --abort')
   [255]
   $ hg status -v
   A bar
+  ? added.rej
   ? baz.rej
   ? foo.rej
   # The repository is in an unfinished *transplant* state.
   
   # To continue:hg transplant --continue
-  # To abort:   hg update
+  # To abort:   hg transplant --abort
   
   $ echo fixed > baz
   $ hg continue
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
-
   $ cd ..
 
 Issue: Test transplant --merge
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -412,6 +412,17 @@
 # this is kept only to reduce changes in a patch.
 pass
 
+def abort(self, ui, repo):
+"""logic to abort an interrupted transplant"""
+if repo.vfs.exists('transplant/journal'):
+startctx = repo['.']
+hg.updaterepo(repo, startctx.node(), overwrite=True)
+ui.status(_("transplant 

D6678: continue: added support for histedit

2019-08-08 Thread taapas1128 (Taapas Agrawal)
taapas1128 marked an inline comment as done.
taapas1128 updated this revision to Diff 16157.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6678?vs=16019=16157

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

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

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

CHANGE DETAILS

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,4 +1,4 @@
-#testcases abortcommand abortflag
+#testcases commandmode abortflag continueflag
 
 #if abortflag
   $ cat >> $HGRCPATH < EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = histedit --continue
+  > EOF
+#endif
+
 Test argument handling and various data parsing
 ==
 
@@ -53,12 +60,13 @@
 histedit --continue/--abort with no existing state
 --
 
-  $ hg histedit --continue
-  abort: no histedit in progress
+  $ hg continue
+  abort: no histedit in progress (continueflag !)
+  abort: no operation in progress (no-continueflag !)
   [255]
   $ hg abort
   abort: no histedit in progress (abortflag !)
-  abort: no operation in progress (abortcommand !)
+  abort: no operation in progress (no-abortflag !)
   [255]
 
 Run a dummy edit to make sure we get tip^^ correctly via revsingle.
@@ -163,7 +171,7 @@
   $ echo alpha >> alpha
   $ mv .hg/histedit-state.back .hg/histedit-state
 
-  $ hg histedit --continue
+  $ hg continue
   saved backup bundle to 
$TESTTMP/foo/.hg/strip-backup/08d98a8350f3-02594089-histedit.hg
   $ hg log -G -T '{rev} {shortest(node)} {desc}\n' -r 2::
   @  4 f5ed five
@@ -493,7 +501,7 @@
   $ hg resolve -m --all
   (no more unresolved files)
   continue: hg histedit --continue
-  $ hg histedit --cont
+  $ hg continue
   merging foo
   warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
   Editing (6f2f0241f119), you may commit or record as needed now.
@@ -516,7 +524,7 @@
   > evolution.allowunstable=True
   > EOF
   $ hg commit --amend -m 'allow this fold'
-  $ hg histedit --continue
+  $ hg continue
 
   $ cd ..
 
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1781,8 +1781,7 @@
 raise error.Abort(_('histedit cancelled\n'))
 # rebuild state
 if goal == goalcontinue:
-state.read()
-state = bootstrapcontinue(ui, state, opts)
+return resumehistedit(ui, repo, state)
 elif goal == goaleditplan:
 _edithisteditplan(ui, repo, state, rules)
 return
@@ -1839,6 +1838,21 @@
 
 state.write()
 
+def resumehistedit(ui, repo, state=None):
+if not state:
+state = histeditstate(repo)
+with repo.wlock() as wlock, repo.lock() as lock:
+state.wlock = wlock
+state.lock = lock
+opts = {'keep' : state.keep}
+fm = ui.formatter('histedit', opts)
+fm.startitem()
+state.read()
+state = bootstrapcontinue(ui, state, opts)
+_continuehistedit(ui, repo, state)
+_finishhistedit(ui, repo, state, fm)
+fm.end()
+
 def _finishhistedit(ui, repo, state, fm):
 """This action runs when histedit is finishing its session"""
 hg.updaterepo(repo, state.parentctxnode, overwrite=False)
@@ -2322,5 +2336,6 @@
 def extsetup(ui):
 cmdutil.summaryhooks.add('histedit', summaryhook)
 statemod.addunfinished('histedit', fname='histedit-state', 
allowcommit=True,
-continueflag=True, abortfunc=hgaborthistedit)
-
+continueflag=True, abortfunc=hgaborthistedit,
+continuefunc=resumehistedit)
+



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


D6689: continue: added support for transplant

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6689?vs=16043=16158

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

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -1,8 +1,16 @@
+#testcases commandmode continueflag
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = transplant --continue
+  > EOF
+#endif
+
   $ hg init t
   $ cd t
   $ hg transplant
@@ -424,8 +432,9 @@
   updated to "e8643552fde5: foobar"
   1 other heads for branch "default"
   $ rm added
-  $ hg transplant --continue
-  abort: no transplant to continue
+  $ hg continue
+  abort: no transplant to continue (continueflag !)
+  abort: no operation in progress (no-continueflag !)
   [255]
   $ hg transplant 1
   applying 46ae92138f3c
@@ -492,7 +501,7 @@
   # To abort:   hg update
   
   $ echo fixed > baz
-  $ hg transplant --continue
+  $ hg continue
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
@@ -881,7 +890,7 @@
   [255]
   $ hg status
   ? b.rej
-  $ hg transplant --continue
+  $ hg continue
   645035761929 skipped due to empty diff
 
   $ cd ..
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -734,6 +734,13 @@
 if cleanupfn:
 cleanupfn()
 
+def continuetransplant(ui, repo):
+"""logic to resume an interrupted transplant using
+'hg continue'"""
+with repo.wlock():
+tp = transplanter(ui, repo, {})
+return tp.resume(repo, repo, {})
+
 revsetpredicate = registrar.revsetpredicate()
 
 @revsetpredicate('transplanted([set])')
@@ -760,6 +767,7 @@
 def extsetup(ui):
 statemod.addunfinished (
 'transplant', fname='transplant/journal', clearable=True,
+continuefunc=continuetransplant,
 statushint=_('To continue:hg transplant --continue\n'
  'To abort:   hg update'),
 cmdhint=_("use 'hg transplant --continue' or 'hg update' to abort")



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


D6659: graft: split graft code into seperate functions

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


  @martinvonz @durin42 Have a look I ve updated the patch.

REPOSITORY
  rHG Mercurial

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

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

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


D6665: continue: added support for graft

2019-08-04 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16121.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6665?vs=15988=16121

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

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

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

CHANGE DETAILS

diff --git a/tests/test-issue1175.t b/tests/test-issue1175.t
--- a/tests/test-issue1175.t
+++ b/tests/test-issue1175.t
@@ -1,3 +1,11 @@
+#testcases continueflag continuecommand
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 https://bz.mercurial-scm.org/1175
 
   $ hg init
@@ -80,7 +88,7 @@
   $ hg resolve --mark b
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:5974126fad84 "b1"
   warning: can't find ancestor for 'b' copied from 'a'!
   $ hg log -f b -T 'changeset:   {rev}:{node|short}\nsummary: {desc}\n\n'
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1,4 +1,4 @@
-#testcases abortcommand abortflag
+#testcases commandmode abortflag continueflag
 
   $ cat >> $HGRCPATH < [extdiff]
@@ -13,6 +13,13 @@
   > EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 Create a repo with some stuff in it:
 
   $ hg init a
@@ -92,9 +99,11 @@
 
   $ hg -q up -cr tip
   $ hg rm -q e
-  $ hg graft --continue
-  abort: no graft in progress
-  [255]
+  $ hg continue
+  abort: no graft in progress (continueflag !)
+  abort: no operation in progress (no-continueflag !)
+  [255]
+
   $ hg revert -r . -q e
 
 Need to specify a rev:
@@ -1697,7 +1706,13 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+
+#if commandmode
+  $ hg continue --dry-run
+  graft in progress, will be resumed
+#endif
+
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1754,7 +1769,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1803,7 +1818,7 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1843,7 +1858,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1997,7 +2012,7 @@
 
   $ hg abort
   abort: no interrupted graft to abort (abortflag !)
-  abort: no operation in progress (abortcommand !)
+  abort: no operation in progress (no-abortflag !)
   [255]
 
 when stripping is required
@@ -2026,7 +2041,7 @@
   abort: cannot specify any other flag with '--abort'
   [255]
 
-#if abortcommand
+#if commandmode
 when in dry-run mode
   $ hg abort --dry-run
   graft in progress, will be aborted
@@ -2273,7 +2288,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
@@ -2350,7 +2365,7 @@
   $ hg resolve --mark
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg diff
   diff -r 2aa9ad1006ff a
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2629,6 +2629,7 @@
 statemod.addunfinished(
 'graft', fname='graftstate', clearable=True, stopflag=True,
 continueflag=True, abortfunc=cmdutil.hgabortgraft,
+continuefunc=cmdutil.continuegraft,
 cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
 )
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3426,6 +3426,29 @@
 graftstate = statemod.cmdstate(repo, 'graftstate')
 return abortgraft(ui, repo, graftstate)
 
+def continuegraft(ui, repo):
+"""logic to resume interrupted graft using 'hg continue'"""
+with repo.wlock():
+graftstate = statemod.cmdstate(repo, 'graftstate')
+opts = {}
+statedata = {}
+cont = True
+basectx = None
+nodes, opts = continuegraftstate(repo, graftstate, opts)
+revs = [repo[node].rev() for node in nodes]
+skipped = set()
+if basectx is None:
+# check for merges
+for rev in repo.revs('%ld and merge()', revs):
+ui.warn(_('skipping ungraftable merge revision %d\n') % rev)
+skipped.add(rev)
+revs = [r for r in revs if r not in 

D6659: graft: split graft code into seperate functions

2019-08-04 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16120.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6659?vs=15987=16120

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

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

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
@@ -2470,9 +2470,6 @@
 if not opts.get('date') and opts.get('currentdate'):
 opts['date'] = "%d %d" % dateutil.makedate()
 
-editor = cmdutil.getcommiteditor(editform='graft',
- **pycompat.strkwargs(opts))
-
 cont = False
 if opts.get('no_commit'):
 if opts.get('edit'):
@@ -2518,16 +2515,7 @@
 raise error.Abort(_("can't specify --continue and revisions"))
 # read in unfinished revisions
 if graftstate.exists():
-statedata = cmdutil.readgraftstate(repo, graftstate)
-if statedata.get('date'):
-opts['date'] = statedata['date']
-if statedata.get('user'):
-opts['user'] = statedata['user']
-if statedata.get('log'):
-opts['log'] = True
-if statedata.get('no_commit'):
-opts['no_commit'] = statedata.get('no_commit')
-nodes = statedata['nodes']
+nodes, opts = cmdutil.continuegraftstate(repo, graftstate, opts)
 revs = [repo[node].rev() for node in nodes]
 else:
 cmdutil.wrongtooltocontinue(repo, _('graft'))
@@ -2619,69 +2607,8 @@
 
 if opts.get('no_commit'):
 statedata['no_commit'] = True
-for pos, ctx in enumerate(repo.set("%ld", revs)):
-desc = '%d:%s "%s"' % (ctx.rev(), ctx,
-   ctx.description().split('\n', 1)[0])
-names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
-if names:
-desc += ' (%s)' % ' '.join(names)
-ui.status(_('grafting %s\n') % desc)
-if opts.get('dry_run'):
-continue
-
-source = ctx.extra().get('source')
-extra = {}
-if source:
-extra['source'] = source
-extra['intermediate-source'] = ctx.hex()
-else:
-extra['source'] = ctx.hex()
-user = ctx.user()
-if opts.get('user'):
-user = opts['user']
-statedata['user'] = user
-date = ctx.date()
-if opts.get('date'):
-date = opts['date']
-statedata['date'] = date
-message = ctx.description()
-if opts.get('log'):
-message += '\n(grafted from %s)' % ctx.hex()
-statedata['log'] = True
-
-# we don't merge the first commit when continuing
-if not cont:
-# perform the graft merge with p1(rev) as 'ancestor'
-overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
-base = ctx.p1() if basectx is None else basectx
-with ui.configoverride(overrides, 'graft'):
-stats = mergemod.graft(repo, ctx, base, ['local', 'graft'])
-# report any conflicts
-if stats.unresolvedcount > 0:
-# write out state for --continue
-nodes = [repo[rev].hex() for rev in revs[pos:]]
-statedata['nodes'] = nodes
-stateversion = 1
-graftstate.save(stateversion, statedata)
-hint = _("use 'hg resolve' and 'hg graft --continue'")
-raise error.Abort(
-_("unresolved conflicts, can't continue"),
-hint=hint)
-else:
-cont = False
-
-# commit if --no-commit is false
-if not opts.get('no_commit'):
-node = repo.commit(text=message, user=user, date=date, extra=extra,
-   editor=editor)
-if node is None:
-ui.warn(
-_('note: graft of %d:%s created no changes to commit\n') %
-(ctx.rev(), ctx))
-# checking that newnodes exist because old state files won't have 
it
-elif statedata.get('newnodes') is not None:
-statedata['newnodes'].append(node)
-
+
+cmdutil.finishgraft(repo, ui, basectx, revs, statedata, cont, opts)
 # remove state when we complete successfully
 if not opts.get('dry_run'):
 graftstate.delete()
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3425,3 +3425,84 @@
 with repo.wlock():
 graftstate = statemod.cmdstate(repo, 'graftstate')
 return abortgraft(ui, repo, graftstate)
+
+def finishgraft(repo, ui, basectx, revs, statedata, cont, opts):
+"""logic to execute graft once revs are generated"""
+graftstate = 

D6696: abort: added support for transplant

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

REVISION SUMMARY
  This adds support of `transplant--abort` to
  `hg abort`. A seperate `aborttransplant` function is
  created for that.
  
  Results are shown in tests.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -1,10 +1,17 @@
-#testcases commandmode continueflag
+#testcases commandmode abortflag continueflag
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
   > graphlog=
   > EOF
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = transplant --abort
+  > EOF
+#endif
+
 #if continueflag
   $ cat >> $HGRCPATH < [alias]
@@ -460,7 +467,7 @@
   abort: fix up the working directory and run hg transplant --continue
   [255]
 
-  $ hg transplant --abort
+  $ hg abort
   transplant aborted
   working directory is now at e8643552fde5
 Repo log after abort
@@ -514,8 +521,9 @@
   abort: no transplant to continue (continueflag !)
   abort: no operation in progress (no-continueflag !)
   [255]
-  $ hg transplant --abort
-  abort: no transplant to abort
+  $ hg abort
+  abort: no transplant to abort (abortflag !)
+  abort: no operation in progress (no-abortflag !)
   [255]
   $ hg transplant 1
   applying 46ae92138f3c
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -771,6 +771,14 @@
 tp.resume(repo, repo, opts)
 return
 
+def aborttransplant(ui, repo):
+"""logic to abort a transplnat in progress using
+'hg abort'"""
+with repo.wlock():
+tp = transplanter(ui, repo, {})
+tp.abort(ui, repo)
+return
+
 revsetpredicate = registrar.revsetpredicate()
 
 @revsetpredicate('transplanted([set])')
@@ -797,7 +805,7 @@
 def extsetup(ui):
 statemod.addunfinished (
 'transplant', fname='transplant/journal', clearable=True,
-continuefunc=continuetransplant,
+continuefunc=continuetransplant, abortfunc=aborttransplant,
 statushint=_('To continue:hg transplant --continue\n'
  'To abort:   hg transplant --abort'),
 cmdhint=_("use 'hg transplant --continue' or 'hg transplant --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


D6695: transplant: added support for --abort flag

2019-07-26 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16069.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6695?vs=16068=16069

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

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -2,6 +2,7 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
+  > graphlog=
   > EOF
 
 #if continueflag
@@ -19,6 +20,9 @@
   $ hg transplant --continue --all
   abort: --continue is incompatible with --branch, --all and --merge
   [255]
+  $ hg transplant --abort --all
+  abort: --abort is incompatible with --branch, --all and --merge
+  [255]
   $ hg transplant --all tip
   abort: --all requires a branch revision
   [255]
@@ -376,7 +380,8 @@
   applying 722f4667af76
   722f4667af76 transplanted to 76e321915884
 
-transplant --continue
+
+transplant --continue and --abort behaviour
 
   $ hg init ../tc
   $ cd ../tc
@@ -416,6 +421,36 @@
   $ echo foobar > foo
   $ hg ci -mfoobar
   created new head
+
+Repo log before transplant
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
   $ hg transplant 1:3
   applying 46ae92138f3c
   patching file foo
@@ -425,6 +460,49 @@
   abort: fix up the working directory and run hg transplant --continue
   [255]
 
+  $ hg transplant --abort
+  transplant aborted
+  working directory is now at e8643552fde5
+Repo log after abort
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
+  $ hg transplant 1:3
+  applying 46ae92138f3c
+  file added already exists
+  1 out of 1 hunks FAILED -- saving rejects to file added.rej
+  patching file foo
+  Hunk #1 FAILED at 0
+  1 out of 1 hunks FAILED -- saving rejects to file foo.rej
+  patch failed to apply
+  abort: fix up the working directory and run hg transplant --continue
+  [255]
+
 transplant -c shouldn't use an old changeset
 
   $ hg up -C
@@ -436,6 +514,9 @@
   abort: no transplant to continue (continueflag !)
   abort: no operation in progress (no-continueflag !)
   [255]
+  $ hg transplant --abort
+  abort: no transplant to abort
+  [255]
   $ hg transplant 1
   applying 46ae92138f3c
   patching file foo
@@ -489,23 +570,23 @@
   [255]
   $ hg transplant 1:3
   abort: transplant in progress
-  (use 'hg transplant --continue' or 'hg update' to abort)
+  (use 'hg transplant --continue' or 'hg transplant --abort' to abort)
   [255]
   $ hg status -v
   A bar
+  ? added.rej
   ? baz.rej
   ? foo.rej
   # The repository is in an unfinished *transplant* state.
   
   # To continue:hg transplant --continue
-  # To abort:   hg update
+  # To abort:   hg transplant --abort
   
   $ echo fixed > baz
   $ hg continue
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
-
   $ cd ..
 
 Issue: Test transplant --merge
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -119,6 +119,7 @@
 class transplanter(object):
 def __init__(self, ui, repo, opts):
 self.ui = ui
+self.repo = repo
 self.path = repo.vfs.join('transplant')
 self.opener = vfsmod.vfs(self.path)
 self.transplants = transplants(self.path, 'transplants',
@@ -412,6 +413,22 @@
 # this is kept only to reduce changes in a patch.
 pass
 
+def clear(self):

D6695: transplant: added support for --abort flag

2019-07-26 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16068.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6695?vs=16067=16068

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

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -2,6 +2,7 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
+  > graphlog=
   > EOF
 
 #if continueflag
@@ -19,6 +20,9 @@
   $ hg transplant --continue --all
   abort: --continue is incompatible with --branch, --all and --merge
   [255]
+  $ hg transplant --abort --all
+  abort: --abort is incompatible with --branch, --all and --merge
+  [255]
   $ hg transplant --all tip
   abort: --all requires a branch revision
   [255]
@@ -376,7 +380,8 @@
   applying 722f4667af76
   722f4667af76 transplanted to 76e321915884
 
-transplant --continue
+
+transplant --continue and --abort behaviour
 
   $ hg init ../tc
   $ cd ../tc
@@ -416,6 +421,36 @@
   $ echo foobar > foo
   $ hg ci -mfoobar
   created new head
+
+Repo log before transplant
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
   $ hg transplant 1:3
   applying 46ae92138f3c
   patching file foo
@@ -425,6 +460,49 @@
   abort: fix up the working directory and run hg transplant --continue
   [255]
 
+  $ hg transplant --abort
+  transplant aborted
+  working directory is now at e8643552fde5
+Repo log after abort
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
+  $ hg transplant 1:3
+  applying 46ae92138f3c
+  file added already exists
+  1 out of 1 hunks FAILED -- saving rejects to file added.rej
+  patching file foo
+  Hunk #1 FAILED at 0
+  1 out of 1 hunks FAILED -- saving rejects to file foo.rej
+  patch failed to apply
+  abort: fix up the working directory and run hg transplant --continue
+  [255]
+
 transplant -c shouldn't use an old changeset
 
   $ hg up -C
@@ -436,6 +514,9 @@
   abort: no transplant to continue (continueflag !)
   abort: no operation in progress (no-continueflag !)
   [255]
+  $ hg transplant --abort
+  abort: no transplant to abort
+  [255]
   $ hg transplant 1
   applying 46ae92138f3c
   patching file foo
@@ -493,6 +574,7 @@
   [255]
   $ hg status -v
   A bar
+  ? added.rej
   ? baz.rej
   ? foo.rej
   # The repository is in an unfinished *transplant* state.
@@ -505,7 +587,6 @@
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
-
   $ cd ..
 
 Issue: Test transplant --merge
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -119,6 +119,7 @@
 class transplanter(object):
 def __init__(self, ui, repo, opts):
 self.ui = ui
+self.repo = repo
 self.path = repo.vfs.join('transplant')
 self.opener = vfsmod.vfs(self.path)
 self.transplants = transplants(self.path, 'transplants',
@@ -412,6 +413,22 @@
 # this is kept only to reduce changes in a patch.
 pass
 
+def clear(self):
+"""clear the state file if it exists"""
+util.unlinkpath(self.repo.vfs.join('transplant/journal'),
+ ignoremissing=True)
+
+def abort(self, ui ,repo):
+"""logic to abort an interrupted transplant"""
+if repo.vfs.exists('transplant/journal'):
+startctx = repo['.']
+

D6695: transplant: added support for --abort flag

2019-07-25 Thread taapas1128 (Taapas Agrawal)
taapas1128 created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This adds fuctionality for `--abort` flag to `transplant`.
  A new method `abort` is added to `transplanter` class
  containing logic to abort transplant.
  
  Tests are updated as shown.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -2,6 +2,7 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
+  > graphlog=
   > EOF
 
 #if continueflag
@@ -19,6 +20,9 @@
   $ hg transplant --continue --all
   abort: --continue is incompatible with --branch, --all and --merge
   [255]
+  $ hg transplant --abort --all
+  abort: --abort is incompatible with --branch, --all and --merge
+  [255]
   $ hg transplant --all tip
   abort: --all requires a branch revision
   [255]
@@ -376,7 +380,8 @@
   applying 722f4667af76
   722f4667af76 transplanted to 76e321915884
 
-transplant --continue
+
+transplant --continue and --abort behaviour
 
   $ hg init ../tc
   $ cd ../tc
@@ -416,6 +421,36 @@
   $ echo foobar > foo
   $ hg ci -mfoobar
   created new head
+
+Repo log before transplant
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
   $ hg transplant 1:3
   applying 46ae92138f3c
   patching file foo
@@ -425,6 +460,49 @@
   abort: fix up the working directory and run hg transplant --continue
   [255]
 
+  $ hg transplant --abort
+  transplant aborted
+  working directory is now at e8643552fde5
+Repo log after abort
+  $ hg glog
+  @  changeset:   4:e8643552fde5
+  |  tag: tip
+  |  parent:  0:493149fa1541
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foobar
+  |
+  | o  changeset:   3:1dab759070cf
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar2
+  | |
+  | o  changeset:   2:9d6d6b5a8275
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: bar
+  | |
+  | o  changeset:   1:46ae92138f3c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: foo2
+  |
+  o  changeset:   0:493149fa1541
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: foo
+  
+  $ hg transplant 1:3
+  applying 46ae92138f3c
+  file added already exists
+  1 out of 1 hunks FAILED -- saving rejects to file added.rej
+  patching file foo
+  Hunk #1 FAILED at 0
+  1 out of 1 hunks FAILED -- saving rejects to file foo.rej
+  patch failed to apply
+  abort: fix up the working directory and run hg transplant --continue
+  [255]
+
 transplant -c shouldn't use an old changeset
 
   $ hg up -C
@@ -436,6 +514,9 @@
   abort: no transplant to continue (continueflag !)
   abort: no operation in progress (no-continueflag !)
   [255]
+  $ hg transplant --abort
+  abort: no transplant to abort
+  [255]
   $ hg transplant 1
   applying 46ae92138f3c
   patching file foo
@@ -493,6 +574,7 @@
   [255]
   $ hg status -v
   A bar
+  ? added.rej
   ? baz.rej
   ? foo.rej
   # The repository is in an unfinished *transplant* state.
@@ -505,7 +587,6 @@
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
-
   $ cd ..
 
 Issue: Test transplant --merge
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -119,6 +119,7 @@
 class transplanter(object):
 def __init__(self, ui, repo, opts):
 self.ui = ui
+self.repo = repo
 self.path = repo.vfs.join('transplant')
 self.opener = vfsmod.vfs(self.path)
 self.transplants = transplants(self.path, 'transplants',
@@ -412,6 +413,23 @@
 # this is kept only to reduce changes in a patch.
 pass
 
+def clear(self):
+"""clear the state file if it exists"""
+util.unlinkpath(self.repo.vfs.join('transplant/journal'),
+ ignoremissing=True)
+
+def abort(self, ui ,repo):
+

D6689: continue: added support for transplant

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

REVISION SUMMARY
  This creates a seperate function `continuetransplant()`
  containing logic for resuming transplant from interrupted
  state.
  `continuetransplant()` is then registered as `continuefunc`
  for state detection API.
  
  Results are shown in tests.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/transplant.py
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -1,8 +1,16 @@
+#testcases commandmode continueflag
   $ cat <> $HGRCPATH
   > [extensions]
   > transplant=
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = transplant --continue
+  > EOF
+#endif
+
   $ hg init t
   $ cd t
   $ hg transplant
@@ -424,8 +432,9 @@
   updated to "e8643552fde5: foobar"
   1 other heads for branch "default"
   $ rm added
-  $ hg transplant --continue
-  abort: no transplant to continue
+  $ hg continue
+  abort: no transplant to continue (continueflag !)
+  abort: no operation in progress (no-continueflag !)
   [255]
   $ hg transplant 1
   applying 46ae92138f3c
@@ -492,7 +501,7 @@
   # To abort:   hg update
   
   $ echo fixed > baz
-  $ hg transplant --continue
+  $ hg continue
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
@@ -881,7 +890,7 @@
   [255]
   $ hg status
   ? b.rej
-  $ hg transplant --continue
+  $ hg continue
   645035761929 skipped due to empty diff
 
   $ cd ..
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -734,6 +734,15 @@
 if cleanupfn:
 cleanupfn()
 
+def continuetransplant(ui, repo):
+"""logic to resume an interrupted transplant using
+'hg continue'"""
+with repo.wlock():
+opts = {}
+tp = transplanter(ui, repo, opts)
+tp.resume(repo, repo, opts)
+return
+
 revsetpredicate = registrar.revsetpredicate()
 
 @revsetpredicate('transplanted([set])')
@@ -760,6 +769,7 @@
 def extsetup(ui):
 statemod.addunfinished (
 'transplant', fname='transplant/journal', clearable=True,
+continuefunc=continuetransplant,
 statushint=_('To continue:hg transplant --continue\n'
  'To abort:   hg update'),
 cmdhint=_("use 'hg transplant --continue' or 'hg update' to 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


D6678: continue: added support for histedit

2019-07-23 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 16019.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6678?vs=16018=16019

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

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

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

CHANGE DETAILS

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,4 +1,4 @@
-#testcases abortcommand abortflag
+#testcases commandmode abortflag continueflag
 
 #if abortflag
   $ cat >> $HGRCPATH < EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = histedit --continue
+  > EOF
+#endif
+
 Test argument handling and various data parsing
 ==
 
@@ -53,12 +60,13 @@
 histedit --continue/--abort with no existing state
 --
 
-  $ hg histedit --continue
-  abort: no histedit in progress
+  $ hg continue
+  abort: no histedit in progress (continueflag !)
+  abort: no operation in progress (no-continueflag !)
   [255]
   $ hg abort
   abort: no histedit in progress (abortflag !)
-  abort: no operation in progress (abortcommand !)
+  abort: no operation in progress (no-abortflag !)
   [255]
 
 Run a dummy edit to make sure we get tip^^ correctly via revsingle.
@@ -163,7 +171,7 @@
   $ echo alpha >> alpha
   $ mv .hg/histedit-state.back .hg/histedit-state
 
-  $ hg histedit --continue
+  $ hg continue
   saved backup bundle to 
$TESTTMP/foo/.hg/strip-backup/08d98a8350f3-02594089-histedit.hg
   $ hg log -G -T '{rev} {shortest(node)} {desc}\n' -r 2::
   @  4 f5ed five
@@ -493,7 +501,7 @@
   $ hg resolve -m --all
   (no more unresolved files)
   continue: hg histedit --continue
-  $ hg histedit --cont
+  $ hg continue
   merging foo
   warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
   Editing (6f2f0241f119), you may commit or record as needed now.
@@ -516,7 +524,7 @@
   > evolution.allowunstable=True
   > EOF
   $ hg commit --amend -m 'allow this fold'
-  $ hg histedit --continue
+  $ hg continue
 
   $ cd ..
 
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1839,6 +1839,20 @@
 
 state.write()
 
+def hgcontinuehistedit(ui, repo):
+state = histeditstate(repo)
+with repo.wlock() as wlock, repo.lock() as lock:
+state.wlock = wlock
+state.lock = lock
+opts = {'keep' : state.keep}
+fm = ui.formatter('histedit', opts)
+fm.startitem()
+state.read()
+state = bootstrapcontinue(ui, state, opts)
+_continuehistedit(ui, repo, state)
+_finishhistedit(ui, repo, state, fm)
+fm.end()
+
 def _finishhistedit(ui, repo, state, fm):
 """This action runs when histedit is finishing its session"""
 hg.updaterepo(repo, state.parentctxnode, overwrite=False)
@@ -2322,5 +2336,6 @@
 def extsetup(ui):
 cmdutil.summaryhooks.add('histedit', summaryhook)
 statemod.addunfinished('histedit', fname='histedit-state', 
allowcommit=True,
-continueflag=True, abortfunc=hgaborthistedit)
-
+continueflag=True, abortfunc=hgaborthistedit,
+continuefunc=hgcontinuehistedit)
+



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


D6678: continue: added support for histedit

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

REVISION SUMMARY
  This patch adds the support for histedit in `hg continue` plan.
  
  As seperate `hgcontinuehistedit()` function is created to handle
  independent calls for resuming histedit. This function is
  then registered as continuefunc for state detection API.
  
  Results are shown as tests.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

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,4 +1,4 @@
-#testcases abortcommand abortflag
+#testcases commandmode abortflag continueflag
 
 #if abortflag
   $ cat >> $HGRCPATH < EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = histedit --continue
+  > EOF
+#endif
+
 Test argument handling and various data parsing
 ==
 
@@ -53,12 +60,13 @@
 histedit --continue/--abort with no existing state
 --
 
-  $ hg histedit --continue
-  abort: no histedit in progress
+  $ hg continue
+  abort: no histedit in progress (continueflag !)
+  abort: no operation in progress (no-continueflag !)
   [255]
   $ hg abort
   abort: no histedit in progress (abortflag !)
-  abort: no operation in progress (abortcommand !)
+  abort: no operation in progress (no-abortflag !)
   [255]
 
 Run a dummy edit to make sure we get tip^^ correctly via revsingle.
@@ -163,7 +171,7 @@
   $ echo alpha >> alpha
   $ mv .hg/histedit-state.back .hg/histedit-state
 
-  $ hg histedit --continue
+  $ hg continue
   saved backup bundle to 
$TESTTMP/foo/.hg/strip-backup/08d98a8350f3-02594089-histedit.hg
   $ hg log -G -T '{rev} {shortest(node)} {desc}\n' -r 2::
   @  4 f5ed five
@@ -493,7 +501,7 @@
   $ hg resolve -m --all
   (no more unresolved files)
   continue: hg histedit --continue
-  $ hg histedit --cont
+  $ hg continue
   merging foo
   warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
   Editing (6f2f0241f119), you may commit or record as needed now.
@@ -516,7 +524,7 @@
   > evolution.allowunstable=True
   > EOF
   $ hg commit --amend -m 'allow this fold'
-  $ hg histedit --continue
+  $ hg continue
 
   $ cd ..
 
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1839,6 +1839,20 @@
 
 state.write()
 
+def hgcontinuehistedit(ui, repo):
+state = histeditstate(repo)
+with repo.wlock() as wlock, repo.lock() as lock:
+state.wlock = wlock
+state.lock = lock
+opts = {'keep':state.keep}
+fm = ui.formatter('histedit', opts)
+fm.startitem()
+state.read()
+state = bootstrapcontinue(ui, state, opts)
+_continuehistedit(ui, repo, state)
+_finishhistedit(ui, repo, state, fm)
+fm.end()
+
 def _finishhistedit(ui, repo, state, fm):
 """This action runs when histedit is finishing its session"""
 hg.updaterepo(repo, state.parentctxnode, overwrite=False)
@@ -2322,5 +2336,6 @@
 def extsetup(ui):
 cmdutil.summaryhooks.add('histedit', summaryhook)
 statemod.addunfinished('histedit', fname='histedit-state', 
allowcommit=True,
-continueflag=True, abortfunc=hgaborthistedit)
-
+continueflag=True, abortfunc=hgaborthistedit,
+continuefunc=hgcontinuehistedit)
+



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


D6665: continue: added support for graft

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

REVISION SUMMARY
  This patch creates `cmdutil.continuegraft()` function
  which contains the logic to resume graft when called directly.
  This function is then registered as `continuefunc` to support
  `hg continue`.
  
  Results are shown as tests.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

diff --git a/tests/test-issue1175.t b/tests/test-issue1175.t
--- a/tests/test-issue1175.t
+++ b/tests/test-issue1175.t
@@ -1,3 +1,11 @@
+#testcases continueflag continuecommand
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 https://bz.mercurial-scm.org/1175
 
   $ hg init
@@ -80,7 +88,7 @@
   $ hg resolve --mark b
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:5974126fad84 "b1"
   warning: can't find ancestor for 'b' copied from 'a'!
   $ hg log -f b -T 'changeset:   {rev}:{node|short}\nsummary: {desc}\n\n'
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1,4 +1,4 @@
-#testcases abortcommand abortflag
+#testcases commandmode abortflag continueflag
 
   $ cat >> $HGRCPATH < [extdiff]
@@ -13,6 +13,13 @@
   > EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 Create a repo with some stuff in it:
 
   $ hg init a
@@ -92,9 +99,11 @@
 
   $ hg -q up -cr tip
   $ hg rm -q e
-  $ hg graft --continue
-  abort: no graft in progress
-  [255]
+  $ hg continue
+  abort: no graft in progress (continueflag !)
+  abort: no operation in progress (no-continueflag !)
+  [255]
+
   $ hg revert -r . -q e
 
 Need to specify a rev:
@@ -1697,7 +1706,13 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+
+#if commandmode
+  $ hg continue --dry-run
+  graft in progress, will be resumed
+#endif
+
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1754,7 +1769,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1803,7 +1818,7 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1843,7 +1858,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1997,7 +2012,7 @@
 
   $ hg abort
   abort: no interrupted graft to abort (abortflag !)
-  abort: no operation in progress (abortcommand !)
+  abort: no operation in progress (no-abortflag !)
   [255]
 
 when stripping is required
@@ -2026,7 +2041,7 @@
   abort: cannot specify any other flag with '--abort'
   [255]
 
-#if abortcommand
+#if commandmode
 when in dry-run mode
   $ hg abort --dry-run
   graft in progress, will be aborted
@@ -2273,7 +2288,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
@@ -2350,7 +2365,7 @@
   $ hg resolve --mark
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg diff
   diff -r 2aa9ad1006ff a
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2628,6 +2628,7 @@
 statemod.addunfinished(
 'graft', fname='graftstate', clearable=True, stopflag=True,
 continueflag=True, abortfunc=cmdutil.hgabortgraft,
+continuefunc=cmdutil.continuegraft,
 cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
 )
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3426,6 +3426,28 @@
 graftstate = statemod.cmdstate(repo, 'graftstate')
 return abortgraft(ui, repo, graftstate)
 
+def continuegraft(ui, repo):
+"""logic to resume interrupted graft using 'hg continue'"""
+with repo.wlock():
+graftstate = statemod.cmdstate(repo, 'graftstate')
+opts = {}
+statedata = {}
+cont = True
+basectx = None
+revs = continuegraftstate(repo, graftstate, opts)
+skipped = set()
+if basectx is None:
+# check for merges
+for rev in repo.revs('%ld and merge()', revs):
+ui.warn(_('skipping ungraftable 

D6659: graft: split graft code into seperate functions

2019-07-21 Thread taapas1128 (Taapas Agrawal)
taapas1128 edited the summary of this revision.
taapas1128 retitled this revision from "graft: split graft code to avoid 
duplication" to "graft: split graft code into seperate functions".
taapas1128 updated this revision to Diff 15987.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6659?vs=15978=15987

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

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

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
@@ -2470,9 +2470,6 @@
 if not opts.get('date') and opts.get('currentdate'):
 opts['date'] = "%d %d" % dateutil.makedate()
 
-editor = cmdutil.getcommiteditor(editform='graft',
- **pycompat.strkwargs(opts))
-
 cont = False
 if opts.get('no_commit'):
 if opts.get('edit'):
@@ -2518,17 +2515,7 @@
 raise error.Abort(_("can't specify --continue and revisions"))
 # read in unfinished revisions
 if graftstate.exists():
-statedata = cmdutil.readgraftstate(repo, graftstate)
-if statedata.get('date'):
-opts['date'] = statedata['date']
-if statedata.get('user'):
-opts['user'] = statedata['user']
-if statedata.get('log'):
-opts['log'] = True
-if statedata.get('no_commit'):
-opts['no_commit'] = statedata.get('no_commit')
-nodes = statedata['nodes']
-revs = [repo[node].rev() for node in nodes]
+revs = cmdutil.continuegraftstate(repo, graftstate, opts)
 else:
 cmdutil.wrongtooltocontinue(repo, _('graft'))
 else:
@@ -2619,69 +2606,8 @@
 
 if opts.get('no_commit'):
 statedata['no_commit'] = True
-for pos, ctx in enumerate(repo.set("%ld", revs)):
-desc = '%d:%s "%s"' % (ctx.rev(), ctx,
-   ctx.description().split('\n', 1)[0])
-names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
-if names:
-desc += ' (%s)' % ' '.join(names)
-ui.status(_('grafting %s\n') % desc)
-if opts.get('dry_run'):
-continue
-
-source = ctx.extra().get('source')
-extra = {}
-if source:
-extra['source'] = source
-extra['intermediate-source'] = ctx.hex()
-else:
-extra['source'] = ctx.hex()
-user = ctx.user()
-if opts.get('user'):
-user = opts['user']
-statedata['user'] = user
-date = ctx.date()
-if opts.get('date'):
-date = opts['date']
-statedata['date'] = date
-message = ctx.description()
-if opts.get('log'):
-message += '\n(grafted from %s)' % ctx.hex()
-statedata['log'] = True
-
-# we don't merge the first commit when continuing
-if not cont:
-# perform the graft merge with p1(rev) as 'ancestor'
-overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
-base = ctx.p1() if basectx is None else basectx
-with ui.configoverride(overrides, 'graft'):
-stats = mergemod.graft(repo, ctx, base, ['local', 'graft'])
-# report any conflicts
-if stats.unresolvedcount > 0:
-# write out state for --continue
-nodes = [repo[rev].hex() for rev in revs[pos:]]
-statedata['nodes'] = nodes
-stateversion = 1
-graftstate.save(stateversion, statedata)
-hint = _("use 'hg resolve' and 'hg graft --continue'")
-raise error.Abort(
-_("unresolved conflicts, can't continue"),
-hint=hint)
-else:
-cont = False
-
-# commit if --no-commit is false
-if not opts.get('no_commit'):
-node = repo.commit(text=message, user=user, date=date, extra=extra,
-   editor=editor)
-if node is None:
-ui.warn(
-_('note: graft of %d:%s created no changes to commit\n') %
-(ctx.rev(), ctx))
-# checking that newnodes exist because old state files won't have 
it
-elif statedata.get('newnodes') is not None:
-statedata['newnodes'].append(node)
-
+
+cmdutil.finishgraft(repo, ui, basectx, revs, statedata, cont, opts)
 # remove state when we complete successfully
 if not opts.get('dry_run'):
 graftstate.delete()
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3425,3 +3425,84 @@
 with repo.wlock():
 graftstate = statemod.cmdstate(repo, 'graftstate')
  

D6660: commands: removed part of description from abort and continue

2019-07-21 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG55d8329ba509: commands: removed part of description from 
abort and continue (authored by taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6660?vs=15974=15984

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

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -141,8 +141,6 @@
 and unshelve if they are in an unfinished state.
 
 use --dry-run/-n to dry run the command.
-A new operation can be added to this by registering the operation and
-abort logic in the unfinishedstates list under statemod.
 """
 dryrun = opts.get(r'dry_run')
 abortstate = cmdutil.getunfinishedstate(repo)
@@ -1903,8 +1901,6 @@
 and unshelve if they are in an interrupted state.
 
 use --dry-run/-n to dry run the command.
-A new operation can be added to this by registering the operation and
-continue logic in the unfinishedstates list under statemod.
 """
 dryrun = opts.get(r'dry_run')
 contstate = cmdutil.getunfinishedstate(repo)



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


D6655: continue: added support for graft

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


  @martinvonz No problem, I will update patch D6659 
.

REPOSITORY
  rHG Mercurial

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

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

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


D6655: continue: added support for graft

2019-07-20 Thread taapas1128 (Taapas Agrawal)
taapas1128 added inline comments.

INLINE COMMENTS

> mharbison72 wrote in test-graft.t:1
> This has the same problem D6579  had 
> where there are 4 separate test cases, instead of 2 with sub cases.

@mharbison72 I have generated a patch for that in D6659 
. I minimized it to 3 cases as @durin42 
stated about bloating of the test sets.

REPOSITORY
  rHG Mercurial

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

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

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


D6659: graft: split graft code to avoid duplication

2019-07-20 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15978.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6659?vs=15973=15978

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

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

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

CHANGE DETAILS

diff --git a/tests/test-issue1175.t b/tests/test-issue1175.t
--- a/tests/test-issue1175.t
+++ b/tests/test-issue1175.t
@@ -1,3 +1,11 @@
+#testcases continueflag continuecommand
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 https://bz.mercurial-scm.org/1175
 
   $ hg init
@@ -80,7 +88,7 @@
   $ hg resolve --mark b
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:5974126fad84 "b1"
   warning: can't find ancestor for 'b' copied from 'a'!
   $ hg log -f b -T 'changeset:   {rev}:{node|short}\nsummary: {desc}\n\n'
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1,4 +1,4 @@
-#testcases abortcommand abortflag continueflag continuecommand
+#testcases commandmode abortflag continueflag
 
   $ cat >> $HGRCPATH < [extdiff]
@@ -1707,7 +1707,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-#if continuecommand
+#if commandmode
   $ hg continue --dry-run
   graft in progress, will be resumed
 #endif
@@ -2041,7 +2041,7 @@
   abort: cannot specify any other flag with '--abort'
   [255]
 
-#if abortcommand
+#if commandmode
 when in dry-run mode
   $ hg abort --dry-run
   graft in progress, will be aborted
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2474,9 +2474,6 @@
 if not opts.get('date') and opts.get('currentdate'):
 opts['date'] = "%d %d" % dateutil.makedate()
 
-editor = cmdutil.getcommiteditor(editform='graft',
- **pycompat.strkwargs(opts))
-
 cont = False
 if opts.get('no_commit'):
 if opts.get('edit'):
@@ -2522,17 +2519,7 @@
 raise error.Abort(_("can't specify --continue and revisions"))
 # read in unfinished revisions
 if graftstate.exists():
-statedata = cmdutil.readgraftstate(repo, graftstate)
-if statedata.get('date'):
-opts['date'] = statedata['date']
-if statedata.get('user'):
-opts['user'] = statedata['user']
-if statedata.get('log'):
-opts['log'] = True
-if statedata.get('no_commit'):
-opts['no_commit'] = statedata.get('no_commit')
-nodes = statedata['nodes']
-revs = [repo[node].rev() for node in nodes]
+revs = cmdutil.continuegraftstate(repo, graftstate, opts)
 else:
 cmdutil.wrongtooltocontinue(repo, _('graft'))
 else:
@@ -2623,69 +2610,8 @@
 
 if opts.get('no_commit'):
 statedata['no_commit'] = True
-for pos, ctx in enumerate(repo.set("%ld", revs)):
-desc = '%d:%s "%s"' % (ctx.rev(), ctx,
-   ctx.description().split('\n', 1)[0])
-names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
-if names:
-desc += ' (%s)' % ' '.join(names)
-ui.status(_('grafting %s\n') % desc)
-if opts.get('dry_run'):
-continue
-
-source = ctx.extra().get('source')
-extra = {}
-if source:
-extra['source'] = source
-extra['intermediate-source'] = ctx.hex()
-else:
-extra['source'] = ctx.hex()
-user = ctx.user()
-if opts.get('user'):
-user = opts['user']
-statedata['user'] = user
-date = ctx.date()
-if opts.get('date'):
-date = opts['date']
-statedata['date'] = date
-message = ctx.description()
-if opts.get('log'):
-message += '\n(grafted from %s)' % ctx.hex()
-statedata['log'] = True
-
-# we don't merge the first commit when continuing
-if not cont:
-# perform the graft merge with p1(rev) as 'ancestor'
-overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
-base = ctx.p1() if basectx is None else basectx
-with ui.configoverride(overrides, 'graft'):
-stats = mergemod.graft(repo, ctx, base, ['local', 'graft'])
-# report any conflicts
-if stats.unresolvedcount > 0:
-# write out state for --continue
-nodes = [repo[rev].hex() for rev in revs[pos:]]
-statedata['nodes'] = nodes
-stateversion = 1
-graftstate.save(stateversion, statedata)
-hint = _("use 'hg resolve' and 'hg graft 

D6655: continue: added support for graft

2019-07-20 Thread taapas1128 (Taapas Agrawal)
taapas1128 added inline comments.

INLINE COMMENTS

> martinvonz wrote in test-graft.t:1
> I tried to fix that but the test fails if I do that.

I will have a look.

REPOSITORY
  rHG Mercurial

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

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

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


D6655: continue: added support for graft

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


  @yuja have a look at D6659  and suggest 
changes there. Extracting the core `for` loop as a helper function sounds like 
a nice idea. I will update the patch for the same.

REPOSITORY
  rHG Mercurial

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

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

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


D6655: continue: added support for graft

2019-07-19 Thread taapas1128 (Taapas Agrawal)
taapas1128 added inline comments.

INLINE COMMENTS

> martinvonz wrote in cmdutil.py:3482-3498
> It looks like pretty much this entire function is copies `commands.graft()` 
> and then all this code is left dead here (since `cont = True` above). I'd 
> prefer to de-queue this commit and let you clean this up and then submit a 
> new patch, but maybe other reviewers are less picky or stubborn than I am, so 
> I'll leave it queued until I hear from someone else.

@martinvonz That code is not dead but it takes care not to merge the first 
commit when continuing graft. `cont=True` is just the first iteration of the 
for loop at line `3455` after that it becomes `False`. Although it may seem 
like all the code has been copied from `commands.graft` but only that part is 
copied but only that part is imported that works when `--continue` flag is 
called. Regarding cleaning I do agree spliting code from `commands.graft()` 
would be nice. So have a look at D6659 .

REPOSITORY
  rHG Mercurial

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

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

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


D6659: graft: split graft code to avoid duplication

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

REVISION SUMMARY
  To avoid duplication of code due to `cmdutil.continuegraft()`; `graft()`
  is split into `cmdutil.finishgraft()` which deals with the execution of graft
  once `revs` are generated and `cmdutil.continuegraftstate()` which updates 
opts
  from `graftstate` file when graft is continued from an interrupted state.
  
  Further tests for issue1175 are updated to show the behaviour of `hg 
continue`.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

diff --git a/tests/test-issue1175.t b/tests/test-issue1175.t
--- a/tests/test-issue1175.t
+++ b/tests/test-issue1175.t
@@ -1,3 +1,11 @@
+#testcases continueflag continuecommand
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 https://bz.mercurial-scm.org/1175
 
   $ hg init
@@ -80,7 +88,7 @@
   $ hg resolve --mark b
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:5974126fad84 "b1"
   warning: can't find ancestor for 'b' copied from 'a'!
   $ hg log -f b -T 'changeset:   {rev}:{node|short}\nsummary: {desc}\n\n'
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2474,9 +2474,6 @@
 if not opts.get('date') and opts.get('currentdate'):
 opts['date'] = "%d %d" % dateutil.makedate()
 
-editor = cmdutil.getcommiteditor(editform='graft',
- **pycompat.strkwargs(opts))
-
 cont = False
 if opts.get('no_commit'):
 if opts.get('edit'):
@@ -2522,17 +2519,7 @@
 raise error.Abort(_("can't specify --continue and revisions"))
 # read in unfinished revisions
 if graftstate.exists():
-statedata = cmdutil.readgraftstate(repo, graftstate)
-if statedata.get('date'):
-opts['date'] = statedata['date']
-if statedata.get('user'):
-opts['user'] = statedata['user']
-if statedata.get('log'):
-opts['log'] = True
-if statedata.get('no_commit'):
-opts['no_commit'] = statedata.get('no_commit')
-nodes = statedata['nodes']
-revs = [repo[node].rev() for node in nodes]
+revs = cmdutil.continuegraftstate(repo, graftstate, opts)
 else:
 cmdutil.wrongtooltocontinue(repo, _('graft'))
 else:
@@ -2623,69 +2610,8 @@
 
 if opts.get('no_commit'):
 statedata['no_commit'] = True
-for pos, ctx in enumerate(repo.set("%ld", revs)):
-desc = '%d:%s "%s"' % (ctx.rev(), ctx,
-   ctx.description().split('\n', 1)[0])
-names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
-if names:
-desc += ' (%s)' % ' '.join(names)
-ui.status(_('grafting %s\n') % desc)
-if opts.get('dry_run'):
-continue
-
-source = ctx.extra().get('source')
-extra = {}
-if source:
-extra['source'] = source
-extra['intermediate-source'] = ctx.hex()
-else:
-extra['source'] = ctx.hex()
-user = ctx.user()
-if opts.get('user'):
-user = opts['user']
-statedata['user'] = user
-date = ctx.date()
-if opts.get('date'):
-date = opts['date']
-statedata['date'] = date
-message = ctx.description()
-if opts.get('log'):
-message += '\n(grafted from %s)' % ctx.hex()
-statedata['log'] = True
-
-# we don't merge the first commit when continuing
-if not cont:
-# perform the graft merge with p1(rev) as 'ancestor'
-overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
-base = ctx.p1() if basectx is None else basectx
-with ui.configoverride(overrides, 'graft'):
-stats = mergemod.graft(repo, ctx, base, ['local', 'graft'])
-# report any conflicts
-if stats.unresolvedcount > 0:
-# write out state for --continue
-nodes = [repo[rev].hex() for rev in revs[pos:]]
-statedata['nodes'] = nodes
-stateversion = 1
-graftstate.save(stateversion, statedata)
-hint = _("use 'hg resolve' and 'hg graft --continue'")
-raise error.Abort(
-_("unresolved conflicts, can't continue"),
-hint=hint)
-else:
-cont = False
-
-# commit if --no-commit is false
-if not opts.get('no_commit'):
-node = repo.commit(text=message, user=user, date=date, extra=extra,
-  

D6660: commands: removed part of description from abort and continue

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

REVISION SUMMARY
  The description for registration of new `continuefunc` or `abortfunc`
  is removed as it is not required from user perspective.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -141,8 +141,6 @@
 and unshelve if they are in an unfinished state.
 
 use --dry-run/-n to dry run the command.
-A new operation can be added to this by registering the operation and
-abort logic in the unfinishedstates list under statemod.
 """
 dryrun = opts.get(r'dry_run')
 abortstate = cmdutil.getunfinishedstate(repo)
@@ -1903,8 +1901,6 @@
 and unshelve if they are in an interrupted state.
 
 use --dry-run/-n to dry run the command.
-A new operation can be added to this by registering the operation and
-continue logic in the unfinishedstates list under statemod.
 """
 dryrun = opts.get(r'dry_run')
 contstate = cmdutil.getunfinishedstate(repo)



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


D6655: continue: added support for graft

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


  @martinvonz I will send a patch doing that.

REPOSITORY
  rHG Mercurial

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

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

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


D6655: continue: added support for graft

2019-07-18 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG0fff3cc9098c: continue: added support for graft (authored 
by taapas1128).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6655?vs=15966=15969

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.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,4 +1,4 @@
-#testcases abortcommand abortflag
+#testcases abortcommand abortflag continueflag continuecommand
 
   $ cat >> $HGRCPATH < [extdiff]
@@ -13,6 +13,13 @@
   > EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 Create a repo with some stuff in it:
 
   $ hg init a
@@ -92,9 +99,11 @@
 
   $ hg -q up -cr tip
   $ hg rm -q e
-  $ hg graft --continue
-  abort: no graft in progress
+  $ hg continue
+  abort: no graft in progress (continueflag !)
+  abort: no operation in progress (no-continueflag !)
   [255]
+
   $ hg revert -r . -q e
 
 Need to specify a rev:
@@ -1697,7 +1706,13 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+
+#if continuecommand
+  $ hg continue --dry-run
+  graft in progress, will be resumed
+#endif
+
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1754,7 +1769,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1803,7 +1818,7 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1843,7 +1858,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1997,7 +2012,7 @@
 
   $ hg abort
   abort: no interrupted graft to abort (abortflag !)
-  abort: no operation in progress (abortcommand !)
+  abort: no operation in progress (no-abortflag !)
   [255]
 
 when stripping is required
@@ -2273,7 +2288,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
@@ -2350,7 +2365,7 @@
   $ hg resolve --mark
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg diff
   diff -r 2aa9ad1006ff a
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2706,6 +2706,7 @@
 statemod.addunfinished(
 'graft', fname='graftstate', clearable=True, stopflag=True,
 continueflag=True, abortfunc=cmdutil.hgabortgraft,
+continuefunc=cmdutil.continuegraft,
 cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
 )
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3425,3 +3425,90 @@
 with repo.wlock():
 graftstate = statemod.cmdstate(repo, 'graftstate')
 return abortgraft(ui, repo, graftstate)
+
+def continuegraft(ui, repo):
+"""logic to resume interrupted graft using 'hg continue'"""
+with repo.wlock():
+graftstate = statemod.cmdstate(repo, 'graftstate')
+statedata = readgraftstate(repo, graftstate)
+opts = {}
+cont = True
+if statedata.get('date'):
+opts['date'] = statedata['date']
+if statedata.get('user'):
+opts['user'] = statedata['user']
+if statedata.get('log'):
+opts['log'] = True
+if statedata.get('no_commit'):
+opts['no_commit'] = statedata.get('no_commit')
+nodes = statedata['nodes']
+revs = [repo[node].rev() for node in nodes]
+
+skipped = set()
+for rev in repo.revs('%ld and merge()', revs):
+ui.warn(_('skipping ungraftable merge revision %d\n') % rev)
+skipped.add(rev)
+revs = [r for r in revs if r not in skipped]
+if not revs:
+return -1
+
+for pos, ctx in enumerate(repo.set("%ld", revs)):
+desc = '%d:%s "%s"' % (ctx.rev(), ctx,
+   ctx.description().split('\n', 1)[0])
+names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
+if names:
+desc += ' (%s)' % ' '.join(names)
+

D6655: continue: added support for graft

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

REVISION SUMMARY
  This adds support of graft to hg continue plan.
  
  The patch creates a seperate function `cmdutil.continuegraft`
  so that continue logic for graft can be called independently.
  This logic is registered to the statedetection API as `continuefunc`.
  
  Results are shown as tests.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.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,4 +1,4 @@
-#testcases abortcommand abortflag
+#testcases abortcommand abortflag continueflag continuecommand
 
   $ cat >> $HGRCPATH < [extdiff]
@@ -13,6 +13,13 @@
   > EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = graft --continue
+  > EOF
+#endif
+
 Create a repo with some stuff in it:
 
   $ hg init a
@@ -92,9 +99,11 @@
 
   $ hg -q up -cr tip
   $ hg rm -q e
-  $ hg graft --continue
-  abort: no graft in progress
-  [255]
+  $ hg continue
+  abort: no graft in progress (continueflag !)
+  abort: no operation in progress (no-continueflag !)
+  [255]
+
   $ hg revert -r . -q e
 
 Need to specify a rev:
@@ -1697,7 +1706,13 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+
+#if continuecommand
+  $ hg continue --dry-run
+  graft in progress, will be resumed
+#endif
+
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1754,7 +1769,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1803,7 +1818,7 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1843,7 +1858,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 1:80e6d2c47cfe "added b"
   grafting 2:8be98ac1a569 "added c"
 
@@ -1997,7 +2012,7 @@
 
   $ hg abort
   abort: no interrupted graft to abort (abortflag !)
-  abort: no operation in progress (abortcommand !)
+  abort: no operation in progress (no-abortflag !)
   [255]
 
 when stripping is required
@@ -2273,7 +2288,7 @@
   (no more unresolved files)
   continue: hg graft --continue
 
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
@@ -2350,7 +2365,7 @@
   $ hg resolve --mark
   (no more unresolved files)
   continue: hg graft --continue
-  $ hg graft --continue
+  $ hg continue
   grafting 3:09e253b87e17 "A in file a"
   $ hg diff
   diff -r 2aa9ad1006ff a
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2706,6 +2706,7 @@
 statemod.addunfinished(
 'graft', fname='graftstate', clearable=True, stopflag=True,
 continueflag=True, abortfunc=cmdutil.hgabortgraft,
+continuefunc=cmdutil.continuegraft,
 cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
 )
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3425,3 +3425,90 @@
 with repo.wlock():
 graftstate = statemod.cmdstate(repo, 'graftstate')
 return abortgraft(ui, repo, graftstate)
+
+def continuegraft(ui, repo):
+"""logic to resume interrupted graft using 'hg continue'"""
+with repo.wlock():
+graftstate = statemod.cmdstate(repo, 'graftstate')
+statedata = readgraftstate(repo, graftstate)
+opts = {}
+cont = True
+if statedata.get('date'):
+opts['date'] = statedata['date']
+if statedata.get('user'):
+opts['user'] = statedata['user']
+if statedata.get('log'):
+opts['log'] = True
+if statedata.get('no_commit'):
+opts['no_commit'] = statedata.get('no_commit')
+nodes = statedata['nodes']
+revs = [repo[node].rev() for node in nodes]
+
+skipped = set()
+for rev in repo.revs('%ld and merge()', revs):
+ui.warn(_('skipping ungraftable merge revision %d\n') % rev)
+skipped.add(rev)
+revs = [r for r in revs if r not in skipped]
+if not revs:
+return -1
+
+for pos, ctx in enumerate(repo.set("%ld", revs)):
+desc = '%d:%s "%s"' % (ctx.rev(), ctx,
+   ctx.description().split('\n', 1)[0])
+names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
+if names:
+desc += ' (%s)' % ' 

D6645: continue: added logic for hg continue

2019-07-17 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHGb53633d3f809: continue: added logic for hg continue 
(authored by taapas1128).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6645?vs=15915=15941

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/state.py
  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
@@ -1895,6 +1895,10 @@
 "topic": "commit"
   },
   {
+"summary": "resumes an interrupted operation (EXPERIMENTAL)",
+"topic": "continue"
+  },
+  {
 "summary": "diff repository (or selected files)",
 "topic": "diff"
   },
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -408,6 +408,7 @@
  show changeset information by line for each file
clone make a copy of an existing repository
commit, cicommit the specified files or all outstanding changes
+   continue  resumes an interrupted operation (EXPERIMENTAL)
diff  diff repository (or selected files)
exportdump the header and diffs for one or more changesets
forgetforget the specified files on the next commit
@@ -2389,6 +2390,13 @@
   commit the specified files or all outstanding changes
   
   
+  
+  continue
+  
+  
+  resumes an interrupted operation (EXPERIMENTAL)
+  
+  
   
   diff
   
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -15,6 +15,7 @@
   clone
   commit
   config
+  continue
   copy
   diff
   export
@@ -252,6 +253,7 @@
   clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, 
remotecmd, insecure
   commit: addremove, close-branch, amend, secret, edit, force-close-branch, 
interactive, include, exclude, message, logfile, date, user, subrepos
   config: untrusted, edit, local, global, template
+  continue: dry-run
   copy: after, force, include, exclude, dry-run
   debugancestor: 
   debugapplystreamclonebundle: 
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -99,7 +99,7 @@
 
 def __init__(self, opname, fname, clearable, allowcommit, reportonly,
  continueflag, stopflag, cmdmsg, cmdhint, statushint,
- abortfunc):
+ abortfunc, continuefunc):
 self._opname = opname
 self._fname = fname
 self._clearable = clearable
@@ -111,6 +111,7 @@
 self._cmdhint = cmdhint
 self._statushint = statushint
 self.abortfunc = abortfunc
+self.continuefunc = continuefunc
 
 def statusmsg(self):
 """returns the hint message corresponding to the command for
@@ -159,7 +160,8 @@
 
 def addunfinished(opname, fname, clearable=False, allowcommit=False,
   reportonly=False, continueflag=False, stopflag=False,
-  cmdmsg="", cmdhint="", statushint="", abortfunc=None):
+  cmdmsg="", cmdhint="", statushint="", abortfunc=None,
+  continuefunc=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.
@@ -184,10 +186,12 @@
 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.
+continuefunc stores the function required to finish an interrupted
+operation.
 """
 statecheckobj = _statecheck(opname, fname, clearable, allowcommit,
 reportonly, continueflag, stopflag, cmdmsg,
-cmdhint, statushint, abortfunc)
+cmdhint, statushint, abortfunc, continuefunc)
 if opname == 'merge':
 _unfinishedstates.append(statecheckobj)
 else:
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1893,6 +1893,32 @@
 return 0
 return 1
 
+@command('continue',
+dryrunopts, helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
+helpbasic=True)
+def continuecmd(ui, repo, **opts):
+"""resumes an interrupted operation (EXPERIMENTAL)
+
+Finishes a multistep operation like graft, histedit, rebase, merge,
+and unshelve if they are in an interrupted state.
+
+use --dry-run/-n to dry run the command.
+A new operation can be added to this 

D6652: continue: added support for unshelve

2019-07-17 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG3072efd46d1c: continue: added support for unshelve 
(authored by taapas1128).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6652?vs=15939=15943

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/shelve.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,5 +1,6 @@
 #testcases stripbased phasebased
 #testcases abortflag abortcommand
+#testcases continueflag continuecommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -27,6 +28,13 @@
   > EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = unshelve --continue
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -560,7 +568,7 @@
   $ hg resolve --mark a
   (no more unresolved files)
   continue: hg unshelve --continue
-  $ hg unshelve --continue
+  $ hg continue
   marked working directory as branch test
   unshelve of 'default' complete
   $ cat a
@@ -641,7 +649,13 @@
   $ hg resolve --mark a
   (no more unresolved files)
   continue: hg unshelve --continue
-  $ hg unshelve --continue
+
+#if continuecommand
+  $ hg continue --dry-run
+  unshelve in progress, will be resumed
+#endif
+
+  $ hg continue
   unshelve of 'default' complete
   $ cat a
   aaabbbccc
@@ -704,7 +718,7 @@
   $ echo somethingsomething > .hg/shelvedstate
 
 Unshelve --continue fails with appropriate message if shelvedstate is corrupted
-  $ hg unshelve --continue
+  $ hg continue
   abort: corrupted shelved state file
   (please run hg unshelve --abort to abort unshelve operation)
   [255]
@@ -751,7 +765,7 @@
   $ hg resolve --mark file
   (no more unresolved files)
   continue: hg unshelve --continue
-  $ hg unshelve --continue
+  $ hg continue
   unshelve of 'default' complete
   $ hg shelve --list
   default (*s ago) * changes to: 1 (glob)
@@ -822,7 +836,7 @@
   (no more unresolved files)
   continue: hg unshelve --continue
 mercurial does not crash
-  $ hg unshelve --continue
+  $ hg continue
   unshelve of 'ashelve' complete
 
 #if phasebased
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -751,6 +751,12 @@
 unshelvecleanup(ui, repo, state.name, opts)
 ui.status(_("unshelve of '%s' complete\n") % state.name)
 
+def hgcontinueunshelve(ui, repo):
+"""logic to resume unshelve using 'hg continue'"""
+with repo.wlock():
+state = _loadshelvedstate(ui, repo, {'continue' : True})
+return unshelvecontinue(ui, repo, state, {'keep' : state.keep})
+
 def _commitworkingcopychanges(ui, repo, opts, tmpwctx):
 """Temporarily commit working copy changes before moving unshelve commit"""
 # Store pending changes in a commit and remember added in case a shelve
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6219,6 +6219,7 @@
 statemod.addunfinished(
 'unshelve', fname='shelvedstate', continueflag=True,
 abortfunc=shelvemod.hgabortunshelve,
+continuefunc=shelvemod.hgcontinueunshelve,
 cmdmsg=_('unshelve already in progress'),
 )
 



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


D6646: continue: added support for rebase

2019-07-17 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHGdb963eda96ef: continue: added support for rebase (authored 
by taapas1128).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6646?vs=15938=15942

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

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-narrow-rebase.t
  tests/test-rebase-abort.t
  tests/test-rebase-legacy.t
  tests/test-rebase-mq-skip.t
  tests/test-rebase-transaction.t

CHANGE DETAILS

diff --git a/tests/test-rebase-transaction.t b/tests/test-rebase-transaction.t
--- a/tests/test-rebase-transaction.t
+++ b/tests/test-rebase-transaction.t
@@ -1,3 +1,4 @@
+#testcases continuecommand continueflag
 Rebasing using a single transaction
 
   $ cat >> $HGRCPATH < tglog = log -G --template "{rev}: {desc}"
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = rebase --continue
+  > EOF
+#endif
+
 Check that a simple rebase works
 
   $ hg init simple && cd simple
@@ -123,7 +131,7 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg rebase --continue
-  $ hg rebase --continue
+  $ hg continue
   already rebased 1:112478962961 "B" (B) as 79bc8f4973ce
   rebasing 3:c26739dbe603 "C" (C)
   rebasing 5:d24bb333861c "D" (D tip)
@@ -177,7 +185,7 @@
   |/
   o  0: A
   
-  $ hg rebase --continue
+  $ hg continue
   rebasing 1:112478962961 "B" (B)
   rebasing 3:26805aba1e60 "C" (C)
   rebasing 5:f585351a92f8 "D" (D tip)
diff --git a/tests/test-rebase-mq-skip.t b/tests/test-rebase-mq-skip.t
--- a/tests/test-rebase-mq-skip.t
+++ b/tests/test-rebase-mq-skip.t
@@ -1,3 +1,4 @@
+#testcases continuecommand continueflag
 This emulates the effects of an hg pull --rebase in which the remote repo
 already has one local mq patch
 
@@ -13,6 +14,12 @@
   > tglog = log -G --template "{rev}: {node|short} '{desc}' tags: {tags}\n"
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = rebase --continue
+  > EOF
+#endif
 
   $ hg init a
   $ cd a
@@ -155,7 +162,7 @@
   (no more unresolved files)
   continue: hg rebase --continue
 
-  $ hg rebase --continue
+  $ hg continue
   already rebased 1:b4bffa6e4776 "r1" (qbase r1) as 057f55ff8f44
   already rebased 2:c0fd129beb01 "r2" (r2) as 1660ab13ce9a
   already rebased 3:6ff5b8feed8e "r3" (r3) as 1660ab13ce9a
diff --git a/tests/test-rebase-legacy.t b/tests/test-rebase-legacy.t
--- a/tests/test-rebase-legacy.t
+++ b/tests/test-rebase-legacy.t
@@ -1,3 +1,4 @@
+#testcases continuecommand continueflag
 Test rebase --continue with rebasestate written by legacy client
 
   $ cat >> $HGRCPATH < drawdag=$TESTDIR/drawdag.py
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = rebase --continue
+  > EOF
+#endif
+
   $ hg init
   $ hg debugdrawdag <<'EOF'
   >D H
@@ -40,7 +48,12 @@
   > 
6582e6951a9c48c236f746f186378e36f59f4928:
   > EOF
 
-  $ hg rebase --continue
+#if continuecommand
+  $ hg continue --dry-run
+  rebase in progress, will be resumed
+#endif
+
+  $ hg continue
   rebasing 4:c1e6b162678d "B" (B)
   rebasing 8:6f7a236de685 "D" (D)
   rebasing 2:de008c61a447 "E" (E)
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,4 +1,5 @@
 #testcases abortcommand abortflag
+#testcases continuecommand continueflag
 
   $ cat >> $HGRCPATH < [extensions]
@@ -18,6 +19,13 @@
   > EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = rebase --continue
+  > EOF
+#endif
+
   $ hg init a
   $ cd a
 
@@ -162,7 +170,7 @@
   $ hg --config extensions.mq= strip --quiet "destination()"
   $ mv .hg/rebasestate.back .hg/rebasestate
 
-  $ hg rebase --continue
+  $ hg continue
   abort: cannot continue inconsistent rebase
   (use "hg rebase --abort" to clear broken state)
   [255]
diff --git a/tests/test-narrow-rebase.t b/tests/test-narrow-rebase.t
--- a/tests/test-narrow-rebase.t
+++ b/tests/test-narrow-rebase.t
@@ -1,3 +1,10 @@
+#testcases continuecommand continueflag
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = rebase --continue
+  > EOF
+#endif
 
   $ . "$TESTDIR/narrow-library.sh"
 
@@ -69,7 +76,7 @@
   $ echo modified3 > inside/f1
   $ hg resolve -m 2>&1 | grep -v continue:
   (no more unresolved files)
-  $ hg rebase --continue
+  $ hg continue
   rebasing 6:cdce97fbf653 "conflicting inside/f1" (tip)
   saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-rebase.hg (glob)
 
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1928,6 +1928,17 @@
 rbsrt = rebaseruntime(repo, ui)
 rbsrt._prepareabortorcontinue(isabort=True)
 
+def continuerebase(ui, repo):
+with repo.wlock(), repo.lock():
+rbsrt 

D6652: continue: added support for unshelve

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

REVISION SUMMARY
  This patch adds the support for `ushelve` in `hg continue` plan.
  
  `hgcontinueunshelve()` has been created for independent calls.
  In case an interrupted unshelve is resumed via hg continue the
  shelvedstate needs to be loaded seperately. This has been
  ensured by `_loadunshelvedstate()`
  
  `hgcontinueunshelve()` is then registered as `continuefunc` for state
  detection API.
  
  Results are shown as tests.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/shelve.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,5 +1,6 @@
 #testcases stripbased phasebased
 #testcases abortflag abortcommand
+#testcases continueflag continuecommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -27,6 +28,13 @@
   > EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = unshelve --continue
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -560,7 +568,7 @@
   $ hg resolve --mark a
   (no more unresolved files)
   continue: hg unshelve --continue
-  $ hg unshelve --continue
+  $ hg continue
   marked working directory as branch test
   unshelve of 'default' complete
   $ cat a
@@ -641,7 +649,13 @@
   $ hg resolve --mark a
   (no more unresolved files)
   continue: hg unshelve --continue
-  $ hg unshelve --continue
+
+#if continuecommand
+  $ hg continue --dry-run
+  unshelve in progress, will be resumed
+#endif
+
+  $ hg continue
   unshelve of 'default' complete
   $ cat a
   aaabbbccc
@@ -704,7 +718,7 @@
   $ echo somethingsomething > .hg/shelvedstate
 
 Unshelve --continue fails with appropriate message if shelvedstate is corrupted
-  $ hg unshelve --continue
+  $ hg continue
   abort: corrupted shelved state file
   (please run hg unshelve --abort to abort unshelve operation)
   [255]
@@ -751,7 +765,7 @@
   $ hg resolve --mark file
   (no more unresolved files)
   continue: hg unshelve --continue
-  $ hg unshelve --continue
+  $ hg continue
   unshelve of 'default' complete
   $ hg shelve --list
   default (*s ago) * changes to: 1 (glob)
@@ -822,7 +836,7 @@
   (no more unresolved files)
   continue: hg unshelve --continue
 mercurial does not crash
-  $ hg unshelve --continue
+  $ hg continue
   unshelve of 'ashelve' complete
 
 #if phasebased
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -751,6 +751,12 @@
 unshelvecleanup(ui, repo, state.name, opts)
 ui.status(_("unshelve of '%s' complete\n") % state.name)
 
+def hgcontinueunshelve(ui, repo):
+"""logic to resume unshelve using 'hg continue'"""
+with repo.wlock():
+state = _loadshelvedstate(ui, repo, {'continue' : True})
+return unshelvecontinue(ui, repo, state, {'keep' : state.keep})
+
 def _commitworkingcopychanges(ui, repo, opts, tmpwctx):
 """Temporarily commit working copy changes before moving unshelve commit"""
 # Store pending changes in a commit and remember added in case a shelve
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6219,6 +6219,7 @@
 statemod.addunfinished(
 'unshelve', fname='shelvedstate', continueflag=True,
 abortfunc=shelvemod.hgabortunshelve,
+continuefunc=shelvemod.hgcontinueunshelve,
 cmdmsg=_('unshelve already in progress'),
 )
 



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


D6646: continue: added support for rebase

2019-07-17 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15938.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6646?vs=15914=15938

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

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-narrow-rebase.t
  tests/test-rebase-abort.t
  tests/test-rebase-legacy.t
  tests/test-rebase-mq-skip.t
  tests/test-rebase-transaction.t

CHANGE DETAILS

diff --git a/tests/test-rebase-transaction.t b/tests/test-rebase-transaction.t
--- a/tests/test-rebase-transaction.t
+++ b/tests/test-rebase-transaction.t
@@ -1,3 +1,4 @@
+#testcases continuecommand continueflag
 Rebasing using a single transaction
 
   $ cat >> $HGRCPATH < tglog = log -G --template "{rev}: {desc}"
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = rebase --continue
+  > EOF
+#endif
+
 Check that a simple rebase works
 
   $ hg init simple && cd simple
@@ -123,7 +131,7 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg rebase --continue
-  $ hg rebase --continue
+  $ hg continue
   already rebased 1:112478962961 "B" (B) as 79bc8f4973ce
   rebasing 3:c26739dbe603 "C" (C)
   rebasing 5:d24bb333861c "D" (D tip)
@@ -177,7 +185,7 @@
   |/
   o  0: A
   
-  $ hg rebase --continue
+  $ hg continue
   rebasing 1:112478962961 "B" (B)
   rebasing 3:26805aba1e60 "C" (C)
   rebasing 5:f585351a92f8 "D" (D tip)
diff --git a/tests/test-rebase-mq-skip.t b/tests/test-rebase-mq-skip.t
--- a/tests/test-rebase-mq-skip.t
+++ b/tests/test-rebase-mq-skip.t
@@ -1,3 +1,4 @@
+#testcases continuecommand continueflag
 This emulates the effects of an hg pull --rebase in which the remote repo
 already has one local mq patch
 
@@ -13,6 +14,12 @@
   > tglog = log -G --template "{rev}: {node|short} '{desc}' tags: {tags}\n"
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = rebase --continue
+  > EOF
+#endif
 
   $ hg init a
   $ cd a
@@ -155,7 +162,7 @@
   (no more unresolved files)
   continue: hg rebase --continue
 
-  $ hg rebase --continue
+  $ hg continue
   already rebased 1:b4bffa6e4776 "r1" (qbase r1) as 057f55ff8f44
   already rebased 2:c0fd129beb01 "r2" (r2) as 1660ab13ce9a
   already rebased 3:6ff5b8feed8e "r3" (r3) as 1660ab13ce9a
diff --git a/tests/test-rebase-legacy.t b/tests/test-rebase-legacy.t
--- a/tests/test-rebase-legacy.t
+++ b/tests/test-rebase-legacy.t
@@ -1,3 +1,4 @@
+#testcases continuecommand continueflag
 Test rebase --continue with rebasestate written by legacy client
 
   $ cat >> $HGRCPATH < drawdag=$TESTDIR/drawdag.py
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = rebase --continue
+  > EOF
+#endif
+
   $ hg init
   $ hg debugdrawdag <<'EOF'
   >D H
@@ -40,7 +48,12 @@
   > 
6582e6951a9c48c236f746f186378e36f59f4928:
   > EOF
 
-  $ hg rebase --continue
+#if continuecommand
+  $ hg continue --dry-run
+  rebase in progress, will be resumed
+#endif
+
+  $ hg continue
   rebasing 4:c1e6b162678d "B" (B)
   rebasing 8:6f7a236de685 "D" (D)
   rebasing 2:de008c61a447 "E" (E)
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,4 +1,5 @@
 #testcases abortcommand abortflag
+#testcases continuecommand continueflag
 
   $ cat >> $HGRCPATH < [extensions]
@@ -18,6 +19,13 @@
   > EOF
 #endif
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = rebase --continue
+  > EOF
+#endif
+
   $ hg init a
   $ cd a
 
@@ -162,7 +170,7 @@
   $ hg --config extensions.mq= strip --quiet "destination()"
   $ mv .hg/rebasestate.back .hg/rebasestate
 
-  $ hg rebase --continue
+  $ hg continue
   abort: cannot continue inconsistent rebase
   (use "hg rebase --abort" to clear broken state)
   [255]
diff --git a/tests/test-narrow-rebase.t b/tests/test-narrow-rebase.t
--- a/tests/test-narrow-rebase.t
+++ b/tests/test-narrow-rebase.t
@@ -1,3 +1,10 @@
+#testcases continuecommand continueflag
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > continue = rebase --continue
+  > EOF
+#endif
 
   $ . "$TESTDIR/narrow-library.sh"
 
@@ -69,7 +76,7 @@
   $ echo modified3 > inside/f1
   $ hg resolve -m 2>&1 | grep -v continue:
   (no more unresolved files)
-  $ hg rebase --continue
+  $ hg continue
   rebasing 6:cdce97fbf653 "conflicting inside/f1" (tip)
   saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-rebase.hg (glob)
 
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1928,6 +1928,17 @@
 rbsrt = rebaseruntime(repo, ui)
 rbsrt._prepareabortorcontinue(isabort=True)
 
+def continuerebase(ui, repo):
+with repo.wlock(), repo.lock():
+rbsrt = rebaseruntime(repo, ui)
+ms = mergemod.mergestate.read(repo)
+mergeutil.checkunresolved(ms)
+retcode = rbsrt._prepareabortorcontinue(isabort=False)
+if retcode is not 

D6645: continue: added logic for hg continue

2019-07-15 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15915.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6645?vs=15913=15915

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/state.py
  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
@@ -1895,6 +1895,10 @@
 "topic": "commit"
   },
   {
+"summary": "resumes an interrupted operation (EXPERIMENTAL)",
+"topic": "continue"
+  },
+  {
 "summary": "diff repository (or selected files)",
 "topic": "diff"
   },
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -408,6 +408,7 @@
  show changeset information by line for each file
clone make a copy of an existing repository
commit, cicommit the specified files or all outstanding changes
+   continue  resumes an interrupted operation (EXPERIMENTAL)
diff  diff repository (or selected files)
exportdump the header and diffs for one or more changesets
forgetforget the specified files on the next commit
@@ -2389,6 +2390,13 @@
   commit the specified files or all outstanding changes
   
   
+  
+  continue
+  
+  
+  resumes an interrupted operation (EXPERIMENTAL)
+  
+  
   
   diff
   
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -15,6 +15,7 @@
   clone
   commit
   config
+  continue
   copy
   diff
   export
@@ -252,6 +253,7 @@
   clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, 
remotecmd, insecure
   commit: addremove, close-branch, amend, secret, edit, force-close-branch, 
interactive, include, exclude, message, logfile, date, user, subrepos
   config: untrusted, edit, local, global, template
+  continue: dry-run
   copy: after, force, include, exclude, dry-run
   debugancestor: 
   debugapplystreamclonebundle: 
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -99,7 +99,7 @@
 
 def __init__(self, opname, fname, clearable, allowcommit, reportonly,
  continueflag, stopflag, cmdmsg, cmdhint, statushint,
- abortfunc):
+ abortfunc, continuefunc):
 self._opname = opname
 self._fname = fname
 self._clearable = clearable
@@ -111,6 +111,7 @@
 self._cmdhint = cmdhint
 self._statushint = statushint
 self.abortfunc = abortfunc
+self.continuefunc = continuefunc
 
 def statusmsg(self):
 """returns the hint message corresponding to the command for
@@ -159,7 +160,8 @@
 
 def addunfinished(opname, fname, clearable=False, allowcommit=False,
   reportonly=False, continueflag=False, stopflag=False,
-  cmdmsg="", cmdhint="", statushint="", abortfunc=None):
+  cmdmsg="", cmdhint="", statushint="", abortfunc=None,
+  continuefunc=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.
@@ -184,10 +186,12 @@
 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.
+continuefunc stores the function required to finish an interrupted
+operation.
 """
 statecheckobj = _statecheck(opname, fname, clearable, allowcommit,
 reportonly, continueflag, stopflag, cmdmsg,
-cmdhint, statushint, abortfunc)
+cmdhint, statushint, abortfunc, continuefunc)
 if opname == 'merge':
 _unfinishedstates.append(statecheckobj)
 else:
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1893,6 +1893,32 @@
 return 0
 return 1
 
+@command('continue',
+dryrunopts, helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
+helpbasic=True)
+def continuecmd(ui, repo, **opts):
+"""resumes an interrupted operation (EXPERIMENTAL)
+
+Finishes a multistep operation like graft, histedit, rebase, merge,
+and unshelve if they are in an interrupted state.
+
+use --dry-run/-n to dry run the command.
+A new operation can be added to this by registering the operation and
+continue logic in the unfinishedstates list under statemod.
+"""
+dryrun = opts.get(r'dry_run')
+contstate = cmdutil.getunfinishedstate(repo)
+if not 

D6646: continue: added support for rebase

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

REVISION SUMMARY
  This adds support of rebase to hg continue plan.
  
  An independent continue logic for rebase is created
  under continuerebase() function. For this a seperate
  rebaseruntime object is created under the function to
  handle an interrupted rebasestate.
  
  Results of tests are shown.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-narrow-rebase.t
  tests/test-rebase-abort.t
  tests/test-rebase-legacy.t
  tests/test-rebase-mq-skip.t
  tests/test-rebase-transaction.t

CHANGE DETAILS

diff --git a/tests/test-rebase-transaction.t b/tests/test-rebase-transaction.t
--- a/tests/test-rebase-transaction.t
+++ b/tests/test-rebase-transaction.t
@@ -1,3 +1,4 @@
+#testcases continuecommand continueflag
 Rebasing using a single transaction
 
   $ cat >> $HGRCPATH < tglog = log -G --template "{rev}: {desc}"
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = rebase --continue
+  > EOF
+#endif
+
 Check that a simple rebase works
 
   $ hg init simple && cd simple
@@ -123,7 +131,7 @@
   $ hg resolve -m
   (no more unresolved files)
   continue: hg rebase --continue
-  $ hg rebase --continue
+  $ hg continue
   already rebased 1:112478962961 "B" (B) as 79bc8f4973ce
   rebasing 3:c26739dbe603 "C" (C)
   rebasing 5:d24bb333861c "D" (D tip)
@@ -177,7 +185,7 @@
   |/
   o  0: A
   
-  $ hg rebase --continue
+  $ hg continue
   rebasing 1:112478962961 "B" (B)
   rebasing 3:26805aba1e60 "C" (C)
   rebasing 5:f585351a92f8 "D" (D tip)
diff --git a/tests/test-rebase-mq-skip.t b/tests/test-rebase-mq-skip.t
--- a/tests/test-rebase-mq-skip.t
+++ b/tests/test-rebase-mq-skip.t
@@ -1,3 +1,4 @@
+#testcases continuecommand continueflag
 This emulates the effects of an hg pull --rebase in which the remote repo
 already has one local mq patch
 
@@ -13,6 +14,12 @@
   > tglog = log -G --template "{rev}: {node|short} '{desc}' tags: {tags}\n"
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = rebase --continue
+  > EOF
+#endif
 
   $ hg init a
   $ cd a
@@ -155,7 +162,7 @@
   (no more unresolved files)
   continue: hg rebase --continue
 
-  $ hg rebase --continue
+  $ hg continue
   already rebased 1:b4bffa6e4776 "r1" (qbase r1) as 057f55ff8f44
   already rebased 2:c0fd129beb01 "r2" (r2) as 1660ab13ce9a
   already rebased 3:6ff5b8feed8e "r3" (r3) as 1660ab13ce9a
diff --git a/tests/test-rebase-legacy.t b/tests/test-rebase-legacy.t
--- a/tests/test-rebase-legacy.t
+++ b/tests/test-rebase-legacy.t
@@ -1,3 +1,4 @@
+#testcases continuecommand continueflag
 Test rebase --continue with rebasestate written by legacy client
 
   $ cat >> $HGRCPATH < drawdag=$TESTDIR/drawdag.py
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = rebase --continue
+  > EOF
+#endif
+
   $ hg init
   $ hg debugdrawdag <<'EOF'
   >D H
@@ -40,7 +48,12 @@
   > 
6582e6951a9c48c236f746f186378e36f59f4928:
   > EOF
 
-  $ hg rebase --continue
+#if continuecommand
+  $ hg continue --dry-run
+  rebase in progress, will be resumed
+#endif
+
+  $ hg continue
   rebasing 4:c1e6b162678d "B" (B)
   rebasing 8:6f7a236de685 "D" (D)
   rebasing 2:de008c61a447 "E" (E)
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
@@ -162,7 +162,7 @@
   $ hg --config extensions.mq= strip --quiet "destination()"
   $ mv .hg/rebasestate.back .hg/rebasestate
 
-  $ hg rebase --continue
+  $ hg continue
   abort: cannot continue inconsistent rebase
   (use "hg rebase --abort" to clear broken state)
   [255]
diff --git a/tests/test-narrow-rebase.t b/tests/test-narrow-rebase.t
--- a/tests/test-narrow-rebase.t
+++ b/tests/test-narrow-rebase.t
@@ -1,3 +1,10 @@
+#testcases continuecommand continueflag
+#if continueflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = rebase --continue
+  > EOF
+#endif
 
   $ . "$TESTDIR/narrow-library.sh"
 
@@ -69,7 +76,7 @@
   $ echo modified3 > inside/f1
   $ hg resolve -m 2>&1 | grep -v continue:
   (no more unresolved files)
-  $ hg rebase --continue
+  $ hg continue
   rebasing 6:cdce97fbf653 "conflicting inside/f1" (tip)
   saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-rebase.hg (glob)
 
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1928,6 +1928,17 @@
 rbsrt = rebaseruntime(repo, ui)
 rbsrt._prepareabortorcontinue(isabort=True)
 
+def continuerebase(ui, repo):
+with repo.wlock(), repo.lock():
+rbsrt = rebaseruntime(repo, ui)
+ms = mergemod.mergestate.read(repo)
+mergeutil.checkunresolved(ms)
+retcode = rbsrt._prepareabortorcontinue(isabort=False)
+if retcode is not None:
+

D6645: continue: added logic for hg continue

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

REVISION SUMMARY
  This is part of GSoC19 project `Implement abort and
  continue commands`. This patch is part of the continue plan.
  
  This adds the basic logic for hg continue. This command
  aborts an multistep operation like graft, histedit, rebase,
  transplant and unshelve if they are in an unfinished state.
  
  The first part of the logic is determining the unfinished
  operation from the state detection API under statemod.
  This API is extended to support hg continue by adding a method
  to register the abort logic as a function (here continuefunc).
  
  Once the unfinished operation is determined the registered
  logic is used to resume the command in case it is interrupted.
  The benefit of this kind of framework is that any new extension
  developed can support hg continue by registering the command
  and logic under statedetection API.
  
  hg continue currently supports --dry-run/-n flag only.
  It is used to dry run hg abort

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/state.py

CHANGE DETAILS

diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -99,7 +99,7 @@
 
 def __init__(self, opname, fname, clearable, allowcommit, reportonly,
  continueflag, stopflag, cmdmsg, cmdhint, statushint,
- abortfunc):
+ abortfunc, continuefunc):
 self._opname = opname
 self._fname = fname
 self._clearable = clearable
@@ -111,6 +111,7 @@
 self._cmdhint = cmdhint
 self._statushint = statushint
 self.abortfunc = abortfunc
+self.continuefunc = continuefunc
 
 def statusmsg(self):
 """returns the hint message corresponding to the command for
@@ -159,7 +160,8 @@
 
 def addunfinished(opname, fname, clearable=False, allowcommit=False,
   reportonly=False, continueflag=False, stopflag=False,
-  cmdmsg="", cmdhint="", statushint="", abortfunc=None):
+  cmdmsg="", cmdhint="", statushint="", abortfunc=None,
+  continuefunc=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.
@@ -184,10 +186,12 @@
 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.
+continuefunc stores the function required to finish an interrupted
+operation.
 """
 statecheckobj = _statecheck(opname, fname, clearable, allowcommit,
 reportonly, continueflag, stopflag, cmdmsg,
-cmdhint, statushint, abortfunc)
+cmdhint, statushint, abortfunc, continuefunc)
 if opname == 'merge':
 _unfinishedstates.append(statecheckobj)
 else:
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1893,6 +1893,32 @@
 return 0
 return 1
 
+@command('continue',
+dryrunopts, helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
+helpbasic=True)
+def continuecmd(ui, repo, **opts):
+"""finishes an interrupted operation (EXPERIMENTAL)
+
+Finishes a multistep operation like graft, histedit, rebase, merge,
+and unshelve if they are in an interrupted state.
+
+use --dry-run/-n to dry run the command.
+A new operation can be added to this by registering the operation and
+continue logic in the unfinishedstates list under statemod.
+"""
+dryrun = opts.get(r'dry_run')
+contstate = cmdutil.getunfinishedstate(repo)
+if not contstate:
+raise error.Abort(_('no operation in progress'))
+if not contstate.continuefunc:
+raise error.Abort((_("%s in progress but does not support "
+ "'hg continue'") % (contstate._opname)),
+ hint=contstate.continuemsg())
+if dryrun:
+ui.status(_('%s in progress, will be resumed\n') % (contstate._opname))
+return
+return contstate.continuefunc(ui, repo)
+
 @command('copy|cp',
 [('A', 'after', None, _('record a copy that has already occurred')),
 ('f', 'force', None, _('forcibly copy over an existing managed file')),



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


D6638: abort: removed labels argument from abortmerge()

2019-07-15 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG8d03ee731751: abort: removed labels argument from 
abortmerge() (authored by taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6638?vs=15889=15911

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

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

AFFECTED FILES
  mercurial/hg.py

CHANGE DETAILS

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -957,7 +957,7 @@
 """Branch merge with node, resolving changes. Return true if any
 unresolved conflicts."""
 if abort:
-return abortmerge(repo.ui, repo, labels=labels)
+return abortmerge(repo.ui, repo)
 
 stats = mergemod.update(repo, node, branchmerge=True, force=force,
 mergeforce=mergeforce, labels=labels)
@@ -969,7 +969,7 @@
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
-def abortmerge(ui, repo, labels=None):
+def abortmerge(ui, repo):
 ms = mergemod.mergestate.read(repo)
 if ms.active():
 # there were conflicts
@@ -980,8 +980,7 @@
 
 repo.ui.status(_("aborting the merge, updating back to"
  " %s\n") % node[:12])
-stats = mergemod.update(repo, node, branchmerge=False, force=True,
-labels=labels)
+stats = mergemod.update(repo, node, branchmerge=False, force=True)
 _showstats(repo, stats)
 return stats.unresolvedcount > 0
 



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


D6638: abort: removed labels argument from abortmerge()

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


  Updated that is it fine now ?

REPOSITORY
  rHG Mercurial

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

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

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


D6638: abort: removed labels argument from abortmerge()

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6638?vs=15886=15889

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

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

AFFECTED FILES
  mercurial/hg.py

CHANGE DETAILS

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -957,7 +957,7 @@
 """Branch merge with node, resolving changes. Return true if any
 unresolved conflicts."""
 if abort:
-return abortmerge(repo.ui, repo, labels=labels)
+return abortmerge(repo.ui, repo)
 
 stats = mergemod.update(repo, node, branchmerge=True, force=force,
 mergeforce=mergeforce, labels=labels)
@@ -969,7 +969,7 @@
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
-def abortmerge(ui, repo, labels=None):
+def abortmerge(ui, repo):
 ms = mergemod.mergestate.read(repo)
 if ms.active():
 # there were conflicts
@@ -980,8 +980,7 @@
 
 repo.ui.status(_("aborting the merge, updating back to"
  " %s\n") % node[:12])
-stats = mergemod.update(repo, node, branchmerge=False, force=True,
-labels=labels)
+stats = mergemod.update(repo, node, branchmerge=False, force=True)
 _showstats(repo, stats)
 return stats.unresolvedcount > 0
 



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


D6638: abort: removed labels argument from abortmerge()

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

REVISION SUMMARY
  Labels are used to label the code that belongs to `working copy` and `merge 
rev`
  in case of a conflicted state.
  However when merge is aborted there is no unresolved merge in progress and 
hence
  no labels are required.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/hg.py

CHANGE DETAILS

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -957,7 +957,7 @@
 """Branch merge with node, resolving changes. Return true if any
 unresolved conflicts."""
 if abort:
-return abortmerge(repo.ui, repo, labels=labels)
+return abortmerge(repo.ui, repo)
 
 stats = mergemod.update(repo, node, branchmerge=True, force=force,
 mergeforce=mergeforce, labels=labels)
@@ -969,7 +969,7 @@
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
-def abortmerge(ui, repo, labels=None):
+def abortmerge(ui, repo):
 ms = mergemod.mergestate.read(repo)
 if ms.active():
 # there were conflicts
@@ -980,8 +980,7 @@
 
 repo.ui.status(_("aborting the merge, updating back to"
  " %s\n") % node[:12])
-stats = mergemod.update(repo, node, branchmerge=False, force=True,
-labels=labels)
+stats = mergemod.update(repo, node, branchmerge=False, force=True)
 _showstats(repo, stats)
 return stats.unresolvedcount > 0
 



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


D6588: abort: added support for merge

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG3bc400ccbf99: abort: added support for merge (authored by 
taapas1128).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6588?vs=15880=15883#toc

REPOSITORY
  rHG Mercurial

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

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
@@ -718,11 +718,16 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#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,13 @@
   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
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,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,31 +956,35 @@
   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()
+if abort:
+return abortmerge(repo.ui, repo, labels=labels)
 
-repo.ui.status(_("aborting the merge, updating back to"
- " %s\n") % node[:12])
-stats = mergemod.update(repo, node, branchmerge=False, force=True,
-labels=labels)
-
+stats = mergemod.update(repo, node, branchmerge=True, force=force,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
  "or 'hg merge --abort' to abandon\n"))
-elif remind and not abort:
+elif remind:
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+ms = mergemod.mergestate.read(repo)
+if ms.active():
+# there were conflicts
+node = ms.localctx.hex()
+else:
+# 

D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG3fb0493812c0: abort: added support for unshelve (authored 
by taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

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

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,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> 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
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,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)
@@ -843,7 +860,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
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, 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 opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return state
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui, repo):
+"""logic to  abort unshelve using 'hg abort"""
+with repo.wlock():
+state = _loadshelvedstate(ui, repo, {'abort' : True})
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -665,7 +694,6 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-
 def unshelvecontinue(ui, repo, state, opts):
 

D6636: unshelve: changed Corruptedstate error msg from ui.warn to error.Abort

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG8ddfdcce4bd6: unshelve: changed Corruptedstate error msg 
from ui.warn to error.Abort (authored by taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6636?vs=15865=15881

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

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

AFFECTED FILES
  mercurial/shelve.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
@@ -696,8 +696,10 @@
 
 Unshelve --abort works with a corrupted shelvedstate
   $ hg unshelve --abort
-  could not read shelved state file, your working copy may be in an unexpected 
state
+  abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
+  
+  [255]
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -880,12 +880,10 @@
  '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)
-return
+raise error.Abort(_('could not read shelved state file, your '
+ 'working copy may be in an unexpected state\n'
+ 'please update to some commit\n'))
 
 if abortf:
 return unshelveabort(ui, repo, state, opts)



To: taapas1128, #hg-reviewers, pulkit
Cc: 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-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15880.

REPOSITORY
  rHG Mercurial

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

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
@@ -718,11 +718,16 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#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,13 @@
   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
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,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,31 +956,35 @@
   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,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
- "or 'hg merge --abort' to abandon\n"))
-elif remind and not abort:
+ "or 'hg merge --abort' todef abortmerge abandon\n"))
+elif remind:
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+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 

D6588: abort: added support for merge

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15879.

REPOSITORY
  rHG Mercurial

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

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
@@ -718,11 +718,16 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#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,13 @@
   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
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,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,31 +956,38 @@
   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,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
  "or 'hg merge --abort' to abandon\n"))
-elif remind and not abort:
+elif remind:
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+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 = 

D6548: mq: fix for merge detection methods

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG51e52a495214: mq: fix for merge detection methods (authored 
by taapas1128).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6548?vs=15643=15878

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

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

AFFECTED FILES
  hgext/mq.py
  tests/test-mq-qnew.t

CHANGE DETAILS

diff --git a/tests/test-mq-qnew.t b/tests/test-mq-qnew.t
--- a/tests/test-mq-qnew.t
+++ b/tests/test-mq-qnew.t
@@ -164,8 +164,7 @@
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to 
abandon
   (no more unresolved files)
-  abort: outstanding uncommitted merge
-  (use 'hg commit' or 'hg merge --abort')
+  abort: cannot manage merge changesets
   $ rm -r sandbox
 
 hg headers
@@ -244,8 +243,7 @@
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to 
abandon
   (no more unresolved files)
-  abort: outstanding uncommitted merge
-  (use 'hg commit' or 'hg merge --abort')
+  abort: cannot manage merge changesets
   $ rm -r sandbox
 
 Test saving last-message.txt
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1162,18 +1162,17 @@
 _("local changes found, qrefresh first")
 _("local changed subrepos found, qrefresh first")
 
-cmdutil.checkunfinished(repo)
 s = repo.status()
 if not force:
-if len(repo[None].parents()) > 1:
-_("outstanding uncommitted merge") #i18 tool detection
-raise error.Abort(_("outstanding uncommitted merge"+ 
excsuffix))
+cmdutil.checkunfinished(repo)
 if s.modified or s.added or s.removed or s.deleted:
 _("local changes found") # i18n tool detection
 raise error.Abort(_("local changes found" + excsuffix))
 if checksubstate(repo):
 _("local changed subrepos found") # i18n tool detection
 raise error.Abort(_("local changed subrepos found" + 
excsuffix))
+else:
+cmdutil.checkunfinished(repo, skipmerge=True)
 return s
 
 _reserved = ('series', 'status', 'guards', '.', '..')



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


D6636: unshelve: changed Corruptedstate error msg from ui.warn to error.Abort

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


  Fixed the message.

REPOSITORY
  rHG Mercurial

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

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

To: taapas1128, #hg-reviewers, pulkit
Cc: 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-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15867.

REPOSITORY
  rHG Mercurial

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

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
@@ -718,11 +718,16 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#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,13 @@
   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
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,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,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
@@ -981,6 +969,22 @@
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+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,
+

D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15866.

REPOSITORY
  rHG Mercurial

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

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,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> 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
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,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)
@@ -843,7 +860,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
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, 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 opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return state
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui, repo):
+"""logic to  abort unshelve using 'hg abort"""
+with repo.wlock():
+state = _loadshelvedstate(ui, repo, {'abort' : True})
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -665,7 +694,6 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-
 def unshelvecontinue(ui, repo, state, opts):
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
@@ 

D6636: unshelve: changed Corruptedstate error msg from ui.warn to error.Abort

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6636?vs=15856=15865

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

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

AFFECTED FILES
  mercurial/shelve.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
@@ -696,8 +696,10 @@
 
 Unshelve --abort works with a corrupted shelvedstate
   $ hg unshelve --abort
-  could not read shelved state file, your working copy may be in an unexpected 
state
+  abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
+  
+  [255]
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -880,12 +880,10 @@
  '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)
-return
+raise error.Abort(_('could not read shelved state file, your '
+ 'working copy may be in an unexpected state\n'
+ 'please update to some commit\n'))
 
 if abortf:
 return unshelveabort(ui, repo, state, opts)



To: taapas1128, #hg-reviewers, pulkit
Cc: 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-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15864.

REPOSITORY
  rHG Mercurial

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

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
@@ -718,11 +718,16 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#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,13 @@
   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
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,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,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
@@ -981,6 +969,22 @@
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+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,
+

D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15863.

REPOSITORY
  rHG Mercurial

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

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,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> 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
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,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)
@@ -843,7 +860,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
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, 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 opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return state
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui, repo):
+"""logic to  abort unshelve using 'hg abort"""
+with repo.wlock():
+state = _loadshelvedstate(ui, repo, {'abort' : True})
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -665,7 +694,6 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-
 def unshelvecontinue(ui, repo, state, opts):
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
@@ 

D6637: unshelve: changed Corruptedstate error msg from ui.warn to error.Abort

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

REVISION SUMMARY
  This changes the message type of Corruptedstate error in case of `hg unshelve 
--abort`
  to error.Abort from warning message. This is done so as to avoid the return 
statement
  after the warning.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/shelve.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
@@ -696,8 +696,10 @@
 
 Unshelve --abort works with a corrupted shelvedstate
   $ hg unshelve --abort
-  could not read shelved state file, your working copy may be in an unexpected 
state
+  abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
+  
+  [255]
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -880,12 +880,10 @@
  '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)
-return
+raise error.Abort(_('could not read shelved state file, your '
+ 'working copy may be in an unexpected state\n'
+ 'please update to some commit\n'))
 
 if abortf:
 return unshelveabort(ui, repo, state, opts)



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


D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15861.

REPOSITORY
  rHG Mercurial

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

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,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> 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
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,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)
@@ -843,7 +860,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
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, 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 opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return state
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui, repo):
+"""logic to  abort unshelve using 'hg abort"""
+with repo.wlock():
+state = _loadshelvedstate(ui, repo, {'abort' : True})
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -665,7 +694,6 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-
 def unshelvecontinue(ui, repo, state, opts):
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
@@ 

D6579: abort: added support for unshelve

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


  updated that.

REPOSITORY
  rHG Mercurial

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

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

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


D6579: abort: added support for unshelve

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

REPOSITORY
  rHG Mercurial

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

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,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> 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
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,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)
@@ -843,7 +860,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
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, 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 opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return (state, opts)
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui, repo):
+"""logic to  abort unshelve using 'hg abort"""
+with repo.wlock():
+state, opts = _loadshelvedstate(ui, repo, {'abort' : True})
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -864,29 +893,9 @@
 if abortf and opts.get('tool', False):
 ui.warn(_('tool option will be ignored\n'))
 
-try:
-state = shelvedstate.load(repo)
-if opts.get('keep') is None:
-   

D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15859.

REPOSITORY
  rHG Mercurial

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

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,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> 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
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,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)
@@ -843,7 +860,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
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, 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 opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return (state, opts)
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui,repo):
+"""logic to  abort unshelve using 'hg abort"""
+with repo.wlock():
+state, opts = _loadshelvedstate(ui, repo, {'abort' : True})
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -864,29 +893,9 @@
 if abortf and opts.get('tool', False):
 ui.warn(_('tool option will be ignored\n'))
 
-try:
-state = shelvedstate.load(repo)
-if opts.get('keep') is None:
-opts['keep'] = state.keep
-except 

D6588: abort: added support for merge

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15858.

REPOSITORY
  rHG Mercurial

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

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
@@ -718,11 +718,16 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#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,13 @@
   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
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,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,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
@@ -981,6 +969,22 @@
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+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,
+

D6579: abort: added support for unshelve

2019-07-10 Thread taapas1128 (Taapas Agrawal)
taapas1128 marked 5 inline comments as done.
taapas1128 updated this revision to Diff 15857.

REPOSITORY
  rHG Mercurial

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

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,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> 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
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,7 +710,7 @@
   [255]
 
 Unshelve --abort works with a corrupted shelvedstate
-  $ hg unshelve --abort
+  $ hg abort
   abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
   
@@ -703,8 +718,10 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -824,7 +841,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)
@@ -843,7 +860,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
@@ -624,7 +624,30 @@
 raise error.Abort(_('working directory parents do not match unshelve '
'state'))
 
-def unshelveabort(ui, repo, state, opts):
+def _loadshelvedstate(ui, repo, 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 opts.get('continue'):
+msg = _('corrupted shelved state file')
+hint = _('please run hg unshelve --abort to abort unshelve '
+ 'operation')
+raise error.Abort(msg, hint=hint)
+elif opts.get('abort'):
+shelvedstate.clear(repo)
+raise error.Abort(_('could not read shelved state file, your '
+'working copy may be in an unexpected state\n'
+'please update to some commit\n'))
+return (state, opts)
+
+def unshelveabort(ui, repo, state):
 """subcommand that abort an in-progress unshelve"""
 with repo.lock():
 try:
@@ -642,6 +665,12 @@
 shelvedstate.clear(repo)
 ui.warn(_("unshelve of '%s' aborted\n") % state.name)
 
+def hgabortunshelve(ui,repo):
+"""logic to  abort unshelve using 'hg abort"""
+state, opts = _loadshelvedstate(ui, repo, {'abort' : True})
+with repo.wlock():
+return unshelveabort(ui, repo, state)
+
 def mergefiles(ui, repo, wctx, shelvectx):
 """updates to wctx and merges the changes from shelvectx into the
 dirstate."""
@@ -864,29 +893,9 @@
 if abortf and opts.get('tool', False):
 ui.warn(_('tool option will be ignored\n'))
 
-try:
-state = shelvedstate.load(repo)
-if opts.get('keep') is None:
-

D6636: unshelve: changed Corruptedstate error msg from ui.warn to error.Abort

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

REVISION SUMMARY
  This changes the message type of Corruptedstate error in case of `hg unshelve 
--abort`
  to error.Abort from warning message. This is fone so as to avoid the return 
statement
  after the warning.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/shelve.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
@@ -696,8 +696,10 @@
 
 Unshelve --abort works with a corrupted shelvedstate
   $ hg unshelve --abort
-  could not read shelved state file, your working copy may be in an unexpected 
state
+  abort: could not read shelved state file, your working copy may be in an 
unexpected state
   please update to some commit
+  
+  [255]
 
 Unshelve --abort fails with appropriate message if there's no unshelve in
 progress
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -880,12 +880,10 @@
  '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)
-return
+raise error.Abort(_('could not read shelved state file, your '
+ 'working copy may be in an unexpected state\n'
+ 'please update to some commit\n'))
 
 if abortf:
 return unshelveabort(ui, repo, state, opts)



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


D6566: abort: added logic for of hg abort

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHGbb135a784b70: abort: added logic for of hg abort (authored 
by taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

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

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: 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':
   

D6567: abort: added support for graft

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHG5171937ad0f9: abort: added support for graft (authored by 
taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

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

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,13 @@
   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
+#endif
+
+  $ hg abort
   graft aborted
   working directory is now at 9150fe93bec6
   $ hg log -GT "{rev}:{node|short} {desc}"
@@ -2041,7 +2057,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 +2101,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 +2178,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
@@ -2677,6 +2677,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
@@ -3419,3 +3419,9 @@
 except error.CorruptedState:
 nodes = repo.vfs.read('graftstate').splitlines()
 return {'nodes': nodes}
+
+def hgabortgraft(ui, repo):
+""" abort logic for aborting graft using 'hg abort'"""
+with repo.wlock():
+graftstate = statemod.cmdstate(repo, 'graftstate')
+return abortgraft(ui, repo, graftstate)



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


D6582: abort: added support for histedit

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHGdb5560c07a28: abort: added support for histedit (authored 
by taapas1128).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6582?vs=15834=15848#toc

REPOSITORY
  rHG Mercurial

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

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,13 @@
   (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
+#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,7 +53,7 @@
   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
@@ -66,5 +75,6 @@
   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
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,14 @@
 finally:
 state.clear()
 
+def hgaborthistedit(ui, repo):
+state = histeditstate(repo)
+nobackup = not ui.configbool('rewrite', 'backup-bundle')
+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 +2322,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, pulkit
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6568: abort: added support for rebase

2019-07-10 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHGb9bc47211cf5: abort: added support for rebase (authored by 
taapas1128).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6568?vs=15832=15847#toc

REPOSITORY
  rHG Mercurial

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

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,13 @@
 
 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
+#endif
+
+  $ hg abort
   saved backup bundle to 
$TESTTMP/a/.hg/strip-backup/3e046f2ecedb-6beef7d5-backup.hg
   rebase aborted
   $ hg debugmergestate
@@ -154,7 +168,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 +285,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 +338,7 @@
 
   $ cat a
   new
-  $ hg rebase --abort
+  $ hg abort
   rebase aborted
   $ cat a
   new
@@ -405,7 +419,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 +470,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 +511,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
+  $ 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,11 @@
 obsoleteextinctsuccessors,
 )
 
+def abortrebase(ui, repo):
+with repo.wlock(), repo.lock():
+rbsrt = rebaseruntime(repo, ui)
+rbsrt._prepareabortorcontinue(isabort=True)
+
 def summaryhook(ui, repo):
 if not repo.vfs.exists('rebasestate'):
 return
@@ -1951,4 +1956,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, pulkit
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6567: abort: added support for graft

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


  amended.

REPOSITORY
  rHG Mercurial

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

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

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


D6566: abort: added logic for of hg abort

2019-07-09 Thread taapas1128 (Taapas Agrawal)
taapas1128 marked 3 inline comments as done.
taapas1128 updated this revision to Diff 15836.

REPOSITORY
  rHG Mercurial

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

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

D6588: abort: added support for merge

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

REPOSITORY
  rHG Mercurial

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

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
@@ -716,11 +716,16 @@
 
 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 in progress but does not support 'hg abort' (no-abortflag !)
-  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
-  [255]
+  aborting the merge, updating back to 9451eaa6eee3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#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,13 @@
   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
+#endif
+
+  $ hg abort
   aborting the merge, updating back to e45016d2b3d3
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
@@ -131,7 +147,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,
+mergeforce=mergeforce, labels=labels)
 _showstats(repo, stats)
 if stats.unresolvedcount:
 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
@@ -981,6 +969,21 @@
 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
 return stats.unresolvedcount > 0
 
+def abortmerge(ui, repo, labels=None):
+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, 

D6579: abort: added support for unshelve

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

REPOSITORY
  rHG Mercurial

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

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,5 @@
 #testcases stripbased phasebased
+#testcases abortflag abortcommand
 
   $ cat <> $HGRCPATH
   > [extensions]
@@ -19,6 +20,13 @@
 
 #endif
 
+#if abortflag
+  $ cat >> $HGRCPATH < [alias]
+  > abort = unshelve --abort
+  > EOF
+#endif
+
 shelve should leave dirstate clean (issue4055)
 
   $ hg init shelverebase
@@ -285,7 +293,14 @@
   >>> 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
+#endif
+
+  $ hg abort
   unshelve of 'default' aborted
   $ hg st
   ? f.orig
@@ -695,14 +710,16 @@
   [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 in progress but does not support 'hg abort' (no-abortflag !)
+  (use 'hg commit' or 'hg merge --abort') (no-abortflag !)
   [255]
   $ cd ..
 
@@ -822,7 +839,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 +858,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,37 @@
 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):
 """subcommand that abort an in-progress unshelve"""
-with repo.lock():
+if not state:
+statetuple = _loadshelvedstate(ui, repo, abortf=True)
+state, opts = statetuple
+with repo.wlock(), repo.lock():
 try:
 checkparents(repo, state)
 
@@ -864,31 +893,12 @@
 if abortf and opts.get('tool', False):
 ui.warn(_('tool option will be ignored\n'))
 
-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, 

D6582: abort: added support for histedit

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

REPOSITORY
  rHG Mercurial

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

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,13 @@
   (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
+#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,13 +53,14 @@
   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:
+
   $ cat >>$HGRCPATH < [rewrite]
   > backup-bundle = False
@@ -66,5 +76,6 @@
   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
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,14 @@
 finally:
 state.clear()
 
+def hgaborthistedit(ui, repo):
+state = histeditstate(repo)
+nobackup = not ui.configbool('rewrite', 'backup-bundle')
+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 +2322,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 list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6567: abort: added support for graft

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

REPOSITORY
  rHG Mercurial

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

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,13 @@
   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
+#endif
+
+  $ hg abort
   graft aborted
   working directory is now at 9150fe93bec6
   $ hg log -GT "{rev}:{node|short} {desc}"
@@ -2041,7 +2057,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 +2101,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 +2178,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
@@ -2677,6 +2677,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
@@ -3418,3 +3418,9 @@
 except error.CorruptedState:
 nodes = repo.vfs.read('graftstate').splitlines()
 return {'nodes': nodes}
+
+def hgabortgraft(ui, repo):
+""" abort logic for aborting graft using 'hg abort'"""
+with repo.wlock():
+graftstate = statemod.cmdstate(repo, 'graftstate')
+return abortgraft(ui, repo, graftstate)



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


D6568: abort: added support for rebase

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

REPOSITORY
  rHG Mercurial

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

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,13 @@
 
 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
+#endif
+
+  $ hg abort
   saved backup bundle to 
$TESTTMP/a/.hg/strip-backup/3e046f2ecedb-6beef7d5-backup.hg
   rebase aborted
   $ hg debugmergestate
@@ -154,7 +168,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 +285,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 +338,7 @@
 
   $ cat a
   new
-  $ hg rebase --abort
+  $ hg abort
   rebase aborted
   $ cat a
   new
@@ -405,7 +419,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 +470,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 +511,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,11 @@
 obsoleteextinctsuccessors,
 )
 
+def abortrebase(ui, repo):
+with repo.wlock(), repo.lock():
+rbsrt = rebaseruntime(repo, ui)
+rbsrt._prepareabortorcontinue(isabort=True)
+
 def summaryhook(ui, repo):
 if not repo.vfs.exists('rebasestate'):
 return
@@ -1951,4 +1956,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


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


D6606: statecheck: updated docstrings related to afterresolvedstates

2019-07-08 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHGceb31d96d3ae: statecheck: updated docstrings related to 
afterresolvedstates (authored by taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6606?vs=15763=15826

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

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

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3301,8 +3301,9 @@
 '''Check for an unfinished operation and return the command to finish
 it.
 
-afterresolvedstates tuples define a .hg/{file} and the corresponding
-command needed to finish it.
+statemod._unfinishedstates list is checked for an unfinished operation
+and the corresponding message to finish it is generated if a method to
+continue is supported by the operation.
 
 Returns a (msg, warning) tuple. 'msg' is a string and 'warning' is
 a boolean.
@@ -3320,8 +3321,8 @@
 def checkafterresolved(repo):
 '''Inform the user about the next action after completing hg resolve
 
-If there's a matching afterresolvedstates, howtocontinue will yield
-repo.ui.warn as the reporter.
+If there's a an unfinished operation that supports continue flag,
+howtocontinue will yield repo.ui.warn as the reporter.
 
 Otherwise, it will yield repo.ui.note.
 '''



To: taapas1128, #hg-reviewers, pulkit
Cc: av6, 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-08 Thread taapas1128 (Taapas Agrawal)
Closed by commit rHGf9da9d5f3f5a: graft: moved abortgraft and readgraft to 
cmdutil (authored by taapas1128).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6608?vs=15803=15817

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

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,
@@ -2465,14 +2464,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'):
@@ -2642,69 +2641,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,67 @@
 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 

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


D6579: abort: added support for unshelve

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


  @mharbison72 Thanks for the suggestions. I have amended the patch accordingly.

REPOSITORY
  rHG Mercurial

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

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

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


  1   2   3   4   5   >