[Bug 6332] New: fold can create merge with ancestor

2020-05-18 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6332

Bug ID: 6332
   Summary: fold can create merge with ancestor
   Product: Mercurial
   Version: default branch
  Hardware: PC
OS: Mac OS
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: evolution
  Assignee: bugzi...@mercurial-scm.org
  Reporter: martinv...@google.com
CC: mercurial-devel@mercurial-scm.org,
pierre-yves.da...@ens-lyon.org
Python Version: ---

If you fold the merge commit with all the commits on one side, you'll get a
merge where one parent is an ancestor of the other. `hg merge` does not let you
do that, so it should probably be considered a bug that `hg fold` allows it.

The evolve tests did not detect the case because they used the null revision as
merge base, so the merge commit ended up having a commit and the null revision
as parents, which mercurial treats like a regular (non-merge) commit. If you
apply this diff:

```
diff --git a/tests/test-fold.t b/tests/test-fold.t
--- a/tests/test-fold.t
+++ b/tests/test-fold.t
@@ -316,9 +316,10 @@ One merge commit
   $ hg init fold-a-merge
   $ cd fold-a-merge

+  $ mkcommit root
   $ mkcommit zebra

-  $ hg up null
+  $ hg up 'desc("root")'
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ mkcommit apple
   $ mkcommit banana
```

Then the tests will fail with this hunk (among others):

```
@@ -362,9 +366,11 @@
   2 changesets folded
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg glf
-  @  6: apple+banana+coconut is a child of zebra (apple banana coconut)
-  |
-  o  0: zebra (zebra)
+  @7: apple+banana+coconut is a child of zebra (apple banana coconut)
+  |\
+  | o  1: zebra (zebra)
+  |/
+  o  0: root (root)
```

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


D8566: cleanup: use mergestate.unresolvedcount() instead of bool(list(unresolved()))

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This avoids some pointless copying.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/fix.py
  mercurial/commands.py
  mercurial/merge.py
  mercurial/mergeutil.py
  mercurial/shelve.py

CHANGE DETAILS

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -802,7 +802,7 @@
 with repo.lock():
 checkparents(repo, state)
 ms = repo[None].mergestate()
-if list(ms.unresolved()):
+if ms.unresolvedcount():
 raise error.Abort(
 _(b"unresolved conflicts, can't continue"),
 hint=_(b"see 'hg resolve', then 'hg unshelve --continue'"),
diff --git a/mercurial/mergeutil.py b/mercurial/mergeutil.py
--- a/mercurial/mergeutil.py
+++ b/mercurial/mergeutil.py
@@ -13,7 +13,7 @@
 
 
 def checkunresolved(ms):
-if list(ms.unresolved()):
+if ms.unresolvedcount():
 raise error.Abort(
 _(b"unresolved merge conflicts (see 'hg help resolve')")
 )
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1594,7 +1594,7 @@
 if len(pl) > 1:
 raise error.Abort(_(b"outstanding uncommitted merge"))
 ms = mergestatemod.mergestate.read(repo)
-if list(ms.unresolved()):
+if ms.unresolvedcount():
 raise error.Abort(
 _(b"outstanding merge conflicts"),
 hint=_(b"use 'hg resolve' to resolve"),
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6176,12 +6176,12 @@
 return 1
 
 # Nudge users into finishing an unfinished operation
-unresolvedf = list(ms.unresolved())
+unresolvedc = ms.unresolvedcount()
 driverresolvedf = list(ms.driverresolved())
-if not unresolvedf and not driverresolvedf:
+if not unresolvedc and not driverresolvedf:
 ui.status(_(b'(no more unresolved files)\n'))
 cmdutil.checkafterresolved(repo)
-elif not unresolvedf:
+elif not unresolvedc:
 ui.status(
 _(
 b'(no more unresolved files -- '
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -426,7 +426,7 @@
 if not (len(revs) == 1 and wdirrev in revs):
 cmdutil.checkunfinished(repo)
 rewriteutil.precheck(repo, revs, b'fix')
-if wdirrev in revs and list(repo[wdirrev].mergestate().unresolved()):
+if wdirrev in revs and repo[wdirrev].mergestate().unresolvedcount():
 raise error.Abort(b'unresolved conflicts', hint=b"use 'hg resolve'")
 if not revs:
 raise error.Abort(



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


D8570: rebase: use context to load mergestate instead of loading it directly

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: martinvonz.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -538,7 +538,7 @@
 user=ctx.user(),
 date=date,
 )
-mergestatemod.mergestate.clean(repo)
+self.wctx.mergestate(clean=True)
 else:
 newnode = commitnode(
 repo,



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


D8568: overlayworkingctx: implement mergestate() using in-memory mergestate

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will allow `hg fix` to use the mergestate() method without regressing.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2520,6 +2520,7 @@
 return len(self._cache) == 0
 
 def clean(self):
+self._mergestate = None
 self._cache = {}
 
 def _compact(self):
@@ -2580,6 +2581,11 @@
 self._repo, path, parent=self, filelog=filelog
 )
 
+def mergestate(self, clean=False):
+if clean or self._mergestate is None:
+self._mergestate = mergestatemod.memmergestate(self._repo)
+return self._mergestate
+
 
 class overlayworkingfilectx(committablefilectx):
 """Wrap a ``workingfilectx`` but intercepts all writes into an in-memory



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


D8569: merge: get mergestate from context instead of directly

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This causes `hg fix` (and probably others) to use the new in-memory mergestate
  object instead of the on-disk one, which may incidentally correct some
  defects.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1182,9 +1182,8 @@
 _prefetchfiles(repo, mctx, actions)
 
 updated, merged, removed = 0, 0, 0
-ms = mergestatemod.mergestate.clean(
-repo, wctx.p1().node(), mctx.node(), labels
-)
+ms = wctx.mergestate(clean=True)
+ms.reset(wctx.p1().node(), mctx.node(), labels)
 
 # add ACTION_GET_OTHER_AND_STORE to mergestate
 for e in actions[mergestatemod.ACTION_GET_OTHER_AND_STORE]:
@@ -1593,7 +1592,7 @@
 if not overwrite:
 if len(pl) > 1:
 raise error.Abort(_(b"outstanding uncommitted merge"))
-ms = mergestatemod.mergestate.read(repo)
+ms = wc.mergestate()
 if ms.unresolvedcount():
 raise error.Abort(
 _(b"outstanding merge conflicts"),



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


D8563: localrepo: get mergestate via context

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2466,7 +2466,7 @@
 ui.status(
 _(b'working directory now based on revision %d\n') % 
parents
 )
-mergestatemod.mergestate.clean(self, self[b'.'].node())
+self[None].mergestate(clean=True)
 
 # TODO: if we know which new heads may result from this rollback, pass
 # them to destroy(), which will prevent the branchhead cache from being
@@ -2865,7 +2865,7 @@
 fparent2 = nullid
 elif not fparentancestors:
 # TODO: this whole if-else might be simplified much more
-ms = mergestatemod.mergestate.read(self)
+ms = self[None].mergestate()
 if (
 fname in ms
 and ms[fname] == mergestatemod.MERGE_RECORD_MERGED_OTHER
@@ -2966,7 +2966,7 @@
 self, status, text, user, date, extra
 )
 
-ms = mergestatemod.mergestate.read(self)
+ms = self[None].mergestate()
 mergeutil.checkunresolved(ms)
 
 # internal config: ui.allowemptycommit



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


D8567: mergestate: implement trivial in-memory mergestate

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is the dumbest possible "mergestate" implementation: it doesn't actually
  handle conflict storage in the slightest, but for the current in-memory merge
  cases it works great, and prevents us from accidentally touching .hg/merge
  while doing non-wdir operations.
  
  NOT DONE: this breaks tests in future changes in the series, currently getting
  stuck on the "premerge()" method in the mergestate object.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/mergestate.py

CHANGE DETAILS

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -85,7 +85,40 @@
 }
 
 
-class mergestate(object):
+class _basemergestate(object):
+def __init__(self, repo):
+self._repo = repo
+self._readmergedriver = None
+
+@util.propertycache
+def mergedriver(self):
+# protect against the following:
+# - A configures a malicious merge driver in their hgrc, then
+#   pauses the merge
+# - A edits their hgrc to remove references to the merge driver
+# - A gives a copy of their entire repo, including .hg, to B
+# - B inspects .hgrc and finds it to be clean
+# - B then continues the merge and the malicious merge driver
+#  gets invoked
+configmergedriver = self._repo.ui.config(
+b'experimental', b'mergedriver'
+)
+if (
+self._readmergedriver is not None
+and self._readmergedriver != configmergedriver
+):
+raise error.ConfigError(
+_(b"merge driver changed since merge started"),
+hint=_(b"revert merge driver change or abort merge"),
+)
+
+return configmergedriver
+
+def reset(self, node=None, other=None, labels=None):
+self._readmergedriver = None
+
+
+class mergestate(_basemergestate):
 '''track 3-way merge state of individual files
 
 The merge state is stored on disk when needed. Two files are used: one with
@@ -154,11 +187,12 @@
 """Initialize the merge state.
 
 Do not use this directly! Instead call read() or clean()."""
-self._repo = repo
+super(mergestate, self).__init__(repo)
 self._dirty = False
 self._labels = None
 
 def reset(self, node=None, other=None, labels=None):
+super(mergestate, self).reset(node=node, other=other, labels=labels)
 self._state = {}
 self._stateextras = {}
 self._local = None
@@ -170,7 +204,6 @@
 if node:
 self._local = node
 self._other = other
-self._readmergedriver = None
 if self.mergedriver:
 self._mdstate = MERGE_DRIVER_STATE_SUCCESS
 else:
@@ -355,30 +388,6 @@
 return records
 
 @util.propertycache
-def mergedriver(self):
-# protect against the following:
-# - A configures a malicious merge driver in their hgrc, then
-#   pauses the merge
-# - A edits their hgrc to remove references to the merge driver
-# - A gives a copy of their entire repo, including .hg, to B
-# - B inspects .hgrc and finds it to be clean
-# - B then continues the merge and the malicious merge driver
-#  gets invoked
-configmergedriver = self._repo.ui.config(
-b'experimental', b'mergedriver'
-)
-if (
-self._readmergedriver is not None
-and self._readmergedriver != configmergedriver
-):
-raise error.ConfigError(
-_(b"merge driver changed since merge started"),
-hint=_(b"revert merge driver change or abort merge"),
-)
-
-return configmergedriver
-
-@util.propertycache
 def local(self):
 if self._local is None:
 msg = b"local accessed but self._local isn't set"
@@ -857,3 +866,35 @@
 repo.dirstate.copy(f0, f)
 else:
 repo.dirstate.normal(f)
+
+
+class memmergestate(_basemergestate):
+def __init__(self, repo):
+super(memmergestate, self).__init__(repo)
+self.reset()
+
+def add(self, fcl, fco, fca, fd):
+"""add a new (potentially?) conflicting file to the merge state"""
+self._conflicts.add(fcl.path())
+
+# Since memmergestate isn't mutable yet, these are all trivial
+# implementations used by the "happy path" in merge code.
+def reset(self, node=None, other=None, labels=None):
+super(memmergestate, self).reset(node=node, other=other, labels=labels)
+self._conflicts = set()
+
+def commit(self):
+if self._conflicts:
+error.InMemoryMergeConflictsError(
+'cannot commit memmergestate wit

D8565: mergestate: optimize unresolvedcount() a little bit

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  It struck me as wasteful to make this extra list copy of a generator. I was
  hoping to manage to return a bool instead of an int (and thus avoid traversing
  the dictionary past the first unresolved entry) but at least one caller cares
  about the count and this is the easy way forward while still making me
  marginally happier.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/mergestate.py

CHANGE DETAILS

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -79,6 +79,12 @@
 ACTION_GET_OTHER_AND_STORE = b'gs'
 
 
+_MERGE_UNRESOLVED_STATES = {
+MERGE_RECORD_UNRESOLVED,
+MERGE_RECORD_UNRESOLVED_PATH,
+}
+
+
 class mergestate(object):
 '''track 3-way merge state of individual files
 
@@ -569,10 +575,7 @@
 """Obtain the paths of unresolved files."""
 
 for f, entry in pycompat.iteritems(self._state):
-if entry[0] in (
-MERGE_RECORD_UNRESOLVED,
-MERGE_RECORD_UNRESOLVED_PATH,
-):
+if entry[0] in _MERGE_UNRESOLVED_STATES:
 yield f
 
 def driverresolved(self):
@@ -713,7 +716,13 @@
 
 def unresolvedcount(self):
 """get unresolved count for this merge (persistent)"""
-return len(list(self.unresolved()))
+return len(
+[
+None
+for entry in pycompat.itervalues(self._state)
+if entry[0] in _MERGE_UNRESOLVED_STATES
+]
+)
 
 def actions(self):
 """return lists of actions to perform on the dirstate"""



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


D8564: fakemergerecord: get mergestate via context

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/fakemergerecord.py

CHANGE DETAILS

diff --git a/tests/fakemergerecord.py b/tests/fakemergerecord.py
--- a/tests/fakemergerecord.py
+++ b/tests/fakemergerecord.py
@@ -4,10 +4,7 @@
 
 from __future__ import absolute_import
 
-from mercurial import (
-mergestate as mergestatemod,
-registrar,
-)
+from mercurial import registrar
 
 cmdtable = {}
 command = registrar.command(cmdtable)
@@ -23,7 +20,7 @@
 )
 def fakemergerecord(ui, repo, *pats, **opts):
 with repo.wlock():
-ms = mergestatemod.mergestate.read(repo)
+ms = repo[None].mergestate()
 records = ms._makerecords()
 if opts.get('mandatory'):
 records.append((b'X', b'mandatory record'))



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


D8562: shelve: get mergestate via context

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/shelve.py

CHANGE DETAILS

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -42,7 +42,6 @@
 lock as lockmod,
 mdiff,
 merge,
-mergestate as mergestatemod,
 node as nodemod,
 patch,
 phases,
@@ -802,7 +801,7 @@
 basename = state.name
 with repo.lock():
 checkparents(repo, state)
-ms = mergestatemod.mergestate.read(repo)
+ms = repo[None].mergestate()
 if list(ms.unresolved()):
 raise error.Abort(
 _(b"unresolved conflicts, can't continue"),



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


D8561: hg: get mergestate via context

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/hg.py

CHANGE DETAILS

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -33,7 +33,6 @@
 logcmdutil,
 logexchange,
 merge as mergemod,
-mergestate as mergestatemod,
 narrowspec,
 node,
 phases,
@@ -1165,7 +1164,7 @@
 
 
 def abortmerge(ui, repo):
-ms = mergestatemod.mergestate.read(repo)
+ms = repo[None].mergestate()
 if ms.active():
 # there were conflicts
 node = ms.localctx.hex()



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


D8556: commands: get mergestate via context

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5939,7 +5939,7 @@
 if show:
 ui.pager(b'resolve')
 fm = ui.formatter(b'resolve', opts)
-ms = mergestatemod.mergestate.read(repo)
+ms = repo[None].mergestate()
 wctx = repo[None]
 m = scmutil.match(wctx, pats, opts)
 
@@ -5982,7 +5982,7 @@
 return 0
 
 with repo.wlock():
-ms = mergestatemod.mergestate.read(repo)
+ms = repo[None].mergestate()
 
 if not (ms.active() or repo.dirstate.p2() != nullid):
 raise error.Abort(
@@ -6949,7 +6949,7 @@
 marks = []
 
 try:
-ms = mergestatemod.mergestate.read(repo)
+ms = repo[None].mergestate()
 except error.UnsupportedMergeRecords as e:
 s = b' '.join(e.recordtypes)
 ui.warn(



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


D8559: revset: get mergestate via context

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Happily, this resolves an import cycle!

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revset.py

CHANGE DETAILS

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -789,9 +789,8 @@
 "merge" here includes merge conflicts from e.g. 'hg rebase' or 'hg graft'.
 """
 getargs(x, 0, 0, _(b"conflictlocal takes no arguments"))
-from . import mergestate as mergestatemod
-
-mergestate = mergestatemod.mergestate.read(repo)
+
+mergestate = repo[None].mergestate()
 if mergestate.active() and repo.changelog.hasnode(mergestate.local):
 return subset & {repo.changelog.rev(mergestate.local)}
 
@@ -805,9 +804,8 @@
 "merge" here includes merge conflicts from e.g. 'hg rebase' or 'hg graft'.
 """
 getargs(x, 0, 0, _(b"conflictother takes no arguments"))
-from . import mergestate as mergestatemod
-
-mergestate = mergestatemod.mergestate.read(repo)
+
+mergestate = repo[None].mergestate()
 if mergestate.active() and repo.changelog.hasnode(mergestate.other):
 return subset & {repo.changelog.rev(mergestate.other)}
 



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


D8560: templatekw: get mergestate via context

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Happily, this resolves an import cycle!

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/templatekw.py

CHANGE DETAILS

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -419,9 +419,7 @@
 else:
 merge_nodes = cache.get(b'merge_nodes')
 if merge_nodes is None:
-from . import mergestate as mergestatemod
-
-mergestate = mergestatemod.mergestate.read(repo)
+mergestate = repo[None].mergestate()
 if mergestate.active():
 merge_nodes = (mergestate.local, mergestate.other)
 else:



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


D8557: debugcommands: get mergestate via context

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2008,7 +2008,7 @@
 b'"}'
 )
 
-ms = mergestatemod.mergestate.read(repo)
+ms = repo[None].mergestate()
 
 fm = ui.formatter(b'debugmergestate', opts)
 fm.startitem()



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


D8558: fileset: get mergestate via context

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Happily, this resolves an import cycle!

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/fileset.py

CHANGE DETAILS

diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -16,7 +16,6 @@
 error,
 filesetlang,
 match as matchmod,
-mergestate as mergestatemod,
 pycompat,
 registrar,
 scmutil,
@@ -245,7 +244,7 @@
 getargs(x, 0, 0, _(b"resolved takes no arguments"))
 if mctx.ctx.rev() is not None:
 return mctx.never()
-ms = mergestatemod.mergestate.read(mctx.ctx.repo())
+ms = mctx.ctx.mergestate()
 return mctx.predicate(
 lambda f: f in ms and ms[f] == b'r', predrepr=b'resolved'
 )
@@ -259,7 +258,7 @@
 getargs(x, 0, 0, _(b"unresolved takes no arguments"))
 if mctx.ctx.rev() is not None:
 return mctx.never()
-ms = mergestatemod.mergestate.read(mctx.ctx.repo())
+ms = mctx.ctx.mergestate()
 return mctx.predicate(
 lambda f: f in ms and ms[f] == b'u', predrepr=b'unresolved'
 )



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


D8555: cmdutil: get mergestate via context

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -38,7 +38,6 @@
 logcmdutil,
 match as matchmod,
 merge as mergemod,
-mergestate as mergestatemod,
 mergeutil,
 obsolete,
 patch,
@@ -891,7 +890,7 @@
 def readmorestatus(repo):
 """Returns a morestatus object if the repo has unfinished state."""
 statetuple = statemod.getrepostate(repo)
-mergestate = mergestatemod.mergestate.read(repo)
+mergestate = repo[None].mergestate()
 activemerge = mergestate.active()
 if not statetuple and not activemerge:
 return None
@@ -3128,7 +3127,7 @@
 if subs:
 subrepoutil.writestate(repo, newsubstate)
 
-ms = mergestatemod.mergestate.read(repo)
+ms = repo[None].mergestate()
 mergeutil.checkunresolved(ms)
 
 filestoamend = {f for f in wctx.files() if matcher(f)}



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


D8553: histedit: use context to load mergestate instead of loading it directly

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -224,7 +224,6 @@
 hg,
 logcmdutil,
 merge as mergemod,
-mergestate as mergestatemod,
 mergeutil,
 node,
 obsolete,
@@ -2290,7 +2289,7 @@
 def bootstrapcontinue(ui, state, opts):
 repo = state.repo
 
-ms = mergestatemod.mergestate.read(repo)
+ms = repo[None].mergestate()
 mergeutil.checkunresolved(ms)
 
 if state.actions:



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


D8551: context: implement mergestate() method

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will let us have the mergestate storage be controlled by the context. In
  particular, for working contexts we should use the existing mergestate, but
  for overlay contexts it's inappropriate to drop files in .hg/merge.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -34,6 +34,7 @@
 error,
 fileset,
 match as matchmod,
+mergestate as mergestatemod,
 obsolete as obsmod,
 patch,
 pathutil,
@@ -474,6 +475,12 @@
 
 return r
 
+def mergestate(self, clean=False):
+"""Get a mergestate object for this context."""
+raise NotImplementedError(
+'%s does not implement mergestate()' % self.__class__
+)
+
 
 class changectx(basectx):
 """A changecontext object makes access to data related to a particular
@@ -2003,6 +2010,11 @@
 
 sparse.aftercommit(self._repo, node)
 
+def mergestate(self, clean=False):
+if clean:
+return mergestatemod.mergestate.clean(self._repo)
+return mergestatemod.mergestate.read(self._repo)
+
 
 class committablefilectx(basefilectx):
 """A committablefilectx provides common functionality for a file context



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


D8554: strip: get mergestate via context

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/strip.py

CHANGE DETAILS

diff --git a/hgext/strip.py b/hgext/strip.py
--- a/hgext/strip.py
+++ b/hgext/strip.py
@@ -13,7 +13,6 @@
 error,
 hg,
 lock as lockmod,
-mergestate as mergestatemod,
 node as nodemod,
 pycompat,
 registrar,
@@ -269,7 +268,7 @@
 repo.dirstate.write(repo.currenttransaction())
 
 # clear resolve state
-mergestatemod.mergestate.clean(repo, repo[b'.'].node())
+repo[None].mergestate(clean=True)
 
 update = False
 



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


D8552: fix: use context to fetch mergestate instead of loading it directly

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/fix.py

CHANGE DETAILS

diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -144,7 +144,6 @@
 match as matchmod,
 mdiff,
 merge,
-mergestate as mergestatemod,
 pycompat,
 registrar,
 rewriteutil,
@@ -427,9 +426,7 @@
 if not (len(revs) == 1 and wdirrev in revs):
 cmdutil.checkunfinished(repo)
 rewriteutil.precheck(repo, revs, b'fix')
-if wdirrev in revs and list(
-mergestatemod.mergestate.read(repo).unresolved()
-):
+if wdirrev in revs and list(repo[wdirrev].mergestate().unresolved()):
 raise error.Abort(b'unresolved conflicts', hint=b"use 'hg resolve'")
 if not revs:
 raise error.Abort(



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


D8353: debugcommands: create new debugantivirusrunning command

2020-05-18 Thread durin42 (Augie Fackler)
Herald added a subscriber: mercurial-patches.
durin42 updated this revision to Diff 21426.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8353?vs=20929&id=21426

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/debugcommands.py
  tests/test-completion.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -971,6 +971,8 @@
   
debugancestor
  find the ancestor revision of two revisions in a given index
+   debugantivirusrunning
+ attempt to trigger an antivirus scanner to see if one is 
active
debugapplystreamclonebundle
  apply a stream clone bundle file
debugbackupbundle
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -74,6 +74,7 @@
 Show debug commands if there are no other candidates
   $ hg debugcomplete debug
   debugancestor
+  debugantivirusrunning
   debugapplystreamclonebundle
   debugbackupbundle
   debugbuilddag
@@ -260,6 +261,7 @@
   continue: dry-run
   copy: forget, after, at-rev, force, include, exclude, dry-run
   debugancestor: 
+  debugantivirusrunning: 
   debugapplystreamclonebundle: 
   debugbackupbundle: recover, patch, git, limit, no-merges, stat, graph, 
style, template
   debugbuilddag: mergeable-file, overwritten-file, new-file
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -127,6 +127,23 @@
 ui.write(b'%d:%s\n' % (r.rev(a), hex(a)))
 
 
+@command(b'debugantivirusrunning', [])
+def debugantivirusrunning(ui, repo):
+"""attempt to trigger an antivirus scanner to see if one is active"""
+with repo.cachevfs.open('eicar-test-file.com', b'wb') as f:
+f.write(
+util.b85decode(
+# This is a base85-armored version of the EICAR test file. See
+# https://en.wikipedia.org/wiki/EICAR_test_file for details.
+b'ST#=}P$fV?P+K%yP+C|uG$>GBDK|qyDK~v2MM*https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D8549: relnotes: add API change note per request in D8502

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -91,3 +91,5 @@
 
  * The `*others` argument of `cmdutil.check_incompatible_arguments()`
changed from being varargs argument to being a single collection.
+
+ * logcmdutil.diffordiffstat() now takes contexts instead of nodes.



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


D8548: tests: add coverage for repo.changelog.children() in the git extension

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-git-interop.t

CHANGE DETAILS

diff --git a/tests/test-git-interop.t b/tests/test-git-interop.t
--- a/tests/test-git-interop.t
+++ b/tests/test-git-interop.t
@@ -199,6 +199,9 @@
  summary: Add beta
   
 
+  $ hg log -r "children(3d9be8deba43)" -T"{node|short} {children}\n"
+  a1983dd7fb19 3:d8ee22687733
+
 hg annotate
 
   $ hg annotate alpha



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


D8547: tests: add coverage for repo.changelog.findmissing() in test-git-interop.t

2020-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This at least does a basic test of the method. It's not
  super-complete, but it's better than the nothing we'd otherwise have.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-git-interop.t

CHANGE DETAILS

diff --git a/tests/test-git-interop.t b/tests/test-git-interop.t
--- a/tests/test-git-interop.t
+++ b/tests/test-git-interop.t
@@ -248,3 +248,5 @@
   $ hg log -r ae1ab744f95bfd5b07cf573baef98a778058537b --template 
"{shortest(node,1)}\n"
   ae
 
+This coveres changelog.findmissing()
+  $ hg merge --preview 3d9be8deba43



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


D8546: relnotes: copy "next" to "5.4" and clear "next"

2020-05-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is the same thing as we've done for the previous few releases.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  relnotes/5.4
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -1,93 +1,11 @@
 == New Features ==
 
- * `hg purge`/`hg clean` can now delete ignored files instead of
-   untracked files, with the new -i flag.
-
- * `hg pull` now has a `--confirm` flag to prompt before applying changes.
-   Config option `pull.confirm` is also added for that.
-
- * `hg log` now defaults to using an '%' symbol for commits involved
-in unresolved merge conflicts. That includes unresolved conflicts
-caused by e.g. `hg update --merge` and `hg graft`. '@' still takes
-precedence, so what used to be marked '@' still is.
-
- * New `conflictlocal()` and `conflictother()` revsets return the
-   commits that are being merged, when there are conflicts. Also works
-   for conflicts caused by e.g. `hg graft`.
-
- * `hg copy --forget` can be used to unmark a file as copied.
-
- * The `format.revlog-compression` configuration entry now accept a list. The
-   first available option will be used. for example setting::
-
- [format]
- revlog-compression=zstd, zlib
-
-   Will use `zstd` compression for new repositories is available, and will
-   simply fall back to `zlib` if not.
-
- * `hg debugmergestate` output is now templated, which may be useful
-   e.g. for IDEs that want to help the user resolve merge conflicts.
-
 
 == New Experimental Features ==
 
- * `hg copy` now supports a `--at-rev` argument to mark files as
-   copied in the specified commit. It only works with `--after` for
-   now (i.e., it's only useful for marking files copied using non-hg
-   `cp` as copied).
-
- * Use `hg copy --forget --at-rev REV` to unmark already committed
-   copies.
-
-== Bug Fixes  ==
-
- * Fix server exception when concurrent pushes delete the same bookmark
-
- * Prevent pushes of divergent bookmarks (foo@remote)
-
- * The push error "remote repository changed while pushing - please
-   try again" now only happens when a concurrent push changed related
-   heads (instead of when a concurrent pushed any revision).
-
 
 == Backwards Compatibility Changes ==
 
- * When `hg rebase` pauses for merge conflict resolution, the working
-   copy will no longer have the rebased node as a second parent. You
-   can use the new `conflictparents()` revset for finding the other
-   parent during a conflict.
-
- * `hg rebase` now accepts repeated `--source` and `--base`
-   arguments. For example, `hg rebase --source 'A + B'` is equivalent
-   to `hg rebase --source A --source B`. This is a
-   backwards-incompatible change because it will break overriding an
-   alias `myrebase = rebase --source A` by `hg myrebase --source B`
-   (it will now rebase `(A + B)::` instead of `B::`).
-
- * `hg recover` does not verify the validity of the whole repository
-   anymore. You can pass `--verify` or call `hg verify` if necessary.
-
- * `hg debugmergestate` output format changed. Let us know if that is
-   causing you problems and we'll roll it back.
-
- * Resolved merge conflicts are now cleared by `hg commit` even if the
-   working copy has no changes.
-
 
 == Internal API Changes ==
 
- * The deprecated `ui.progress()` has now been deleted. Please use
-   `ui.makeprogress()` instead.
-
- * `hg.merge()` now takes a `ctx` instead of the previous `repo` and
-   `node` arguments.
-
- * `hg.merge()` has lost its `abort` argument. Please call
-   `hg.abortmerge()` directly instead.
-
- * `hg.merge()` has lost its `mergeforce` argument. It should have
-   only ever been called with the same value as the `force` argument.
-
- * The `*others` argument of `cmdutil.check_incompatible_arguments()`
-   changed from being varargs argument to being a single collection.
diff --git a/relnotes/next b/relnotes/5.4
copy from relnotes/next
copy to relnotes/5.4



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