D6683: unshelve: unify logic around creating an unshelve changeset

2019-07-29 Thread navaneeth.suresh (Navaneeth Suresh)
Closed by commit rHGc9114885c14b: unshelve: unify logic around creating an 
unshelve changeset (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/D6683?vs=16078=16090

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

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

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
@@ -721,15 +721,8 @@
 with repo.ui.configoverride(overrides, 'unshelve'):
 with repo.dirstate.parentchange():
 repo.setparents(state.parents[0], nodemod.nullid)
-if not interactive:
-ispartialunshelve = False
-newnode = repo.commit(text=shelvectx.description(),
-extra=shelvectx.extra(),
-user=shelvectx.user(),
-date=shelvectx.date())
-else:
-newnode, ispartialunshelve = _dounshelveinteractive(ui,
-repo, shelvectx, basename, opts)
+newnode, ispartialunshelve = _createunshelvectx(ui,
+repo, shelvectx, basename, interactive, opts)
 
 if newnode is None:
 # If it ended up being a no-op commit, then the normal
@@ -804,14 +797,37 @@
 
 return repo, shelvectx
 
-def _dounshelveinteractive(ui, repo, shelvectx, basename, opts):
-"""The user might want to unshelve certain changes only from the stored
-shelve. So, we would create two commits. One with requested changes to
-unshelve at that time and the latter is shelved for future.
+def _createunshelvectx(ui, repo, shelvectx, basename, interactive, opts):
+"""Handles the creation of unshelve commit and updates the shelve if it
+was partially unshelved.
+
+If interactive is:
+
+  * False: Commits all the changes in the working directory.
+  * True: Prompts the user to select changes to unshelve and commit them.
+  Update the shelve with remaining changes.
+
+Returns the node of the new commit formed and a bool indicating whether
+the shelve was partially unshelved.Creates a commit ctx to unshelve
+interactively or non-interactively.
+
+The user might want to unshelve certain changes only from the stored
+shelve in interactive. So, we would create two commits. One with requested
+changes to unshelve at that time and the latter is shelved for future.
+
+Here, we return both the newnode which is created interactively and a
+bool to know whether the shelve is partly done or completely done.
 """
 opts['message'] = shelvectx.description()
 opts['interactive-unshelve'] = True
 pats = []
+if not interactive:
+newnode = repo.commit(text=shelvectx.description(),
+  extra=shelvectx.extra(),
+  user=shelvectx.user(),
+  date=shelvectx.date())
+return newnode, False
+
 commitfunc = getcommitfunc(shelvectx.extra(), interactive=True,
editor=True)
 newnode = cmdutil.dorecord(ui, repo, commitfunc, None, False,
@@ -861,15 +877,8 @@
 
 with repo.dirstate.parentchange():
 repo.setparents(tmpwctx.node(), nodemod.nullid)
-if not interactive:
-ispartialunshelve = False
-newnode = repo.commit(text=shelvectx.description(),
-  extra=shelvectx.extra(),
-  user=shelvectx.user(),
-  date=shelvectx.date())
-else:
-newnode, ispartialunshelve = _dounshelveinteractive(ui, repo,
-shelvectx, basename, opts)
+newnode, ispartialunshelve = _createunshelvectx(ui, repo,
+   shelvectx, basename, interactive, opts)
 
 if newnode is None:
 # If it ended up being a no-op commit, then the normal



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


D6683: unshelve: unify logic around creating an unshelve changeset

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6683?vs=16074=16078

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

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

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
@@ -726,15 +726,8 @@
 with repo.ui.configoverride(overrides, 'unshelve'):
 with repo.dirstate.parentchange():
 repo.setparents(state.parents[0], nodemod.nullid)
-if not interactive:
-ispartialunshelve = False
-newnode = repo.commit(text=shelvectx.description(),
-extra=shelvectx.extra(),
-user=shelvectx.user(),
-date=shelvectx.date())
-else:
-newnode, ispartialunshelve = _dounshelveinteractive(ui,
-repo, shelvectx, basename, opts)
+newnode, ispartialunshelve = _createunshelvectx(ui,
+repo, shelvectx, basename, interactive, opts)
 
 if newnode is None:
 # If it ended up being a no-op commit, then the normal
@@ -809,14 +802,37 @@
 
 return repo, shelvectx
 
-def _dounshelveinteractive(ui, repo, shelvectx, basename, opts):
-"""The user might want to unshelve certain changes only from the stored
-shelve. So, we would create two commits. One with requested changes to
-unshelve at that time and the latter is shelved for future.
+def _createunshelvectx(ui, repo, shelvectx, basename, interactive, opts):
+"""Handles the creation of unshelve commit and updates the shelve if it
+was partially unshelved.
+
+If interactive is:
+
+  * False: Commits all the changes in the working directory.
+  * True: Prompts the user to select changes to unshelve and commit them.
+  Update the shelve with remaining changes.
+
+Returns the node of the new commit formed and a bool indicating whether
+the shelve was partially unshelved.Creates a commit ctx to unshelve
+interactively or non-interactively.
+
+The user might want to unshelve certain changes only from the stored
+shelve in interactive. So, we would create two commits. One with requested
+changes to unshelve at that time and the latter is shelved for future.
+
+Here, we return both the newnode which is created interactively and a
+bool to know whether the shelve is partly done or completely done.
 """
 opts['message'] = shelvectx.description()
 opts['interactive-unshelve'] = True
 pats = []
+if not interactive:
+newnode = repo.commit(text=shelvectx.description(),
+  extra=shelvectx.extra(),
+  user=shelvectx.user(),
+  date=shelvectx.date())
+return newnode, False
+
 commitfunc = getcommitfunc(shelvectx.extra(), interactive=True,
editor=True)
 newnode = cmdutil.dorecord(ui, repo, commitfunc, None, False,
@@ -867,15 +883,8 @@
 
 with repo.dirstate.parentchange():
 repo.setparents(tmpwctx.node(), nodemod.nullid)
-if not interactive:
-ispartialunshelve = False
-newnode = repo.commit(text=shelvectx.description(),
-  extra=shelvectx.extra(),
-  user=shelvectx.user(),
-  date=shelvectx.date())
-else:
-newnode, ispartialunshelve = _dounshelveinteractive(ui, repo,
-shelvectx, basename, opts)
+newnode, ispartialunshelve = _createunshelvectx(ui, repo,
+   shelvectx, basename, interactive, opts)
 
 if newnode is None:
 # If it ended up being a no-op commit, then the normal



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


D6683: unshelve: unify logic around creating an unshelve changeset

2019-07-26 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added inline comments.

INLINE COMMENTS

> pulkit wrote in shelve.py:812
> How about:
> 
>   Handles creation of unshelve commit and updating the shelve if it was 
> partially unshelved.
>   
>   If interactive is:
>   
> * false: commit all the changes in working directory.
> * true: prompts user to select changes to unshelve and commit them. 
> Update the shelve with remaining changes.
>   
>   Returns the node of the new commit formed and a bool indicating whether the 
> shelve was partially unshelved.

Awesome! Amending that right away.

REPOSITORY
  rHG Mercurial

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

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

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


D6683: unshelve: unify logic around creating an unshelve changeset

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

INLINE COMMENTS

> shelve.py:812
> +Here, we return both the newnode which is created interactively and a
> +bool to know whether the shelve is partly done or completely done.
>  """

How about:

  Handles creation of unshelve commit and updating the shelve if it was 
partially unshelved.
  
  If interactive is:
  
* false: commit all the changes in working directory.
* true: prompts user to select changes to unshelve and commit them. Update 
the shelve with remaining changes.
  
  Returns the node of the new commit formed and a bool indicating whether the 
shelve was partially unshelved.

REPOSITORY
  rHG Mercurial

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

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

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


D6683: unshelve: unify logic around creating an unshelve changeset

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6683?vs=16038=16074

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

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

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
@@ -726,15 +726,8 @@
 with repo.ui.configoverride(overrides, 'unshelve'):
 with repo.dirstate.parentchange():
 repo.setparents(state.parents[0], nodemod.nullid)
-if not interactive:
-ispartialunshelve = False
-newnode = repo.commit(text=shelvectx.description(),
-extra=shelvectx.extra(),
-user=shelvectx.user(),
-date=shelvectx.date())
-else:
-newnode, ispartialunshelve = _dounshelveinteractive(ui,
-repo, shelvectx, basename, opts)
+newnode, ispartialunshelve = _createunshelvectx(ui,
+repo, shelvectx, basename, interactive, opts)
 
 if newnode is None:
 # If it ended up being a no-op commit, then the normal
@@ -809,14 +802,25 @@
 
 return repo, shelvectx
 
-def _dounshelveinteractive(ui, repo, shelvectx, basename, opts):
-"""The user might want to unshelve certain changes only from the stored
-shelve. So, we would create two commits. One with requested changes to
-unshelve at that time and the latter is shelved for future.
+def _createunshelvectx(ui, repo, shelvectx, basename, interactive, opts):
+"""Creates a commit ctx to unshelve interactively or non-interactively.
+The user might want to unshelve certain changes only from the stored
+shelve in interactive. So, we would create two commits. One with requested
+changes to unshelve at that time and the latter is shelved for future.
+
+Here, we return both the newnode which is created interactively and a
+bool to know whether the shelve is partly done or completely done.
 """
 opts['message'] = shelvectx.description()
 opts['interactive-unshelve'] = True
 pats = []
+if not interactive:
+newnode = repo.commit(text=shelvectx.description(),
+  extra=shelvectx.extra(),
+  user=shelvectx.user(),
+  date=shelvectx.date())
+return newnode, False
+
 commitfunc = getcommitfunc(shelvectx.extra(), interactive=True,
editor=True)
 newnode = cmdutil.dorecord(ui, repo, commitfunc, None, False,
@@ -867,15 +871,8 @@
 
 with repo.dirstate.parentchange():
 repo.setparents(tmpwctx.node(), nodemod.nullid)
-if not interactive:
-ispartialunshelve = False
-newnode = repo.commit(text=shelvectx.description(),
-  extra=shelvectx.extra(),
-  user=shelvectx.user(),
-  date=shelvectx.date())
-else:
-newnode, ispartialunshelve = _dounshelveinteractive(ui, repo,
-shelvectx, basename, opts)
+newnode, ispartialunshelve = _createunshelvectx(ui, repo,
+   shelvectx, basename, interactive, opts)
 
 if newnode is None:
 # If it ended up being a no-op commit, then the normal



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


D6683: unshelve: unify logic around creating an unshelve changeset

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


  In D6683#97731 , @pulkit wrote:
  
  > This patch does following things:
  >
  > 1. unify logic around creating unshelvectx
  > 2. changes how date is set in iteractive mode
  > 3. handles stripping in interavtive mode
  > 4. compute a matcher only if it's required
  > 5. and a change around making basename madatory argument
  >
  > Can we have them in separate patches?
  
  Done.

REPOSITORY
  rHG Mercurial

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

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

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


D6683: unshelve: unify logic around creating an unshelve changeset

2019-07-24 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh edited the summary of this revision.
navaneeth.suresh retitled this revision from "unshelve: fixes on interactive 
mode" to "unshelve: unify logic around creating an unshelve changeset".
navaneeth.suresh updated this revision to Diff 16038.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6683?vs=16025=16038

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

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

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
@@ -726,15 +726,8 @@
 with repo.ui.configoverride(overrides, 'unshelve'):
 with repo.dirstate.parentchange():
 repo.setparents(state.parents[0], nodemod.nullid)
-if not interactive:
-ispartialunshelve = False
-newnode = repo.commit(text=shelvectx.description(),
-extra=shelvectx.extra(),
-user=shelvectx.user(),
-date=shelvectx.date())
-else:
-newnode, ispartialunshelve = _dounshelveinteractive(ui,
-repo, shelvectx, basename, opts)
+newnode, ispartialunshelve = _createunshelvectx(ui,
+repo, shelvectx, basename, interactive, opts)
 
 if newnode is None:
 # If it ended up being a no-op commit, then the normal
@@ -809,14 +802,25 @@
 
 return repo, shelvectx
 
-def _dounshelveinteractive(ui, repo, shelvectx, basename, opts):
-"""The user might want to unshelve certain changes only from the stored
-shelve. So, we would create two commits. One with requested changes to
-unshelve at that time and the latter is shelved for future.
+def _createunshelvectx(ui, repo, shelvectx, basename, interactive, opts):
+"""Creates a commit ctx to unshelve interactively or non-interactively.
+The user might want to unshelve certain changes only from the stored
+shelve in interactive. So, we would create two commits. One with requested
+changes to unshelve at that time and the latter is shelved for future.
+
+Here, we return both the newnode which is created interactively and a
+bool to know whether the shelve is partly done or completely done.
 """
 opts['message'] = shelvectx.description()
 opts['interactive-unshelve'] = True
 pats = []
+if not interactive:
+newnode = repo.commit(text=shelvectx.description(),
+  extra=shelvectx.extra(),
+  user=shelvectx.user(),
+  date=shelvectx.date())
+return newnode, False
+
 commitfunc = getcommitfunc(shelvectx.extra(), interactive=True,
editor=True)
 newnode = cmdutil.dorecord(ui, repo, commitfunc, None, False,
@@ -867,15 +871,8 @@
 
 with repo.dirstate.parentchange():
 repo.setparents(tmpwctx.node(), nodemod.nullid)
-if not interactive:
-ispartialunshelve = False
-newnode = repo.commit(text=shelvectx.description(),
-  extra=shelvectx.extra(),
-  user=shelvectx.user(),
-  date=shelvectx.date())
-else:
-newnode, ispartialunshelve = _dounshelveinteractive(ui, repo,
-shelvectx, basename, opts)
+newnode, ispartialunshelve = _createunshelvectx(ui, repo,
+shelvectx, basename, interactive, 
opts)
 
 if newnode is None:
 # If it ended up being a no-op commit, then the normal



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