D6503: statecheck: added support for STATES

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15588.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6503?vs=15587=15588

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

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

AFFECTED FILES
  hgext/rebase.py
  hgext/strip.py
  hgext/transplant.py
  mercurial/cmdutil.py
  mercurial/state.py
  tests/test-graft.t
  tests/test-merge1.t
  tests/test-mq-qnew.t
  tests/test-shelve.t
  tests/test-strip.t
  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
@@ -40,6 +40,7 @@
   (branch merge, don't forget to commit)
   $ hg transplant 1
   abort: outstanding uncommitted merge
+  (use 'hg commit' or 'hg merge --abort')
   [255]
   $ hg up -qC tip
   $ echo b0 > b1
@@ -461,7 +462,7 @@
   baz
   foo
 
-test multiple revisions and --continue
+test multiple revisions, --continue and hg status --verbose
 
   $ hg up -qC 0
   $ echo bazbaz > baz
@@ -481,6 +482,15 @@
   abort: transplant in progress
   (use 'hg transplant --continue' or 'hg update' to abort)
   [255]
+  $ hg status -v
+  A bar
+  ? baz.rej
+  ? foo.rej
+  # The repository is in an unfinished *transplant* state.
+  
+  # To continue:hg transplant --continue
+  # To abort:   hg update
+  
   $ echo fixed > baz
   $ hg transplant --continue
   9d6d6b5a8275 transplanted as d80c49962290
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -275,6 +275,7 @@
 ##strip not allowed with merge in progress
   $ hg strip 4
   abort: outstanding uncommitted merge
+  (use 'hg commit' or 'hg merge --abort')
   [255]
 ##strip allowed --force with merge in progress
   $ hg strip 4 --force
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1153,7 +1153,8 @@
 -- trying to pull in the shelve bits
 -- unshelve should abort otherwise, it'll eat my second parent.
   $ hg unshelve
-  abort: cannot unshelve while merging
+  abort: outstanding uncommitted merge
+  (use 'hg commit' or 'hg merge --abort')
   [255]
 
   $ cd ..
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,7 +164,8 @@
   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: cannot manage merge changesets
+  abort: outstanding uncommitted merge
+  (use 'hg commit' or 'hg merge --abort')
   $ rm -r sandbox
 
 hg headers
@@ -243,7 +244,8 @@
   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: cannot manage merge changesets
+  abort: outstanding uncommitted merge
+  (use 'hg commit' or 'hg merge --abort')
   $ rm -r sandbox
 
 Test saving last-message.txt
diff --git a/tests/test-merge1.t b/tests/test-merge1.t
--- a/tests/test-merge1.t
+++ b/tests/test-merge1.t
@@ -44,6 +44,13 @@
   commit: 1 unknown (interrupted update)
   update: 1 new changesets (update)
   phases: 2 draft
+Detect interrupted update by hg status --verbose
+  $ hg status -v
+  ? b/nonempty
+  # The repository is in an unfinished *update* state.
+  
+  # To continue:hg update
+  
 
   $ rm b/nonempty
 
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -281,6 +281,7 @@
   
   # To continue:hg graft --continue
   # To abort:   hg graft --abort
+  # To stop:hg graft --stop
   
 
 Commit while interrupted should fail:
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=False, allowcommit=False,
- cmdmsg="", cmdhint=""):
+ cmdmsg="", cmdhint="", statushint="", stopflag=False,
+ reportonly=False):
 """opname is the name the command or operation
 fname is the file name in which data should be stored in .hg directory.
 It is None for merge command.
@@ -110,18 +111,44 @@
 cmdmsg is used to pass a different status message in case standard
 message of the format "abort: cmdname in progress" is not desired.
 cmdhint is used to pass a different hint message in case standard
-message of the format use 'hg cmdname --continue' or
-'hg cmdname --abort'" is not desired.
+message of the format "To continue: hg cmdname --continue
+To abort: hg cmdname --abort" is not desired.
+status hint is used to pass a different status message in case standard
+message of the format ('To continue:hg cmdname --continue'
+'To abort:   hg 

D6503: statecheck: added support for STATES

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

INLINE COMMENTS

> martinvonz wrote in test-graft.t:284
> What caused this change?

the `stopflag`. Since graft supports `--stop`. It should be displayed in `hg 
status --verbose` and similar should happen with any extension in future which 
supports `--stop`.

> martinvonz wrote in test-merge1.t:52
> This should use the multi-line style

there is no `hg update --abort` so I am afraid I cant add a multi line comment 
here.

REPOSITORY
  rHG Mercurial

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

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

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


D6503: statecheck: added support for STATES

2019-06-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> state.py:134
> +
> +def hint(self, status=False):
>  """returns the hint message corresponding to the command"""

This function shares no functionality between the `status=False` and 
`status=True` cases and the callers all seem to know which version they want to 
call (no dynamic switching between the two), so it would be better to have two 
separate functions.

> state.py:199
> + 'To abort:   hg merge --abort'),
> +cmdhint=_("use 'hg commit' or 'hg merge --abort'")
> +)

I think we should pass `cmdmsg='outstanding uncommitted merge'` here so we 
affect existing tests as little as possible.

> test-graft.t:284
># To abort:   hg graft --abort
> +  # To stop:hg graft --stop
>

What caused this change?

> test-merge1.t:52
> +  
> +  # use 'hg update' to get a consistent checkout
> +  

This should use the multi-line style

REPOSITORY
  rHG Mercurial

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

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

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


D6503: statecheck: added support for STATES

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 added a comment.
taapas1128 marked 3 inline comments as done.


  I forgot to add tests for hg status -v case of interrupted update. That is 
added now.

INLINE COMMENTS

> martinvonz wrote in state.py:215
> Note that I didn't suggest changing `getrepostate()` -- I said (or tried to 
> say) that I would like `checkunfinished()` and `clearunfinished()` to not 
> have handle bisect specially.

added `reportonly` flag

REPOSITORY
  rHG Mercurial

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

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

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


D6484: states: moved cmdutil.unfinishedstates to state.py

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15586.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6484?vs=15582=15586

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

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

AFFECTED FILES
  hgext/absorb.py
  hgext/fix.py
  hgext/histedit.py
  hgext/mq.py
  hgext/phabricator.py
  hgext/rebase.py
  hgext/record.py
  hgext/shelve.py
  hgext/strip.py
  hgext/transplant.py
  mercurial/cmdutil.py
  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
@@ -19,6 +19,8 @@
 
 from __future__ import absolute_import
 
+from .i18n import _
+
 from . import (
 error,
 util,
@@ -85,3 +87,44 @@
 def exists(self):
 """check whether the state file exists or not"""
 return self._repo.vfs.exists(self.fname)
+
+# A list of state files kept by multistep operations like graft.
+# Since graft cannot be aborted, it is considered 'clearable' by update.
+# note: bisect is intentionally excluded
+# (state file, clearable, allowcommit, error, hint)
+unfinishedstates = [
+('graftstate', True, False, _('graft in progress'),
+ _("use 'hg graft --continue' or 'hg graft --stop' to stop")),
+('updatestate', True, False, _('last update was interrupted'),
+ _("use 'hg update' to get a consistent checkout"))
+]
+
+def checkunfinished(repo, commit=False):
+'''Look for an unfinished multistep operation, like graft, and abort
+if found. It's probably good to check this right before
+bailifchanged().
+'''
+# Check for non-clearable states first, so things like rebase will take
+# precedence over update.
+for f, clearable, allowcommit, msg, hint in unfinishedstates:
+if clearable or (commit and allowcommit):
+continue
+if repo.vfs.exists(f):
+raise error.Abort(msg, hint=hint)
+
+for f, clearable, allowcommit, msg, hint in unfinishedstates:
+if not clearable or (commit and allowcommit):
+continue
+if repo.vfs.exists(f):
+raise error.Abort(msg, hint=hint)
+
+def clearunfinished(repo):
+'''Check for unfinished operations (as above), and clear the ones
+that are clearable.
+'''
+for f, clearable, allowcommit, msg, hint in unfinishedstates:
+if not clearable and repo.vfs.exists(f):
+raise error.Abort(msg, hint=hint)
+for f, clearable, allowcommit, msg, hint in unfinishedstates:
+if clearable and repo.vfs.exists(f):
+util.unlink(repo.vfs.join(f))
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -618,7 +618,7 @@
 if date:
 opts['date'] = dateutil.parsedate(date)
 
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 cmdutil.bailifchanged(repo)
 node = scmutil.revsingle(repo, rev).node()
 
@@ -847,7 +847,7 @@
 """common used update sequence"""
 if noupdate:
 return
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 cmdutil.bailifchanged(repo)
 return hg.clean(repo, node, show_stats=show_stats)
 
@@ -1664,7 +1664,7 @@
 # Let --subrepos on the command line override config setting.
 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
 
-cmdutil.checkunfinished(repo, commit=True)
+statemod.checkunfinished(repo, commit=True)
 
 branch = repo[None].branch()
 bheads = repo.branchheads(branch)
@@ -1699,7 +1699,7 @@
 # Note: eventually this guard will be removed. Please do not expect
 # this behavior to remain.
 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 
 node = cmdutil.amend(ui, repo, old, extra, pats, opts)
 if node == old.node():
@@ -2482,7 +2482,7 @@
 else:
 if not revs:
 raise error.Abort(_('no revisions specified'))
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 cmdutil.bailifchanged(repo)
 revs = scmutil.revrange(repo, revs)
 
@@ -3484,7 +3484,7 @@
 
 with repo.wlock():
 if update:
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 if (exact or not opts.get('force')):
 cmdutil.bailifchanged(repo)
 
@@ -6147,8 +6147,7 @@
 updatecheck = 'none'
 
 with repo.wlock():
-cmdutil.clearunfinished(repo)
-
+statemod.clearunfinished(repo)
 if date:
 rev = cmdutil.finddate(ui, repo, date)
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -42,6 +42,7 @@
 rewriteutil,
 scmutil,
 smartset,
+state as statemod,

D6503: statecheck: added support for STATES

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 edited the summary of this revision.
taapas1128 marked an inline comment as done.
taapas1128 updated this revision to Diff 15587.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6503?vs=15584=15587

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

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

AFFECTED FILES
  hgext/rebase.py
  hgext/strip.py
  hgext/transplant.py
  mercurial/cmdutil.py
  mercurial/state.py
  tests/test-graft.t
  tests/test-merge1.t
  tests/test-mq-qnew.t
  tests/test-shelve.t
  tests/test-strip.t
  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
@@ -39,7 +39,8 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg transplant 1
-  abort: outstanding uncommitted merge
+  abort: merge in progress
+  (use 'hg commit' or 'hg merge --abort')
   [255]
   $ hg up -qC tip
   $ echo b0 > b1
@@ -461,7 +462,7 @@
   baz
   foo
 
-test multiple revisions and --continue
+test multiple revisions, --continue and hg status --verbose
 
   $ hg up -qC 0
   $ echo bazbaz > baz
@@ -481,6 +482,15 @@
   abort: transplant in progress
   (use 'hg transplant --continue' or 'hg update' to abort)
   [255]
+  $ hg status -v
+  A bar
+  ? baz.rej
+  ? foo.rej
+  # The repository is in an unfinished *transplant* state.
+  
+  # To continue:hg transplant --continue
+  # To abort:   hg update
+  
   $ echo fixed > baz
   $ hg transplant --continue
   9d6d6b5a8275 transplanted as d80c49962290
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -274,7 +274,8 @@
   
 ##strip not allowed with merge in progress
   $ hg strip 4
-  abort: outstanding uncommitted merge
+  abort: merge in progress
+  (use 'hg commit' or 'hg merge --abort')
   [255]
 ##strip allowed --force with merge in progress
   $ hg strip 4 --force
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1153,7 +1153,8 @@
 -- trying to pull in the shelve bits
 -- unshelve should abort otherwise, it'll eat my second parent.
   $ hg unshelve
-  abort: cannot unshelve while merging
+  abort: merge in progress
+  (use 'hg commit' or 'hg merge --abort')
   [255]
 
   $ cd ..
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,7 +164,8 @@
   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: cannot manage merge changesets
+  abort: merge in progress
+  (use 'hg commit' or 'hg merge --abort')
   $ rm -r sandbox
 
 hg headers
@@ -243,7 +244,8 @@
   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: cannot manage merge changesets
+  abort: merge in progress
+  (use 'hg commit' or 'hg merge --abort')
   $ rm -r sandbox
 
 Test saving last-message.txt
diff --git a/tests/test-merge1.t b/tests/test-merge1.t
--- a/tests/test-merge1.t
+++ b/tests/test-merge1.t
@@ -44,6 +44,13 @@
   commit: 1 unknown (interrupted update)
   update: 1 new changesets (update)
   phases: 2 draft
+Detect interrupted update by hg status --verbose
+  $ hg status -v
+  ? b/nonempty
+  # The repository is in an unfinished *update* state.
+  
+  # use 'hg update' to get a consistent checkout
+  
 
   $ rm b/nonempty
 
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -281,6 +281,7 @@
   
   # To continue:hg graft --continue
   # To abort:   hg graft --abort
+  # To stop:hg graft --stop
   
 
 Commit while interrupted should fail:
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=False, allowcommit=False,
- cmdmsg="", cmdhint=""):
+ cmdmsg="", cmdhint="", statushint="", stopflag=False,
+ reportonly=False):
 """opname is the name the command or operation
 fname is the file name in which data should be stored in .hg directory.
 It is None for merge command.
@@ -110,22 +111,43 @@
 cmdmsg is used to pass a different status message in case standard
 message of the format "abort: cmdname in progress" is not desired.
 cmdhint is used to pass a different hint message in case standard
-message of the format use 'hg cmdname --continue' or
-'hg cmdname --abort'" is not desired.
+message of the format "To continue: hg cmdname --continue
+To abort: hg cmdname 

D6484: states: moved cmdutil.unfinishedstates to state.py

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15582.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6484?vs=15569=15582

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

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

AFFECTED FILES
  hgext/absorb.py
  hgext/fix.py
  hgext/histedit.py
  hgext/phabricator.py
  hgext/rebase.py
  hgext/record.py
  hgext/shelve.py
  hgext/strip.py
  hgext/transplant.py
  mercurial/cmdutil.py
  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
@@ -19,6 +19,8 @@
 
 from __future__ import absolute_import
 
+from .i18n import _
+
 from . import (
 error,
 util,
@@ -85,3 +87,44 @@
 def exists(self):
 """check whether the state file exists or not"""
 return self._repo.vfs.exists(self.fname)
+
+# A list of state files kept by multistep operations like graft.
+# Since graft cannot be aborted, it is considered 'clearable' by update.
+# note: bisect is intentionally excluded
+# (state file, clearable, allowcommit, error, hint)
+unfinishedstates = [
+('graftstate', True, False, _('graft in progress'),
+ _("use 'hg graft --continue' or 'hg graft --stop' to stop")),
+('updatestate', True, False, _('last update was interrupted'),
+ _("use 'hg update' to get a consistent checkout"))
+]
+
+def checkunfinished(repo, commit=False):
+'''Look for an unfinished multistep operation, like graft, and abort
+if found. It's probably good to check this right before
+bailifchanged().
+'''
+# Check for non-clearable states first, so things like rebase will take
+# precedence over update.
+for f, clearable, allowcommit, msg, hint in unfinishedstates:
+if clearable or (commit and allowcommit):
+continue
+if repo.vfs.exists(f):
+raise error.Abort(msg, hint=hint)
+
+for f, clearable, allowcommit, msg, hint in unfinishedstates:
+if not clearable or (commit and allowcommit):
+continue
+if repo.vfs.exists(f):
+raise error.Abort(msg, hint=hint)
+
+def clearunfinished(repo):
+'''Check for unfinished operations (as above), and clear the ones
+that are clearable.
+'''
+for f, clearable, allowcommit, msg, hint in unfinishedstates:
+if not clearable and repo.vfs.exists(f):
+raise error.Abort(msg, hint=hint)
+for f, clearable, allowcommit, msg, hint in unfinishedstates:
+if clearable and repo.vfs.exists(f):
+util.unlink(repo.vfs.join(f))
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -618,7 +618,7 @@
 if date:
 opts['date'] = dateutil.parsedate(date)
 
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 cmdutil.bailifchanged(repo)
 node = scmutil.revsingle(repo, rev).node()
 
@@ -847,7 +847,7 @@
 """common used update sequence"""
 if noupdate:
 return
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 cmdutil.bailifchanged(repo)
 return hg.clean(repo, node, show_stats=show_stats)
 
@@ -1664,7 +1664,7 @@
 # Let --subrepos on the command line override config setting.
 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
 
-cmdutil.checkunfinished(repo, commit=True)
+statemod.checkunfinished(repo, commit=True)
 
 branch = repo[None].branch()
 bheads = repo.branchheads(branch)
@@ -1699,7 +1699,7 @@
 # Note: eventually this guard will be removed. Please do not expect
 # this behavior to remain.
 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 
 node = cmdutil.amend(ui, repo, old, extra, pats, opts)
 if node == old.node():
@@ -2482,7 +2482,7 @@
 else:
 if not revs:
 raise error.Abort(_('no revisions specified'))
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 cmdutil.bailifchanged(repo)
 revs = scmutil.revrange(repo, revs)
 
@@ -3484,7 +3484,7 @@
 
 with repo.wlock():
 if update:
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 if (exact or not opts.get('force')):
 cmdutil.bailifchanged(repo)
 
@@ -6147,8 +6147,7 @@
 updatecheck = 'none'
 
 with repo.wlock():
-cmdutil.clearunfinished(repo)
-
+statemod.clearunfinished(repo)
 if date:
 rev = cmdutil.finddate(ui, repo, date)
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -42,6 +42,7 @@
 rewriteutil,
 scmutil,
 smartset,
+state as statemod,
 subrepoutil,

D6503: statecheck: added support for STATES

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15584.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6503?vs=15581=15584

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

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

AFFECTED FILES
  hgext/rebase.py
  hgext/strip.py
  mercurial/cmdutil.py
  mercurial/state.py
  tests/test-graft.t
  tests/test-histedit-fold.t
  tests/test-rebase-conflicts.t
  tests/test-shelve.t
  tests/test-strip.t
  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
@@ -39,7 +39,9 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg transplant 1
-  abort: outstanding uncommitted merge
+  abort: merge in progress
+  (To continue:hg commit
+  To abort:   hg merge --abort)
   [255]
   $ hg up -qC tip
   $ echo b0 > b1
@@ -461,7 +463,7 @@
   baz
   foo
 
-test multiple revisions and --continue
+test multiple revisions, --continue and hg status --verbose
 
   $ hg up -qC 0
   $ echo bazbaz > baz
@@ -481,6 +483,14 @@
   abort: transplant in progress
   (use 'hg transplant --continue' or 'hg update' to abort)
   [255]
+  $ hg status -v
+  A bar
+  ? baz.rej
+  ? foo.rej
+  # The repository is in an unfinished *transplant* state.
+  
+  # use 'hg transplant --continue' or 'hg update' to abort
+  
   $ echo fixed > baz
   $ hg transplant --continue
   9d6d6b5a8275 transplanted as d80c49962290
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -274,7 +274,9 @@
   
 ##strip not allowed with merge in progress
   $ hg strip 4
-  abort: outstanding uncommitted merge
+  abort: merge in progress
+  (To continue:hg commit
+  To abort:   hg merge --abort)
   [255]
 ##strip allowed --force with merge in progress
   $ hg strip 4 --force
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -375,8 +375,7 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg unshelve --continue
-  # To abort:   hg unshelve --abort
+  # use 'hg unshelve --continue' or 'hg unshelve --abort'
   
 
 ensure that we have a merge with unresolved conflicts
@@ -1153,7 +1152,9 @@
 -- trying to pull in the shelve bits
 -- unshelve should abort otherwise, it'll eat my second parent.
   $ hg unshelve
-  abort: cannot unshelve while merging
+  abort: merge in progress
+  (To continue:hg commit
+  To abort:   hg merge --abort)
   [255]
 
   $ cd ..
diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -80,8 +80,7 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg rebase --continue
-  # To abort:   hg rebase --abort
+  # use 'hg rebase --continue' or 'hg rebase --abort'
   
 
 Try to continue without solving the conflict:
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -306,8 +306,7 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg histedit --continue
-  # To abort:   hg histedit --abort
+  # use 'hg histedit --continue' or 'hg histedit --abort'
   
   $ hg resolve -l
   U file
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -279,8 +279,7 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg graft --continue
-  # To abort:   hg graft --abort
+  # use 'hg graft --continue' or 'hg graft --stop' to stop
   
 
 Commit while interrupted should fail:
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -134,8 +134,13 @@
 return self._cmdmsg
 
 def isunfinished(self, repo):
-"""determines whether a multi-step operation is in progress or not"""
-return repo.vfs.exists(self._fname)
+"""determines whether a multi-step operation is in progress
+or not
+"""
+if self._opname == 'merge':
+return len(repo[None].parents()) > 1
+else:
+return repo.vfs.exists(self._fname)
 
 # A list of statecheck objects for multistep operations like graft.
 _unfinishedstates = []
@@ -144,7 +149,10 @@
 """this registers a new command or operation to unfinishedstates
 """
 statecheckobj = _statecheck(opname, **kwargs)
-_unfinishedstates.append(statecheckobj)
+if opname == 'merge' or opname == 'bisect':
+_unfinishedstates.append(statecheckobj)
+else:
+_unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
 'graft', fname='graftstate', clearable=True,
@@ -155,8 +163,19 @@
 cmdmsg=_('last 

D6504: statecheck: fix for hint message format

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15585.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6504?vs=15571=15585

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

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

AFFECTED FILES
  hgext/transplant.py
  mercurial/state.py
  tests/test-graft.t
  tests/test-histedit-fold.t
  tests/test-rebase-conflicts.t
  tests/test-shelve.t
  tests/test-strip.t
  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
@@ -40,8 +40,7 @@
   (branch merge, don't forget to commit)
   $ hg transplant 1
   abort: merge in progress
-  (To continue:hg commit
-  To abort:   hg merge --abort)
+  (use 'hg commit' or 'hg merge --abort')
   [255]
   $ hg up -qC tip
   $ echo b0 > b1
@@ -489,7 +488,8 @@
   ? foo.rej
   # The repository is in an unfinished *transplant* state.
   
-  # use 'hg transplant --continue' or 'hg update' to abort
+  # To continue:hg transplant --continue
+  # To abort:   hg update
   
   $ echo fixed > baz
   $ hg transplant --continue
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -275,8 +275,7 @@
 ##strip not allowed with merge in progress
   $ hg strip 4
   abort: merge in progress
-  (To continue:hg commit
-  To abort:   hg merge --abort)
+  (use 'hg commit' or 'hg merge --abort')
   [255]
 ##strip allowed --force with merge in progress
   $ hg strip 4 --force
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -375,7 +375,8 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg unshelve --continue' or 'hg unshelve --abort'
+  # To continue:hg unshelve --continue
+  # To abort:   hg unshelve --abort
   
 
 ensure that we have a merge with unresolved conflicts
@@ -1153,8 +1154,7 @@
 -- unshelve should abort otherwise, it'll eat my second parent.
   $ hg unshelve
   abort: merge in progress
-  (To continue:hg commit
-  To abort:   hg merge --abort)
+  (use 'hg commit' or 'hg merge --abort')
   [255]
 
   $ cd ..
diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -80,7 +80,8 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg rebase --continue' or 'hg rebase --abort'
+  # To continue:hg rebase --continue
+  # To abort:   hg rebase --abort
   
 
 Try to continue without solving the conflict:
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -306,7 +306,8 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg histedit --continue' or 'hg histedit --abort'
+  # To continue:hg histedit --continue
+  # To abort:   hg histedit --abort
   
   $ hg resolve -l
   U file
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -279,7 +279,9 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg graft --continue' or 'hg graft --stop' to stop
+  # To continue:hg graft --continue
+  # To abort:   hg graft --abort
+  # To stop:hg graft --stop
   
 
 Commit while interrupted should fail:
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -98,7 +98,7 @@
 """
 
 def __init__(self, opname, fname, clearable=False, allowcommit=False,
- cmdmsg="", cmdhint=""):
+ cmdmsg="", cmdhint="", statushint="", stopflag=False):
 """opname is the name the command or operation
 fname is the file name in which data should be stored in .hg directory.
 It is None for merge command.
@@ -110,22 +110,40 @@
 cmdmsg is used to pass a different status message in case standard
 message of the format "abort: cmdname in progress" is not desired.
 cmdhint is used to pass a different hint message in case standard
-message of the format use 'hg cmdname --continue' or
-'hg cmdname --abort'" is not desired.
+message of the format "To continue: hg cmdname --continue
+To abort: hg cmdname --abort" is not desired.
+status hint 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
+stopflag is a boolean that determines whether or not a command supports
+--stop flag
 """
 self._opname = opname
 self._fname = fname
 self._clearable = clearable
 self._allowcommit = allowcommit
 self._cmdhint = cmdhint
+self._statushint = statushint

D6502: state: moved cmdutil.STATES and utilities to state.py

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15583.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6502?vs=15579=15583

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/state.py

CHANGE DETAILS

diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -186,3 +186,64 @@
 for s in _unfinishedstates:
 if s._clearable and s.isunfinished(repo):
 util.unlink(repo.vfs.join(s._fname))
+
+def _commentlines(raw):
+'''Surround lineswith a comment char and a new line'''
+lines = raw.splitlines()
+commentedlines = ['# %s' % line for line in lines]
+return '\n'.join(commentedlines) + '\n'
+
+def _helpmessage(continuecmd, abortcmd):
+msg = _('To continue:%s\n'
+'To abort:   %s') % (continuecmd, abortcmd)
+return _commentlines(msg)
+
+def _rebasemsg():
+return _helpmessage('hg rebase --continue', 'hg rebase --abort')
+
+def _histeditmsg():
+return _helpmessage('hg histedit --continue', 'hg histedit --abort')
+
+def _unshelvemsg():
+return _helpmessage('hg unshelve --continue', 'hg unshelve --abort')
+
+def _graftmsg():
+return _helpmessage('hg graft --continue', 'hg graft --abort')
+
+def _mergemsg():
+return _helpmessage('hg commit', 'hg merge --abort')
+
+def _bisectmsg():
+msg = _('To mark the changeset good:hg bisect --good\n'
+'To mark the changeset bad: hg bisect --bad\n'
+'To abort:  hg bisect --reset\n')
+return _commentlines(msg)
+
+def fileexistspredicate(filename):
+return lambda repo: repo.vfs.exists(filename)
+
+def _mergepredicate(repo):
+return len(repo[None].parents()) > 1
+
+STATES = (
+# (state, predicate to detect states, helpful message function)
+('histedit', fileexistspredicate('histedit-state'), _histeditmsg),
+('bisect', fileexistspredicate('bisect.state'), _bisectmsg),
+('graft', fileexistspredicate('graftstate'), _graftmsg),
+('unshelve', fileexistspredicate('shelvedstate'), _unshelvemsg),
+('rebase', fileexistspredicate('rebasestate'), _rebasemsg),
+# The merge state is part of a list that will be iterated over.
+# They need to be last because some of the other unfinished states may also
+# be in a merge or update state (eg. rebase, histedit, graft, etc).
+# We want those to have priority.
+('merge', _mergepredicate, _mergemsg),
+)
+
+def getrepostate(repo):
+# experimental config: commands.status.skipstates
+skip = set(repo.ui.configlist('commands', 'status.skipstates'))
+for state, statedetectionpredicate, msgfn in STATES:
+if state in skip:
+continue
+if statedetectionpredicate(repo):
+return (state, statedetectionpredicate, msgfn)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -619,63 +619,8 @@
 
 return _commentlines(msg)
 
-def _helpmessage(continuecmd, abortcmd):
-msg = _('To continue:%s\n'
-'To abort:   %s') % (continuecmd, abortcmd)
-return _commentlines(msg)
-
-def _rebasemsg():
-return _helpmessage('hg rebase --continue', 'hg rebase --abort')
-
-def _histeditmsg():
-return _helpmessage('hg histedit --continue', 'hg histedit --abort')
-
-def _unshelvemsg():
-return _helpmessage('hg unshelve --continue', 'hg unshelve --abort')
-
-def _graftmsg():
-return _helpmessage('hg graft --continue', 'hg graft --abort')
-
-def _mergemsg():
-return _helpmessage('hg commit', 'hg merge --abort')
-
-def _bisectmsg():
-msg = _('To mark the changeset good:hg bisect --good\n'
-'To mark the changeset bad: hg bisect --bad\n'
-'To abort:  hg bisect --reset\n')
-return _commentlines(msg)
-
-def fileexistspredicate(filename):
-return lambda repo: repo.vfs.exists(filename)
-
-def _mergepredicate(repo):
-return len(repo[None].parents()) > 1
-
-STATES = (
-# (state, predicate to detect states, helpful message function)
-('histedit', fileexistspredicate('histedit-state'), _histeditmsg),
-('bisect', fileexistspredicate('bisect.state'), _bisectmsg),
-('graft', fileexistspredicate('graftstate'), _graftmsg),
-('unshelve', fileexistspredicate('shelvedstate'), _unshelvemsg),
-('rebase', fileexistspredicate('rebasestate'), _rebasemsg),
-# The merge state is part of a list that will be iterated over.
-# They need to be last because some of the other unfinished states may also
-# be in a merge or update state (eg. rebase, histedit, graft, etc).
-# We want those to have priority.
-('merge', _mergepredicate, _mergemsg),
-)
-
-def _getrepostate(repo):
-# experimental config: commands.status.skipstates
-skip = 

D6503: statecheck: added support for STATES

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6503?vs=15565=15581

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

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

AFFECTED FILES
  hgext/rebase.py
  hgext/strip.py
  mercurial/cmdutil.py
  mercurial/state.py
  tests/test-graft.t
  tests/test-histedit-fold.t
  tests/test-rebase-conflicts.t
  tests/test-shelve.t
  tests/test-strip.t
  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
@@ -39,7 +39,9 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg transplant 1
-  abort: outstanding uncommitted merge
+  abort: merge in progress
+  (To continue:hg commit
+  To abort:   hg merge --abort)
   [255]
   $ hg up -qC tip
   $ echo b0 > b1
@@ -461,7 +463,7 @@
   baz
   foo
 
-test multiple revisions and --continue
+test multiple revisions, --continue and hg status --verbose
 
   $ hg up -qC 0
   $ echo bazbaz > baz
@@ -481,6 +483,14 @@
   abort: transplant in progress
   (use 'hg transplant --continue' or 'hg update' to abort)
   [255]
+  $ hg status -v
+  A bar
+  ? baz.rej
+  ? foo.rej
+  # The repository is in an unfinished *transplant* state.
+  
+  # use 'hg transplant --continue' or 'hg update' to abort
+  
   $ echo fixed > baz
   $ hg transplant --continue
   9d6d6b5a8275 transplanted as d80c49962290
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -274,7 +274,9 @@
   
 ##strip not allowed with merge in progress
   $ hg strip 4
-  abort: outstanding uncommitted merge
+  abort: merge in progress
+  (To continue:hg commit
+  To abort:   hg merge --abort)
   [255]
 ##strip allowed --force with merge in progress
   $ hg strip 4 --force
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -375,8 +375,7 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg unshelve --continue
-  # To abort:   hg unshelve --abort
+  # use 'hg unshelve --continue' or 'hg unshelve --abort'
   
 
 ensure that we have a merge with unresolved conflicts
@@ -1153,7 +1152,9 @@
 -- trying to pull in the shelve bits
 -- unshelve should abort otherwise, it'll eat my second parent.
   $ hg unshelve
-  abort: cannot unshelve while merging
+  abort: merge in progress
+  (To continue:hg commit
+  To abort:   hg merge --abort)
   [255]
 
   $ cd ..
diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -80,8 +80,7 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg rebase --continue
-  # To abort:   hg rebase --abort
+  # use 'hg rebase --continue' or 'hg rebase --abort'
   
 
 Try to continue without solving the conflict:
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -306,8 +306,7 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg histedit --continue
-  # To abort:   hg histedit --abort
+  # use 'hg histedit --continue' or 'hg histedit --abort'
   
   $ hg resolve -l
   U file
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -279,8 +279,7 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg graft --continue
-  # To abort:   hg graft --abort
+  # use 'hg graft --continue' or 'hg graft --stop' to stop
   
 
 Commit while interrupted should fail:
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -134,8 +134,13 @@
 return self._cmdmsg
 
 def isunfinished(self, repo):
-"""determines whether a multi-step operation is in progress or not"""
-return repo.vfs.exists(self._fname)
+"""determines whether a multi-step operation is in progress
+or not
+"""
+if self._opname == 'merge':
+return len(repo[None].parents()) > 1
+else:
+return repo.vfs.exists(self._fname)
 
 # A list of statecheck objects for multistep operations like graft.
 _unfinishedstates = []
@@ -144,7 +149,10 @@
 """this registers a new command or operation to unfinishedstates
 """
 statecheckobj = _statecheck(opname, **kwargs)
-_unfinishedstates.append(statecheckobj)
+if opname == 'merge' or opname == 'bisect':
+_unfinishedstates.append(statecheckobj)
+else:
+_unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
 'graft', fname='graftstate', 

D6503: statecheck: added support for STATES

2019-06-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> taapas1128 wrote in state.py:215
> the special handling is given so that `checkunfinished()` and 
> `clearunfinished()` bypass `bisect` completely.(see line 93 D6501 
>  the comment above unfinishedstates)  
> And reportonly flag is not required because for `morestatus`  uses 
> `getrepostate()` which is itself a report only feature.

Note that I didn't suggest changing `getrepostate()` -- I said (or tried to 
say) that I would like `checkunfinished()` and `clearunfinished()` to not have 
handle bisect specially.

> taapas1128 wrote in test-graft.t:282
> that is done in D6504 . Do you want me 
> to fold that here?

I thought we had agreed (at least Pulkit seemed to agree with me) to add a 
third argument for the multi-line message for verbose status. That should mean 
that no tests would need to change.

REPOSITORY
  rHG Mercurial

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

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

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


D6503: statecheck: added support for STATES

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 added inline comments.
taapas1128 marked 3 inline comments as done.

INLINE COMMENTS

> martinvonz wrote in state.py:215
> I can see that `getrepostate()` is unchanged, but I cannot see that 
> `checkunfinished()` is unchanged (line 187 includes `'bisect'` in the version 
> I'm looking at). `clearunfinished()` also seems to handle bisect specially. I 
> still think my suggested `reportonly` flag is the best option we have.

the special handling is given so that `checkunfinished()` and 
`clearunfinished()` bypass `bisect` completely.(see line 93 D6501 
 the comment above unfinishedstates)  And 
reportonly flag is not required because for `morestatus`  uses `getrepostate()` 
which is itself a report only feature.

> martinvonz wrote in test-graft.t:282
> This should use the multi-line style

that is done in D6504 . Do you want me to 
fold that here?

REPOSITORY
  rHG Mercurial

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

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

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


D6540: relnotes: document template support for `hg root`

2019-06-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -3,6 +3,9 @@
  * New config `commands.commit.post-status` shows status after successful
  commit.
 
+ * `hg root` now has templating support, including support for showing
+   where a repo share's source is. See `hg help -v root` for details.
+
 
 == New Experimental Features ==
 



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


D6490: commit: add --force flag to close branch from a non-head changeset

2019-06-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  Could you also update relnotes/next (documenting either the new flag or 
config option, whatever this patch ends up doing)?

REPOSITORY
  rHG Mercurial

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

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

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


D6501: state: created new class statecheck to handle unfinishedstates

2019-06-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  At some point in this series (probably as a separate patch at the end), you 
should update relnotes/next to describe the API change and how to register 
stateful operations

REPOSITORY
  rHG Mercurial

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

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

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


D6502: state: moved cmdutil.STATES and utilities to state.py

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6502?vs=15552=15579

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/state.py

CHANGE DETAILS

diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -186,3 +186,64 @@
 for s in _unfinishedstates:
 if s._clearable and s.isunfinished(repo):
 util.unlink(repo.vfs.join(s._fname))
+
+def _commentlines(raw):
+'''Surround lineswith a comment char and a new line'''
+lines = raw.splitlines()
+commentedlines = ['# %s' % line for line in lines]
+return '\n'.join(commentedlines) + '\n'
+
+def _helpmessage(continuecmd, abortcmd):
+msg = _('To continue:%s\n'
+'To abort:   %s') % (continuecmd, abortcmd)
+return _commentlines(msg)
+
+def _rebasemsg():
+return _helpmessage('hg rebase --continue', 'hg rebase --abort')
+
+def _histeditmsg():
+return _helpmessage('hg histedit --continue', 'hg histedit --abort')
+
+def _unshelvemsg():
+return _helpmessage('hg unshelve --continue', 'hg unshelve --abort')
+
+def _graftmsg():
+return _helpmessage('hg graft --continue', 'hg graft --abort')
+
+def _mergemsg():
+return _helpmessage('hg commit', 'hg merge --abort')
+
+def _bisectmsg():
+msg = _('To mark the changeset good:hg bisect --good\n'
+'To mark the changeset bad: hg bisect --bad\n'
+'To abort:  hg bisect --reset\n')
+return _commentlines(msg)
+
+def fileexistspredicate(filename):
+return lambda repo: repo.vfs.exists(filename)
+
+def _mergepredicate(repo):
+return len(repo[None].parents()) > 1
+
+STATES = (
+# (state, predicate to detect states, helpful message function)
+('histedit', fileexistspredicate('histedit-state'), _histeditmsg),
+('bisect', fileexistspredicate('bisect.state'), _bisectmsg),
+('graft', fileexistspredicate('graftstate'), _graftmsg),
+('unshelve', fileexistspredicate('shelvedstate'), _unshelvemsg),
+('rebase', fileexistspredicate('rebasestate'), _rebasemsg),
+# The merge state is part of a list that will be iterated over.
+# They need to be last because some of the other unfinished states may also
+# be in a merge or update state (eg. rebase, histedit, graft, etc).
+# We want those to have priority.
+('merge', _mergepredicate, _mergemsg),
+)
+
+def getrepostate(repo):
+# experimental config: commands.status.skipstates
+skip = set(repo.ui.configlist('commands', 'status.skipstates'))
+for state, statedetectionpredicate, msgfn in STATES:
+if state in skip:
+continue
+if statedetectionpredicate(repo):
+return (state, statedetectionpredicate, msgfn)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -619,63 +619,8 @@
 
 return _commentlines(msg)
 
-def _helpmessage(continuecmd, abortcmd):
-msg = _('To continue:%s\n'
-'To abort:   %s') % (continuecmd, abortcmd)
-return _commentlines(msg)
-
-def _rebasemsg():
-return _helpmessage('hg rebase --continue', 'hg rebase --abort')
-
-def _histeditmsg():
-return _helpmessage('hg histedit --continue', 'hg histedit --abort')
-
-def _unshelvemsg():
-return _helpmessage('hg unshelve --continue', 'hg unshelve --abort')
-
-def _graftmsg():
-return _helpmessage('hg graft --continue', 'hg graft --abort')
-
-def _mergemsg():
-return _helpmessage('hg commit', 'hg merge --abort')
-
-def _bisectmsg():
-msg = _('To mark the changeset good:hg bisect --good\n'
-'To mark the changeset bad: hg bisect --bad\n'
-'To abort:  hg bisect --reset\n')
-return _commentlines(msg)
-
-def fileexistspredicate(filename):
-return lambda repo: repo.vfs.exists(filename)
-
-def _mergepredicate(repo):
-return len(repo[None].parents()) > 1
-
-STATES = (
-# (state, predicate to detect states, helpful message function)
-('histedit', fileexistspredicate('histedit-state'), _histeditmsg),
-('bisect', fileexistspredicate('bisect.state'), _bisectmsg),
-('graft', fileexistspredicate('graftstate'), _graftmsg),
-('unshelve', fileexistspredicate('shelvedstate'), _unshelvemsg),
-('rebase', fileexistspredicate('rebasestate'), _rebasemsg),
-# The merge state is part of a list that will be iterated over.
-# They need to be last because some of the other unfinished states may also
-# be in a merge or update state (eg. rebase, histedit, graft, etc).
-# We want those to have priority.
-('merge', _mergepredicate, _mergemsg),
-)
-
-def _getrepostate(repo):
-# experimental config: 

D6503: statecheck: added support for STATES

2019-06-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> strip.py:49-61
>  def checklocalchanges(repo, force=False, excsuffix=''):
> -statemod.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))
> +statemod.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))

I moved this code very recently, so this needs to be rebased.

> strip.py:60
> +else:
> +statemod.checkunfinished(repo ,mergeskip=True)
>  return s

Move comma one step left

> pulkit wrote in state.py:154
> Because we can have a unresolved bisect state and unresolved 
> rebase/histedit/evolve/graft or even merge state at the same time.

But what fails if we don't have it here? No tests fail.

> taapas1128 wrote in state.py:215
> because the hard-coded values were removed. And regarding bisect as you can 
> see nothing has been changed it is not handled by `checkunfinished()` and 
> `getrpostate` remains unchanged too.

I can see that `getrepostate()` is unchanged, but I cannot see that 
`checkunfinished()` is unchanged (line 187 includes `'bisect'` in the version 
I'm looking at). `clearunfinished()` also seems to handle bisect specially. I 
still think my suggested `reportonly` flag is the best option we have.

> test-graft.t:282
>
> -  # To continue:hg graft --continue
> -  # To abort:   hg graft --abort
> +  # use 'hg graft --continue' or 'hg graft --stop' to stop
>

This should use the multi-line style

> test-histedit-fold.t:309
>
> -  # To continue:hg histedit --continue
> -  # To abort:   hg histedit --abort
> +  # use 'hg histedit --continue' or 'hg histedit --abort'
>

This should use the multi-line style

> test-rebase-conflicts.t:83
>
> -  # To continue:hg rebase --continue
> -  # To abort:   hg rebase --abort
> +  # use 'hg rebase --continue' or 'hg rebase --abort'
>

This should use the multi-line style

> test-shelve.t:378
>
> -  # To continue:hg unshelve --continue
> -  # To abort:   hg unshelve --abort
> +  # use 'hg unshelve --continue' or 'hg unshelve --abort'
>

This should use the multi-line style

> test-shelve.t:1156-1157
> +  abort: merge in progress
> +  (To continue:hg commit
> +  To abort:   hg merge --abort)
>[255]

This should use the single-line style like our other hints

> test-strip.t:278-279
> +  abort: merge in progress
> +  (To continue:hg commit
> +  To abort:   hg merge --abort)
>[255]

This should use the single-line style

> test-transplant.t:43-44
> +  abort: merge in progress
> +  (To continue:hg commit
> +  To abort:   hg merge --abort)
>[255]

This should use the single-line style

> test-transplant.t:492
> +  
> +  # use 'hg transplant --continue' or 'hg update' to abort
> +  

This should use the multi-line style

REPOSITORY
  rHG Mercurial

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

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

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


D6539: remotefilelog: tell runbgcommand to not block on child process startup

2019-06-18 Thread durin42 (Augie Fackler)
Closed by commit rHGdf1419c5756a: remotefilelog: tell runbgcommand to not block 
on child process startup (authored by durin42).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6539?vs=15574=15578

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

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

AFFECTED FILES
  hgext/remotefilelog/repack.py
  hgext/remotefilelog/shallowrepo.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/shallowrepo.py 
b/hgext/remotefilelog/shallowrepo.py
--- a/hgext/remotefilelog/shallowrepo.py
+++ b/hgext/remotefilelog/shallowrepo.py
@@ -190,7 +190,9 @@
 cmd.append('--repack')
 if revs:
 cmd += ['-r', revs]
-procutil.runbgcommand(cmd, encoding.environ)
+# We know this command will find a binary, so don't block
+# on it starting.
+procutil.runbgcommand(cmd, encoding.environ, ensurestart=False)
 
 def prefetch(self, revs, base=None, pats=None, opts=None):
 """Prefetches all the necessary file revisions for the given revs
diff --git a/hgext/remotefilelog/repack.py b/hgext/remotefilelog/repack.py
--- a/hgext/remotefilelog/repack.py
+++ b/hgext/remotefilelog/repack.py
@@ -43,7 +43,8 @@
 if packsonly:
 cmd.append('--packsonly')
 repo.ui.warn(msg)
-procutil.runbgcommand(cmd, encoding.environ)
+# We know this command will find a binary, so don't block on it starting.
+procutil.runbgcommand(cmd, encoding.environ, ensurestart=False)
 
 def fullrepack(repo, options=None):
 """If ``packsonly`` is True, stores creating only loose objects are 
skipped.



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


D6537: procutil: allow callers of runbgcommand to assume the process starts

2019-06-18 Thread durin42 (Augie Fackler)
Closed by commit rHGca1014ad3de4: procutil: allow callers of runbgcommand to 
assume the process starts (authored by durin42).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6537?vs=15575=15577

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

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

AFFECTED FILES
  mercurial/utils/procutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -470,7 +470,8 @@
 # See https://phab.mercurial-scm.org/D1701 for discussion
 _creationflags = DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP
 
-def runbgcommand(script, env, shell=False, stdout=None, stderr=None):
+def runbgcommand(
+  script, env, shell=False, stdout=None, stderr=None, ensurestart=True):
 '''Spawn a command without waiting for it to finish.'''
 # we can't use close_fds *and* redirect stdin. I'm not sure that we
 # need to because the detached process has no console connection.
@@ -480,12 +481,15 @@
 creationflags=_creationflags, stdout=stdout,
 stderr=stderr)
 else:
-def runbgcommand(cmd, env, shell=False, stdout=None, stderr=None):
+def runbgcommand(
+  cmd, env, shell=False, stdout=None, stderr=None, ensurestart=True):
 '''Spawn a command without waiting for it to finish.'''
 # double-fork to completely detach from the parent process
 # based on http://code.activestate.com/recipes/278731
 pid = os.fork()
 if pid:
+if not ensurestart:
+return
 # Parent process
 (_pid, status) = os.waitpid(pid, 0)
 if os.WIFEXITED(status):



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


D6538: shallowrepo: remove backwards compat code that predates in-tree remotefilelog

2019-06-18 Thread durin42 (Augie Fackler)
Closed by commit rHG373aeede7352: shallowrepo: remove backwards compat code 
that predates in-tree remotefilelog (authored by durin42).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6538?vs=15573=15576

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

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

AFFECTED FILES
  hgext/remotefilelog/shallowrepo.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/shallowrepo.py 
b/hgext/remotefilelog/shallowrepo.py
--- a/hgext/remotefilelog/shallowrepo.py
+++ b/hgext/remotefilelog/shallowrepo.py
@@ -33,13 +33,6 @@
 shallowutil,
 )
 
-if util.safehasattr(util, '_hgexecutable'):
-# Before 5be286db
-_hgexecutable = util.hgexecutable
-else:
-from mercurial.utils import procutil
-_hgexecutable = procutil.hgexecutable
-
 # These make*stores functions are global so that other extensions can replace
 # them.
 def makelocalstores(repo):
@@ -192,7 +185,7 @@
opts=None):
 """Runs prefetch in background with optional repack
 """
-cmd = [_hgexecutable(), '-R', repo.origroot, 'prefetch']
+cmd = [procutil.hgexecutable(), '-R', repo.origroot, 'prefetch']
 if repack:
 cmd.append('--repack')
 if revs:



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


D6490: commit: add --force flag to close branch from a non-head changeset

2019-06-18 Thread markand (David Demelier)
markand added a comment.


  In D6490#95328 , @mharbison72 
wrote:
  
  > In D6490#95305 , @pulkit wrote:
  >
  >> I think adding a `--force` flag to `hg commit` is not a nice option. force 
can mean a lot of things and here except in closing the non-head changeset, it 
is no-op. 
  >> For example, I am in middle of a rebase, tried to commit, it says rebase 
in progress. I see there is a --force flag, I try to use that to force the 
commit.
  >> We can do one of the following:
  >>
  >> 1. maybe a more specific flag name like `--allow-close-branch` or 
something like that
  >> 2. a config option instead of a flag name
  >
  > Fair point.  Specific is better.
  > I'd suggest `--force-close-branch` as a standalone flag (i.e. you don't 
need to also use `--close-branch`; it wasn't clear to me if that's what you 
meant).  `--allow-close-branch` and `--close-branch` don't seem different 
enough to remember the difference.
  
  Just my $0.02.
  
  I think that `hg commit` already has many options that do not even belong to 
committing (such as -A, --close-branch). Let's not add an option that is not 
related to commit. To my opinion closing a branch should be done with `hg 
branch` not commit (unfortunately this was never the case). Anyway if you 
really want to do it with commit, I would suggest that `--close-branch` takes 
an optional argument rather than adding a new option. This makes UX a bit more 
convenient
  
  e.g.
  
hg commit --close-branch --force-close-branch (not that)
hg commit --close-branch forced (or force or something like that)

REPOSITORY
  rHG Mercurial

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

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

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


D6502: state: moved cmdutil.STATES and utilities to state.py

2019-06-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> cmdutil.py:623
>  def morestatus(repo, fm):
> -statetuple = _getrepostate(repo)
> +statetuple = statemod._getrepostate(repo)
>  label = 'status.morestatus'

Should drop the `_` from `_getrepostate` since it's no longer private.

REPOSITORY
  rHG Mercurial

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

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

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


mercurial@42494: 2 new changesets

2019-06-18 Thread Mercurial Commits
2 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/9f7cb777b654
changeset:   42493:9f7cb777b654
user:Sushil khanchi 
date:Tue Apr 16 02:33:54 2019 +0530
summary: commit: add a check if it is trying to close an already closed 
branch head

https://www.mercurial-scm.org/repo/hg/rev/abd4783db5a7
changeset:   42494:abd4783db5a7
bookmark:@
tag: tip
user:Sushil khanchi 
date:Tue Apr 16 02:53:28 2019 +0530
summary: commit: make the error message more specific while aborting branch 
closing

-- 
Repository URL: https://www.mercurial-scm.org/repo/hg
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6537: procutil: allow callers of runbgcommand to assume the process starts

2019-06-18 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 15575.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6537?vs=15572=15575

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

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

AFFECTED FILES
  mercurial/utils/procutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -470,7 +470,8 @@
 # See https://phab.mercurial-scm.org/D1701 for discussion
 _creationflags = DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP
 
-def runbgcommand(script, env, shell=False, stdout=None, stderr=None):
+def runbgcommand(
+  script, env, shell=False, stdout=None, stderr=None, ensurestart=True):
 '''Spawn a command without waiting for it to finish.'''
 # we can't use close_fds *and* redirect stdin. I'm not sure that we
 # need to because the detached process has no console connection.
@@ -480,12 +481,15 @@
 creationflags=_creationflags, stdout=stdout,
 stderr=stderr)
 else:
-def runbgcommand(cmd, env, shell=False, stdout=None, stderr=None):
+def runbgcommand(
+  cmd, env, shell=False, stdout=None, stderr=None, ensurestart=True):
 '''Spawn a command without waiting for it to finish.'''
 # double-fork to completely detach from the parent process
 # based on http://code.activestate.com/recipes/278731
 pid = os.fork()
 if pid:
+if not ensurestart:
+return
 # Parent process
 (_pid, status) = os.waitpid(pid, 0)
 if os.WIFEXITED(status):



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


D6539: remotefilelog: tell runbgcommand to not block on child process startup

2019-06-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  These two invocations will always find a binary because they're
  re-running hg. As a result, we can skip waiting for the subprocess to
  start running and save a little bit of wall-time.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/repack.py
  hgext/remotefilelog/shallowrepo.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/shallowrepo.py 
b/hgext/remotefilelog/shallowrepo.py
--- a/hgext/remotefilelog/shallowrepo.py
+++ b/hgext/remotefilelog/shallowrepo.py
@@ -190,7 +190,9 @@
 cmd.append('--repack')
 if revs:
 cmd += ['-r', revs]
-procutil.runbgcommand(cmd, encoding.environ)
+# We know this command will find a binary, so don't block
+# on it starting.
+procutil.runbgcommand(cmd, encoding.environ, ensurestart=False)
 
 def prefetch(self, revs, base=None, pats=None, opts=None):
 """Prefetches all the necessary file revisions for the given revs
diff --git a/hgext/remotefilelog/repack.py b/hgext/remotefilelog/repack.py
--- a/hgext/remotefilelog/repack.py
+++ b/hgext/remotefilelog/repack.py
@@ -43,7 +43,8 @@
 if packsonly:
 cmd.append('--packsonly')
 repo.ui.warn(msg)
-procutil.runbgcommand(cmd, encoding.environ)
+# We know this command will find a binary, so don't block on it starting.
+procutil.runbgcommand(cmd, encoding.environ, ensurestart=False)
 
 def fullrepack(repo, options=None):
 """If ``packsonly`` is True, stores creating only loose objects are 
skipped.



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


D6538: shallowrepo: remove backwards compat code that predates in-tree remotefilelog

2019-06-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/shallowrepo.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/shallowrepo.py 
b/hgext/remotefilelog/shallowrepo.py
--- a/hgext/remotefilelog/shallowrepo.py
+++ b/hgext/remotefilelog/shallowrepo.py
@@ -33,13 +33,6 @@
 shallowutil,
 )
 
-if util.safehasattr(util, '_hgexecutable'):
-# Before 5be286db
-_hgexecutable = util.hgexecutable
-else:
-from mercurial.utils import procutil
-_hgexecutable = procutil.hgexecutable
-
 # These make*stores functions are global so that other extensions can replace
 # them.
 def makelocalstores(repo):
@@ -192,7 +185,7 @@
opts=None):
 """Runs prefetch in background with optional repack
 """
-cmd = [_hgexecutable(), '-R', repo.origroot, 'prefetch']
+cmd = [procutil.hgexecutable(), '-R', repo.origroot, 'prefetch']
 if repack:
 cmd.append('--repack')
 if revs:



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


D6490: commit: add --force flag to close branch from a non-head changeset

2019-06-18 Thread mharbison72 (Matt Harbison)
mharbison72 added a comment.


  In D6490#95305 , @pulkit wrote:
  
  > I think adding a `--force` flag to `hg commit` is not a nice option. force 
can mean a lot of things and here except in closing the non-head changeset, it 
is no-op. 
  > For example, I am in middle of a rebase, tried to commit, it says rebase in 
progress. I see there is a --force flag, I try to use that to force the commit.
  > We can do one of the following:
  >
  > 1. maybe a more specific flag name like `--allow-close-branch` or something 
like that
  > 2. a config option instead of a flag name
  
  Fair point.  Specific is better.
  
  I'd suggest `--force-close-branch` as a standalone flag (i.e. you don't need 
to also use `--close-branch`; it wasn't clear to me if that's what you meant).  
`--allow-close-branch` and `--close-branch` don't seem different enough to 
remember the difference.

REPOSITORY
  rHG Mercurial

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

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

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


D6537: procutil: allow callers of runbgcommand to assume the process starts

2019-06-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Experimentally starting the subprocess can take as much as 40ms, and
  for some of our use cases that's frivolous: we know the binary will
  start, and if it doesn't we'd only ever ignore it and continue
  anyway. This lets those use cases be faster.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/utils/procutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -470,7 +470,8 @@
 # See https://phab.mercurial-scm.org/D1701 for discussion
 _creationflags = DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP
 
-def runbgcommand(script, env, shell=False, stdout=None, stderr=None):
+def runbgcommand(
+  script, env, shell=False, stdout=None, stderr=None, ensurestart=True):
 '''Spawn a command without waiting for it to finish.'''
 # we can't use close_fds *and* redirect stdin. I'm not sure that we
 # need to because the detached process has no console connection.
@@ -480,12 +481,15 @@
 creationflags=_creationflags, stdout=stdout,
 stderr=stderr)
 else:
-def runbgcommand(cmd, env, shell=False, stdout=None, stderr=None):
+def runbgcommand(
+  cmd, env, shell=False, stdout=None, stderr=None, ensurestart=True):
 '''Spawn a command without waiting for it to finish.'''
 # double-fork to completely detach from the parent process
 # based on http://code.activestate.com/recipes/278731
 pid = os.fork()
 if pid:
+if not ensurestart:
+  return
 # Parent process
 (_pid, status) = os.waitpid(pid, 0)
 if os.WIFEXITED(status):



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


[Bug 6156] New: File Sorting Order Doesn't Match OS

2019-06-18 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6156

Bug ID: 6156
   Summary: File Sorting Order Doesn't Match OS
   Product: Mercurial
   Version: 4.9
  Hardware: PC
OS: Windows
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: bugreporter5...@protonmail.com
CC: mercurial-devel@mercurial-scm.org

Windows uses a case insensitive sort when listing files.
```
aaa.txt
ABC.txt
and.txt
ART.txt
as.txt
```

Mercurial instead uses a case sensitive sort.
```
>hg status
? ABC.txt
? ART.txt
? aaa.txt
? and.txt
? as.txt
```

Shouldn't Mercurial match the OS default sort here? Or should users have an
option to use OS sorting rules in mercurial.ini?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


mercurial@42492: 5 new changesets

2019-06-18 Thread Mercurial Commits
5 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/c0b51449bf6b
changeset:   42488:c0b51449bf6b
user:Martin von Zweigbergk 
date:Thu May 02 23:39:33 2019 -0700
summary: copies: avoid calling matcher if matcher.always()

https://www.mercurial-scm.org/repo/hg/rev/cf445a212b9c
changeset:   42489:cf445a212b9c
user:Martin von Zweigbergk 
date:Mon Jun 17 10:38:50 2019 -0700
summary: mq: remove dependency on strip's checklocalchanges()

https://www.mercurial-scm.org/repo/hg/rev/3a1988e915f9
changeset:   42490:3a1988e915f9
user:Martin von Zweigbergk 
date:Mon Jun 17 10:40:24 2019 -0700
summary: strip: remove unused excsuffix argument from checklocalchanges()

https://www.mercurial-scm.org/repo/hg/rev/1474f5d84662
changeset:   42491:1474f5d84662
user:Martin von Zweigbergk 
date:Mon Jun 17 10:19:41 2019 -0700
summary: strip: use bailifchanged() instead of reimplementing it

https://www.mercurial-scm.org/repo/hg/rev/4bcabb5ae9b6
changeset:   42492:4bcabb5ae9b6
bookmark:@
tag: tip
user:Martin von Zweigbergk 
date:Mon Jun 17 10:53:00 2019 -0700
summary: strip: move checksubstate() to mq (its only caller)

-- 
Repository URL: https://www.mercurial-scm.org/repo/hg
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6504: statecheck: fix for hint message format

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 edited the summary of this revision.
taapas1128 retitled this revision from "statecheck: changed hint message 
format" to "statecheck: fix for hint message format".
taapas1128 updated this revision to Diff 15571.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6504?vs=15566=15571

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

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

AFFECTED FILES
  hgext/transplant.py
  mercurial/state.py
  tests/test-graft.t
  tests/test-histedit-fold.t
  tests/test-rebase-conflicts.t
  tests/test-shelve.t
  tests/test-strip.t
  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
@@ -40,8 +40,7 @@
   (branch merge, don't forget to commit)
   $ hg transplant 1
   abort: merge in progress
-  (To continue:hg commit
-  To abort:   hg merge --abort)
+  (use 'hg commit' or 'hg merge --abort')
   [255]
   $ hg up -qC tip
   $ echo b0 > b1
@@ -489,7 +488,8 @@
   ? foo.rej
   # The repository is in an unfinished *transplant* state.
   
-  # use 'hg transplant --continue' or 'hg update' to abort
+  # To continue:hg transplant --continue
+  # To abort:   hg update
   
   $ echo fixed > baz
   $ hg transplant --continue
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -275,8 +275,7 @@
 ##strip not allowed with merge in progress
   $ hg strip 4
   abort: merge in progress
-  (To continue:hg commit
-  To abort:   hg merge --abort)
+  (use 'hg commit' or 'hg merge --abort')
   [255]
 ##strip allowed --force with merge in progress
   $ hg strip 4 --force
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -375,7 +375,8 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg unshelve --continue' or 'hg unshelve --abort'
+  # To continue:hg unshelve --continue
+  # To abort:   hg unshelve --abort
   
 
 ensure that we have a merge with unresolved conflicts
@@ -1153,8 +1154,7 @@
 -- unshelve should abort otherwise, it'll eat my second parent.
   $ hg unshelve
   abort: merge in progress
-  (To continue:hg commit
-  To abort:   hg merge --abort)
+  (use 'hg commit' or 'hg merge --abort')
   [255]
 
   $ cd ..
diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -80,7 +80,8 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg rebase --continue' or 'hg rebase --abort'
+  # To continue:hg rebase --continue
+  # To abort:   hg rebase --abort
   
 
 Try to continue without solving the conflict:
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -306,7 +306,8 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg histedit --continue' or 'hg histedit --abort'
+  # To continue:hg histedit --continue
+  # To abort:   hg histedit --abort
   
   $ hg resolve -l
   U file
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -279,7 +279,9 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg graft --continue' or 'hg graft --stop' to stop
+  # To continue:hg graft --continue
+  # To abort:   hg graft --abort
+  # To stop:hg graft --stop
   
 
 Commit while interrupted should fail:
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -98,7 +98,7 @@
 """
 
 def __init__(self, opname, fname, clearable=False, allowcommit=False,
- cmdmsg="", cmdhint=""):
+ cmdmsg="", cmdhint="", statushint="", stopflag=False):
 """opname is the name the command or operation
 fname is the file name in which data should be stored in .hg directory.
 It is None for merge command.
@@ -110,22 +110,40 @@
 cmdmsg is used to pass a different status message in case standard
 message of the format "abort: cmdname in progress" is not desired.
 cmdhint is used to pass a different hint message in case standard
-message of the format use 'hg cmdname --continue' or
-'hg cmdname --abort'" is not desired.
+message of the format "To continue: hg cmdname --continue
+To abort: hg cmdname --abort" is not desired.
+status hint 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
+stopflag is a boolean that determines whether or not a command supports
+--stop flag
 """
 self._opname = opname
   

D6484: states: moved cmdutil.unfinishedstates to state.py

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15569.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6484?vs=15402=15569

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

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

AFFECTED FILES
  hgext/absorb.py
  hgext/fix.py
  hgext/histedit.py
  hgext/phabricator.py
  hgext/rebase.py
  hgext/record.py
  hgext/shelve.py
  hgext/strip.py
  hgext/transplant.py
  mercurial/cmdutil.py
  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
@@ -19,6 +19,8 @@
 
 from __future__ import absolute_import
 
+from .i18n import _
+
 from . import (
 error,
 util,
@@ -85,3 +87,44 @@
 def exists(self):
 """check whether the state file exists or not"""
 return self._repo.vfs.exists(self.fname)
+
+# A list of state files kept by multistep operations like graft.
+# Since graft cannot be aborted, it is considered 'clearable' by update.
+# note: bisect is intentionally excluded
+# (state file, clearable, allowcommit, error, hint)
+unfinishedstates = [
+('graftstate', True, False, _('graft in progress'),
+ _("use 'hg graft --continue' or 'hg graft --stop' to stop")),
+('updatestate', True, False, _('last update was interrupted'),
+ _("use 'hg update' to get a consistent checkout"))
+]
+
+def checkunfinished(repo, commit=False):
+'''Look for an unfinished multistep operation, like graft, and abort
+if found. It's probably good to check this right before
+bailifchanged().
+'''
+# Check for non-clearable states first, so things like rebase will take
+# precedence over update.
+for f, clearable, allowcommit, msg, hint in unfinishedstates:
+if clearable or (commit and allowcommit):
+continue
+if repo.vfs.exists(f):
+raise error.Abort(msg, hint=hint)
+
+for f, clearable, allowcommit, msg, hint in unfinishedstates:
+if not clearable or (commit and allowcommit):
+continue
+if repo.vfs.exists(f):
+raise error.Abort(msg, hint=hint)
+
+def clearunfinished(repo):
+'''Check for unfinished operations (as above), and clear the ones
+that are clearable.
+'''
+for f, clearable, allowcommit, msg, hint in unfinishedstates:
+if not clearable and repo.vfs.exists(f):
+raise error.Abort(msg, hint=hint)
+for f, clearable, allowcommit, msg, hint in unfinishedstates:
+if clearable and repo.vfs.exists(f):
+util.unlink(repo.vfs.join(f))
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -618,7 +618,7 @@
 if date:
 opts['date'] = dateutil.parsedate(date)
 
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 cmdutil.bailifchanged(repo)
 node = scmutil.revsingle(repo, rev).node()
 
@@ -847,7 +847,7 @@
 """common used update sequence"""
 if noupdate:
 return
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 cmdutil.bailifchanged(repo)
 return hg.clean(repo, node, show_stats=show_stats)
 
@@ -1664,7 +1664,7 @@
 # Let --subrepos on the command line override config setting.
 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
 
-cmdutil.checkunfinished(repo, commit=True)
+statemod.checkunfinished(repo, commit=True)
 
 branch = repo[None].branch()
 bheads = repo.branchheads(branch)
@@ -1696,7 +1696,7 @@
 # Note: eventually this guard will be removed. Please do not expect
 # this behavior to remain.
 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 
 node = cmdutil.amend(ui, repo, old, extra, pats, opts)
 if node == old.node():
@@ -2479,7 +2479,7 @@
 else:
 if not revs:
 raise error.Abort(_('no revisions specified'))
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 cmdutil.bailifchanged(repo)
 revs = scmutil.revrange(repo, revs)
 
@@ -3481,7 +3481,7 @@
 
 with repo.wlock():
 if update:
-cmdutil.checkunfinished(repo)
+statemod.checkunfinished(repo)
 if (exact or not opts.get('force')):
 cmdutil.bailifchanged(repo)
 
@@ -6144,8 +6144,7 @@
 updatecheck = 'none'
 
 with repo.wlock():
-cmdutil.clearunfinished(repo)
-
+statemod.clearunfinished(repo)
 if date:
 rev = cmdutil.finddate(ui, repo, date)
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -42,6 +42,7 @@
 rewriteutil,
 scmutil,
 smartset,
+state as statemod,
 subrepoutil,

D6501: state: created new class statecheck to handle unfinishedstates

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 marked 2 inline comments as done.
taapas1128 updated this revision to Diff 15570.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6501?vs=15564=15570

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

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

AFFECTED FILES
  hgext/histedit.py
  hgext/rebase.py
  hgext/shelve.py
  hgext/transplant.py
  mercurial/state.py

CHANGE DETAILS

diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -88,16 +88,73 @@
 """check whether the state file exists or not"""
 return self._repo.vfs.exists(self.fname)
 
-# A list of state files kept by multistep operations like graft.
-# Since graft cannot be aborted, it is considered 'clearable' by update.
-# note: bisect is intentionally excluded
-# (state file, clearable, allowcommit, error, hint)
-unfinishedstates = [
-('graftstate', True, False, _('graft in progress'),
- _("use 'hg graft --continue' or 'hg graft --stop' to stop")),
-('updatestate', True, False, _('last update was interrupted'),
- _("use 'hg update' to get a consistent checkout"))
-]
+class _statecheck(object):
+"""a utility class that deals with multistep operations like graft,
+   histedit, bisect, update etc and check whether such commands
+   are in an unfinished conditition or not and return appropriate message
+   and hint.
+   It also has the ability to register and determine the states of any new
+   multistep operation or multistep command extension.
+"""
+
+def __init__(self, opname, fname, clearable=False, allowcommit=False,
+ cmdmsg="", cmdhint=""):
+"""opname is the name the command or operation
+fname is the file name in which data should be stored in .hg directory.
+It is None for merge command.
+clearable boolean determines whether or not interrupted states can be
+cleared by running `hg update -C .` which in turn deletes the
+state file.
+allowcommit boolean decides whether commit is allowed during 
interrupted
+state or not.
+cmdmsg is used to pass a different status message in case standard
+message of the format "abort: cmdname in progress" is not desired.
+cmdhint is used to pass a different hint message in case standard
+message of the format use 'hg cmdname --continue' or
+'hg cmdname --abort'" is not desired.
+"""
+self._opname = opname
+self._fname = fname
+self._clearable = clearable
+self._allowcommit = allowcommit
+self._cmdhint = cmdhint
+self._cmdmsg = cmdmsg
+
+def hint(self):
+"""returns the hint message corresponding to the command"""
+if not self._cmdhint:
+return (_("use 'hg %s --continue' or 'hg %s --abort'") %
+(self._opname, self._opname))
+return self._cmdhint
+
+def msg(self):
+"""returns the status message corresponding to the command"""
+if not self._cmdmsg:
+return _('%s in progress') % (self._opname)
+return self._cmdmsg
+
+def isunfinished(self, repo):
+"""determines whether a multi-step operation is in progress or not"""
+return repo.vfs.exists(self._fname)
+
+# A list of statecheck objects for multistep operations like graft.
+_unfinishedstates = []
+
+def addunfinished(opname, **kwargs):
+"""this registers a new command or operation to unfinishedstates
+"""
+statecheckobj = _statecheck(opname, **kwargs)
+_unfinishedstates.append(statecheckobj)
+
+addunfinished(
+'graft', fname='graftstate', clearable=True,
+cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
+)
+addunfinished(
+'update',fname='updatestate', clearable=True,
+cmdmsg=_('last update was interrupted'),
+cmdhint=_("use 'hg update' to get a consistent checkout")
+)
 
 def checkunfinished(repo, commit=False):
 '''Look for an unfinished multistep operation, like graft, and abort
@@ -106,25 +163,26 @@
 '''
 # Check for non-clearable states first, so things like rebase will take
 # precedence over update.
-for f, clearable, allowcommit, msg, hint in unfinishedstates:
-if clearable or (commit and allowcommit):
+for state in _unfinishedstates:
+if state._clearable or (commit and state._allowcommit):
 continue
-if repo.vfs.exists(f):
-raise error.Abort(msg, hint=hint)
+if state.isunfinished(repo):
+raise error.Abort(state.msg(), hint=state.hint())
 
-for f, clearable, allowcommit, msg, hint in unfinishedstates:
-if not clearable or (commit and allowcommit):
+for s in _unfinishedstates:
+if not s._clearable or (commit and s._allowcommit):
 continue
-if repo.vfs.exists(f):
-

mercurial@42487: 3 new changesets

2019-06-18 Thread Mercurial Commits
3 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/4c39c99d9492
changeset:   42485:4c39c99d9492
user:Martin von Zweigbergk 
date:Thu Apr 18 00:40:53 2019 -0700
summary: copies: do full filtering at end of _changesetforwardcopies()

https://www.mercurial-scm.org/repo/hg/rev/35d674a3d5db
changeset:   42486:35d674a3d5db
user:Martin von Zweigbergk 
date:Thu Apr 18 21:22:14 2019 -0700
summary: copies: don't filter out copy targets created on other side of 
merge commit

https://www.mercurial-scm.org/repo/hg/rev/5ceb91136ebe
changeset:   42487:5ceb91136ebe
bookmark:@
tag: tip
user:Martin von Zweigbergk 
date:Thu Apr 18 21:21:44 2019 -0700
summary: copies: avoid unnecessary copying of copy dict

-- 
Repository URL: https://www.mercurial-scm.org/repo/hg
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6501: state: created new class statecheck to handle unfinishedstates

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 added inline comments.
taapas1128 marked 2 inline comments as done.

INLINE COMMENTS

> pulkit wrote in phabricator.py:53
> unrelated change?

need to amend it D6484 . sorry.

REPOSITORY
  rHG Mercurial

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

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

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


D6493: commit: make the error message more specific while aborting branch closing

2019-06-18 Thread khanchi97 (Sushil khanchi)
Closed by commit rHGabd4783db5a7: commit: make the error message more specific 
while aborting branch closing (authored by khanchi97).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6493?vs=15533=15568#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6493?vs=15533=15568

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

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-commit-amend.t

CHANGE DETAILS

diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -892,7 +892,7 @@
   marked working directory as branch silliness
   $ echo b >> b
   $ hg ci --close-branch -m'open and close'
-  abort: can only close branch heads
+  abort: branch "silliness" has no heads to close
   [255]
 
 Test that amend with --secret creates new secret changeset forcibly
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1677,7 +1677,7 @@
 raise error.Abort(_('current revision is already a branch closing'
 ' head'))
 elif not bheads:
-raise error.Abort(_('can only close branch heads'))
+raise error.Abort(_('branch "%s" has no heads to close') % branch)
 elif branch == repo['.'].branch() and repo['.'].node() not in bheads:
 raise error.Abort(_('can only close branch heads'))
 elif opts.get('amend'):



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


D6491: commit: add a check if it is trying to close an already closed branch head

2019-06-18 Thread khanchi97 (Sushil khanchi)
Closed by commit rHG9f7cb777b654: commit: add a check if it is trying to close 
an already closed branch head (authored by khanchi97).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6491?vs=15532=15567#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6491?vs=15532=15567

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

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

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

CHANGE DETAILS

diff --git a/tests/test-branches.t b/tests/test-branches.t
--- a/tests/test-branches.t
+++ b/tests/test-branches.t
@@ -280,7 +280,7 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg commit -d '9 0' --close-branch -m 'close this part branch too'
   $ hg commit -d '9 0' --close-branch -m 're-closing this branch'
-  abort: can only close branch heads
+  abort: current revision is already a branch closing head
   [255]
 
   $ hg log -r tip --debug
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1673,7 +1673,10 @@
 if opts.get('close_branch'):
 extra['close'] = '1'
 
-if not bheads:
+if repo['.'].closesbranch():
+raise error.Abort(_('current revision is already a branch closing'
+' head'))
+elif not bheads:
 raise error.Abort(_('can only close branch heads'))
 elif branch == repo['.'].branch() and repo['.'].node() not in bheads:
 raise error.Abort(_('can only close branch heads'))



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


D6490: commit: add --force flag to close branch from a non-head changeset

2019-06-18 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  I think adding a `--force` flag to `hg commit` is not a nice option. force 
can mean a lot of things and here except in closing the non-head changeset, it 
is no-op.
  
  For example, I am in middle of a rebase, tried to commit, it says rebase in 
progress. I see there is a --force flag, I try to use that to force the commit.
  
  We can do one of the following:
  
  1. maybe a more specific flag name like `--allow-close-branch` or something 
like that
  2. a config option instead of a flag name

REPOSITORY
  rHG Mercurial

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

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

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


D6504: statecheck: changed hint message format

2019-06-18 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  > This changes the old message format used by unfinishedstates
  > to the format which was used by STATES.
  
  The commit message seems outdated.
  
  Also I think we can fold this one in previous patch so that there are no 
un-necessary test changes. @martinvonz what do you think?

REPOSITORY
  rHG Mercurial

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

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

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


D6501: state: created new class statecheck to handle unfinishedstates

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

INLINE COMMENTS

> phabricator.py:53
>  from mercurial import (
> -cmdutil,
>  context,

unrelated change?

> rebase.py:1953
>  cmdutil.summaryhooks.add('rebase', summaryhook)
> -statemod.unfinishedstates.append(
> -['rebasestate', False, False, _('rebase in progress'),
> - _("use 'hg rebase --continue' or 'hg rebase --abort'")])
> +statemod.addunfinished('rebase',fname='rebasestate')
>  cmdutil.afterresolvedstates.append(

need a space after `,`.

> strip.py:11
>  bookmarks as bookmarksmod,
> -cmdutil,
>  error,

unrelated change?

> state.py:94
> +   histedit, bisect, update etc and check whether such commands
> +   are in an unfinished conditition of not and return appropriate message
> +   and hint.

s/of/or (unfinished condition or not)

REPOSITORY
  rHG Mercurial

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

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

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


[Bug 6155] New: [Hg 5.0.1] Absorb: recordfilter() argument missing

2019-06-18 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6155

Bug ID: 6155
   Summary: [Hg 5.0.1] Absorb: recordfilter() argument missing
   Product: Mercurial
   Version: unspecified
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: mh-mercur...@online.de
CC: mercurial-devel@mercurial-scm.org

Hg absorb runs into this exception

$ hg absorb -i -e
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat
4.8.5-36)]
** Mercurial Distributed SCM (version 5.0.1)
** Extensions loaded: absorb, pager, shelve, show
Traceback (most recent call last):
  File "/home/username/.local/bin/hg", line 43, in 
dispatch.run()
  File
"/home/username/.local/lib/python2.7/site-packages/mercurial/dispatch.py", line
99, in run
status = dispatch(req)
  File
"/home/username/.local/lib/python2.7/site-packages/mercurial/dispatch.py", line
225, in dispatch
ret = _runcatch(req) or 0
  File
"/home/username/.local/lib/python2.7/site-packages/mercurial/dispatch.py", line
376, in _runcatch
return _callcatch(ui, _runcatchfunc)
  File
"/home/username/.local/lib/python2.7/site-packages/mercurial/dispatch.py", line
384, in _callcatch
return scmutil.callcatch(ui, func)
  File
"/home/username/.local/lib/python2.7/site-packages/mercurial/scmutil.py", line
167, in callcatch
return func()
  File
"/home/username/.local/lib/python2.7/site-packages/mercurial/dispatch.py", line
367, in _runcatchfunc
return _dispatch(req)
  File
"/home/username/.local/lib/python2.7/site-packages/mercurial/dispatch.py", line
1021, in _dispatch
cmdpats, cmdoptions)
  File
"/home/username/.local/lib/python2.7/site-packages/mercurial/dispatch.py", line
756, in runcommand
ret = _runcommand(ui, options, cmd, d)
  File "/home/username/.local/lib/python2.7/site-packages/hgext/pager.py", line
77, in pagecmd
return orig(ui, options, cmd, cmdfunc)
  File
"/home/username/.local/lib/python2.7/site-packages/mercurial/dispatch.py", line
1030, in _runcommand
return cmdfunc()
  File
"/home/username/.local/lib/python2.7/site-packages/mercurial/dispatch.py", line
1018, in 
d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
  File "/home/username/.local/lib/python2.7/site-packages/mercurial/util.py",
line 1680, in check
return func(*args, **kwargs)
  File "/home/username/.local/lib/python2.7/site-packages/hgext/absorb.py",
line 1013, in absorbcmd
state = absorb(ui, repo, pats=pats, opts=opts)
  File "/home/username/.local/lib/python2.7/site-packages/hgext/absorb.py",
line 935, in absorb
chunks = cmdutil.recordfilter(ui, origchunks)[0]
TypeError: recordfilter() takes at least 3 arguments (2 given)
$

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6501: state: created new class statecheck to handle unfinishedstates

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 added inline comments.
taapas1128 marked 4 inline comments as done.

INLINE COMMENTS

> av6 wrote in state.py:151
> It's funny how Pulkit's comment is now at this line and looks like asking to 
> add spaces around `=` here. But in this case `=` is not an operator, it's 
> used to indicate keyword arguments. We don't want spaces around it (similarly 
> to PEP8).
> 
> Bad:
> 
>   addunfinished(
>   'graft',
>   fname = 'graftstate',
>   clearable = True,
>   allowcommit = False,
>   cmdhint = _("use 'hg graft --continue' or 'hg graft --stop' to stop")
>   )
> 
> Good:
> 
>   addunfinished(
>   'graft',
>   fname='graftstate',
>   clearable=True,
>   allowcommit=False,
>   cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
>   )
> 
> Even better (as long as it fits into 79 characters per line):
> 
>   addunfinished(
>   'graft', 'graftstate', clearable=True, allowcommit=False,
>   cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
>   )
> 
> There's a lot of places where this needs to be fixed in this series, not just 
> here.

Thank you I will take care from now on  :)

REPOSITORY
  rHG Mercurial

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

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

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


D6503: statecheck: added support for STATES

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15565.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6503?vs=15556=15565

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

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

AFFECTED FILES
  hgext/rebase.py
  hgext/strip.py
  mercurial/cmdutil.py
  mercurial/state.py
  tests/test-graft.t
  tests/test-histedit-fold.t
  tests/test-rebase-conflicts.t
  tests/test-shelve.t
  tests/test-strip.t
  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
@@ -39,7 +39,9 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg transplant 1
-  abort: outstanding uncommitted merge
+  abort: merge in progress
+  (To continue:hg commit
+  To abort:   hg merge --abort)
   [255]
   $ hg up -qC tip
   $ echo b0 > b1
@@ -461,7 +463,7 @@
   baz
   foo
 
-test multiple revisions and --continue
+test multiple revisions, --continue and hg status --verbose
 
   $ hg up -qC 0
   $ echo bazbaz > baz
@@ -481,6 +483,14 @@
   abort: transplant in progress
   (use 'hg transplant --continue' or 'hg update' to abort)
   [255]
+  $ hg status -v
+  A bar
+  ? baz.rej
+  ? foo.rej
+  # The repository is in an unfinished *transplant* state.
+  
+  # use 'hg transplant --continue' or 'hg update' to abort
+  
   $ echo fixed > baz
   $ hg transplant --continue
   9d6d6b5a8275 transplanted as d80c49962290
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -274,7 +274,9 @@
   
 ##strip not allowed with merge in progress
   $ hg strip 4
-  abort: outstanding uncommitted merge
+  abort: merge in progress
+  (To continue:hg commit
+  To abort:   hg merge --abort)
   [255]
 ##strip allowed --force with merge in progress
   $ hg strip 4 --force
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -375,8 +375,7 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg unshelve --continue
-  # To abort:   hg unshelve --abort
+  # use 'hg unshelve --continue' or 'hg unshelve --abort'
   
 
 ensure that we have a merge with unresolved conflicts
@@ -1153,7 +1152,9 @@
 -- trying to pull in the shelve bits
 -- unshelve should abort otherwise, it'll eat my second parent.
   $ hg unshelve
-  abort: cannot unshelve while merging
+  abort: merge in progress
+  (To continue:hg commit
+  To abort:   hg merge --abort)
   [255]
 
   $ cd ..
diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -80,8 +80,7 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg rebase --continue
-  # To abort:   hg rebase --abort
+  # use 'hg rebase --continue' or 'hg rebase --abort'
   
 
 Try to continue without solving the conflict:
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -306,8 +306,7 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg histedit --continue
-  # To abort:   hg histedit --abort
+  # use 'hg histedit --continue' or 'hg histedit --abort'
   
   $ hg resolve -l
   U file
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -279,8 +279,7 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # To continue:hg graft --continue
-  # To abort:   hg graft --abort
+  # use 'hg graft --continue' or 'hg graft --stop' to stop
   
 
 Commit while interrupted should fail:
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -134,8 +134,13 @@
 return self._cmdmsg
 
 def isunfinished(self, repo):
-"""determines whether a multi-step operation is in progress or not"""
-return repo.vfs.exists(self._fname)
+"""determines whether a multi-step operation is in progress
+or not
+"""
+if self._opname == 'merge':
+return len(repo[None].parents()) > 1
+else:
+return repo.vfs.exists(self._fname)
 
 # A list of statecheck objects for multistep operations like graft.
 _unfinishedstates = []
@@ -144,7 +149,10 @@
 """this registers a new command or operation to unfinishedstates
 """
 statecheckobj = _statecheck(opname, **kwargs)
-_unfinishedstates.append(statecheckobj)
+if opname == 'merge' or opname == 'bisect':
+_unfinishedstates.append(statecheckobj)
+else:
+_unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
 'graft', fname='graftstate', clearable=True,
@@ -155,8 +163,19 @@
 cmdmsg=_('last 

D6504: statecheck: changed hint message format

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15566.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6504?vs=15557=15566

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

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

AFFECTED FILES
  hgext/transplant.py
  mercurial/state.py
  tests/test-graft.t
  tests/test-histedit-fold.t
  tests/test-rebase-conflicts.t
  tests/test-shelve.t
  tests/test-strip.t
  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
@@ -40,8 +40,7 @@
   (branch merge, don't forget to commit)
   $ hg transplant 1
   abort: merge in progress
-  (To continue:hg commit
-  To abort:   hg merge --abort)
+  (use 'hg commit' or 'hg merge --abort')
   [255]
   $ hg up -qC tip
   $ echo b0 > b1
@@ -489,7 +488,8 @@
   ? foo.rej
   # The repository is in an unfinished *transplant* state.
   
-  # use 'hg transplant --continue' or 'hg update' to abort
+  # To continue:hg transplant --continue
+  # To abort:   hg update
   
   $ echo fixed > baz
   $ hg transplant --continue
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -275,8 +275,7 @@
 ##strip not allowed with merge in progress
   $ hg strip 4
   abort: merge in progress
-  (To continue:hg commit
-  To abort:   hg merge --abort)
+  (use 'hg commit' or 'hg merge --abort')
   [255]
 ##strip allowed --force with merge in progress
   $ hg strip 4 --force
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -375,7 +375,8 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg unshelve --continue' or 'hg unshelve --abort'
+  # To continue:hg unshelve --continue
+  # To abort:   hg unshelve --abort
   
 
 ensure that we have a merge with unresolved conflicts
@@ -1153,8 +1154,7 @@
 -- unshelve should abort otherwise, it'll eat my second parent.
   $ hg unshelve
   abort: merge in progress
-  (To continue:hg commit
-  To abort:   hg merge --abort)
+  (use 'hg commit' or 'hg merge --abort')
   [255]
 
   $ cd ..
diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -80,7 +80,8 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg rebase --continue' or 'hg rebase --abort'
+  # To continue:hg rebase --continue
+  # To abort:   hg rebase --abort
   
 
 Try to continue without solving the conflict:
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -306,7 +306,8 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg histedit --continue' or 'hg histedit --abort'
+  # To continue:hg histedit --continue
+  # To abort:   hg histedit --abort
   
   $ hg resolve -l
   U file
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -279,7 +279,9 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg graft --continue' or 'hg graft --stop' to stop
+  # To continue:hg graft --continue
+  # To abort:   hg graft --abort
+  # To stop:hg graft --stop
   
 
 Commit while interrupted should fail:
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -98,7 +98,7 @@
 """
 
 def __init__(self, opname, fname, clearable=False, allowcommit=False,
- cmdmsg="", cmdhint=""):
+ cmdmsg="", cmdhint="", statushint="", stopflag=False):
 """opname is the name the command or operation
 fname is the file name in which data should be stored in .hg directory.
 It is None for merge command.
@@ -110,22 +110,40 @@
 cmdmsg is used to pass a different status message in case standard
 message of the format "abort: cmdname in progress" is not desired.
 cmdhint is used to pass a different hint message in case standard
-message of the format use 'hg cmdname --continue' or
-'hg cmdname --abort'" is not desired.
+message of the format "To continue: hg cmdname --continue
+To abort: hg cmdname --abort" is not desired.
+status hint 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
+stopflag is a boolean that determines whether or not a command supports
+--stop flag
 """
 self._opname = opname
 self._fname = fname
 self._clearable = clearable
 self._allowcommit = allowcommit
 self._cmdhint = cmdhint
+self._statushint = statushint

D6501: state: created new class statecheck to handle unfinishedstates

2019-06-18 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15564.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6501?vs=15551=15564

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

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

AFFECTED FILES
  hgext/histedit.py
  hgext/phabricator.py
  hgext/rebase.py
  hgext/shelve.py
  hgext/strip.py
  hgext/transplant.py
  mercurial/state.py

CHANGE DETAILS

diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -88,16 +88,73 @@
 """check whether the state file exists or not"""
 return self._repo.vfs.exists(self.fname)
 
-# A list of state files kept by multistep operations like graft.
-# Since graft cannot be aborted, it is considered 'clearable' by update.
-# note: bisect is intentionally excluded
-# (state file, clearable, allowcommit, error, hint)
-unfinishedstates = [
-('graftstate', True, False, _('graft in progress'),
- _("use 'hg graft --continue' or 'hg graft --stop' to stop")),
-('updatestate', True, False, _('last update was interrupted'),
- _("use 'hg update' to get a consistent checkout"))
-]
+class _statecheck(object):
+"""a utility class that deals with multistep operations like graft,
+   histedit, bisect, update etc and check whether such commands
+   are in an unfinished conditition of not and return appropriate message
+   and hint.
+   It also has the ability to register and determine the states of any new
+   multistep operation or multistep command extension.
+"""
+
+def __init__(self, opname, fname, clearable=False, allowcommit=False,
+ cmdmsg="", cmdhint=""):
+"""opname is the name the command or operation
+fname is the file name in which data should be stored in .hg directory.
+It is None for merge command.
+clearable boolean determines whether or not interrupted states can be
+cleared by running `hg update -C .` which in turn deletes the
+state file.
+allowcommit boolean decides whether commit is allowed during 
interrupted
+state or not.
+cmdmsg is used to pass a different status message in case standard
+message of the format "abort: cmdname in progress" is not desired.
+cmdhint is used to pass a different hint message in case standard
+message of the format use 'hg cmdname --continue' or
+'hg cmdname --abort'" is not desired.
+"""
+self._opname = opname
+self._fname = fname
+self._clearable = clearable
+self._allowcommit = allowcommit
+self._cmdhint = cmdhint
+self._cmdmsg = cmdmsg
+
+def hint(self):
+"""returns the hint message corresponding to the command"""
+if not self._cmdhint:
+return (_("use 'hg %s --continue' or 'hg %s --abort'") %
+(self._opname, self._opname))
+return self._cmdhint
+
+def msg(self):
+"""returns the status message corresponding to the command"""
+if not self._cmdmsg:
+return _('%s in progress') % (self._opname)
+return self._cmdmsg
+
+def isunfinished(self, repo):
+"""determines whether a multi-step operation is in progress or not"""
+return repo.vfs.exists(self._fname)
+
+# A list of statecheck objects for multistep operations like graft.
+_unfinishedstates = []
+
+def addunfinished(opname, **kwargs):
+"""this registers a new command or operation to unfinishedstates
+"""
+statecheckobj = _statecheck(opname, **kwargs)
+_unfinishedstates.append(statecheckobj)
+
+addunfinished(
+'graft', fname='graftstate', clearable=True,
+cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
+)
+addunfinished(
+'update',fname='updatestate', clearable=True,
+cmdmsg=_('last update was interrupted'),
+cmdhint=_("use 'hg update' to get a consistent checkout")
+)
 
 def checkunfinished(repo, commit=False):
 '''Look for an unfinished multistep operation, like graft, and abort
@@ -106,25 +163,26 @@
 '''
 # Check for non-clearable states first, so things like rebase will take
 # precedence over update.
-for f, clearable, allowcommit, msg, hint in unfinishedstates:
-if clearable or (commit and allowcommit):
+for state in _unfinishedstates:
+if state._clearable or (commit and state._allowcommit):
 continue
-if repo.vfs.exists(f):
-raise error.Abort(msg, hint=hint)
+if state.isunfinished(repo):
+raise error.Abort(state.msg(), hint=state.hint())
 
-for f, clearable, allowcommit, msg, hint in unfinishedstates:
-if not clearable or (commit and allowcommit):
+for s in _unfinishedstates:
+if not s._clearable or (commit and s._allowcommit):
 continue
-if repo.vfs.exists(f):
-raise 

D6501: state: created new class statecheck to handle unfinishedstates

2019-06-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> shelve.py:1148
> +allowcommit = False,
> +cmdmsg = _('unshelve already in progress')
> +)

A good patch to send right after this patch is one that removes this line and 
lets shelve use the default message. I understand why they picked "already" 
(because it makes sense when you run `hg shelve/unshelve` with an ongoing 
unshelve), but it doesn't make sense when e.g. running `hg commit`. There is 
already a test showing the bad example (and the good one) in `test-shelve.t`.

> state.py:100
> +
> +def __init__(self, opname, fname, clearable=False, allowcommit=False,
> + cmdmsg="", cmdhint=""):

I'm not sure  if we should have a default for `clearable`. Not having a default 
would force callers to think about it, which may be good. OTOH, the default of 
`False` is pretty safe, so it's probably fine to have a default. But if we do 
have a default, I think you should update the callers to not pass `clearable` 
when they want the default.

> state.py:153
> +clearable = True,
> +allowcommit = False,
> +cmdhint = _("use 'hg graft --continue' or 'hg graft --stop' to stop")

Don't specify `allowcommit` when it's the same as the default (the same applies 
in other places)

REPOSITORY
  rHG Mercurial

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

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

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


D6501: state: created new class statecheck to handle unfinishedstates

2019-06-18 Thread av6 (Anton Shestakov)
av6 added inline comments.

INLINE COMMENTS

> state.py:151
> +'graft',
> +fname = 'graftstate',
> +clearable = True,

It's funny how Pulkit's comment is now at this line and looks like asking to 
add spaces around `=` here. But in this case `=` is not an operator, it's used 
to indicate keyword arguments. We don't want spaces around it (similarly to 
PEP8).

Bad:

  addunfinished(
  'graft',
  fname = 'graftstate',
  clearable = True,
  allowcommit = False,
  cmdhint = _("use 'hg graft --continue' or 'hg graft --stop' to stop")
  )

Good:

  addunfinished(
  'graft',
  fname='graftstate',
  clearable=True,
  allowcommit=False,
  cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
  )

Even better (as long as it fits into 79 characters per line):

  addunfinished(
  'graft', 'graftstate', clearable=True, allowcommit=False,
  cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
  )

There's a lot of places where this needs to be fixed in this series, not just 
here.

REPOSITORY
  rHG Mercurial

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

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

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