D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-30 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added a comment.


  > mercurial/shelve.py:938: local variable 'interactive' is assigned to but 
never used
  > Maybe `--continue --interactive` has to be banned if the mode can't be
  > overridden by the command option.
  
  Noted. Created D6703 . Thanks!

REPOSITORY
  rHG Mercurial

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

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

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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-29 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > @@ -936,7 +942,7 @@
  >
  >   if opts.get("name"):
  >   shelved.append(opts["name"])
  >
  > - if abortf or continuef and not interactive:
  >
  > +if abortf or continuef:
  
  mercurial/shelve.py:938: local variable 'interactive' is assigned to but 
never used
  
  Maybe `--continue --interactive` has to be banned if the mode can't be
  overridden by the command option.

REPOSITORY
  rHG Mercurial

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

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

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


Re: D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-29 Thread Yuya Nishihara
> @@ -936,7 +942,7 @@
>  if opts.get("name"):
>  shelved.append(opts["name"])
>  
> -if abortf or continuef and not interactive:
> +if abortf or continuef:

mercurial/shelve.py:938: local variable 'interactive' is assigned to but never 
used

Maybe `--continue --interactive` has to be banned if the mode can't be
overridden by the command option.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-29 Thread navaneeth.suresh (Navaneeth Suresh)
Closed by commit rHGee86ad6f50fe: unshelve: store information about interactive 
mode in shelvedstate (authored by navaneeth.suresh).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6679?vs=16064=16093

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

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

AFFECTED FILES
  mercurial/shelve.py
  tests/test-shelve.t

CHANGE DETAILS

diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1351,13 +1351,12 @@
   A
   B
   C
-  $ hg unshelve --continue -i < y
   > y
   > y
   > y
   > EOF
-  unshelving change 'default-01'
   diff --git a/bar1 b/bar1
   1 hunks, 1 lines changed
   examine changes to 'bar1'?
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -177,6 +177,7 @@
 _nokeep = 'nokeep'
 # colon is essential to differentiate from a real bookmark name
 _noactivebook = ':no-active-bookmark'
+_interactive = 'interactive'
 
 @classmethod
 def _verifyandtransform(cls, d):
@@ -247,6 +248,7 @@
 obj.activebookmark = ''
 if d.get('activebook', '') != cls._noactivebook:
 obj.activebookmark = d.get('activebook', '')
+obj.interactive = d.get('interactive') == cls._interactive
 except (error.RepoLookupError, KeyError) as err:
 raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +256,7 @@
 
 @classmethod
 def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
- branchtorestore, keep=False, activebook=''):
+ branchtorestore, keep=False, activebook='', interactive=False):
 info = {
 "name": name,
 "originalwctx": nodemod.hex(originalwctx.node()),
@@ -267,6 +269,8 @@
 "keep": cls._keep if keep else cls._nokeep,
 "activebook": activebook or cls._noactivebook
 }
+if interactive:
+info['interactive'] = cls._interactive
 scmutil.simplekeyvaluefile(
 repo.vfs, cls._filename).write(info,
firstline=("%d" % cls._version))
@@ -694,11 +698,12 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-def unshelvecontinue(ui, repo, state, opts, basename=None):
+def unshelvecontinue(ui, repo, state, opts):
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
-interactive = opts.get('interactive')
+interactive = state.interactive
+basename = state.name
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -869,7 +874,8 @@
 nodestoremove = [repo.changelog.node(rev)
  for rev in pycompat.xrange(oldtiprev, len(repo))]
 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
-  branchtorestore, opts.get('keep'), 
activebookmark)
+  branchtorestore, opts.get('keep'), 
activebookmark,
+  interactive)
 raise error.InterventionRequired(
 _("unresolved conflicts (see 'hg resolve', then "
   "'hg unshelve --continue')"))
@@ -936,7 +942,7 @@
 if opts.get("name"):
 shelved.append(opts["name"])
 
-if abortf or continuef and not interactive:
+if abortf or continuef:
 if abortf and continuef:
 raise error.Abort(_('cannot use both abort and continue'))
 if shelved:
@@ -958,11 +964,8 @@
 raise error.Abort(_('no shelved changes to apply!'))
 basename = util.split(shelved[0][1])[1]
 ui.status(_("unshelving change '%s'\n") % basename)
-elif shelved:
+else:
 basename = shelved[0]
-if continuef and interactive:
-state = _loadshelvedstate(ui, repo, opts)
-return unshelvecontinue(ui, repo, state, opts, basename)
 
 if not shelvedfile(repo, basename, patchextension).exists():
 raise error.Abort(_("shelved change '%s' not found") % basename)



To: navaneeth.suresh, #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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-25 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16064.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6679?vs=16057=16064

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

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

AFFECTED FILES
  mercurial/shelve.py
  tests/test-shelve.t

CHANGE DETAILS

diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1351,13 +1351,12 @@
   A
   B
   C
-  $ hg unshelve --continue -i < y
   > y
   > y
   > y
   > EOF
-  unshelving change 'default-01'
   diff --git a/bar1 b/bar1
   1 hunks, 1 lines changed
   examine changes to 'bar1'?
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -177,6 +177,7 @@
 _nokeep = 'nokeep'
 # colon is essential to differentiate from a real bookmark name
 _noactivebook = ':no-active-bookmark'
+_interactive = 'interactive'
 
 @classmethod
 def _verifyandtransform(cls, d):
@@ -247,6 +248,7 @@
 obj.activebookmark = ''
 if d.get('activebook', '') != cls._noactivebook:
 obj.activebookmark = d.get('activebook', '')
+obj.interactive = d.get('interactive') == cls._interactive
 except (error.RepoLookupError, KeyError) as err:
 raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +256,7 @@
 
 @classmethod
 def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
- branchtorestore, keep=False, activebook=''):
+ branchtorestore, keep=False, activebook='', interactive=False):
 info = {
 "name": name,
 "originalwctx": nodemod.hex(originalwctx.node()),
@@ -267,6 +269,8 @@
 "keep": cls._keep if keep else cls._nokeep,
 "activebook": activebook or cls._noactivebook
 }
+if interactive:
+info['interactive'] = cls._interactive
 scmutil.simplekeyvaluefile(
 repo.vfs, cls._filename).write(info,
firstline=("%d" % cls._version))
@@ -694,11 +698,12 @@
 if shfile.exists():
 shfile.movetobackup()
 cleanupoldbackups(repo)
-def unshelvecontinue(ui, repo, state, opts, basename=None):
+def unshelvecontinue(ui, repo, state, opts):
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
-interactive = opts.get('interactive')
+interactive = state.interactive
+basename = state.name
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -854,7 +859,8 @@
 nodestoremove = [repo.changelog.node(rev)
  for rev in pycompat.xrange(oldtiprev, len(repo))]
 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
-  branchtorestore, opts.get('keep'), 
activebookmark)
+  branchtorestore, opts.get('keep'), 
activebookmark,
+  interactive)
 raise error.InterventionRequired(
 _("unresolved conflicts (see 'hg resolve', then "
   "'hg unshelve --continue')"))
@@ -928,7 +934,7 @@
 if opts.get("name"):
 shelved.append(opts["name"])
 
-if abortf or continuef and not interactive:
+if abortf or continuef:
 if abortf and continuef:
 raise error.Abort(_('cannot use both abort and continue'))
 if shelved:
@@ -950,11 +956,8 @@
 raise error.Abort(_('no shelved changes to apply!'))
 basename = util.split(shelved[0][1])[1]
 ui.status(_("unshelving change '%s'\n") % basename)
-elif shelved:
+else:
 basename = shelved[0]
-if continuef and interactive:
-state = _loadshelvedstate(ui, repo, opts)
-return unshelvecontinue(ui, repo, state, opts, basename)
 
 if not shelvedfile(repo, basename, patchextension).exists():
 raise error.Abort(_("shelved change '%s' not found") % basename)



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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16057.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6679?vs=16055=16057

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

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

AFFECTED FILES
  mercurial/shelve.py
  tests/test-shelve.t

CHANGE DETAILS

diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1351,13 +1351,12 @@
   A
   B
   C
-  $ hg unshelve --continue -i < y
   > y
   > y
   > y
   > EOF
-  unshelving change 'default-01'
   diff --git a/bar1 b/bar1
   1 hunks, 1 lines changed
   examine changes to 'bar1'?
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -177,6 +177,7 @@
 _nokeep = 'nokeep'
 # colon is essential to differentiate from a real bookmark name
 _noactivebook = ':no-active-bookmark'
+_interactive = 'interactive'
 
 @classmethod
 def _verifyandtransform(cls, d):
@@ -247,6 +248,7 @@
 obj.activebookmark = ''
 if d.get('activebook', '') != cls._noactivebook:
 obj.activebookmark = d.get('activebook', '')
+obj.interactive = d.get('interactive') == cls._interactive
 except (error.RepoLookupError, KeyError) as err:
 raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +256,7 @@
 
 @classmethod
 def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
- branchtorestore, keep=False, activebook=''):
+ branchtorestore, keep=False, activebook='', interactive=False):
 info = {
 "name": name,
 "originalwctx": nodemod.hex(originalwctx.node()),
@@ -267,6 +269,8 @@
 "keep": cls._keep if keep else cls._nokeep,
 "activebook": activebook or cls._noactivebook
 }
+if interactive:
+info['interactive'] = cls._interactive
 scmutil.simplekeyvaluefile(
 repo.vfs, cls._filename).write(info,
firstline=("%d" % cls._version))
@@ -698,7 +702,7 @@
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
-interactive = opts.get('interactive')
+interactive = state.interactive
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -854,7 +858,8 @@
 nodestoremove = [repo.changelog.node(rev)
  for rev in pycompat.xrange(oldtiprev, len(repo))]
 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
-  branchtorestore, opts.get('keep'), 
activebookmark)
+  branchtorestore, opts.get('keep'), 
activebookmark,
+  interactive)
 raise error.InterventionRequired(
 _("unresolved conflicts (see 'hg resolve', then "
   "'hg unshelve --continue')"))



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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh marked an inline comment as done.
navaneeth.suresh updated this revision to Diff 16055.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6679?vs=16054=16055

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

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

AFFECTED FILES
  mercurial/shelve.py

CHANGE DETAILS

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -177,6 +177,7 @@
 _nokeep = 'nokeep'
 # colon is essential to differentiate from a real bookmark name
 _noactivebook = ':no-active-bookmark'
+_interactive = 'interactive'
 
 @classmethod
 def _verifyandtransform(cls, d):
@@ -247,6 +248,7 @@
 obj.activebookmark = ''
 if d.get('activebook', '') != cls._noactivebook:
 obj.activebookmark = d.get('activebook', '')
+obj.interactive = d.get('interactive') == cls._interactive
 except (error.RepoLookupError, KeyError) as err:
 raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +256,7 @@
 
 @classmethod
 def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
- branchtorestore, keep=False, activebook=''):
+ branchtorestore, keep=False, activebook='', interactive=False):
 info = {
 "name": name,
 "originalwctx": nodemod.hex(originalwctx.node()),
@@ -267,6 +269,8 @@
 "keep": cls._keep if keep else cls._nokeep,
 "activebook": activebook or cls._noactivebook
 }
+if interactive:
+info['interactive'] = cls._interactive
 scmutil.simplekeyvaluefile(
 repo.vfs, cls._filename).write(info,
firstline=("%d" % cls._version))
@@ -698,7 +702,7 @@
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
-interactive = opts.get('interactive')
+interactive = state.interactive
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -854,7 +858,8 @@
 nodestoremove = [repo.changelog.node(rev)
  for rev in pycompat.xrange(oldtiprev, len(repo))]
 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
-  branchtorestore, opts.get('keep'), 
activebookmark)
+  branchtorestore, opts.get('keep'), 
activebookmark,
+  interactive)
 raise error.InterventionRequired(
 _("unresolved conflicts (see 'hg resolve', then "
   "'hg unshelve --continue')"))



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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added inline comments.
navaneeth.suresh marked an inline comment as done.

INLINE COMMENTS

> pulkit wrote in shelve.py:181
> The above comment is not done.
> 
> I meant, we don't need _noninteractive.

Done.

REPOSITORY
  rHG Mercurial

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

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

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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh marked an inline comment as done.
navaneeth.suresh updated this revision to Diff 16054.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6679?vs=16036=16054

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

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

AFFECTED FILES
  mercurial/shelve.py

CHANGE DETAILS

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -177,6 +177,7 @@
 _nokeep = 'nokeep'
 # colon is essential to differentiate from a real bookmark name
 _noactivebook = ':no-active-bookmark'
+_interactive = 'interactive'
 
 @classmethod
 def _verifyandtransform(cls, d):
@@ -247,6 +248,7 @@
 obj.activebookmark = ''
 if d.get('activebook', '') != cls._noactivebook:
 obj.activebookmark = d.get('activebook', '')
+obj.interactive = d.get('interactive') == cls._interactive
 except (error.RepoLookupError, KeyError) as err:
 raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +256,7 @@
 
 @classmethod
 def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
- branchtorestore, keep=False, activebook=''):
+ branchtorestore, keep=False, activebook='', interactive=False):
 info = {
 "name": name,
 "originalwctx": nodemod.hex(originalwctx.node()),
@@ -265,8 +267,10 @@
   for n in nodestoremove]),
 "branchtorestore": branchtorestore,
 "keep": cls._keep if keep else cls._nokeep,
-"activebook": activebook or cls._noactivebook
+"activebook": activebook or cls._noactivebook,
 }
+if interactive:
+info['interactive'] = cls._interactive
 scmutil.simplekeyvaluefile(
 repo.vfs, cls._filename).write(info,
firstline=("%d" % cls._version))
@@ -698,7 +702,7 @@
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
-interactive = opts.get('interactive')
+interactive = state.interactive
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -854,7 +858,8 @@
 nodestoremove = [repo.changelog.node(rev)
  for rev in pycompat.xrange(oldtiprev, len(repo))]
 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
-  branchtorestore, opts.get('keep'), 
activebookmark)
+  branchtorestore, opts.get('keep'), 
activebookmark,
+  interactive)
 raise error.InterventionRequired(
 _("unresolved conflicts (see 'hg resolve', then "
   "'hg unshelve --continue')"))



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


D6679: unshelve: store information about interactive mode in shelvedstate

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

INLINE COMMENTS

> pulkit wrote in shelve.py:181
> We are already in shelve code, so no need to prepend shelved to the name.
> 
> Also, we can only had `interactive` stored in the shelved state. If it's not 
> present in the state file, we can assume we were not running interactive 
> unshelve.

The above comment is not done.

I meant, we don't need _noninteractive.

REPOSITORY
  rHG Mercurial

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

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

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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added inline comments.
navaneeth.suresh marked 3 inline comments as done.

INLINE COMMENTS

> pulkit wrote in shelve.py:938
> This change is unrelated to storing info about interactive in shelvedstate. 
> Can you decouple this into a separate patch?

Doing that right away!

REPOSITORY
  rHG Mercurial

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

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

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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16036.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6679?vs=16021=16036

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

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

AFFECTED FILES
  mercurial/shelve.py

CHANGE DETAILS

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -177,6 +177,8 @@
 _nokeep = 'nokeep'
 # colon is essential to differentiate from a real bookmark name
 _noactivebook = ':no-active-bookmark'
+_interactive = 'interactive'
+_noninteractive = 'noninteractive'
 
 @classmethod
 def _verifyandtransform(cls, d):
@@ -247,6 +249,7 @@
 obj.activebookmark = ''
 if d.get('activebook', '') != cls._noactivebook:
 obj.activebookmark = d.get('activebook', '')
+obj.interactive = d.get('interactive') == cls._interactive
 except (error.RepoLookupError, KeyError) as err:
 raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +257,7 @@
 
 @classmethod
 def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
- branchtorestore, keep=False, activebook=''):
+ branchtorestore, keep=False, activebook='', interactive=False):
 info = {
 "name": name,
 "originalwctx": nodemod.hex(originalwctx.node()),
@@ -265,7 +268,9 @@
   for n in nodestoremove]),
 "branchtorestore": branchtorestore,
 "keep": cls._keep if keep else cls._nokeep,
-"activebook": activebook or cls._noactivebook
+"activebook": activebook or cls._noactivebook,
+"interactive": (cls._interactive
+if interactive else cls._noninteractive)
 }
 scmutil.simplekeyvaluefile(
 repo.vfs, cls._filename).write(info,
@@ -698,7 +703,7 @@
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
-interactive = opts.get('interactive')
+interactive = state.interactive
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -854,7 +859,8 @@
 nodestoremove = [repo.changelog.node(rev)
  for rev in pycompat.xrange(oldtiprev, len(repo))]
 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
-  branchtorestore, opts.get('keep'), 
activebookmark)
+  branchtorestore, opts.get('keep'), 
activebookmark,
+  interactive)
 raise error.InterventionRequired(
 _("unresolved conflicts (see 'hg resolve', then "
   "'hg unshelve --continue')"))



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


D6679: unshelve: store information about interactive mode in shelvedstate

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

INLINE COMMENTS

> shelve.py:181
> +_shelvedinteractively = 'shelvedinteractively'
> +_notshelvedinteractively = 'notshelvedinteractively'
>  

We are already in shelve code, so no need to prepend shelved to the name.

Also, we can only had `interactive` stored in the shelved state. If it's not 
present in the state file, we can assume we were not running interactive 
unshelve.

> shelve.py:842
>  # we'll be merging with, rebase it to be on top.
> -interactive = opts.get('interactive')
> +interactive = opts.get('interactive', False)
>  if tmpwctx.node() == shelvectx.p1().node() and not interactive:

unrequired change.

> shelve.py:938
>  
> -if abortf or continuef and not interactive:
> +if len(shelved) > 1:
> +raise error.Abort(_('can only unshelve one change at a time'))

This change is unrelated to storing info about interactive in shelvedstate. Can 
you decouple this into a separate patch?

REPOSITORY
  rHG Mercurial

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

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

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


D6679: unshelve: store information about interactive mode in shelvedstate

2019-07-23 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is a follow-up patch to 5162753c4c14 
. 
This makes `unshelve`
  stores the information about interactive mode on conflicts.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/shelve.py
  tests/test-shelve.t

CHANGE DETAILS

diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1351,13 +1351,12 @@
   A
   B
   C
-  $ hg unshelve --continue -i < y
   > y
   > y
   > y
   > EOF
-  unshelving change 'default-01'
   diff --git a/bar1 b/bar1
   1 hunks, 1 lines changed
   examine changes to 'bar1'?
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -177,6 +177,8 @@
 _nokeep = 'nokeep'
 # colon is essential to differentiate from a real bookmark name
 _noactivebook = ':no-active-bookmark'
+_shelvedinteractively = 'shelvedinteractively'
+_notshelvedinteractively = 'notshelvedinteractively'
 
 @classmethod
 def _verifyandtransform(cls, d):
@@ -247,6 +249,8 @@
 obj.activebookmark = ''
 if d.get('activebook', '') != cls._noactivebook:
 obj.activebookmark = d.get('activebook', '')
+obj.shelvedinteractively = (d.get('shelvedinteractively')
+ == cls._shelvedinteractively)
 except (error.RepoLookupError, KeyError) as err:
 raise error.CorruptedState(pycompat.bytestr(err))
 
@@ -254,7 +258,7 @@
 
 @classmethod
 def save(cls, repo, name, originalwctx, pendingctx, nodestoremove,
- branchtorestore, keep=False, activebook=''):
+ branchtorestore, keep=False, activebook='', 
shelvedinteractively=False):
 info = {
 "name": name,
 "originalwctx": nodemod.hex(originalwctx.node()),
@@ -265,7 +269,9 @@
   for n in nodestoremove]),
 "branchtorestore": branchtorestore,
 "keep": cls._keep if keep else cls._nokeep,
-"activebook": activebook or cls._noactivebook
+"activebook": activebook or cls._noactivebook,
+"shelvedinteractively": (cls._shelvedinteractively
+if shelvedinteractively else cls._notshelvedinteractively)
 }
 scmutil.simplekeyvaluefile(
 repo.vfs, cls._filename).write(info,
@@ -698,7 +704,7 @@
 """subcommand to continue an in-progress unshelve"""
 # We're finishing off a merge. First parent is our original
 # parent, second is the temporary "fake" commit we're unshelving.
-interactive = opts.get('interactive')
+interactive = state.shelvedinteractively
 with repo.lock():
 checkparents(repo, state)
 ms = merge.mergestate.read(repo)
@@ -833,7 +839,7 @@
 """Rebase restored commit from its original location to a destination"""
 # If the shelve is not immediately on top of the commit
 # we'll be merging with, rebase it to be on top.
-interactive = opts.get('interactive')
+interactive = opts.get('interactive', False)
 if tmpwctx.node() == shelvectx.p1().node() and not interactive:
 # We won't skip on interactive mode because, the user might want to
 # unshelve certain changes only.
@@ -854,7 +860,8 @@
 nodestoremove = [repo.changelog.node(rev)
  for rev in pycompat.xrange(oldtiprev, len(repo))]
 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoremove,
-  branchtorestore, opts.get('keep'), 
activebookmark)
+  branchtorestore, opts.get('keep'), 
activebookmark,
+  shelvedinteractively=interactive)
 raise error.InterventionRequired(
 _("unresolved conflicts (see 'hg resolve', then "
   "'hg unshelve --continue')"))
@@ -928,10 +935,21 @@
 if opts.get("name"):
 shelved.append(opts["name"])
 
-if abortf or continuef and not interactive:
+if len(shelved) > 1:
+raise error.Abort(_('can only unshelve one change at a time'))
+elif not shelved:
+shelved = listshelves(repo)
+if not shelved:
+raise error.Abort(_('no shelved changes to apply!'))
+basename = util.split(shelved[0][1])[1]
+if not (abortf or continuef):
+ui.status(_("unshelving change '%s'\n") % basename)
+elif shelved:
+basename = shelved[0]
+if abortf or continuef:
 if abortf and continuef:
 raise error.Abort(_('cannot use both abort and continue'))
-if shelved:
+if opts.get("name"):
 raise error.Abort(_('cannot combine