D6555: vfs: require use of .seek() or .write() before .tell() on append-mode files

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


  I worked around the same bug in Windows in platform.posixfile [1].  Should 
this be done in the posix layer (which is currently only an alias to `open()`)? 
 It looks like there are uses of posixfile outside of vfs.
  
  [1] https://www.mercurial-scm.org/repo/hg/file/tip/mercurial/windows.py#l161

REPOSITORY
  rHG Mercurial

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

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

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


D6564: copies: avoid reusing the same variable for two different copy dicts

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

REVISION SUMMARY
  "childcopies" is initally the copies the current changeset to one of
  its children and then we reassign it with the copies from the start of
  the chain to the child. Let's use different names for these two
  things.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -302,15 +302,15 @@
if match(dst)}
 # Copy the dict only if later iterations will also need it
 if i != len(children[r]) - 1:
-copies = copies.copy()
-if childcopies:
-childcopies = _chain(copies, childcopies)
+newcopies = copies.copy()
 else:
-childcopies = copies
+newcopies = copies
+if childcopies:
+newcopies = _chain(newcopies, childcopies)
 for f in childctx.filesremoved():
-if f in childcopies:
-del childcopies[f]
-heapq.heappush(work, (c, parent, childcopies))
+if f in newcopies:
+del newcopies[f]
+heapq.heappush(work, (c, parent, newcopies))
 assert False
 
 def _forwardcopies(a, b, match=None):



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


D6562: filemerge: make last line of prompts <40 english chars (issue6158)

2019-06-20 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I've chosen <40 as the target so that other languages that may have a 2x 
blowup
  in character count can still have a chance to fit into an 80 column screen.
  
  Previously, we would show a prompt like:
  
keep (l)ocal [dest], take (o)ther [source], or leave (u)nresolved for 
some/potentially/really/long/path?
  
  On at least some systems, if readline was in use then the last line of the
  prompt would be wrapped strangely if it couldn't fit entirely on one line. 
This
  strange wrapping may be just a carriage return without a line feed, 
overwriting
  the beginning of the line; example (100 columns wide, 65 character filename, 
and
  yes there's 10 spaces on the end, I assume this is to handle the user 
inputting
  longest word we provide as an option, "unresolved"):
  
ng/dir/name/that/does/not/work/well/with/readline/file.txt? ave 
(u)nresolved for some/lon
  
  In some cases it may partially wrap onto the next line, but still be missing
  earlier parts in the line, such as below (60 columns wide, 65 character
  filename):
  
 rev], or leave (u)nresolved for some/long/dir/name/that/do
s/not/work/well/with/readline/file.txt?
  
  With this fix, this looks like this on a 60 column screen:
  
tool vim_with_markers (for pattern some/long/dir/name/that/d
oes/not/work/well/with/readline/file.txt) can't handle binar
y
tool meld can't handle binary
tool vim_with_markers can't handle binary
tool internal:merge3 can't handle binary
tool merge can't handle binary
no tool found to merge some/long/dir/name/that/does/not/work
/well/with/readline/file.txt
file 'some/long/dir/name/that/does/not/work/well/with/readli
ne/file.txt' needs to be resolved.
You can keep (l)ocal [working copy], take (o)ther [merge rev
], or leave (u)nresolved.
What do you want to do?

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/filemerge.py
  tests/test-commit-amend.t
  tests/test-copy-move-merge.t
  tests/test-copytrace-heuristics.t
  tests/test-largefiles-update.t
  tests/test-lfconvert.t
  tests/test-merge-changedelete.t
  tests/test-merge-force.t
  tests/test-merge-remove.t
  tests/test-merge-subrepos.t
  tests/test-merge-tools.t
  tests/test-merge-types.t
  tests/test-rebase-newancestor.t
  tests/test-rename-merge2.t
  tests/test-resolve.t
  tests/test-sparse-merges.t

CHANGE DETAILS

diff --git a/tests/test-sparse-merges.t b/tests/test-sparse-merges.t
--- a/tests/test-sparse-merges.t
+++ b/tests/test-sparse-merges.t
@@ -114,8 +114,8 @@
   $ hg merge
   temporarily included 1 file(s) in the sparse checkout for merging
   file 'd' was deleted in other [merge rev] but was modified in local [working 
copy].
-  What do you want to do?
-  use (c)hanged version, (d)elete, or leave (u)nresolved? u
+  You can use (c)hanged version, (d)elete, or leave (u)nresolved.
+  What do you want to do? u
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to 
abandon
   [1]
diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -649,8 +649,8 @@
 
   $ hg merge -r 1
   file 'file1' was deleted in local [working copy] but was modified in other 
[merge rev].
-  What do you want to do?
-  use (c)hanged version, leave (d)eleted, or leave (u)nresolved? u
+  You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
+  What do you want to do? u
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to 
abandon
   [1]
@@ -678,8 +678,8 @@
   $ hg resolve --unmark file1
   $ echo 'd' | hg resolve file1 --config ui.interactive=1
   file 'file1' was deleted in local [working copy] but was modified in other 
[merge rev].
-  What do you want to do?
-  use (c)hanged version, leave (d)eleted, or leave (u)nresolved? d
+  You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
+  What do you want to do? d
   (no more unresolved files)
   $ hg resolve --list
   R file1
@@ -694,8 +694,8 @@
   $ hg resolve --unmark file1
   $ hg resolve file1
   file 'file1' was deleted in local [working copy] but was modified in other 
[merge rev].
-  What do you want to do?
-  use (c)hanged version, leave (d)eleted, or leave (u)nresolved? u
+  You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
+  What do you want to do? u
   [1]
   $ [ -f file1 ] || echo "File does not exist?"
   $ hg resolve --list
@@ -708,8 +708,8 @@
   $ hg resolve --unmark file1
   $ hg resolve file1
   file 'file1' was deleted in local [working copy] but was modified in other 
[merge rev].
-  What do you want to do?
-  use (c)hanged version, leave (d)eleted, or 

D6563: patch: use a short, fixed-size message for last line of prompt (issue6158)

2019-06-20 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  See issue6158 and the previous commit for examples of what might go wrong if 
we
  have some combinations of readline version and terminal and need to wrap the
  line.
  
  Briefly: readline may not display the beginning of the last line of the 
prompt,
  or it may print over it with the end of the prompt, making it difficult for
  users to know what's going on.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/patch.py
  tests/test-absorb.t
  tests/test-amend.t
  tests/test-commit-interactive.t
  tests/test-diff-color.t
  tests/test-editor-filename.t
  tests/test-keyword.t
  tests/test-mq-qrefresh-interactive.t
  tests/test-mq-subrepo.t
  tests/test-qrecord.t
  tests/test-revert-interactive.t
  tests/test-shelve.t
  tests/test-split.t

CHANGE DETAILS

diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -135,22 +135,26 @@
   $ HGEDITOR=false runsplit
   diff --git a/a b/a
   3 hunks, 3 lines changed
-  examine changes to 'a'? [Ynesfdaq?] y
+  examine changes to 'a'?
+  (enter ? for help) [Ynesfdaq?] y
   
   @@ -1,1 +1,1 @@
   -1
   +11
-  record change 1/3 to 'a'? [Ynesfdaq?] n
+  record change 1/3 to 'a'?
+  (enter ? for help) [Ynesfdaq?] n
   
   @@ -3,1 +3,1 @@ 2
   -3
   +33
-  record change 2/3 to 'a'? [Ynesfdaq?] n
+  record change 2/3 to 'a'?
+  (enter ? for help) [Ynesfdaq?] n
   
   @@ -5,1 +5,1 @@ 4
   -5
   +55
-  record change 3/3 to 'a'? [Ynesfdaq?] y
+  record change 3/3 to 'a'?
+  (enter ? for help) [Ynesfdaq?] y
   
   transaction abort!
   rollback completed
@@ -162,22 +166,26 @@
   $ runsplit
   diff --git a/a b/a
   3 hunks, 3 lines changed
-  examine changes to 'a'? [Ynesfdaq?] y
+  examine changes to 'a'?
+  (enter ? for help) [Ynesfdaq?] y
   
   @@ -1,1 +1,1 @@
   -1
   +11
-  record change 1/3 to 'a'? [Ynesfdaq?] n
+  record change 1/3 to 'a'?
+  (enter ? for help) [Ynesfdaq?] n
   
   @@ -3,1 +3,1 @@ 2
   -3
   +33
-  record change 2/3 to 'a'? [Ynesfdaq?] n
+  record change 2/3 to 'a'?
+  (enter ? for help) [Ynesfdaq?] n
   
   @@ -5,1 +5,1 @@ 4
   -5
   +55
-  record change 3/3 to 'a'? [Ynesfdaq?] y
+  record change 3/3 to 'a'?
+  (enter ? for help) [Ynesfdaq?] y
   
   EDITOR: HG: Splitting 1df0d5c5a3ab. Write commit message for the first split 
changeset.
   EDITOR: a2
@@ -192,17 +200,20 @@
   created new head
   diff --git a/a b/a
   2 hunks, 2 lines changed
-  examine changes to 'a'? [Ynesfdaq?] y
+  examine changes to 'a'?
+  (enter ? for help) [Ynesfdaq?] y
   
   @@ -1,1 +1,1 @@
   -1
   +11
-  record change 1/2 to 'a'? [Ynesfdaq?] n
+  record change 1/2 to 'a'?
+  (enter ? for help) [Ynesfdaq?] n
   
   @@ -3,1 +3,1 @@ 2
   -3
   +33
-  record change 2/2 to 'a'? [Ynesfdaq?] y
+  record change 2/2 to 'a'?
+  (enter ? for help) [Ynesfdaq?] y
   
   EDITOR: HG: Splitting 1df0d5c5a3ab. So far it has been split into:
   EDITOR: HG: - e704349bd21b: split 1
@@ -218,12 +229,14 @@
   EDITOR: HG: changed a
   diff --git a/a b/a
   1 hunks, 1 lines changed
-  examine changes to 'a'? [Ynesfdaq?] y
+  examine changes to 'a'?
+  (enter ? for help) [Ynesfdaq?] y
   
   @@ -1,1 +1,1 @@
   -1
   +11
-  record this change to 'a'? [Ynesfdaq?] y
+  record this change to 'a'?
+  (enter ? for help) [Ynesfdaq?] y
   
   EDITOR: HG: Splitting 1df0d5c5a3ab. So far it has been split into:
   EDITOR: HG: - e704349bd21b: split 1
@@ -515,12 +528,14 @@
   > EOF
   diff --git a/B b/B
   new file mode 100644
-  examine changes to 'B'? [Ynesfdaq?] y
+  examine changes to 'B'?
+  (enter ? for help) [Ynesfdaq?] y
   
   @@ -0,0 +1,1 @@
   +B
   \ No newline at end of file
-  record this change to 'B'? [Ynesfdaq?] y
+  record this change to 'B'?
+  (enter ? for help) [Ynesfdaq?] y
   
   EDITOR: HG: Splitting 112478962961. Write commit message for the first split 
changeset.
   EDITOR: B
@@ -621,11 +636,13 @@
   $ printf 'f\nn\nf\n' | hg --config extensions.split= --config 
diff.ignoreblanklines=1 split
   diff --git a/bar b/bar
   2 hunks, 2 lines changed
-  examine changes to 'bar'? [Ynesfdaq?] f
+  examine changes to 'bar'?
+  (enter ? for help) [Ynesfdaq?] f
   
   diff --git a/foo b/foo
   1 hunks, 1 lines changed
-  examine changes to 'foo'? [Ynesfdaq?] n
+  examine changes to 'foo'?
+  (enter ? for help) [Ynesfdaq?] n
   
   EDITOR: HG: Splitting dd3c45017cbf. Write commit message for the first split 
changeset.
   EDITOR: splitme
@@ -640,7 +657,8 @@
   created new head
   diff --git a/foo b/foo
   1 hunks, 1 lines changed
-  examine changes to 'foo'? [Ynesfdaq?] f
+  examine changes to 'foo'?
+  (enter ? for help) [Ynesfdaq?] f
   
   EDITOR: HG: Splitting dd3c45017cbf. So far it has been split into:
   EDITOR: HG: - f205aea1c624: split 1
@@ -675,11 +693,13 @@
   $ printf 'f\nn\nf\n' | hg --config extensions.split= --config 
diff.ignoreblanklines=1 

D6561: copies: simplify merging of copy dicts on merge commits

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

REVISION SUMMARY
  After we removed some filtering in 35d674a3d5db 
 
(copies: don't filter
  out copy targets created on other side of merge commit, 2019-04-18),
  we will always include all entries from "copies1", so we can simplify
  the code based on that.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -272,25 +272,19 @@
 heapq.heapify(work)
 alwaysmatch = match.always()
 while work:
-r, i1, copies1 = heapq.heappop(work)
+r, i1, copies = heapq.heappop(work)
 if work and work[0][0] == r:
 # We are tracing copies from both parents
 r, i2, copies2 = heapq.heappop(work)
-copies = {}
-allcopies = set(copies1) | set(copies2)
-for dst in allcopies:
+for dst, src in copies2.items():
 # Unlike when copies are stored in the filelog, we consider
 # it a copy even if the destination already existed on the
 # other branch. It's simply too expensive to check if the
 # file existed in the manifest.
-if dst in copies1:
-# If it was copied on the p1 side, mark it as copied from
+if dst not in copies:
+# If it was copied on the p1 side, leave it as copied from
 # that side, even if it was also copied on the p2 side.
-copies[dst] = copies1[dst]
-else:
 copies[dst] = copies2[dst]
-else:
-copies = copies1
 if r == b.rev():
 _filter(a, b, copies)
 return copies



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


D6560: copies: remove a redundant matcher filtering in _changesetforwardcopies()

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

REVISION SUMMARY
  We filter before pushing items on the queue, so we don't need to
  filter after popping.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -279,8 +279,6 @@
 copies = {}
 allcopies = set(copies1) | set(copies2)
 for dst in allcopies:
-if not alwaysmatch and not match(dst):
-continue
 # Unlike when copies are stored in the filelog, we consider
 # it a copy even if the destination already existed on the
 # other branch. It's simply too expensive to check if the



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


D6559: copies: delete obsolete comment in _changesetforwardcopies()

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

REVISION SUMMARY
  IIRC, the comment applied to the filtering we did before 35d674a3d5db 

  (copies: don't filter out copy targets created on other side of merge
  commit, 2019-04-18).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -278,8 +278,6 @@
 r, i2, copies2 = heapq.heappop(work)
 copies = {}
 allcopies = set(copies1) | set(copies2)
-# TODO: perhaps this filtering should be done as long as ctx
-# is merge, whether or not we're tracing from both parent.
 for dst in allcopies:
 if not alwaysmatch and not match(dst):
 continue



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


[Bug 6160] New: "hg merge --abort" uncleanly aborts an in-progress unshelve

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

Bug ID: 6160
   Summary: "hg merge --abort" uncleanly aborts an in-progress
unshelve
   Product: Mercurial
   Version: 5.0
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: shelve
  Assignee: bugzi...@mercurial-scm.org
  Reporter: mplam...@janestreet.com
CC: mercurial-devel@mercurial-scm.org

Created attachment 2052
  --> https://bz.mercurial-scm.org/attachment.cgi?id=2052=edit
A test demonstrating the bug

If an "hg unshelve" is in-progress and you run
  $ hg merge --abort
this aborts the merge portion of the in-progress unshelve, but the unshelve is
still in-progress -- many hg commands still return "abort: unshelve already in
progress".

But then, aborting the unshelve fails:
  $ hg unshelve --abort
  unshelve of 'default' aborted
  abort: working directory parents do not match unshelve state

The working directory is still at the "pending changes temporary commit"
created by the unshelve. From here, it's easy to accidentally create more
commits on top of this temporary commit.

In this situation, I would expect "hg merge --abort" to fail, directing the
user to use "hg unshelve --abort".

See the attachment for a test demonstrating this bug.

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


[Bug 6159] New: hg pushes bookmarks pointing to secret revisions

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

Bug ID: 6159
   Summary: hg pushes bookmarks pointing to secret revisions
   Product: Mercurial
   Version: 5.0
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: bookmarks
  Assignee: bugzi...@mercurial-scm.org
  Reporter: mplam...@janestreet.com
CC: mercurial-devel@mercurial-scm.org

Created attachment 2051
  --> https://bz.mercurial-scm.org/attachment.cgi?id=2051=edit
A unified test demonstrating the bug

If a repo has a bookmark "some-bookmark" pointing to a secret changeset,
running "hg push -r some-bookmark" will push that bookmark, but not the
changeset referenced by that bookmark.

This leaves the server's bookmarks in a bad state, because that bookmark now
points to a revision that does not exist on the server.

See the attachment for a test demonstrating this bug (tested against hg 5.0.1).

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


[Bug 6158] New: readline may wrap prompts poorly

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

Bug ID: 6158
   Summary: readline may wrap prompts poorly
   Product: Mercurial
   Version: unspecified
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: h...@pewpew.net
CC: mercurial-devel@mercurial-scm.org

Some combination of readline version (I'm using libreadline7) and terminal (I'm
using rxvt-unicode, but users of gnome-terminal have also reported issues) may
poorly wrap the last line of the prompt we pass to readline. Here's an example
on a 60-column-wide window:

```
tool vim_with_markers (for pattern some/long/dir/name/that/d
oes/not/work/well/with/readline/file.txt) can't handle binar
y
tool meld can't handle binary
tool vim_with_markers can't handle binary
tool internal:merge3 can't handle binary
tool merge can't handle binary
no tool found to merge some/long/dir/name/that/does/not/work
/well/with/readline/file.txt
 rev], or leave (u)nresolved for some/long/dir/name/that/do
s/not/work/well/with/readline/file.txt?
```

Originally, that prompt was supposed to be:

```
tool vim_with_markers (for pattern
some/long/dir/name/that/does/not/work/well/with/readline/file.txt) can't handle
binary
tool meld can't handle binary
tool vim_with_markers can't handle binary
tool internal:merge3 can't handle binary
tool merge can't handle binary
no tool found to merge
some/long/dir/name/that/does/not/work/well/with/readline/file.txt
keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved
for some/long/dir/name/that/does/not/work/well/with/readline/file.txt
```

I'm planning on working on a fix.

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


D6558: cmdutil: updated description for bailifchanged()

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

REVISION SUMMARY
  This is added to establish a connection between `statemod.checkunfinished()`
  and `bailifchanged()`.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -787,6 +787,9 @@
 ignored (such as when 'update --check' runs).
 
 'hint' is the usual hint given to Abort exception.
+
+It's probably good to check statemod.checkunfinished() right before
+this.
 """
 
 if merge and repo.dirstate.p2() != nullid:



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


D6553: shelve: move shelve extension to core

2019-06-20 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 15621.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6553?vs=15616=15621

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

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

AFFECTED FILES
  contrib/win32/mercurial.ini
  hgext/shelve.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/configitems.py
  mercurial/shelve.py
  mercurial/ui.py
  tests/test-bookflow.t
  tests/test-completion.t
  tests/test-copytrace-heuristics.t
  tests/test-globalopts.t
  tests/test-help-hide.t
  tests/test-help.t
  tests/test-hgweb-json.t
  tests/test-keyword.t
  tests/test-shelve.t
  tests/test-shelve2.t
  tests/test-treemanifest.t

CHANGE DETAILS

diff --git a/tests/test-treemanifest.t b/tests/test-treemanifest.t
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -357,10 +357,10 @@
 Shelving and unshelving should work
 
   $ echo foo >> dir1/a
-  $ hg --config extensions.shelve= shelve
+  $ hg shelve
   shelved as default
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg --config extensions.shelve= unshelve
+  $ hg unshelve
   unshelving change 'default'
   $ hg diff --nodates
   diff -r 708a273da119 dir1/a
diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -3,7 +3,6 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > mq =
-  > shelve =
   > [defaults]
   > diff = --nodates --git
   > qnew = --date '0 0'
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -3,7 +3,6 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > mq =
-  > shelve =
   > [defaults]
   > diff = --nodates --git
   > qnew = --date '0 0'
@@ -65,8 +64,6 @@
   To delete specific shelved changes, use "--delete". To delete all shelved
   changes, use "--cleanup".
   
-  (use 'hg help -e shelve' to show help for the shelve extension)
-  
   options ([+] can be repeated):
   
-A --addremove   mark new/missing files as added/removed before
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -1248,11 +1248,6 @@
 
 Test restricted mode with unshelve
 
-  $ cat <> $HGRCPATH
-  > [extensions]
-  > shelve =
-  > EOF
-
   $ echo  >> a
   $ hg diff
   diff -r 800511b3a22d a
diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -2057,6 +2057,10 @@
 "topic": "root"
   },
   {
+"summary": "save and set aside changes from the working directory",
+"topic": "shelve"
+  },
+  {
 "summary": "add one or more tags for the current or given revision",
 "topic": "tag"
   },
@@ -2069,6 +2073,10 @@
 "topic": "unbundle"
   },
   {
+"summary": "restore a shelved change to the working directory",
+"topic": "unshelve"
+  },
+  {
 "summary": "verify the integrity of the repository",
 "topic": "verify"
   },
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -112,8 +112,10 @@
resolve   redo merges or set/view the merge status of files
revertrestore files to their checkout state
root  print the root (top) of the current working directory
+   shelvesave and set aside changes from the working directory
statusshow changed files in the working directory
summary   summarize working directory state
+   unshelve  restore a shelved change to the working directory
updateupdate working directory (or switch revisions)
   
   Change import/export:
@@ -238,8 +240,10 @@
resolve   redo merges or set/view the merge status of files
revertrestore files to their checkout state
root  print the root (top) of the current working directory
+   shelvesave and set aside changes from the working directory
statusshow changed files in the working directory
summary   summarize working directory state
+   unshelve  restore a shelved change to the working directory
updateupdate working directory (or switch revisions)
   
   Change import/export:
@@ -375,7 +379,6 @@
relinkrecreates hardlinks between repository clones
schemes   extend schemes with shortcuts to repository swarms
share share a common history between several working directories
-   shelvesave and restore changes to the working directory
strip strip changesets and their descendants from history
transplantcommand to transplant changesets from another branch
win32mbcs allow the use of MBCS paths with problematic encodings
@@ -2690,6 +2693,13 @@
   (no help text available)
   
   
+  
+  shelve
+  
+  
+  save and set 

D6501: state: created new class statecheck to handle unfinishedstates

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


  @martinvonz relnotes/next have been updated in D6557 
.

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


D6557: relnotes: added description about statemod._statecheck

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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -54,3 +54,17 @@
 
  * `util.dirs()` and `util.finddirs()` now include an entry for the
root directory (empty string).
+
+ * New API to manage unfinished operations: Earlier there were distinct APIs
+   which dealt with unfinished states and separate lists maintaining them.
+   eg:`cmdutil.afterresolvestates`, `cmdutil.unfinishedstates` and
+   `cmdutil.STATES`. Now these have been unified to a single
+   API which handles the various states and their utilities.This API
+   has been added to `state.py` and is form of class called `_statecheck`.
+   To register a new state for an operation you need to add a `_statecheck`
+   object with necessary information to `_unfinishedstates` list.
+   The method of registration of a `_statecheck` object into 
`_unfinishedstates`
+   is not direct but through `addunfinished()`. The data needed for various
+   operations to be registered under `_unfinishedstates` list is stated in
+   `_statecheck` class.
+



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


D6554: cleanup: always `seek(0, io.SEEK_END)` after open in append mode before tell()

2019-06-20 Thread durin42 (Augie Fackler)
durin42 added a comment.


  Note that I mailed 
 
a version to the list for stable. This doesn't quite cleanly apply there, so I 
made the change twice so I could write the next change without waiting for a 
merge.

REPOSITORY
  rHG Mercurial

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

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

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


D6556: cleanup: use named constants for second arg to .seek()

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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/fastannotate/revmap.py
  mercurial/revlog.py
  mercurial/tags.py

CHANGE DETAILS

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -563,7 +563,7 @@
 " branch name\n") % name)
 
 def writetags(fp, names, munge, prevtags):
-fp.seek(0, 2)
+fp.seek(0, io.SEEK_END)
 if prevtags and not prevtags.endswith('\n'):
 fp.write('\n')
 for name in names:
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -16,6 +16,7 @@
 import collections
 import contextlib
 import errno
+import io
 import os
 import struct
 import zlib
@@ -2306,7 +2307,7 @@
 
 try:
 with self._datafp() as f:
-f.seek(0, 2)
+f.seek(0, io.SEEK_END)
 actual = f.tell()
 dd = actual - expected
 except IOError as inst:
@@ -2316,7 +2317,7 @@
 
 try:
 f = self.opener(self.indexfile)
-f.seek(0, 2)
+f.seek(0, io.SEEK_END)
 actual = f.tell()
 f.close()
 s = self._io.size
diff --git a/hgext/fastannotate/revmap.py b/hgext/fastannotate/revmap.py
--- a/hgext/fastannotate/revmap.py
+++ b/hgext/fastannotate/revmap.py
@@ -8,6 +8,7 @@
 from __future__ import absolute_import
 
 import bisect
+import io
 import os
 import struct
 
@@ -246,7 +247,7 @@
 hsh = None
 try:
 with open(path, 'rb') as f:
-f.seek(-_hshlen, 2)
+f.seek(-_hshlen, io.SEEK_END)
 if f.tell() > len(revmap.HEADER):
 hsh = f.read(_hshlen)
 except IOError:



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


[PATCH STABLE] cleanup: always `seek(0, io.SEEK_END)` after open in append mode before tell()

2019-06-20 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1561049708 14400
#  Thu Jun 20 12:55:08 2019 -0400
# Branch stable
# Node ID e99fa717419b71a2493fd7211cab5a0de9c86c7c
# Parent  b6387a65851d4421d5580b1a4db4c55366a94ec8
cleanup: always `seek(0, io.SEEK_END)` after open in append mode before tell()

Consider the program:

#include 

int main() {
  FILE *f = fopen("narf", "w");
  fprintf(f, "narf\n");
  fclose(f);

  f = fopen("narf", "a");
  printf("%ld\n", ftell(f));
  fprintf(f, "troz\n");
  printf("%ld\n", ftell(f));

  return 0;
}

on macOS, FreeBSD, and Linux with glibc, this program prints

5
10

but on musl libc (Alpine Linux and probably others) this prints

0
10

By my reading of
https://pubs.opengroup.org/onlinepubs/009695399/functions/fopen.html
this is technically correct, specifically:

> Opening a file with append mode (a as the first character in the
> mode argument) shall cause all subsequent writes to the file to be
> forced to the then current end-of-file, regardless of intervening
> calls to fseek().

in other words, the file position doesn't really matter in append-mode
files, and we can't depend on it being at all meaningful unless we
perform a seek() before tell() after open(..., 'a'). Experimentally
after a .write() we can do a .tell() and it'll always be reasonable,
but I'm unclear from reading the specification if that's a smart thing
to rely on.

I audited the callsites matching the regular expression
`(open|vfs)\([^,]+, ['"]a` manually. It's possible I missed something
if I overlooked some other idiom for opening files.

This is a simple fix for the stable branch. We'll do a more
comprehensive fix on default.

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -7,6 +7,7 @@
 
 from __future__ import absolute_import
 
+import io
 import struct
 
 from .node import (
@@ -613,6 +614,7 @@ class revbranchcache(object):
 wlock = repo.wlock(wait=False)
 if self._rbcnamescount != 0:
 f = repo.cachevfs.open(_rbcnames, 'ab')
+f.seek(0, io.SEEK_END)
 if f.tell() == self._rbcsnameslen:
 f.write('\0')
 else:
@@ -638,6 +640,7 @@ class revbranchcache(object):
 revs = min(len(repo.changelog),
len(self._rbcrevs) // _rbcrecsize)
 f = repo.cachevfs.open(_rbcrevs, 'ab')
+f.seek(0, io.SEEK_END)
 if f.tell() != start:
 repo.ui.debug("truncating cache/%s to %d\n"
   % (_rbcrevs, start))
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -71,6 +71,7 @@ from __future__ import absolute_import
 
 import errno
 import hashlib
+import io
 import struct
 
 from .i18n import _
@@ -634,6 +635,7 @@ class obsstore(object):
 new.append(m)
 if new:
 f = self.svfs('obsstore', 'ab')
+f.seek(0, io.SEEK_END)
 try:
 offset = f.tell()
 transaction.add('obsstore', offset)
diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -13,6 +13,7 @@
 from __future__ import absolute_import
 
 import errno
+import io
 
 from .node import (
 bin,
@@ -582,6 +583,7 @@ def _tag(repo, names, node, message, loc
 fp = repo.vfs('localtags', 'r+')
 except IOError:
 fp = repo.vfs('localtags', 'a')
+fp.seek(0, io.SEEK_END)
 else:
 prevtags = fp.read()
 
@@ -597,6 +599,7 @@ def _tag(repo, names, node, message, loc
 if e.errno != errno.ENOENT:
 raise
 fp = repo.wvfs('.hgtags', 'ab')
+fp.seek(0, io.SEEK_END)
 else:
 prevtags = fp.read()
 
@@ -767,6 +770,7 @@ class hgtagsfnodescache(object):
 
 try:
 f = repo.cachevfs.open(_fnodescachefile, 'ab')
+f.seek(0, io.SEEK_END)
 try:
 # if the file has been truncated
 actualoffset = f.tell()
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6554: cleanup: always `seek(0, io.SEEK_END)` after open in append mode before tell()

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

REVISION SUMMARY
  Consider the program:
  
#include 

int main() {
  FILE *f = fopen("narf", "w");
  fprintf(f, "narf\n");
  fclose(f);

  f = fopen("narf", "a");
  printf("%ld\n", ftell(f));
  fprintf(f, "troz\n");
  printf("%ld\n", ftell(f));

  return 0;
}
  
  on macOS, FreeBSD, and Linux with glibc, this program prints
  
5
10
  
  but on musl libc (Alpine Linux and probably others) this prints
  
0
10
  
  By my reading of
  https://pubs.opengroup.org/onlinepubs/009695399/functions/fopen.html
  this is technically correct, specifically:
  
  > Opening a file with append mode (a as the first character in the
  > mode argument) shall cause all subsequent writes to the file to be
  > forced to the then current end-of-file, regardless of intervening
  > calls to fseek().
  
  in other words, the file position doesn't really matter in append-mode
  files, and we can't depend on it being at all meaningful unless we
  perform a seek() before tell() after open(..., 'a'). Experimentally
  after a .write() we can do a .tell() and it'll always be reasonable,
  but I'm unclear from reading the specification if that's a smart thing
  to rely on.
  
  These callsites were identified by applying the next changeset and
  then fixing new crashes.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/branchmap.py
  mercurial/obsolete.py
  mercurial/tags.py

CHANGE DETAILS

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -13,6 +13,7 @@
 from __future__ import absolute_import
 
 import errno
+import io
 
 from .node import (
 bin,
@@ -584,6 +585,7 @@
 fp = repo.vfs('localtags', 'r+')
 except IOError:
 fp = repo.vfs('localtags', 'a')
+fp.seek(0, io.SEEK_END)
 else:
 prevtags = fp.read()
 
@@ -599,6 +601,7 @@
 if e.errno != errno.ENOENT:
 raise
 fp = repo.wvfs('.hgtags', 'ab')
+fp.seek(0, io.SEEK_END)
 else:
 prevtags = fp.read()
 
@@ -793,6 +796,7 @@
 
 try:
 f = repo.cachevfs.open(_fnodescachefile, 'ab')
+f.seek(0, io.SEEK_END)
 try:
 # if the file has been truncated
 actualoffset = f.tell()
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -71,6 +71,7 @@
 
 import errno
 import hashlib
+import io
 import struct
 
 from .i18n import _
@@ -625,6 +626,7 @@
 new.append(m)
 if new:
 f = self.svfs('obsstore', 'ab')
+f.seek(0, io.SEEK_END)
 try:
 offset = f.tell()
 transaction.add('obsstore', offset)
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -7,6 +7,7 @@
 
 from __future__ import absolute_import
 
+import io
 import struct
 
 from .node import (
@@ -640,6 +641,7 @@
 """ write the new branch names to revbranchcache """
 if self._rbcnamescount != 0:
 f = repo.cachevfs.open(_rbcnames, 'ab')
+f.seek(0, io.SEEK_END)
 if f.tell() == self._rbcsnameslen:
 f.write('\0')
 else:
@@ -661,6 +663,7 @@
 """ write the new revs to revbranchcache """
 revs = min(len(repo.changelog), len(self._rbcrevs) // _rbcrecsize)
 with repo.cachevfs.open(_rbcrevs, 'ab') as f:
+f.seek(0, io.SEEK_END)
 if f.tell() != start:
 repo.ui.debug("truncating cache/%s to %d\n" % (_rbcrevs, 
start))
 f.seek(start)



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


D6555: vfs: require use of .seek() or .write() before .tell() on append-mode files

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

REVISION SUMMARY
  This prevents the bug in the previous change, but avoids an extraneous
  seek() call in the common case when it's not required. My preference
  was to ban .seek() and .tell() entirely on append-mode files since
  they're potentially misleading, but our codebase doesn't make that
  easy. This is better than nothing.
  
  See the previous change for a detailed explanation of the bug we've
  observed in the wild.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/vfs.py

CHANGE DETAILS

diff --git a/mercurial/vfs.py b/mercurial/vfs.py
--- a/mercurial/vfs.py
+++ b/mercurial/vfs.py
@@ -303,6 +303,53 @@
 finally:
 vfs._backgroundfilecloser = None
 
+class _appendfileproxy(object):
+"""Proxy type to prevent .tell() before .seek() or .write() append files.
+
+Files opened for append aren't required to have a meaningful fpos
+after open, so we require a write or explicit seek before allowing
+.tell() on those files.
+"""
+def __init__(self, fp):
+object.__setattr__(self, r'_fp', fp)
+object.__setattr__(self, r'_tellok', False)
+
+def tell(self):
+if not self._tellok:
+raise error.ProgrammingError(
+'tell() on append-mode file requires write() or seek() first')
+return self._fp.tell()
+
+def seek(self, *args, **kwargs):
+object.__setattr__(self, r'_tellok', True)
+return self._fp.seek(*args, **kwargs)
+
+def write(self, *args, **kwargs):
+object.__setattr__(self, r'_tellok', True)
+return self._fp.write(*args, **kwargs)
+
+def __repr__(self):
+return r'<_appendfileproxy of %r>' % self._fp
+
+# __magic__ methods get looked up on the type, not the instance,
+# so we have to proxy __enter__ and __exit__ by hand.
+def __enter__(self):
+self._fp.__enter__()
+return self
+
+def __exit__(self, *args, **kwargs):
+self._fp.__exit__(*args, **kwargs)
+
+# proxy all other methods
+def __getattr__(self, attr):
+return getattr(self._fp, attr)
+
+def __setattr__(self, attr, value):
+return setattr(self._fp, attr, value)
+
+def __delattr__(self, attr):
+return delattr(self._fp, attr)
+
 class vfs(abstractvfs):
 '''Operate files relative to a base directory
 
@@ -441,7 +488,8 @@
   )
 
 fp = delayclosedfile(fp, self._backgroundfilecloser)
-
+if mode in ('a', 'ab'):
+return _appendfileproxy(fp)
 return fp
 
 def symlink(self, src, dst):



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


D6553: shelve: move shelve extension to core

2019-06-20 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Until now,`shelve` was bootstrapped as an extension. This patch adds
  `shelve` on core.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/shelve.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/configitems.py
  mercurial/shelve.py
  tests/test-shelve.t
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -3,7 +3,6 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > mq =
-  > shelve =
   > [defaults]
   > diff = --nodates --git
   > qnew = --date '0 0'
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -3,7 +3,6 @@
   $ cat <> $HGRCPATH
   > [extensions]
   > mq =
-  > shelve =
   > [defaults]
   > diff = --nodates --git
   > qnew = --date '0 0'
@@ -65,8 +64,6 @@
   To delete specific shelved changes, use "--delete". To delete all shelved
   changes, use "--cleanup".
   
-  (use 'hg help -e shelve' to show help for the shelve extension)
-  
   options ([+] can be repeated):
   
-A --addremove   mark new/missing files as added/removed before
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
new file mode 100644
--- /dev/null
+++ b/mercurial/shelve.py
@@ -0,0 +1,971 @@
+# shelve.py - save/restore working directory state
+#
+# Copyright 2013 Facebook, Inc.
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+"""save and restore changes to the working directory
+
+The "hg shelve" command saves changes made to the working directory
+and reverts those changes, resetting the working directory to a clean
+state.
+
+Later on, the "hg unshelve" command restores the changes saved by "hg
+shelve". Changes can be restored even after updating to a different
+parent, in which case Mercurial's merge machinery will resolve any
+conflicts if necessary.
+
+You can have more than one shelved change outstanding at a time; each
+shelved change has a distinct name. For details, see the help for "hg
+shelve".
+"""
+from __future__ import absolute_import
+
+import collections
+import errno
+import itertools
+import stat
+
+from .i18n import _
+from . import (
+bookmarks,
+bundle2,
+bundlerepo,
+changegroup,
+cmdutil,
+discovery,
+error,
+exchange,
+hg,
+lock as lockmod,
+mdiff,
+merge,
+node as nodemod,
+patch,
+phases,
+pycompat,
+registrar,
+repair,
+scmutil,
+templatefilters,
+util,
+vfs as vfsmod,
+)
+
+from hgext import (
+rebase,
+)
+from .utils import (
+dateutil,
+stringutil,
+)
+
+backupdir = 'shelve-backup'
+shelvedir = 'shelved'
+shelvefileextensions = ['hg', 'patch', 'shelve']
+# universal extension is present in all types of shelves
+patchextension = 'patch'
+
+# we never need the user, so we use a
+# generic user for all shelve operations
+shelveuser = 'shelve@localhost'
+
+class shelvedfile(object):
+"""Helper for the file storing a single shelve
+
+Handles common functions on shelve files (.hg/.patch) using
+the vfs layer"""
+def __init__(self, repo, name, filetype=None):
+self.repo = repo
+self.name = name
+self.vfs = vfsmod.vfs(repo.vfs.join(shelvedir))
+self.backupvfs = vfsmod.vfs(repo.vfs.join(backupdir))
+self.ui = self.repo.ui
+if filetype:
+self.fname = name + '.' + filetype
+else:
+self.fname = name
+
+def exists(self):
+return self.vfs.exists(self.fname)
+
+def filename(self):
+return self.vfs.join(self.fname)
+
+def backupfilename(self):
+def gennames(base):
+yield base
+base, ext = base.rsplit('.', 1)
+for i in itertools.count(1):
+yield '%s-%d.%s' % (base, i, ext)
+
+name = self.backupvfs.join(self.fname)
+for n in gennames(name):
+if not self.backupvfs.exists(n):
+return n
+
+def movetobackup(self):
+if not self.backupvfs.isdir():
+self.backupvfs.makedir()
+util.rename(self.filename(), self.backupfilename())
+
+def stat(self):
+return self.vfs.stat(self.fname)
+
+def opener(self, mode='rb'):
+try:
+return self.vfs(self.fname, mode)
+except IOError as err:
+if err.errno != errno.ENOENT:
+raise
+raise error.Abort(_("shelved change '%s' not found") % self.name)
+
+def applybundle(self, tr):
+fp = self.opener()
+try:
+targetphase = phases.internal
+if not phases.supportinternal(self.repo):
+targetphase = phases.secret
+   

D6552: statecheck: added support for cmdutil.afterresolvedstates

2019-06-20 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15615.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6552?vs=15612=15615

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

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

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
@@ -98,8 +98,8 @@
 """
 
 def __init__(self, opname, fname, clearable=False, allowcommit=False,
- reportonly=False, cmdmsg="", cmdhint="", statushint="",
- stopflag=False):
+ reportonly=False, doesnotcontinue=False, 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.
@@ -111,6 +111,8 @@
 reportonly flag is used for operations like bisect where we just
 need to detect the operation using 'hg status --verbose'
 cmdmsg is used to pass a different status message in case standard
+doesnotcontinue flag determines whether a command supports `--continue`
+option or not.
 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 "To continue: hg cmdname --continue
@@ -132,6 +134,7 @@
 self._cmdmsg = cmdmsg
 self._stopflag = stopflag
 self._reportonly = reportonly
+self._doesnotcontinue = doesnotcontinue
 
 def statusmsg(self):
 """returns the hint message corresponding to the command for
@@ -162,6 +165,10 @@
 return _('%s in progress') % (self._opname)
 return self._cmdmsg
 
+def continuemsg(self):
+""" returns appropriate continue message corresponding to command"""
+return _('hg %s --continue') % (self._opname)
+
 def isunfinished(self, repo):
 """determines whether a multi-step operation is in progress
 or not
@@ -188,19 +195,20 @@
 cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop"),
 )
 addunfinished(
-'update', fname='updatestate', clearable=True,
+'update', fname='updatestate', clearable=True, doesnotcontinue=True,
 cmdmsg=_('last update was interrupted'),
 cmdhint=_("use 'hg update' to get a consistent checkout"),
 statushint=_("To continue:hg update")
 )
 addunfinished(
 'bisect', fname='bisect.state', allowcommit=True, reportonly=True,
+doesnotcontinue=True,
 statushint=_('To mark the changeset good:hg bisect --good\n'
  'To mark the changeset bad: hg bisect --bad\n'
  'To abort:  hg bisect --reset\n')
 )
 addunfinished(
-'merge', fname=None, clearable=True, allowcommit=True,
+'merge', fname=None, clearable=True, allowcommit=True, 
doesnotcontinue=True,
 cmdmsg=_('outstanding uncommitted merge'),
 statushint=_('To continue:hg commit\n'
  'To abort:   hg merge --abort'),
@@ -253,11 +261,6 @@
 if state.isunfinished(repo):
 return (state._opname, state.statusmsg())
 
-afterresolvedstates = [
-('graftstate',
- _('hg graft --continue')),
-]
-
 def howtocontinue(repo):
 '''Check for an unfinished operation and return the command to finish
 it.
@@ -269,9 +272,11 @@
 a boolean.
 '''
 contmsg = _("continue: %s")
-for f, msg in afterresolvedstates:
-if repo.vfs.exists(f):
-return contmsg % msg, True
+for state in _unfinishedstates:
+if state._doesnotcontinue:
+continue
+if state.isunfinished(repo):
+return contmsg % state.continuemsg(), True
 if repo[None].dirty(missing=True, merge=False, branch=False):
 return contmsg % _("hg commit"), False
 return None, None
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -760,6 +760,7 @@
 def extsetup(ui):
 statemod.addunfinished (
 'transplant', fname='transplant/journal', clearable=True,
+doesnotcontinue=True,
 statushint=_('To continue:hg transplant --continue\n'
  'To abort:   hg update'),
 cmdhint=_("use 'hg transplant --continue' or 'hg update' to abort")
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -1142,5 +1142,4 @@
 'unshelve', fname=shelvedstate._filename,
 cmdmsg=_('unshelve already in progress')
 )
-statemod.afterresolvedstates.append(
-[shelvedstate._filename, _('hg unshelve --continue')])
+
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- 

mercurial@42504: 7 new changesets

2019-06-20 Thread Mercurial Commits
7 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/089f14dd7df3
changeset:   42498:089f14dd7df3
user:Martin von Zweigbergk 
date:Tue Jun 18 08:55:23 2019 -0700
summary: relnotes: document template support for `hg root`

https://www.mercurial-scm.org/repo/hg/rev/f93762f251d2
changeset:   42499:f93762f251d2
user:Martin von Zweigbergk 
date:Wed Jun 19 11:12:06 2019 -0700
summary: remotefilelog: check if RFL is enabled in getrenamedfn() override

https://www.mercurial-scm.org/repo/hg/rev/e387cb22f6c0
changeset:   42500:e387cb22f6c0
user:Martin von Zweigbergk 
date:Wed Jun 19 10:33:13 2019 -0700
summary: remotefilelog: handle copies in changesets in getrenamedfn() 
override

https://www.mercurial-scm.org/repo/hg/rev/75334e5b519e
changeset:   42501:75334e5b519e
user:Martin von Zweigbergk 
date:Tue Jun 18 23:23:30 2019 -0700
summary: tests: demonstrate missing copy information in working copy with 
graphlog

https://www.mercurial-scm.org/repo/hg/rev/c929f612afac
changeset:   42502:c929f612afac
user:Martin von Zweigbergk 
date:Tue Jun 18 23:19:24 2019 -0700
summary: logcmdutil: also check for copies in null revision and working copy

https://www.mercurial-scm.org/repo/hg/rev/88ba0ff94605
changeset:   42503:88ba0ff94605
user:Martin von Zweigbergk 
date:Wed Jun 19 09:59:45 2019 -0700
summary: copies: create helper for getting all copies for changeset

https://www.mercurial-scm.org/repo/hg/rev/a68350a7fc55
changeset:   42504:a68350a7fc55
bookmark:@
tag: tip
user:Martin von Zweigbergk 
date:Wed Jun 19 10:19:32 2019 -0700
summary: log: pass getcopies() function instead of getrenamed() to 
displayer (API)

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


D6503: statecheck: added support for STATES

2019-06-20 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15614.

REPOSITORY
  rHG Mercurial

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

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-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,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-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -82,6 +82,7 @@
   
   # To continue:hg rebase --continue
   # To abort:   hg rebase --abort
+  # To stop:hg rebase --stop
   
 
 Try to continue without solving the conflict:
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=""):
+ reportonly=False, 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.
@@ -107,21 +108,49 @@
 state file.
 allowcommit boolean decides whether commit is allowed during 
interrupted
 state or not.
+reportonly flag is used for operations like bisect where we just
+need to detect the operation using 'hg status --verbose'
  

D6501: state: created new class statecheck to handle unfinishedstates

2019-06-20 Thread taapas1128 (Taapas Agrawal)
taapas1128 updated this revision to Diff 15613.

REPOSITORY
  rHG Mercurial

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

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):
-raise error.Abort(msg, hint=hint)
+if 

D6501: state: created new class statecheck to handle unfinishedstates

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

INLINE COMMENTS

> state.py:154
> +addunfinished(
> +'update',fname='updatestate', clearable=True,
> +cmdmsg=_('last update was interrupted'),

Add space before `fname`

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-20 Thread taapas1128 (Taapas Agrawal)
taapas1128 added inline comments.
taapas1128 marked an inline comment as done.

INLINE COMMENTS

> martinvonz wrote in rebase.py:1954-1955
> It seems like this should also be unified with the new tracking of unfinished 
> operations. Will you have time to look into that after the current series?

Yes sure have a look at D6551  , D6552 
.

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


D6551: state: moved cmdutil.afterresolvedstates to statemod

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

REVISION SUMMARY
  This commit moves `cmdutil.afterresolvedstates` and
  adjoining function to `state.py`. The existing users are
  updated accordingly.
  
  Tests remain unchanged.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/histedit.py
  hgext/rebase.py
  hgext/shelve.py
  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
@@ -252,3 +252,26 @@
 continue
 if state.isunfinished(repo):
 return (state._opname, state.statusmsg())
+
+afterresolvedstates = [
+('graftstate',
+ _('hg graft --continue')),
+]
+
+def howtocontinue(repo):
+'''Check for an unfinished operation and return the command to finish
+it.
+
+afterresolvedstates tuples define a .hg/{file} and the corresponding
+command needed to finish it.
+
+Returns a (msg, warning) tuple. 'msg' is a string and 'warning' is
+a boolean.
+'''
+contmsg = _("continue: %s")
+for f, msg in afterresolvedstates:
+if repo.vfs.exists(f):
+return contmsg % msg, True
+if repo[None].dirty(missing=True, merge=False, branch=False):
+return contmsg % _("hg commit"), False
+return None, None
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3258,29 +3258,6 @@
 #  - (desturl,   destbranch,   destpeer,   outgoing)
 summaryremotehooks = util.hooks()
 
-afterresolvedstates = [
-('graftstate',
- _('hg graft --continue')),
-]
-
-def howtocontinue(repo):
-'''Check for an unfinished operation and return the command to finish
-it.
-
-afterresolvedstates tuples define a .hg/{file} and the corresponding
-command needed to finish it.
-
-Returns a (msg, warning) tuple. 'msg' is a string and 'warning' is
-a boolean.
-'''
-contmsg = _("continue: %s")
-for f, msg in afterresolvedstates:
-if repo.vfs.exists(f):
-return contmsg % msg, True
-if repo[None].dirty(missing=True, merge=False, branch=False):
-return contmsg % _("hg commit"), False
-return None, None
-
 def checkafterresolved(repo):
 '''Inform the user about the next action after completing hg resolve
 
@@ -3289,7 +3266,7 @@
 
 Otherwise, it will yield repo.ui.note.
 '''
-msg, warning = howtocontinue(repo)
+msg, warning = statemod.howtocontinue(repo)
 if msg is not None:
 if warning:
 repo.ui.warn("%s\n" % msg)
@@ -3305,7 +3282,7 @@
 If there's no task (repo.ui.note for 'hg commit'), it does not offer
 a hint.
 '''
-after = howtocontinue(repo)
+after = statemod.howtocontinue(repo)
 hint = None
 if after[1]:
 hint = after[0]
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -1142,5 +1142,5 @@
 'unshelve', fname=shelvedstate._filename,
 cmdmsg=_('unshelve already in progress')
 )
-cmdutil.afterresolvedstates.append(
+statemod.afterresolvedstates.append(
 [shelvedstate._filename, _('hg unshelve --continue')])
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1951,5 +1951,5 @@
  _("specify merge tool for rebase")))
 cmdutil.summaryhooks.add('rebase', summaryhook)
 statemod.addunfinished('rebase', fname='rebasestate', stopflag=True)
-cmdutil.afterresolvedstates.append(
+statemod.afterresolvedstates.append(
 ['rebasestate', _('hg rebase --continue')])
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -2314,5 +2314,5 @@
 def extsetup(ui):
 cmdutil.summaryhooks.add('histedit', summaryhook)
 statemod.addunfinished('histedit', fname='histedit-state', 
allowcommit=True)
-cmdutil.afterresolvedstates.append(
+statemod.afterresolvedstates.append(
 ['histedit-state', _('hg histedit --continue')])



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


D6552: statecheck: added support for cmdutil.afterresolvedstates

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

REVISION SUMMARY
  This removes `afterresolvedstates` from `state.py` and adds
  support for it in `_statecheck` class.
  
  A new flag `doesnotcontinue` is added to the class to check whether an
  operation supports `--continue` option or not.
  
  Tests remain unchanged.

REPOSITORY
  rHG Mercurial

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

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
@@ -98,8 +98,8 @@
 """
 
 def __init__(self, opname, fname, clearable=False, allowcommit=False,
- reportonly=False, cmdmsg="", cmdhint="", statushint="",
- stopflag=False):
+ reportonly=False, doesnotcontinue=False, 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.
@@ -111,6 +111,8 @@
 reportonly flag is used for operations like bisect where we just
 need to detect the operation using 'hg status --verbose'
 cmdmsg is used to pass a different status message in case standard
+doesnotcontinue flag determines whether a command supports `--continue`
+option or not.
 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 "To continue: hg cmdname --continue
@@ -132,6 +134,7 @@
 self._cmdmsg = cmdmsg
 self._stopflag = stopflag
 self._reportonly = reportonly
+self._doesnotcontinue = doesnotcontinue
 
 def statusmsg(self):
 """returns the hint message corresponding to the command for
@@ -162,6 +165,10 @@
 return _('%s in progress') % (self._opname)
 return self._cmdmsg
 
+def continuemsg(self):
+""" returns appropriate continue message corresponding to command"""
+return _('hg %s --continue') % (self._opname)
+
 def isunfinished(self, repo):
 """determines whether a multi-step operation is in progress
 or not
@@ -188,19 +195,20 @@
 cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop"),
 )
 addunfinished(
-'update',fname='updatestate', clearable=True,
+'update',fname='updatestate', clearable=True, doesnotcontinue=True,
 cmdmsg=_('last update was interrupted'),
 cmdhint=_("use 'hg update' to get a consistent checkout"),
 statushint=_("To continue:hg update")
 )
 addunfinished(
 'bisect', fname='bisect.state', allowcommit=True, reportonly=True,
+doesnotcontinue=True,
 statushint=_('To mark the changeset good:hg bisect --good\n'
  'To mark the changeset bad: hg bisect --bad\n'
  'To abort:  hg bisect --reset\n')
 )
 addunfinished(
-'merge', fname=None, clearable=True, allowcommit=True,
+'merge', fname=None, clearable=True, allowcommit=True, 
doesnotcontinue=True,
 cmdmsg=_('outstanding uncommitted merge'),
 statushint=_('To continue:hg commit\n'
  'To abort:   hg merge --abort'),
@@ -253,11 +261,6 @@
 if state.isunfinished(repo):
 return (state._opname, state.statusmsg())
 
-afterresolvedstates = [
-('graftstate',
- _('hg graft --continue')),
-]
-
 def howtocontinue(repo):
 '''Check for an unfinished operation and return the command to finish
 it.
@@ -269,9 +272,11 @@
 a boolean.
 '''
 contmsg = _("continue: %s")
-for f, msg in afterresolvedstates:
-if repo.vfs.exists(f):
-return contmsg % msg, True
+for state in _unfinishedstates:
+if state._doesnotcontinue:
+continue
+if state.isunfinished(repo):
+return contmsg % state.continuemsg(), True
 if repo[None].dirty(missing=True, merge=False, branch=False):
 return contmsg % _("hg commit"), False
 return None, None
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -760,6 +760,7 @@
 def extsetup(ui):
 statemod.addunfinished (
 'transplant', fname='transplant/journal', clearable=True,
+doesnotcontinue=True,
 statushint=_('To continue:hg transplant --continue\n'
  'To abort:   hg update'),
 cmdhint=_("use 'hg transplant --continue' or 'hg update' to abort")
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -1142,5 +1142,4 @@