D8763: diff: move no-eol text constant to a common location

2020-07-17 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio 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/D8763

AFFECTED FILES
  mercurial/crecord.py
  mercurial/diffhelper.py
  mercurial/mdiff.py
  mercurial/patch.py

CHANGE DETAILS

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -785,7 +785,7 @@
 for l in x.hunk:
 lines.append(l)
 if l[-1:] != b'\n':
-lines.append(b"\n\\ No newline at end of file\n")
+lines.append(b'\n' + diffhelper.MISSING_NEWLINE_MARKER)
 self.backend.writerej(self.fname, len(self.rej), self.hunks, lines)
 
 def apply(self, h):
@@ -1069,7 +1069,7 @@
 
 def write(self, fp):
 delta = len(self.before) + len(self.after)
-if self.after and self.after[-1] == b'\\ No newline at end of file\n':
+if self.after and self.after[-1] == diffhelper.MISSING_NEWLINE_MARKER:
 delta -= 1
 fromlen = delta + self.removed
 tolen = delta + self.added
diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
--- a/mercurial/mdiff.py
+++ b/mercurial/mdiff.py
@@ -17,6 +17,7 @@
 setattr,
 )
 from . import (
+diffhelper,
 encoding,
 error,
 policy,
@@ -25,8 +26,6 @@
 )
 from .utils import dateutil
 
-_missing_newline_marker = b"\\ No newline at end of file\n"
-
 bdiff = policy.importmod('bdiff')
 mpatch = policy.importmod('mpatch')
 
@@ -309,7 +308,7 @@
 hunklines = [b"@@ -0,0 +1,%d @@\n" % size] + [b"+" + e for e in b]
 if without_newline:
 hunklines[-1] += b'\n'
-hunklines.append(_missing_newline_marker)
+hunklines.append(diffhelper.MISSING_NEWLINE_MARKER)
 hunks = ((hunkrange, hunklines),)
 elif not b:
 without_newline = not a.endswith(b'\n')
@@ -325,7 +324,7 @@
 hunklines = [b"@@ -1,%d +0,0 @@\n" % size] + [b"-" + e for e in a]
 if without_newline:
 hunklines[-1] += b'\n'
-hunklines.append(_missing_newline_marker)
+hunklines.append(diffhelper.MISSING_NEWLINE_MARKER)
 hunks = ((hunkrange, hunklines),)
 else:
 hunks = _unidiff(a, b, opts=opts)
@@ -418,13 +417,13 @@
 if hunklines[i].startswith(b' '):
 skip = True
 hunklines[i] += b'\n'
-hunklines.insert(i + 1, _missing_newline_marker)
+hunklines.insert(i + 1, diffhelper.MISSING_NEWLINE_MARKER)
 break
 if not skip and not t2.endswith(b'\n') and bstart + blen == len(l2) + 
1:
 for i in pycompat.xrange(len(hunklines) - 1, -1, -1):
 if hunklines[i].startswith(b'+'):
 hunklines[i] += b'\n'
-hunklines.insert(i + 1, _missing_newline_marker)
+hunklines.insert(i + 1, diffhelper.MISSING_NEWLINE_MARKER)
 break
 yield hunkrange, hunklines
 
diff --git a/mercurial/diffhelper.py b/mercurial/diffhelper.py
--- a/mercurial/diffhelper.py
+++ b/mercurial/diffhelper.py
@@ -14,6 +14,8 @@
 pycompat,
 )
 
+MISSING_NEWLINE_MARKER = b'\\ No newline at end of file\n'
+
 
 def addlines(fp, hunk, lena, lenb, a, b):
 """Read lines from fp into the hunk
@@ -32,7 +34,7 @@
 s = fp.readline()
 if not s:
 raise error.ParseError(_(b'incomplete hunk'))
-if s == b"\\ No newline at end of file\n":
+if s == MISSING_NEWLINE_MARKER:
 fixnewline(hunk, a, b)
 continue
 if s == b'\n' or s == b'\r\n':
diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -20,6 +20,7 @@
 open,
 )
 from . import (
+diffhelper,
 encoding,
 error,
 patch as patchmod,
@@ -416,7 +417,7 @@
 contextlen = (
 len(self.before) + len(self.after) + removedconvertedtocontext
 )
-if self.after and self.after[-1] == b'\\ No newline at end of file\n':
+if self.after and self.after[-1] == diffhelper.MISSING_NEWLINE_MARKER:
 contextlen -= 1
 fromlen = contextlen + self.removed
 tolen = contextlen + self.added
@@ -503,7 +504,7 @@
 noeol = False
 for line in self.changedlines:
 text = line.linetext
-if line.linetext == b'\\ No newline at end of file\n':
+if line.linetext == diffhelper.MISSING_NEWLINE_MARKER:
 noeol = True
 break
 if line.applied:



To: rdamazio, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D8762: revert: fix interactive reverting of end-of-file newline changes

2020-07-17 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The chunk reversal used by `revert -i` in Curses mode was not taking this case
  into account.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/crecord.py
  tests/test-revert-interactive-curses.t

CHANGE DETAILS

diff --git a/tests/test-revert-interactive-curses.t 
b/tests/test-revert-interactive-curses.t
new file mode 100644
--- /dev/null
+++ b/tests/test-revert-interactive-curses.t
@@ -0,0 +1,55 @@
+#require tic
+
+Revert interactive tests with the Curses interface
+
+  $ cat <> $HGRCPATH
+  > [ui]
+  > interactive = true
+  > interface = curses
+  > [experimental]
+  > crecordtest = testModeCommands
+  > EOF
+
+TODO: Make a curses version of the other tests from test-revert-interactive.t.
+
+When a line without EOL is selected during "revert -i"
+
+  $ hg init $TESTTMP/revert-i-curses-eol
+  $ cd $TESTTMP/revert-i-curses-eol
+  $ echo 0 > a
+  $ hg ci -qAm 0
+  $ printf 1 >> a
+  $ hg ci -qAm 1
+  $ cat a
+  0
+  1 (no-eol)
+
+  $ cat  c
+  > EOF
+
+  $ hg revert -ir'.^'
+  reverting a
+  $ cat a
+  0
+
+When a selected line is reverted to have no EOL
+
+  $ hg init $TESTTMP/revert-i-curses-eol2
+  $ cd $TESTTMP/revert-i-curses-eol2
+  $ printf 0 > a
+  $ hg ci -qAm 0
+  $ echo 0 > a
+  $ hg ci -qAm 1
+  $ cat a
+  0
+
+  $ cat  c
+  > EOF
+
+  $ hg revert -ir'.^'
+  reverting a
+  $ cat a
+  0 (no-eol)
+
diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -500,8 +500,12 @@
 """
 dels = []
 adds = []
+noeol = False
 for line in self.changedlines:
 text = line.linetext
+if line.linetext == b'\\ No newline at end of file\n':
+noeol = True
+break
 if line.applied:
 if text.startswith(b'+'):
 dels.append(text[1:])
@@ -511,6 +515,9 @@
 dels.append(text[1:])
 adds.append(text[1:])
 hunk = [b'-%s' % l for l in dels] + [b'+%s' % l for l in adds]
+if noeol and hunk:
+# Remove the newline from the end of the hunk.
+hunk[-1] = hunk[-1][:-1]
 h = self._hunk
 return patchmod.recordhunk(
 h.header, h.toline, h.fromline, h.proc, h.before, hunk, h.after



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


D8721: scmutil: allowing different files to be prefetched per revision

2020-07-10 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The old API takes a list of revision separate from the file matcher, and thus
  provides no way to fetch different sets of files from each revision. In
  preparation for adding one such usage, I'm changing the API to take a list of
  (revision, file matcher) tuples instead.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/lfs/wrapper.py
  hgext/remotefilelog/__init__.py
  mercurial/archival.py
  mercurial/cmdutil.py
  mercurial/context.py
  mercurial/merge.py
  mercurial/patch.py
  mercurial/scmutil.py
  mercurial/subrepo.py

CHANGE DETAILS

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -639,7 +639,7 @@
 rev = self._state[1]
 ctx = self._repo[rev]
 scmutil.prefetchfiles(
-self._repo, [ctx.rev()], scmutil.matchfiles(self._repo, files)
+self._repo, [(ctx.rev(), scmutil.matchfiles(self._repo, files))]
 )
 total = abstractsubrepo.archive(self, archiver, prefix, match)
 for subpath in ctx.substate:
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1880,18 +1880,30 @@
 ]
 
 
-def prefetchfiles(repo, revs, match):
+def prefetchfiles(repo, revmatches):
 """Invokes the registered file prefetch functions, allowing extensions to
 ensure the corresponding files are available locally, before the command
-uses them."""
-if match:
-# The command itself will complain about files that don't exist, so
-# don't duplicate the message.
-match = matchmod.badmatch(match, lambda fn, msg: None)
-else:
-match = matchall(repo)
+uses them.
 
-fileprefetchhooks(repo, revs, match)
+Args:
+  revmatches: a list of (revision, match) tuples to indicate the files to
+  fetch at each revision. If any of the match elements is None, it matches
+  all files.
+"""
+def _matcher(m):
+if m:
+assert isinstance(m, matchmod.basematcher)
+# The command itself will complain about files that don't exist, so
+# don't duplicate the message.
+return matchmod.badmatch(m, lambda fn, msg: None)
+else:
+return matchall(repo)
+
+revbadmatches = [
+(rev, _matcher(match)) for (rev, match) in revmatches
+]
+
+fileprefetchhooks(repo, revbadmatches)
 
 
 # a list of (repo, revs, match) prefetch functions
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2666,7 +2666,11 @@
 prefetchmatch = scmutil.matchfiles(
 repo, list(modifiedset | addedset | removedset)
 )
-scmutil.prefetchfiles(repo, [ctx1.rev(), ctx2.rev()], prefetchmatch)
+revmatches = [
+(ctx1.rev(), prefetchmatch),
+(ctx2.rev(), prefetchmatch),
+]
+scmutil.prefetchfiles(repo, revmatches)
 
 def difffn(opts, losedata):
 return trydiff(
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1121,8 +1121,9 @@
 matchfiles = scmutil.matchfiles
 prefetch(
 repo,
-[ctx.rev()],
-matchfiles(repo, [f for sublist in oplist for f, args, msg in 
sublist]),
+[(ctx.rev(),
+  matchfiles(repo,
+ [f for sublist in oplist for f, args, msg in sublist]))],
 )
 
 
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2540,8 +2540,8 @@
 # using things like remotefilelog.
 scmutil.prefetchfiles(
 self.repo(),
-[self.p1().rev()],
-scmutil.matchfiles(self.repo(), self._cache.keys()),
+[(self.p1().rev(),
+  scmutil.matchfiles(self.repo(), self._cache.keys()))],
 )
 
 for path in self._cache.keys():
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2138,7 +2138,9 @@
 for file in repo[rev].files():
 if not match or match(file):
 allfiles.add(file)
-scmutil.prefetchfiles(repo, revs, scmutil.matchfiles(repo, allfiles))
+match = scmutil.matchfiles(repo, allfiles)
+revmatches = [(rev, match) for rev in revs]
+scmutil.prefetchfiles(repo, revmatches)
 
 
 def export(
@@ -2997,14 +2999,14 @@
 try:
 if mfnode and mfl[mfnode].find(file)[0]:
 if _catfmtneedsdata(basefm):
-scmutil.prefetchfiles(repo, [ctx.rev()], matcher)
+scmutil.prefetchfiles(repo, [(ctx.rev(), matcher)])
 write(file)
 return 0
 except KeyError:
 pass
 
 if 

D8723: fix: prefetch file contents

2020-07-10 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This prevents the worker subprocesses from contacting the server individually,
  which is either inefficient, or leads to problems if the connection is shared
  among them.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -271,6 +271,11 @@
 basepaths = getbasepaths(repo, opts, workqueue, basectxs)
 fixers = getfixers(ui)
 
+# Rather than letting each worker independently fetch the files
+# (which also would add complications for shared/keepalive
+# connections), prefetch them all first.
+_prefetchfiles(repo, workqueue, basepaths)
+
 # There are no data dependencies between the workers fixing each file
 # revision, so we can use all available parallelism.
 def getfixes(items):
@@ -630,6 +635,24 @@
 basectxs[rev].add(pctx)
 return basectxs
 
+def _prefetchfiles(repo, workqueue, basepaths):
+toprefetch = set()
+
+# Prefetch the files that will be fixed.
+for rev, path in workqueue:
+if rev == wdirrev:
+continue
+toprefetch.add((rev, path))
+
+# Prefetch the base contents for lineranges().
+for (baserev, fixrev, path), basepath in basepaths.items():
+toprefetch.add((baserev, basepath))
+
+if toprefetch:
+scmutil.prefetchfiles(repo, [
+(rev, scmutil.matchfiles(repo, [path])) for rev, path in toprefetch
+])
+
 
 def fixfile(ui, repo, opts, fixers, fixctx, path, basepaths, basectxs):
 """Run any configured fixers that should affect the file in this context



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


D8722: fix: obtain base paths before starting workers

2020-07-10 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This moves calculation of base paths to before work is dispatched.
  While this does mean that copy tracing will be serialized instead of
  parallel, it is necessary to be able to prefetch the base contents
  in a batch, which will likely be more efficient.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -268,6 +268,7 @@
 workqueue, numitems = getworkqueue(
 ui, repo, pats, opts, revstofix, basectxs
 )
+basepaths = getbasepaths(repo, opts, workqueue, basectxs)
 fixers = getfixers(ui)
 
 # There are no data dependencies between the workers fixing each file
@@ -277,7 +278,7 @@
 ctx = repo[rev]
 olddata = ctx[path].data()
 metadata, newdata = fixfile(
-ui, repo, opts, fixers, ctx, path, basectxs[rev]
+ui, repo, opts, fixers, ctx, path, basepaths, basectxs[rev]
 )
 # Don't waste memory/time passing unchanged content back, but
 # produce one result per item either way.
@@ -473,7 +474,8 @@
 return files
 
 
-def lineranges(opts, path, basectxs, fixctx, content2):
+
+def lineranges(opts, path, basepaths, basectxs, fixctx, content2):
 """Returns the set of line ranges that should be fixed in a file
 
 Of the form [(10, 20), (30, 40)].
@@ -492,7 +494,8 @@
 
 rangeslist = []
 for basectx in basectxs:
-basepath = copies.pathcopies(basectx, fixctx).get(path, path)
+basepath = basepaths.get((basectx.rev(), fixctx.rev(), path), path)
+
 if basepath in basectx:
 content1 = basectx[basepath].data()
 else:
@@ -501,6 +504,21 @@
 return unionranges(rangeslist)
 
 
+def getbasepaths(repo, opts, workqueue, basectxs):
+if opts.get(b'whole'):
+# Base paths will never be fetched for line range determination.
+return {}
+
+basepaths = {}
+for rev, path in workqueue:
+fixctx = repo[rev]
+for basectx in basectxs[rev]:
+basepath = copies.pathcopies(basectx, fixctx).get(path, path)
+if basepath in basectx:
+basepaths[(basectx.rev(), fixctx.rev(), path)] = basepath
+return basepaths
+
+
 def unionranges(rangeslist):
 """Return the union of some closed intervals
 
@@ -613,7 +631,7 @@
 return basectxs
 
 
-def fixfile(ui, repo, opts, fixers, fixctx, path, basectxs):
+def fixfile(ui, repo, opts, fixers, fixctx, path, basepaths, basectxs):
 """Run any configured fixers that should affect the file in this context
 
 Returns the file content that results from applying the fixers in some 
order
@@ -629,7 +647,8 @@
 newdata = fixctx[path].data()
 for fixername, fixer in pycompat.iteritems(fixers):
 if fixer.affects(opts, fixctx, path):
-ranges = lineranges(opts, path, basectxs, fixctx, newdata)
+ranges = lineranges(
+opts, path, basepaths, basectxs, fixctx, newdata)
 command = fixer.command(ui, path, ranges)
 if command is None:
 continue



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


D8521: pyoxidizer: formatting bazel definitions

2020-05-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This meets the Bazel style guide:
  https://docs.bazel.build/versions/master/skylark/bzl-style.html
  and was mostly done automatically with buildifier.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hgcli/pyoxidizer.bzl

CHANGE DETAILS

diff --git a/rust/hgcli/pyoxidizer.bzl b/rust/hgcli/pyoxidizer.bzl
--- a/rust/hgcli/pyoxidizer.bzl
+++ b/rust/hgcli/pyoxidizer.bzl
@@ -3,19 +3,16 @@
 # Code to run in Python interpreter.
 RUN_CODE = "import hgdemandimport; hgdemandimport.enable(); from mercurial 
import dispatch; dispatch.run()"
 
-
 set_build_path(ROOT + "/build/pyoxidizer")
 
-
 def make_distribution():
 return default_python_distribution()
 
-
 def make_distribution_windows():
-return default_python_distribution(flavor="standalone_dynamic")
-
+return default_python_distribution(flavor = "standalone_dynamic")
 
 def make_exe(dist):
+"""Builds a Rust-wrapped Mercurial binary."""
 config = PythonInterpreterConfig(
 raw_allocator = "system",
 run_eval = RUN_CODE,
@@ -58,23 +55,20 @@
 # On Windows, we install extra packages for convenience.
 if "windows" in BUILD_TARGET_TRIPLE:
 exe.add_python_resources(
-dist.pip_install(["-r", ROOT + 
"/contrib/packaging/requirements_win32.txt"])
+dist.pip_install(["-r", ROOT + 
"/contrib/packaging/requirements_win32.txt"]),
 )
 
 return exe
 
-
 def make_manifest(dist, exe):
 m = FileManifest()
 m.add_python_resource(".", exe)
 
 return m
 
-
 def make_embedded_resources(exe):
 return exe.to_embedded_resources()
 
-
 register_target("distribution_posix", make_distribution)
 register_target("distribution_windows", make_distribution_windows)
 



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


D8497: procutil: always waiting on child processes to prevent zombies with 'hg serve'

2020-05-07 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  When runbgcommand is invoked by an extension with ensurestart=False, we never
  called waitpid - which is fine in most cases, except if that's happening on a
  command server (e.g. chg), in which case the child defunct process will just
  sit there for as long as the server is running.
  
  The actual semantics of SIGCHLD signal handling is a lot more complex than
  it seems, and the POSIX standard *seems* to read that it's ignored by default
  and everything would just work without the waitpid if we're not listening for
  it, but the truth is that it's only ignored if we *explicitly* set it to
  SIG_IGN. We further cannot set it to SIG_IGN or to a catch-all handler across
  all of 'hg serve', because Python's suprocess.Popen relies on that signal,
  and a few specific parts of hg also set custom handlers, so instead we wait
  for specific PIDs in dedicated threads.
  
  I did a poor-man's benchmark of the thread creation and it seems to take
  about 1ms, which is way better than the 20+ms from ensurestart=True.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hg
  mercurial/utils/procutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -16,6 +16,7 @@
 import signal
 import subprocess
 import sys
+import threading
 import time
 
 from ..i18n import _
@@ -604,6 +605,14 @@
 pid = os.fork()
 if pid:
 if not ensurestart:
+# Even though we're not waiting on the child process,
+# we still must call waitpid() on it at some point so
+# it's not a zombie/defunct. This is especially relevant 
for
+# chg since the parent process won't die anytime soon.
+# We use a thread to make the overhead tiny.
+def _do_wait():
+os.waitpid(pid, 0)
+threading.Thread(target=_do_wait, daemon=True).start()
 return
 # Parent process
 (_pid, status) = os.waitpid(pid, 0)
diff --git a/hg b/hg
--- a/hg
+++ b/hg
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # mercurial - scalable distributed SCM
 #



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


D7631: absorb: allowing committed changes to be absorbed into their ancestors

2020-02-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 19981.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7631?vs=19979=19981

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  mercurial/scmutil.py
  relnotes/5.3
  relnotes/next
  tests/test-absorb-rev.t
  tests/test-absorb.t

CHANGE DETAILS

diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -143,7 +143,7 @@
   nothing applied
   [1]
 
-Insertaions:
+Insertions:
 
   $ cat > a << EOF
   > insert before 2b
diff --git a/tests/test-absorb.t b/tests/test-absorb-rev.t
copy from tests/test-absorb.t
copy to tests/test-absorb-rev.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb-rev.t
@@ -1,26 +1,16 @@
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > absorb=
+  > rebase=
+  > [experimental]
+  > evolution=createmarkers
+  > [alias]
+  > glog=log -G -T '{node|short} {desc} {instabilities}'
   > EOF
 
-  $ sedi() { # workaround check-code
-  > pattern="$1"
-  > shift
-  > for i in "$@"; do
-  > sed "$pattern" "$i" > "$i".tmp
-  > mv "$i".tmp "$i"
-  > done
-  > }
-
   $ hg init repo1
   $ cd repo1
 
-Do not crash with empty repo:
-
-  $ hg absorb
-  abort: no mutable changeset to change
-  [255]
-
 Make some commits:
 
   $ for i in 1 2 3 4 5; do
@@ -45,9 +35,26 @@
   > 5e
   > EOF
 
+Commit that, too.
+
+  $ hg commit -qm "commit to absorb"
+  $ hg glog
+  @  1631091f9648 commit to absorb
+  |
+  o  4f55fa657dae commit 5
+  |
+  o  ad8b8b75557f commit 4
+  |
+  o  43f0a75bede7 commit 3
+  |
+  o  5c5f95224a50 commit 2
+  |
+  o  4ec16f85269a commit 1
+  
+
 Preview absorb changes:
 
-  $ hg absorb --print-changes --dry-run
+  $ hg absorb --print-changes --dry-run --from .
   showing changes for a
   @@ -0,2 +0,2 @@
   4ec16f8 -1
@@ -66,462 +73,185 @@
   5c5f952 commit 2
   4ec16f8 commit 1
 
+Try to absorb multiple revisions:
+
+  $ hg absorb --apply-changes --from '.^+.'
+  abort: revision set matched multiple revisions
+  [255]
+
+Add an uncommitted working directory change:
+
+  $ echo 6 >> a
+
 Run absorb:
 
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
+  $ hg absorb --apply-changes --from .
+  1 new orphan changesets
   2 of 2 chunk(s) applied
-  $ hg annotate a
-  0: 1a
-  1: 2b
-  2: 3
-  3: 4d
-  4: 5e
-
-Delete a few lines and related commits will be removed if they will be empty:
-
-  $ cat > a < 2b
-  > 4d
-  > EOF
-  $ echo y | hg absorb --config ui.interactive=1
-  showing changes for a
-  @@ -0,1 +0,0 @@
-  f548282 -1a
-  @@ -2,1 +1,0 @@
-  ff5d556 -3
-  @@ -4,1 +2,0 @@
-  84e5416 -5e
+Note: this only shows disconnected graphs because the root node was also
+absorbed into.
+  $ hg glog
+  o  2f7ba78d6abc commit 5
+  |
+  o  04c8ba6df782 commit 4
+  |
+  o  484c6ac0cea3 commit 3
+  |
+  o  9b19176bb127 commit 2
+  |
+  o  241ace8326d0 commit 1
   
-  3 changesets affected
-  84e5416 commit 5
-  ff5d556 commit 3
-  f548282 commit 1
-  apply changes (yn)?  y
-  saved backup bundle to * (glob)
-  3 of 3 chunk(s) applied
-  $ hg annotate a
-  1: 2b
-  2: 4d
-  $ hg log -T '{rev} {desc}\n' -Gp
-  @  2 commit 4
-  |  diff -r 1cae118c7ed8 -r 58a62bade1c6 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -1,1 +1,2 @@
-  |   2b
-  |  +4d
+  @  1631091f9648 commit to absorb orphan
+  |
+  x  4f55fa657dae commit 5
+  |
+  x  ad8b8b75557f commit 4
   |
-  o  1 commit 2
-  |  diff -r 84add69aeac0 -r 1cae118c7ed8 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -0,0 +1,1 @@
-  |  +2b
+  x  43f0a75bede7 commit 3
   |
-  o  0 commit 1
+  x  5c5f95224a50 commit 2
+  |
+  x  4ec16f85269a commit 1
   
 
-Non 1:1 map changes will be ignored:
-
-  $ echo 1 > a
-  $ hg absorb --apply-changes
-  nothing applied
-  [1]
-
-The prompt is not given if there are no changes to be applied, even if there
-are some changes that won't be applied:
-
-  $ hg absorb
-  showing changes for a
-  @@ -0,2 +0,1 @@
-  -2b
-  -4d
-  +1
-  
-  0 changesets affected
-  nothing applied
-  [1]
-
-Insertaions:
-
-  $ cat > a << EOF
-  > insert before 2b
-  > 2b
-  > 4d
-  > insert aftert 4d
-  > EOF
-  $ hg absorb -q --apply-changes
-  $ hg status
-  $ hg annotate a
-  1: insert before 2b
-  1: 2b
-  2: 4d
-  2: insert aftert 4d
-
-Bookmarks are moved:
-
-  $ hg bookmark -r 1 b1
-  $ hg bookmark -r 2 b2
-  $ hg bookmark ba
-  $ hg bookmarks
- b11:b35060a57a50
- b22:946e4bc87915
-   * ba2:946e4bc87915
-  $ sedi 's/insert/INSERT/' a
-  $ hg absorb -q --apply-changes
-  $ hg status
-  $ hg bookmarks
- b11:a4183e9b3d31
- b22:c9b20c925790
-   * ba

D7630: absorb: make the absorbed changeset be automatically "evolved"

2020-02-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 19982.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7630?vs=19980=19982

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t

CHANGE DETAILS

diff --git a/tests/test-absorb-rev.t b/tests/test-absorb-rev.t
--- a/tests/test-absorb-rev.t
+++ b/tests/test-absorb-rev.t
@@ -86,11 +86,10 @@
 Run absorb:
 
   $ hg absorb --apply-changes --from .
-  1 new orphan changesets
   2 of 2 chunk(s) applied
-Note: this only shows disconnected graphs because the root node was also
-absorbed into.
   $ hg glog
+  @  9a0ec5cae1a1 commit to absorb
+  |
   o  2f7ba78d6abc commit 5
   |
   o  04c8ba6df782 commit 4
@@ -101,18 +100,6 @@
   |
   o  241ace8326d0 commit 1
   
-  @  1631091f9648 commit to absorb orphan
-  |
-  x  4f55fa657dae commit 5
-  |
-  x  ad8b8b75557f commit 4
-  |
-  x  43f0a75bede7 commit 3
-  |
-  x  5c5f95224a50 commit 2
-  |
-  x  4ec16f85269a commit 1
-  
 
 Check that the pending wdir change was left alone:
 
@@ -127,34 +114,21 @@
4d
5e
   +6
-  $ hg update -Cq .
-
-Rebase the absorbed revision on top of the destination (as evolve would):
-TODO: the evolve-type operation should happen automatically for the changeset
-being absorbed, and even through that the pending wdir change should be left
-alone.
-
-  $ hg rebase -d tip -r .
-  rebasing 5:1631091f9648 "commit to absorb"
-  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
-  $ hg glog
-  @  2f7ba78d6abc commit 5
-  |
-  o  04c8ba6df782 commit 4
-  |
-  o  484c6ac0cea3 commit 3
-  |
-  o  9b19176bb127 commit 2
-  |
-  o  241ace8326d0 commit 1
-  
-  $ hg annotate -c a
-  241ace8326d0: 1a
-  9b19176bb127: 2b
-  484c6ac0cea3: 3
-  04c8ba6df782: 4d
-  2f7ba78d6abc: 5e
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  9b19176bb127 : 2b
+  484c6ac0cea3 : 3
+  04c8ba6df782 : 4d
+  2f7ba78d6abc : 5e
+  9a0ec5cae1a1+: 6
+
+TODO: The absorbed commit should have disappeared when it became empty.
+  $ hg diff -c .
+  $ hg debugobsolete $(hg log -T "{node}\n" -r .)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg update -Cq '.^'
 
 Do it again, but this time with an unrelated commit checked out (plus working
 directory changes on top):
@@ -200,22 +174,17 @@
   2 changesets affected
   2f7ba78 commit 5
   04c8ba6 commit 4
-  1 new orphan changesets
   1 of 1 chunk(s) applied
 
   $ hg glog
+  o  da8aed1fcb63 commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
   | @  dbce69d9fe03 unrelated commit
   | |
-  | | *  410fcc72c5c9 commit to absorb 2 orphan
-  | | |
-  | | x  2f7ba78d6abc commit 5
-  | | |
-  +---x  04c8ba6df782 commit 4
-  | |
   o |  484c6ac0cea3 commit 3
   | |
   o |  9b19176bb127 commit 2
@@ -228,18 +197,16 @@
   dbce69d9fe03 : committed unrelated
   dbce69d9fe03+: pending wdir change
 
-  $ hg update -Cq .
-
-  $ hg rebase -d tip -r ${TOABSORB}
-  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
-  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+  $ hg update -Cq tip
 
   $ hg glog
+  o  da8aed1fcb63 commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
-  | @  dbce69d9fe03 unrelated commit
+  | o  dbce69d9fe03 unrelated commit
   | |
   o |  484c6ac0cea3 commit 3
   | |
@@ -248,7 +215,7 @@
   o  241ace8326d0 commit 1
   
 
-  $ hg annotate -c a -r tip
+  $ hg annotate -c a
   241ace8326d0: 1a
   9b19176bb127: 2b
   484c6ac0cea3: 3
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -34,6 +34,7 @@
 from __future__ import absolute_import
 
 import collections
+import itertools
 
 from mercurial.i18n import _
 from mercurial import (
@@ -662,16 +663,19 @@
 4. call commit, to commit changes to hg database
 """
 
-def __init__(self, stack, ui=None, opts=None):
+def __init__(self, stack, fixuptargets=[], ui=None, opts=None):
 """([ctx], ui or None) -> None
 
 stack: should be linear, and sorted by topo order - oldest first.
+fixuptargets: changeset contexts that need to be fixed up, but are not
+used for fixup computation.
 all commits in stack are considered mutable.
 """
 assert stack
 self.ui = ui or nullui()
 self.opts = opts or {}
 self.stack = stack
+self.fixuptargets = fixuptargets
 self.repo = stack[-1].repo().unfiltered()
 
 # following fields will be filled later
@@ -777,7 +781,7 @@
 # p1 which overrides the parent of the next commit, "None" means use
 # the original parent unchanged
 nextp1 = None
-for ctx in self.stack:
+for ctx in itertools.chain(self.stack, self.fixuptargets):
 

D7631: absorb: allowing committed changes to be absorbed into their ancestors

2020-02-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 19979.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7631?vs=19811=19979

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  mercurial/scmutil.py
  relnotes/5.3
  relnotes/next
  tests/test-absorb-rev.t
  tests/test-absorb.t

CHANGE DETAILS

diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -143,7 +143,7 @@
   nothing applied
   [1]
 
-Insertaions:
+Insertions:
 
   $ cat > a << EOF
   > insert before 2b
diff --git a/tests/test-absorb.t b/tests/test-absorb-rev.t
copy from tests/test-absorb.t
copy to tests/test-absorb-rev.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb-rev.t
@@ -1,26 +1,16 @@
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > absorb=
+  > rebase=
+  > [experimental]
+  > evolution=createmarkers
+  > [alias]
+  > glog=log -G -T '{node|short} {desc} {instabilities}'
   > EOF
 
-  $ sedi() { # workaround check-code
-  > pattern="$1"
-  > shift
-  > for i in "$@"; do
-  > sed "$pattern" "$i" > "$i".tmp
-  > mv "$i".tmp "$i"
-  > done
-  > }
-
   $ hg init repo1
   $ cd repo1
 
-Do not crash with empty repo:
-
-  $ hg absorb
-  abort: no mutable changeset to change
-  [255]
-
 Make some commits:
 
   $ for i in 1 2 3 4 5; do
@@ -45,9 +35,26 @@
   > 5e
   > EOF
 
+Commit that, too.
+
+  $ hg commit -qm "commit to absorb"
+  $ hg glog
+  @  1631091f9648 commit to absorb
+  |
+  o  4f55fa657dae commit 5
+  |
+  o  ad8b8b75557f commit 4
+  |
+  o  43f0a75bede7 commit 3
+  |
+  o  5c5f95224a50 commit 2
+  |
+  o  4ec16f85269a commit 1
+  
+
 Preview absorb changes:
 
-  $ hg absorb --print-changes --dry-run
+  $ hg absorb --print-changes --dry-run -s .
   showing changes for a
   @@ -0,2 +0,2 @@
   4ec16f8 -1
@@ -66,462 +73,185 @@
   5c5f952 commit 2
   4ec16f8 commit 1
 
+Try to absorb multiple revisions:
+
+  $ hg absorb --apply-changes -s '.^+.'
+  abort: revision set matched multiple revisions
+  [255]
+
+Add an uncommitted working directory change:
+
+  $ echo 6 >> a
+
 Run absorb:
 
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
+  $ hg absorb --apply-changes -s .
+  1 new orphan changesets
   2 of 2 chunk(s) applied
-  $ hg annotate a
-  0: 1a
-  1: 2b
-  2: 3
-  3: 4d
-  4: 5e
-
-Delete a few lines and related commits will be removed if they will be empty:
-
-  $ cat > a < 2b
-  > 4d
-  > EOF
-  $ echo y | hg absorb --config ui.interactive=1
-  showing changes for a
-  @@ -0,1 +0,0 @@
-  f548282 -1a
-  @@ -2,1 +1,0 @@
-  ff5d556 -3
-  @@ -4,1 +2,0 @@
-  84e5416 -5e
+Note: this only shows disconnected graphs because the root node was also
+absorbed into.
+  $ hg glog
+  o  2f7ba78d6abc commit 5
+  |
+  o  04c8ba6df782 commit 4
+  |
+  o  484c6ac0cea3 commit 3
+  |
+  o  9b19176bb127 commit 2
+  |
+  o  241ace8326d0 commit 1
   
-  3 changesets affected
-  84e5416 commit 5
-  ff5d556 commit 3
-  f548282 commit 1
-  apply changes (yn)?  y
-  saved backup bundle to * (glob)
-  3 of 3 chunk(s) applied
-  $ hg annotate a
-  1: 2b
-  2: 4d
-  $ hg log -T '{rev} {desc}\n' -Gp
-  @  2 commit 4
-  |  diff -r 1cae118c7ed8 -r 58a62bade1c6 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -1,1 +1,2 @@
-  |   2b
-  |  +4d
+  @  1631091f9648 commit to absorb orphan
+  |
+  x  4f55fa657dae commit 5
+  |
+  x  ad8b8b75557f commit 4
   |
-  o  1 commit 2
-  |  diff -r 84add69aeac0 -r 1cae118c7ed8 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -0,0 +1,1 @@
-  |  +2b
+  x  43f0a75bede7 commit 3
   |
-  o  0 commit 1
+  x  5c5f95224a50 commit 2
+  |
+  x  4ec16f85269a commit 1
   
 
-Non 1:1 map changes will be ignored:
-
-  $ echo 1 > a
-  $ hg absorb --apply-changes
-  nothing applied
-  [1]
-
-The prompt is not given if there are no changes to be applied, even if there
-are some changes that won't be applied:
-
-  $ hg absorb
-  showing changes for a
-  @@ -0,2 +0,1 @@
-  -2b
-  -4d
-  +1
-  
-  0 changesets affected
-  nothing applied
-  [1]
-
-Insertaions:
-
-  $ cat > a << EOF
-  > insert before 2b
-  > 2b
-  > 4d
-  > insert aftert 4d
-  > EOF
-  $ hg absorb -q --apply-changes
-  $ hg status
-  $ hg annotate a
-  1: insert before 2b
-  1: 2b
-  2: 4d
-  2: insert aftert 4d
-
-Bookmarks are moved:
-
-  $ hg bookmark -r 1 b1
-  $ hg bookmark -r 2 b2
-  $ hg bookmark ba
-  $ hg bookmarks
- b11:b35060a57a50
- b22:946e4bc87915
-   * ba2:946e4bc87915
-  $ sedi 's/insert/INSERT/' a
-  $ hg absorb -q --apply-changes
-  $ hg status
-  $ hg bookmarks
- b11:a4183e9b3d31
- b22:c9b20c925790
-   * ba

D7630: absorb: make the absorbed changeset be automatically "evolved"

2020-02-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 19980.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7630?vs=19812=19980

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t

CHANGE DETAILS

diff --git a/tests/test-absorb-rev.t b/tests/test-absorb-rev.t
--- a/tests/test-absorb-rev.t
+++ b/tests/test-absorb-rev.t
@@ -86,11 +86,10 @@
 Run absorb:
 
   $ hg absorb --apply-changes -s .
-  1 new orphan changesets
   2 of 2 chunk(s) applied
-Note: this only shows disconnected graphs because the root node was also
-absorbed into.
   $ hg glog
+  @  9a0ec5cae1a1 commit to absorb
+  |
   o  2f7ba78d6abc commit 5
   |
   o  04c8ba6df782 commit 4
@@ -101,18 +100,6 @@
   |
   o  241ace8326d0 commit 1
   
-  @  1631091f9648 commit to absorb orphan
-  |
-  x  4f55fa657dae commit 5
-  |
-  x  ad8b8b75557f commit 4
-  |
-  x  43f0a75bede7 commit 3
-  |
-  x  5c5f95224a50 commit 2
-  |
-  x  4ec16f85269a commit 1
-  
 
 Check that the pending wdir change was left alone:
 
@@ -127,34 +114,21 @@
4d
5e
   +6
-  $ hg update -Cq .
-
-Rebase the absorbed revision on top of the destination (as evolve would):
-TODO: the evolve-type operation should happen automatically for the changeset
-being absorbed, and even through that the pending wdir change should be left
-alone.
-
-  $ hg rebase -d tip -r .
-  rebasing 5:1631091f9648 "commit to absorb"
-  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
-  $ hg glog
-  @  2f7ba78d6abc commit 5
-  |
-  o  04c8ba6df782 commit 4
-  |
-  o  484c6ac0cea3 commit 3
-  |
-  o  9b19176bb127 commit 2
-  |
-  o  241ace8326d0 commit 1
-  
-  $ hg annotate -c a
-  241ace8326d0: 1a
-  9b19176bb127: 2b
-  484c6ac0cea3: 3
-  04c8ba6df782: 4d
-  2f7ba78d6abc: 5e
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  9b19176bb127 : 2b
+  484c6ac0cea3 : 3
+  04c8ba6df782 : 4d
+  2f7ba78d6abc : 5e
+  9a0ec5cae1a1+: 6
+
+TODO: The absorbed commit should have disappeared when it became empty.
+  $ hg diff -c .
+  $ hg debugobsolete $(hg log -T "{node}\n" -r .)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg update -Cq '.^'
 
 Do it again, but this time with an unrelated commit checked out (plus working
 directory changes on top):
@@ -200,22 +174,17 @@
   2 changesets affected
   2f7ba78 commit 5
   04c8ba6 commit 4
-  1 new orphan changesets
   1 of 1 chunk(s) applied
 
   $ hg glog
+  o  da8aed1fcb63 commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
   | @  dbce69d9fe03 unrelated commit
   | |
-  | | *  410fcc72c5c9 commit to absorb 2 orphan
-  | | |
-  | | x  2f7ba78d6abc commit 5
-  | | |
-  +---x  04c8ba6df782 commit 4
-  | |
   o |  484c6ac0cea3 commit 3
   | |
   o |  9b19176bb127 commit 2
@@ -228,18 +197,16 @@
   dbce69d9fe03 : committed unrelated
   dbce69d9fe03+: pending wdir change
 
-  $ hg update -Cq .
-
-  $ hg rebase -d tip -r ${TOABSORB}
-  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
-  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+  $ hg update -Cq tip
 
   $ hg glog
+  o  da8aed1fcb63 commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
-  | @  dbce69d9fe03 unrelated commit
+  | o  dbce69d9fe03 unrelated commit
   | |
   o |  484c6ac0cea3 commit 3
   | |
@@ -248,7 +215,7 @@
   o  241ace8326d0 commit 1
   
 
-  $ hg annotate -c a -r tip
+  $ hg annotate -c a
   241ace8326d0: 1a
   9b19176bb127: 2b
   484c6ac0cea3: 3
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -34,6 +34,7 @@
 from __future__ import absolute_import
 
 import collections
+import itertools
 
 from mercurial.i18n import _
 from mercurial import (
@@ -662,16 +663,19 @@
 4. call commit, to commit changes to hg database
 """
 
-def __init__(self, stack, ui=None, opts=None):
+def __init__(self, stack, fixuptargets=[], ui=None, opts=None):
 """([ctx], ui or None) -> None
 
 stack: should be linear, and sorted by topo order - oldest first.
+fixuptargets: changeset contexts that need to be fixed up, but are not
+used for fixup computation.
 all commits in stack are considered mutable.
 """
 assert stack
 self.ui = ui or nullui()
 self.opts = opts or {}
 self.stack = stack
+self.fixuptargets = fixuptargets
 self.repo = stack[-1].repo().unfiltered()
 
 # following fields will be filled later
@@ -777,7 +781,7 @@
 # p1 which overrides the parent of the next commit, "None" means use
 # the original parent unchanged
 nextp1 = None
-for ctx in self.stack:
+for ctx in itertools.chain(self.stack, self.fixuptargets):
 

D8064: split: add a --single flag to only ask for one split

2020-01-31 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The majority of split invocations only want to split a revision in two,
  so this allows them to do that without getting a second chunk selector.
  I thought of making a generic "max_splits" flag, but that seemed like
  overkill.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/split.py
  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
@@ -976,3 +976,60 @@
   2
   3
   4
+
+Test doing single splits, where it doesn't prompt to inspect what's left after
+the first split.
+--
+
+  $ hg init $TESTTMP/splitsingle
+  $ cd $TESTTMP/splitsingle
+  $ printf '1\n2\n' > file
+  $ hg ci -qAm initial
+  $ printf '0\n1\n2\n3\n' > file
+  $ hg ci -qm splitme
+  $ cat > $TESTTMP/messages < split1
+  > --
+  > split2
+  > EOF
+  $ printf 'y\ny\nn\n' | hg split --single
+  diff --git a/file b/file
+  2 hunks, 2 lines changed
+  examine changes to 'file'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  @@ -0,0 +1,1 @@
+  +0
+  record change 1/2 to 'file'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  @@ -2,0 +4,1 @@ 2
+  +3
+  record change 2/2 to 'file'?
+  (enter ? for help) [Ynesfdaq?] n
+  
+  EDITOR: HG: Splitting 82efe286d133. Write commit message for the first split 
changeset.
+  EDITOR: splitme
+  EDITOR: 
+  EDITOR: 
+  EDITOR: HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  EDITOR: HG: Leave message empty to abort commit.
+  EDITOR: HG: --
+  EDITOR: HG: user: test
+  EDITOR: HG: branch 'default'
+  EDITOR: HG: changed file
+  created new head
+  EDITOR: HG: Splitting 82efe286d133. So far it has been split into:
+  EDITOR: HG: - 810358029ce5: split1
+  EDITOR: HG: Write commit message for the next split changeset.
+  EDITOR: splitme
+  EDITOR: 
+  EDITOR: 
+  EDITOR: HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  EDITOR: HG: Leave message empty to abort commit.
+  EDITOR: HG: --
+  EDITOR: HG: user: test
+  EDITOR: HG: branch 'default'
+  EDITOR: HG: changed file
+  saved backup bundle to 
$TESTTMP/splitsingle/.hg/strip-backup/82efe286d133-1ff8b354-split.hg 
(obsstore-off !)
+
diff --git a/hgext/split.py b/hgext/split.py
--- a/hgext/split.py
+++ b/hgext/split.py
@@ -47,6 +47,7 @@
 [
 (b'r', b'rev', b'', _(b"revision to split"), _(b'REV')),
 (b'', b'rebase', True, _(b'rebase descendants after split')),
+(b'', b'single', False, _(b'make a single split')),
 ]
 + cmdutil.commitopts2,
 _(b'hg split [--no-rebase] [[-r] REV]'),
@@ -137,8 +138,13 @@
 return any((st.modified, st.added, st.removed, st.deleted))
 
 # Main split loop
+opts.update({b'edit': True, b'interactive': True})
 while incomplete(repo):
 if committed:
+if opts[b'single']:
+# Will make this take all changes and be the last split.
+del opts[b'interactive']
+
 header = _(
 b'HG: Splitting %s. So far it has been split into:\n'
 ) % short(ctx.node())
@@ -153,13 +159,8 @@
 b'HG: Splitting %s. Write commit message for the '
 b'first split changeset.\n'
 ) % short(ctx.node())
-opts.update(
-{
-b'edit': True,
-b'interactive': True,
-b'message': header + ctx.description(),
-}
-)
+
+opts.update({b'message': header + ctx.description()})
 commands.commit(ui, repo, **pycompat.strkwargs(opts))
 newctx = repo[b'.']
 committed.append(newctx)



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


D7630: absorb: make the absorbed changeset be automatically "evolved"

2020-01-31 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  > In D7630#117270 , @marmoute 
wrote:
  >
  >> In D7630#115320 , @pulkit 
wrote:
  >>
  > This results in an empty commit which is not similar to what rebase or 
evolve will generally result in after `D7631` unless `ui.allowemptycommit=True` 
is set. I think good behavior is to obsolete the absorbed changeset in favour 
of either it's parent or one of the revs in which it was absorbed.
  
   I made a related comment on the parent patch before I realized that this 
patch adds obsmarker handling. My suggestion there was to mark all the commits 
that got absorbed into as successors, and if there's anything left in the 
absorbed commit, that would be yet another successor. Would that work?
  >>>
  >>> Yep, that sounds good.
  >
  > I'm fine with doing this, but is there an efficient way to detect that it 
became empty?
  
  And by "this" I meant I'm fine with making it disappear if allowemptycommit 
is False. I don't fully understand how markers help accomplish that.

REPOSITORY
  rHG Mercurial

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

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

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


D7631: absorb: allowing committed changes to be absorbed into their ancestors

2020-01-31 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio marked 5 inline comments as done.
rdamazio updated this revision to Diff 19811.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7631?vs=19048=19811

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  mercurial/scmutil.py
  relnotes/5.3
  relnotes/next
  tests/test-absorb-rev.t
  tests/test-absorb.t

CHANGE DETAILS

diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -143,7 +143,7 @@
   nothing applied
   [1]
 
-Insertaions:
+Insertions:
 
   $ cat > a << EOF
   > insert before 2b
diff --git a/tests/test-absorb.t b/tests/test-absorb-rev.t
copy from tests/test-absorb.t
copy to tests/test-absorb-rev.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb-rev.t
@@ -1,26 +1,16 @@
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > absorb=
+  > rebase=
+  > [experimental]
+  > evolution=createmarkers
+  > [alias]
+  > glog=log -G -T '{node|short} {desc} {instabilities}'
   > EOF
 
-  $ sedi() { # workaround check-code
-  > pattern="$1"
-  > shift
-  > for i in "$@"; do
-  > sed "$pattern" "$i" > "$i".tmp
-  > mv "$i".tmp "$i"
-  > done
-  > }
-
   $ hg init repo1
   $ cd repo1
 
-Do not crash with empty repo:
-
-  $ hg absorb
-  abort: no mutable changeset to change
-  [255]
-
 Make some commits:
 
   $ for i in 1 2 3 4 5; do
@@ -45,9 +35,26 @@
   > 5e
   > EOF
 
+Commit that, too.
+
+  $ hg commit -qm "commit to absorb"
+  $ hg glog
+  @  1631091f9648 commit to absorb
+  |
+  o  4f55fa657dae commit 5
+  |
+  o  ad8b8b75557f commit 4
+  |
+  o  43f0a75bede7 commit 3
+  |
+  o  5c5f95224a50 commit 2
+  |
+  o  4ec16f85269a commit 1
+  
+
 Preview absorb changes:
 
-  $ hg absorb --print-changes --dry-run
+  $ hg absorb --print-changes --dry-run -s .
   showing changes for a
   @@ -0,2 +0,2 @@
   4ec16f8 -1
@@ -66,462 +73,185 @@
   5c5f952 commit 2
   4ec16f8 commit 1
 
+Try to absorb multiple revisions:
+
+  $ hg absorb --apply-changes -s '.^+.'
+  abort: revision set matched multiple revisions
+  [255]
+
+Add an uncommitted working directory change:
+
+  $ echo 6 >> a
+
 Run absorb:
 
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
+  $ hg absorb --apply-changes -s .
+  1 new orphan changesets
   2 of 2 chunk(s) applied
-  $ hg annotate a
-  0: 1a
-  1: 2b
-  2: 3
-  3: 4d
-  4: 5e
-
-Delete a few lines and related commits will be removed if they will be empty:
-
-  $ cat > a < 2b
-  > 4d
-  > EOF
-  $ echo y | hg absorb --config ui.interactive=1
-  showing changes for a
-  @@ -0,1 +0,0 @@
-  f548282 -1a
-  @@ -2,1 +1,0 @@
-  ff5d556 -3
-  @@ -4,1 +2,0 @@
-  84e5416 -5e
+Note: this only shows disconnected graphs because the root node was also
+absorbed into.
+  $ hg glog
+  o  2f7ba78d6abc commit 5
+  |
+  o  04c8ba6df782 commit 4
+  |
+  o  484c6ac0cea3 commit 3
+  |
+  o  9b19176bb127 commit 2
+  |
+  o  241ace8326d0 commit 1
   
-  3 changesets affected
-  84e5416 commit 5
-  ff5d556 commit 3
-  f548282 commit 1
-  apply changes (yn)?  y
-  saved backup bundle to * (glob)
-  3 of 3 chunk(s) applied
-  $ hg annotate a
-  1: 2b
-  2: 4d
-  $ hg log -T '{rev} {desc}\n' -Gp
-  @  2 commit 4
-  |  diff -r 1cae118c7ed8 -r 58a62bade1c6 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -1,1 +1,2 @@
-  |   2b
-  |  +4d
+  @  1631091f9648 commit to absorb orphan
+  |
+  x  4f55fa657dae commit 5
+  |
+  x  ad8b8b75557f commit 4
   |
-  o  1 commit 2
-  |  diff -r 84add69aeac0 -r 1cae118c7ed8 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -0,0 +1,1 @@
-  |  +2b
+  x  43f0a75bede7 commit 3
   |
-  o  0 commit 1
+  x  5c5f95224a50 commit 2
+  |
+  x  4ec16f85269a commit 1
   
 
-Non 1:1 map changes will be ignored:
-
-  $ echo 1 > a
-  $ hg absorb --apply-changes
-  nothing applied
-  [1]
-
-The prompt is not given if there are no changes to be applied, even if there
-are some changes that won't be applied:
-
-  $ hg absorb
-  showing changes for a
-  @@ -0,2 +0,1 @@
-  -2b
-  -4d
-  +1
-  
-  0 changesets affected
-  nothing applied
-  [1]
-
-Insertaions:
-
-  $ cat > a << EOF
-  > insert before 2b
-  > 2b
-  > 4d
-  > insert aftert 4d
-  > EOF
-  $ hg absorb -q --apply-changes
-  $ hg status
-  $ hg annotate a
-  1: insert before 2b
-  1: 2b
-  2: 4d
-  2: insert aftert 4d
-
-Bookmarks are moved:
-
-  $ hg bookmark -r 1 b1
-  $ hg bookmark -r 2 b2
-  $ hg bookmark ba
-  $ hg bookmarks
- b11:b35060a57a50
- b22:946e4bc87915
-   * ba2:946e4bc87915
-  $ sedi 's/insert/INSERT/' a
-  $ hg absorb -q --apply-changes
-  $ hg status
-  $ hg bookmarks
- b11:a4183e9b3d31
- b2

D7630: absorb: make the absorbed changeset be automatically "evolved"

2020-01-31 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 19812.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7630?vs=19049=19812

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t

CHANGE DETAILS

diff --git a/tests/test-absorb-rev.t b/tests/test-absorb-rev.t
--- a/tests/test-absorb-rev.t
+++ b/tests/test-absorb-rev.t
@@ -86,11 +86,10 @@
 Run absorb:
 
   $ hg absorb --apply-changes -s .
-  1 new orphan changesets
   2 of 2 chunk(s) applied
-Note: this only shows disconnected graphs because the root node was also
-absorbed into.
   $ hg glog
+  @  9a0ec5cae1a1 commit to absorb
+  |
   o  2f7ba78d6abc commit 5
   |
   o  04c8ba6df782 commit 4
@@ -101,18 +100,6 @@
   |
   o  241ace8326d0 commit 1
   
-  @  1631091f9648 commit to absorb orphan
-  |
-  x  4f55fa657dae commit 5
-  |
-  x  ad8b8b75557f commit 4
-  |
-  x  43f0a75bede7 commit 3
-  |
-  x  5c5f95224a50 commit 2
-  |
-  x  4ec16f85269a commit 1
-  
 
 Check that the pending wdir change was left alone:
 
@@ -127,34 +114,21 @@
4d
5e
   +6
-  $ hg update -Cq .
-
-Rebase the absorbed revision on top of the destination (as evolve would):
-TODO: the evolve-type operation should happen automatically for the changeset
-being absorbed, and even through that the pending wdir change should be left
-alone.
-
-  $ hg rebase -d tip -r .
-  rebasing 5:1631091f9648 "commit to absorb"
-  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
-  $ hg glog
-  @  2f7ba78d6abc commit 5
-  |
-  o  04c8ba6df782 commit 4
-  |
-  o  484c6ac0cea3 commit 3
-  |
-  o  9b19176bb127 commit 2
-  |
-  o  241ace8326d0 commit 1
-  
-  $ hg annotate -c a
-  241ace8326d0: 1a
-  9b19176bb127: 2b
-  484c6ac0cea3: 3
-  04c8ba6df782: 4d
-  2f7ba78d6abc: 5e
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  9b19176bb127 : 2b
+  484c6ac0cea3 : 3
+  04c8ba6df782 : 4d
+  2f7ba78d6abc : 5e
+  9a0ec5cae1a1+: 6
+
+TODO: The absorbed commit should have disappeared when it became empty.
+  $ hg diff -c .
+  $ hg debugobsolete $(hg log -T "{node}\n" -r .)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg update -Cq '.^'
 
 Do it again, but this time with an unrelated commit checked out (plus working
 directory changes on top):
@@ -200,22 +174,17 @@
   2 changesets affected
   2f7ba78 commit 5
   04c8ba6 commit 4
-  1 new orphan changesets
   1 of 1 chunk(s) applied
 
   $ hg glog
+  o  da8aed1fcb63 commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
   | @  dbce69d9fe03 unrelated commit
   | |
-  | | *  410fcc72c5c9 commit to absorb 2 orphan
-  | | |
-  | | x  2f7ba78d6abc commit 5
-  | | |
-  +---x  04c8ba6df782 commit 4
-  | |
   o |  484c6ac0cea3 commit 3
   | |
   o |  9b19176bb127 commit 2
@@ -228,18 +197,16 @@
   dbce69d9fe03 : committed unrelated
   dbce69d9fe03+: pending wdir change
 
-  $ hg update -Cq .
-
-  $ hg rebase -d tip -r ${TOABSORB}
-  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
-  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+  $ hg update -Cq tip
 
   $ hg glog
+  o  da8aed1fcb63 commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
-  | @  dbce69d9fe03 unrelated commit
+  | o  dbce69d9fe03 unrelated commit
   | |
   o |  484c6ac0cea3 commit 3
   | |
@@ -248,7 +215,7 @@
   o  241ace8326d0 commit 1
   
 
-  $ hg annotate -c a -r tip
+  $ hg annotate -c a
   241ace8326d0: 1a
   9b19176bb127: 2b
   484c6ac0cea3: 3
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -34,6 +34,7 @@
 from __future__ import absolute_import
 
 import collections
+import itertools
 
 from mercurial.i18n import _
 from mercurial import (
@@ -662,16 +663,19 @@
 4. call commit, to commit changes to hg database
 """
 
-def __init__(self, stack, ui=None, opts=None):
+def __init__(self, stack, fixuptargets=[], ui=None, opts=None):
 """([ctx], ui or None) -> None
 
 stack: should be linear, and sorted by topo order - oldest first.
+fixuptargets: changeset contexts that need to be fixed up, but are not
+used for fixup computation.
 all commits in stack are considered mutable.
 """
 assert stack
 self.ui = ui or nullui()
 self.opts = opts or {}
 self.stack = stack
+self.fixuptargets = fixuptargets
 self.repo = stack[-1].repo().unfiltered()
 
 # following fields will be filled later
@@ -777,7 +781,7 @@
 # p1 which overrides the parent of the next commit, "None" means use
 # the original parent unchanged
 nextp1 = None
-for ctx in self.stack:
+for ctx in itertools.chain(self.stack, self.fixuptargets):
 

D7631: absorb: allowing committed changes to be absorbed into their ancestors

2020-01-31 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  Sorry for the delay in replying here.

INLINE COMMENTS

> martinvonz wrote in absorb.py:993
> Maybe I'm also misunderstanding what this patch does in that case. `hg absorb 
> -r A` will not obsolete A? I would think it definitely should do that. 
> Perhaps the successors or the absorbed commit should be all the nodes 
> absorbed into as well as any potential leftovers (which were not absorbed).

See the child commit (D7630 ), which adds 
the "evolve" operation.

Because of the invariant about parent phases, checking that the revision being 
absorbed is not public also ensures that everything it's absorbing into is not 
public. Is that what you were looking for? If the commit A being absorbed is a 
draft and its parent is public, then absorb just won't find anywhere to absorb 
the lines and will leave everything in A.

About setting obsmarkers from the absorbed commit into the targets, while 
that's technically correct, I suspect it'll become a hard-to-navigate mess 
which adds very little. Do you want me to add that?

REPOSITORY
  rHG Mercurial

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

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

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


D7630: absorb: make the absorbed changeset be automatically "evolved"

2020-01-31 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In D7630#115300 , @pulkit wrote:
  
  > This results in an empty commit which is not similar to what rebase or 
evolve will generally result in after `D7631` unless `ui.allowemptycommit=True` 
is set. I think good behavior is to obsolete the absorbed changeset in favour 
of either it's parent or one of the revs in which it was absorbed.
  
  It's not *always* empty - if there had been lines that it failed absorb 
(because it couldn't find where to absorb into), those would be left in the 
commit.
  
  In D7630#117270 , @marmoute 
wrote:
  
  > In D7630#115320 , @pulkit 
wrote:
  >
   This results in an empty commit which is not similar to what rebase or 
evolve will generally result in after `D7631` unless `ui.allowemptycommit=True` 
is set. I think good behavior is to obsolete the absorbed changeset in favour 
of either it's parent or one of the revs in which it was absorbed.
  >>>
  >>> I made a related comment on the parent patch before I realized that this 
patch adds obsmarker handling. My suggestion there was to mark all the commits 
that got absorbed into as successors, and if there's anything left in the 
absorbed commit, that would be yet another successor. Would that work?
  >>
  >> Yep, that sounds good.
  
  I'm fine with doing this, but is there an efficient way to detect that it 
became empty?
  
  > This means generate split+fold markers. That is going to be fun to deal 
with :-). I dont' really have any much better idea however (the alternative 
seems to use simple prune markers, which is meh).
  
  I'm not following this part - why do you need markers at all?
  (you can argue whether you want them - but I don't see why you *need* them)

REPOSITORY
  rHG Mercurial

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

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

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


D7854: phases: make phasecache._phasesets immutable

2020-01-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHGc31ec768d70a: phases: make phasecache._phasesets immutable 
(authored by rdamazio).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7854?vs=19195=19206

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

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

AFFECTED FILES
  mercurial/phases.py

CHANGE DETAILS

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -253,15 +253,19 @@
 
 # fast path: _phasesets contains the interesting sets,
 # might only need a union and post-filtering.
+revsneedscopy = False
 if len(phases) == 1:
 [p] = phases
 revs = self._phasesets[p]
+revsneedscopy = True  # Don't modify _phasesets
 else:
 # revs has the revisions in all *other* phases.
 revs = set.union(*[self._phasesets[p] for p in phases])
 
 def _addwdir(wdirsubset, wdirrevs):
 if wdirrev in wdirsubset and repo[None].phase() in phases:
+if revsneedscopy:
+wdirrevs = wdirrevs.copy()
 # The working dir would never be in the # cache, but it was in
 # the subset being filtered for its phase (or filtered out,
 # depending on publicphase), so add it to the output to be



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


D7853: phases: reduce code duplication in phasecache.getrevset

2020-01-14 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHG90eedaa80503: phases: reduce code duplication in 
phasecache.getrevset (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7853?vs=19194=19205

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

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

AFFECTED FILES
  mercurial/phases.py

CHANGE DETAILS

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -243,49 +243,46 @@
 """return a smartset for the given phases"""
 self.loadphaserevs(repo)  # ensure phase's sets are loaded
 phases = set(phases)
+publicphase = public in phases
 
-if public not in phases:
-# fast path: _phasesets contains the interesting sets,
-# might only need a union and post-filtering.
-if len(phases) == 1:
-[p] = phases
-revs = self._phasesets[p]
-else:
-revs = set.union(*[self._phasesets[p] for p in phases])
+if publicphase:
+# In this case, phases keeps all the *other* phases.
+phases = set(allphases).difference(phases)
+if not phases:
+return smartset.fullreposet(repo)
+
+# fast path: _phasesets contains the interesting sets,
+# might only need a union and post-filtering.
+if len(phases) == 1:
+[p] = phases
+revs = self._phasesets[p]
+else:
+# revs has the revisions in all *other* phases.
+revs = set.union(*[self._phasesets[p] for p in phases])
+
+def _addwdir(wdirsubset, wdirrevs):
+if wdirrev in wdirsubset and repo[None].phase() in phases:
+# The working dir would never be in the # cache, but it was in
+# the subset being filtered for its phase (or filtered out,
+# depending on publicphase), so add it to the output to be
+# included (or filtered out).
+wdirrevs.add(wdirrev)
+return wdirrevs
+
+if not publicphase:
 if repo.changelog.filteredrevs:
 revs = revs - repo.changelog.filteredrevs
 
 if subset is None:
 return smartset.baseset(revs)
 else:
-if wdirrev in subset and repo[None].phase() in phases:
-# The working dir would never be in the cache, but it was
-# in the subset being filtered for its phase, so add it to
-# the output.
-revs.add(wdirrev)
-
+revs = _addwdir(subset, revs)
 return subset & smartset.baseset(revs)
 else:
-# phases keeps all the *other* phases.
-phases = set(allphases).difference(phases)
-if not phases:
-return smartset.fullreposet(repo)
-
-# revs has the revisions in all *other* phases.
-if len(phases) == 1:
-[p] = phases
-revs = self._phasesets[p]
-else:
-revs = set.union(*[self._phasesets[p] for p in phases])
-
 if subset is None:
 subset = smartset.fullreposet(repo)
 
-if wdirrev in subset and repo[None].phase() in phases:
-# The working dir is in the subset being filtered, and its
-# phase is in the phases *not* being returned, so add it to the
-# set of revisions to filter out.
-revs.add(wdirrev)
+revs = _addwdir(subset, revs)
 
 if not revs:
 return subset



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


D7854: phases: make phasecache._phasesets immutable

2020-01-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Previously, some code paths would mutate the cache itself, which
  could give weird results if multiple revsets got evaluated through
  that path.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/phases.py

CHANGE DETAILS

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -253,15 +253,19 @@
 
 # fast path: _phasesets contains the interesting sets,
 # might only need a union and post-filtering.
+revsneedscopy = False
 if len(phases) == 1:
 [p] = phases
 revs = self._phasesets[p]
+revsneedscopy = True  # Don't modify _phasesets
 else:
 # revs has the revisions in all *other* phases.
 revs = set.union(*[self._phasesets[p] for p in phases])
 
 def _addwdir(wdirsubset, wdirrevs):
 if wdirrev in wdirsubset and repo[None].phase() in phases:
+if revsneedscopy:
+wdirrevs = wdirrevs.copy()
 # The working dir would never be in the # cache, but it was in
 # the subset being filtered for its phase (or filtered out,
 # depending on publicphase), so add it to the output to be



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


D7853: phases: reduce code duplication in phasecache.getrevset

2020-01-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is a functional NOP other than reducing some of the duplication
  in that method.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/phases.py

CHANGE DETAILS

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -243,49 +243,46 @@
 """return a smartset for the given phases"""
 self.loadphaserevs(repo)  # ensure phase's sets are loaded
 phases = set(phases)
+publicphase = public in phases
 
-if public not in phases:
-# fast path: _phasesets contains the interesting sets,
-# might only need a union and post-filtering.
-if len(phases) == 1:
-[p] = phases
-revs = self._phasesets[p]
-else:
-revs = set.union(*[self._phasesets[p] for p in phases])
+if publicphase:
+# In this case, phases keeps all the *other* phases.
+phases = set(allphases).difference(phases)
+if not phases:
+return smartset.fullreposet(repo)
+
+# fast path: _phasesets contains the interesting sets,
+# might only need a union and post-filtering.
+if len(phases) == 1:
+[p] = phases
+revs = self._phasesets[p]
+else:
+# revs has the revisions in all *other* phases.
+revs = set.union(*[self._phasesets[p] for p in phases])
+
+def _addwdir(wdirsubset, wdirrevs):
+if wdirrev in wdirsubset and repo[None].phase() in phases:
+# The working dir would never be in the # cache, but it was in
+# the subset being filtered for its phase (or filtered out,
+# depending on publicphase), so add it to the output to be
+# included (or filtered out).
+wdirrevs.add(wdirrev)
+return wdirrevs
+
+if not publicphase:
 if repo.changelog.filteredrevs:
 revs = revs - repo.changelog.filteredrevs
 
 if subset is None:
 return smartset.baseset(revs)
 else:
-if wdirrev in subset and repo[None].phase() in phases:
-# The working dir would never be in the cache, but it was
-# in the subset being filtered for its phase, so add it to
-# the output.
-revs.add(wdirrev)
-
+revs = _addwdir(subset, revs)
 return subset & smartset.baseset(revs)
 else:
-# phases keeps all the *other* phases.
-phases = set(allphases).difference(phases)
-if not phases:
-return smartset.fullreposet(repo)
-
-# revs has the revisions in all *other* phases.
-if len(phases) == 1:
-[p] = phases
-revs = self._phasesets[p]
-else:
-revs = set.union(*[self._phasesets[p] for p in phases])
-
 if subset is None:
 subset = smartset.fullreposet(repo)
 
-if wdirrev in subset and repo[None].phase() in phases:
-# The working dir is in the subset being filtered, and its
-# phase is in the phases *not* being returned, so add it to the
-# set of revisions to filter out.
-revs.add(wdirrev)
+revs = _addwdir(subset, revs)
 
 if not revs:
 return subset



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


D7705: phases: make the working directory consistently a draft

2020-01-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  x

REPOSITORY
  rHG Mercurial

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

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

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


D7705: phases: make the working directory consistently a draft

2020-01-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In D7705#114943 , @yuja wrote:
  
  >> @@ -252,25 +254,44 @@
  >>
  >>   revs = set.union(*[self._phasesets[p] for p in phases])
  >>   if repo.changelog.filteredrevs:
  >>   revs = revs - repo.changelog.filteredrevs
  >>
  >> +
  >>
  >>   if subset is None:
  >>   return smartset.baseset(revs)
  >>   else:
  >>
  >> +if wdirrev in subset and repo[None].phase() in phases:
  >> +# The working dir would never be in the cache, but it 
was
  >> +# in the subset being filtered for its phase, so add 
it to
  >> +# the output.
  >> +revs.add(wdirrev)
  >
  > Suppose `self._phasesets[]` is a read-only object in this method,
  > I think `revs` shouldn't be mutated if `revs is self._phasesets[p]`.
  >
  >> +if wdirrev in subset and repo[None].phase() in phases:
  >> +# The working dir is in the subset being filtered, and its
  >> +# phase is in the phases *not* being returned, so add it 
to the
  >> +# set of revisions to filter out.
  >> +revs.add(wdirrev)
  >
  > Same here.
  
  Good point, I'll send another change.

REPOSITORY
  rHG Mercurial

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

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

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


D7705: phases: make the working directory consistently a draft

2020-01-08 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHG2ab225377c27: phases: make the working directory 
consistently a draft (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7705?vs=19050=19067

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

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

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

CHANGE DETAILS

diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -48,13 +48,58 @@
   1 1 B
   0 1 A
 
-Draft commit are properly created over public one:
+Working directory phase is secret when its parent is secret.
+
+  $ hg phase --force --secret .
+  test-debug-phase: move rev 0: 1 -> 2
+  test-debug-phase: move rev 1: 1 -> 2
+  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:  draft -> 
secret
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  draft -> 
secret
+  $ hg log -r 'wdir()' -T '{phase}\n'
+  secret
+  $ hg log -r 'wdir() and public()' -T '{phase}\n'
+  $ hg log -r 'wdir() and draft()' -T '{phase}\n'
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n'
+  secret
+
+Working directory phase is draft when its parent is draft.
+
+  $ hg phase --draft .
+  test-debug-phase: move rev 1: 2 -> 1
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  secret -> 
draft
+  $ hg log -r 'wdir()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and public()' -T '{phase}\n'
+  $ hg log -r 'wdir() and draft()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n'
+
+Working directory phase is secret when a new commit will be created as secret,
+even if the parent is draft.
+
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n' \
+  > --config phases.new-commit='secret'
+  secret
+
+Working directory phase is draft when its parent is public.
 
   $ hg phase --public .
   test-debug-phase: move rev 0: 1 -> 0
   test-debug-phase: move rev 1: 1 -> 0
   test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:  draft -> 
public
   test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  draft -> 
public
+  $ hg log -r 'wdir()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and public()' -T '{phase}\n'
+  $ hg log -r 'wdir() and draft()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n'
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n' \
+  > --config phases.new-commit='secret'
+  secret
+
+Draft commit are properly created over public one:
+
   $ hg phase
   1: public
   $ hglog
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -112,6 +112,7 @@
 nullid,
 nullrev,
 short,
+wdirrev,
 )
 from .pycompat import (
 getattr,
@@ -242,6 +243,7 @@
 """return a smartset for the given phases"""
 self.loadphaserevs(repo)  # ensure phase's sets are loaded
 phases = set(phases)
+
 if public not in phases:
 # fast path: _phasesets contains the interesting sets,
 # might only need a union and post-filtering.
@@ -252,25 +254,44 @@
 revs = set.union(*[self._phasesets[p] for p in phases])
 if repo.changelog.filteredrevs:
 revs = revs - repo.changelog.filteredrevs
+
 if subset is None:
 return smartset.baseset(revs)
 else:
+if wdirrev in subset and repo[None].phase() in phases:
+# The working dir would never be in the cache, but it was
+# in the subset being filtered for its phase, so add it to
+# the output.
+revs.add(wdirrev)
+
 return subset & smartset.baseset(revs)
 else:
+# phases keeps all the *other* phases.
 phases = set(allphases).difference(phases)
 if not phases:
 return smartset.fullreposet(repo)
+
+# revs has the revisions in all *other* phases.
 if len(phases) == 1:
 [p] = phases
 revs = self._phasesets[p]
 else:
 revs = set.union(*[self._phasesets[p] for p in phases])
+
 if subset is None:
 subset = smartset.fullreposet(repo)
+
+if wdirrev in subset and repo[None].phase() in phases:
+# The working dir is in the subset being filtered, and its
+# phase is in the phases *not* being returned, so add it to the
+# set of revisions to filter out.
+revs.add(wdirrev)
+
 if not revs:
 return subset
 return subset.filter(lambda r: r not in revs)
 
+
 def copy(self):
 # Shallow copy 

D7705: phases: make the working directory consistently a draft

2020-01-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In D7705#114157 , @marmoute 
wrote:
  
  > In D7705#114045 , @rdamazio 
wrote:
  >
  >> I don't understand what you're asking me to do here, can you clarify?
  >
  > In short we should have a test matching
  >
  >   $ hg log -r 'wdir() and secret()' -T '{phase}\n' --config 
phases.new-commit=secret
  >   secret
  
  Done.

REPOSITORY
  rHG Mercurial

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

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

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


D7705: phases: make the working directory consistently a draft

2020-01-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 19050.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7705?vs=18921=19050

BRANCH
  default

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

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

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

CHANGE DETAILS

diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -48,13 +48,58 @@
   1 1 B
   0 1 A
 
-Draft commit are properly created over public one:
+Working directory phase is secret when its parent is secret.
+
+  $ hg phase --force --secret .
+  test-debug-phase: move rev 0: 1 -> 2
+  test-debug-phase: move rev 1: 1 -> 2
+  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:  draft -> 
secret
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  draft -> 
secret
+  $ hg log -r 'wdir()' -T '{phase}\n'
+  secret
+  $ hg log -r 'wdir() and public()' -T '{phase}\n'
+  $ hg log -r 'wdir() and draft()' -T '{phase}\n'
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n'
+  secret
+
+Working directory phase is draft when its parent is draft.
+
+  $ hg phase --draft .
+  test-debug-phase: move rev 1: 2 -> 1
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  secret -> 
draft
+  $ hg log -r 'wdir()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and public()' -T '{phase}\n'
+  $ hg log -r 'wdir() and draft()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n'
+
+Working directory phase is secret when a new commit will be created as secret,
+even if the parent is draft.
+
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n' \
+  > --config phases.new-commit='secret'
+  secret
+
+Working directory phase is draft when its parent is public.
 
   $ hg phase --public .
   test-debug-phase: move rev 0: 1 -> 0
   test-debug-phase: move rev 1: 1 -> 0
   test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:  draft -> 
public
   test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  draft -> 
public
+  $ hg log -r 'wdir()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and public()' -T '{phase}\n'
+  $ hg log -r 'wdir() and draft()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n'
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n' \
+  > --config phases.new-commit='secret'
+  secret
+
+Draft commit are properly created over public one:
+
   $ hg phase
   1: public
   $ hglog
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -112,6 +112,7 @@
 nullid,
 nullrev,
 short,
+wdirrev,
 )
 from .pycompat import (
 getattr,
@@ -242,6 +243,7 @@
 """return a smartset for the given phases"""
 self.loadphaserevs(repo)  # ensure phase's sets are loaded
 phases = set(phases)
+
 if public not in phases:
 # fast path: _phasesets contains the interesting sets,
 # might only need a union and post-filtering.
@@ -252,25 +254,44 @@
 revs = set.union(*[self._phasesets[p] for p in phases])
 if repo.changelog.filteredrevs:
 revs = revs - repo.changelog.filteredrevs
+
 if subset is None:
 return smartset.baseset(revs)
 else:
+if wdirrev in subset and repo[None].phase() in phases:
+# The working dir would never be in the cache, but it was
+# in the subset being filtered for its phase, so add it to
+# the output.
+revs.add(wdirrev)
+
 return subset & smartset.baseset(revs)
 else:
+# phases keeps all the *other* phases.
 phases = set(allphases).difference(phases)
 if not phases:
 return smartset.fullreposet(repo)
+
+# revs has the revisions in all *other* phases.
 if len(phases) == 1:
 [p] = phases
 revs = self._phasesets[p]
 else:
 revs = set.union(*[self._phasesets[p] for p in phases])
+
 if subset is None:
 subset = smartset.fullreposet(repo)
+
+if wdirrev in subset and repo[None].phase() in phases:
+# The working dir is in the subset being filtered, and its
+# phase is in the phases *not* being returned, so add it to the
+# set of revisions to filter out.
+revs.add(wdirrev)
+
 if not revs:
 return subset
 return subset.filter(lambda r: r not in revs)
 
+
 def copy(self):
 # Shallow copy meant to ensure isolation in
 # advance/retractboundary(), nothing more.



To: rdamazio, #hg-reviewers, marmoute
Cc: marmoute, mercurial-devel
___

D7631: absorb: allowing committed changes to be absorbed into their ancestors

2020-01-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In D7631#114393 , @mharbison72 
wrote:
  
  > In D7631#112604 , @rdamazio 
wrote:
  >
  >> In D7631#112414 , @quark 
wrote:
  >>
  >>> `--rev` seems ambiguous since there might be different kinds of revisions 
to specify - target and revisions to edit. Maybe something like `--source`, 
`--from`, `--target`?
  >>
  >> Done. Used `--source` to match `rebase`.
  >
  > Is `--exact` from `hg fold` a better model?  I don't feel strongly; I only 
mention it because `hg rebase -s` will take that revision and its descendants, 
so it's more like "stack" in my mind.  I'm not sure how many other commands 
have `-s` off the top of my head, but @martinvonz 
  > mentioned adding that to `hg fix` (probably in IRC), and I think mentioned 
the word "stack" in that context.  So I might not be the only one to get 
slightly tripped up by that.
  
  IMHO no, needing `--exact` is actually confusing to almost every user we've 
talked to, and they'd instead expect that to be the default behavior, with 
"fold up to this commit" being the one that needs a specific flag.
  
  >> I'm assuming no fundamental objections then? Removing the "RFC" part so it 
gets a proper review then.
  >
  > I like it.
  
  Thanks

INLINE COMMENTS

> mharbison72 wrote in absorb.py:1141
> Should it abort if multiple revisions are given, instead of picking the 
> latest?

I suspect other places may want something similar (e.g. it'd make sense in 
`rebase --dest`, so I changed revsingle to add the behavior.

REPOSITORY
  rHG Mercurial

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

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

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


D7631: absorb: allowing committed changes to be absorbed into their ancestors

2020-01-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio marked an inline comment as done.
rdamazio updated this revision to Diff 19048.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7631?vs=18873=19048

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  mercurial/scmutil.py
  relnotes/next
  tests/test-absorb-rev.t
  tests/test-absorb.t

CHANGE DETAILS

diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -143,7 +143,7 @@
   nothing applied
   [1]
 
-Insertaions:
+Insertions:
 
   $ cat > a << EOF
   > insert before 2b
diff --git a/tests/test-absorb.t b/tests/test-absorb-rev.t
copy from tests/test-absorb.t
copy to tests/test-absorb-rev.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb-rev.t
@@ -1,26 +1,14 @@
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > absorb=
+  > rebase=
+  > [experimental]
+  > evolution=createmarkers
   > EOF
 
-  $ sedi() { # workaround check-code
-  > pattern="$1"
-  > shift
-  > for i in "$@"; do
-  > sed "$pattern" "$i" > "$i".tmp
-  > mv "$i".tmp "$i"
-  > done
-  > }
-
   $ hg init repo1
   $ cd repo1
 
-Do not crash with empty repo:
-
-  $ hg absorb
-  abort: no mutable changeset to change
-  [255]
-
 Make some commits:
 
   $ for i in 1 2 3 4 5; do
@@ -45,9 +33,13 @@
   > 5e
   > EOF
 
+Commit that, too.
+
+  $ hg commit -qm "commit to absorb"
+
 Preview absorb changes:
 
-  $ hg absorb --print-changes --dry-run
+  $ hg absorb --print-changes --dry-run -s .
   showing changes for a
   @@ -0,2 +0,2 @@
   4ec16f8 -1
@@ -66,462 +58,126 @@
   5c5f952 commit 2
   4ec16f8 commit 1
 
+Try to absorb multiple revisions:
+
+  $ hg absorb --apply-changes -s .^+.
+  abort: revision set matched multiple revisions
+  [255]
+
+Add an uncommitted working directory change:
+
+  $ echo 6 >> a
+
 Run absorb:
 
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
+  $ hg absorb --apply-changes -s .
+  1 new orphan changesets
   2 of 2 chunk(s) applied
-  $ hg annotate a
-  0: 1a
-  1: 2b
-  2: 3
-  3: 4d
-  4: 5e
-
-Delete a few lines and related commits will be removed if they will be empty:
-
-  $ cat > a < 2b
-  > 4d
-  > EOF
-  $ echo y | hg absorb --config ui.interactive=1
-  showing changes for a
-  @@ -0,1 +0,0 @@
-  f548282 -1a
-  @@ -2,1 +1,0 @@
-  ff5d556 -3
-  @@ -4,1 +2,0 @@
-  84e5416 -5e
-  
-  3 changesets affected
-  84e5416 commit 5
-  ff5d556 commit 3
-  f548282 commit 1
-  apply changes (yn)?  y
-  saved backup bundle to * (glob)
-  3 of 3 chunk(s) applied
-  $ hg annotate a
-  1: 2b
-  2: 4d
-  $ hg log -T '{rev} {desc}\n' -Gp
-  @  2 commit 4
-  |  diff -r 1cae118c7ed8 -r 58a62bade1c6 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -1,1 +1,2 @@
-  |   2b
-  |  +4d
-  |
-  o  1 commit 2
-  |  diff -r 84add69aeac0 -r 1cae118c7ed8 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -0,0 +1,1 @@
-  |  +2b
-  |
-  o  0 commit 1
-  
-
-Non 1:1 map changes will be ignored:
-
-  $ echo 1 > a
-  $ hg absorb --apply-changes
-  nothing applied
-  [1]
-
-The prompt is not given if there are no changes to be applied, even if there
-are some changes that won't be applied:
-
-  $ hg absorb
-  showing changes for a
-  @@ -0,2 +0,1 @@
-  -2b
-  -4d
-  +1
-  
-  0 changesets affected
-  nothing applied
-  [1]
-
-Insertaions:
-
-  $ cat > a << EOF
-  > insert before 2b
-  > 2b
-  > 4d
-  > insert aftert 4d
-  > EOF
-  $ hg absorb -q --apply-changes
-  $ hg status
-  $ hg annotate a
-  1: insert before 2b
-  1: 2b
-  2: 4d
-  2: insert aftert 4d
-
-Bookmarks are moved:
-
-  $ hg bookmark -r 1 b1
-  $ hg bookmark -r 2 b2
-  $ hg bookmark ba
-  $ hg bookmarks
- b11:b35060a57a50
- b22:946e4bc87915
-   * ba2:946e4bc87915
-  $ sedi 's/insert/INSERT/' a
-  $ hg absorb -q --apply-changes
-  $ hg status
-  $ hg bookmarks
- b11:a4183e9b3d31
- b22:c9b20c925790
-   * ba2:c9b20c925790
-
-Non-modified files are ignored:
 
-  $ touch b
-  $ hg commit -A b -m b
-  $ touch c
-  $ hg add c
-  $ hg rm b
-  $ hg absorb --apply-changes
-  nothing applied
-  [1]
-  $ sedi 's/INSERT/Insert/' a
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
-  2 of 2 chunk(s) applied
-  $ hg status
-  A c
-  R b
-
-Public commits will not be changed:
-
-  $ hg phase -p 1
-  $ sedi 's/Insert/insert/' a
-  $ hg absorb -pn
-  showing changes for a
-  @@ -0,1 +0,1 @@
-  -Insert before 2b
-  +insert before 2b
-  @@ -3,1 +3,1 @@
-  85b4e0e -Insert aftert 4d
-  85b4e0e +insert aftert 4d
-  
-  1 changesets affected
-  85b4e0e commit 4
-  $ hg absorb 

D7630: absorb: make the absorbed changeset be automatically "evolved"

2020-01-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 19049.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7630?vs=18874=19049

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t

CHANGE DETAILS

diff --git a/tests/test-absorb-rev.t b/tests/test-absorb-rev.t
--- a/tests/test-absorb-rev.t
+++ b/tests/test-absorb-rev.t
@@ -71,10 +71,10 @@
 Run absorb:
 
   $ hg absorb --apply-changes -s .
-  1 new orphan changesets
   2 of 2 chunk(s) applied
 
 Check that the pending wdir change was left alone:
+TODO: The absorbed commit should have disappeared when it became empty.
 
   $ hg status
   M a
@@ -87,19 +87,11 @@
4d
5e
   +6
-  $ hg update -Cq .
-
-Rebase the absorbed revision on top of the destination (as evolve would):
-TODO: the evolve-type operation should happen automatically for the changeset
-being absorbed, and even through that the pending wdir change should be left
-alone.
-
-  $ hg rebase -d tip -r .
-  rebasing 5:1631091f9648 "commit to absorb"
-  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
-  @  2f7ba78d6abc commit 5
+  @  9a0ec5cae1a1 commit to absorb
+  |
+  o  2f7ba78d6abc commit 5
   |
   o  04c8ba6df782 commit 4
   |
@@ -109,12 +101,15 @@
   |
   o  241ace8326d0 commit 1
   
-  $ hg annotate -c a
-  241ace8326d0: 1a
-  9b19176bb127: 2b
-  484c6ac0cea3: 3
-  04c8ba6df782: 4d
-  2f7ba78d6abc: 5e
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  9b19176bb127 : 2b
+  484c6ac0cea3 : 3
+  04c8ba6df782 : 4d
+  2f7ba78d6abc : 5e
+  9a0ec5cae1a1+: 6
+
+  $ hg diff -c .
 
 Do it again, but this time with an unrelated commit checked out (plus working
 directory changes on top):
@@ -145,7 +140,6 @@
   2 changesets affected
   2f7ba78 commit 5
   04c8ba6 commit 4
-  1 new orphan changesets
   1 of 1 chunk(s) applied
 
   $ hg annotate -c a -r 'wdir()'
@@ -153,19 +147,16 @@
   dbce69d9fe03 : committed unrelated
   dbce69d9fe03+: pending wdir change
 
-
-  $ hg update -Cq .
-
-  $ hg rebase -d tip -r ${TOABSORB}
-  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
-  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+  $ hg update -Cq tip
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  59655ff113fb commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
-  | @  dbce69d9fe03 unrelated commit
+  | o  dbce69d9fe03 unrelated commit
   | |
   o |  484c6ac0cea3 commit 3
   | |
@@ -174,7 +165,7 @@
   o  241ace8326d0 commit 1
   
 
-  $ hg annotate -c a -r tip
+  $ hg annotate -c a
   241ace8326d0: 1a
   9b19176bb127: 2b
   484c6ac0cea3: 3
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -34,6 +34,7 @@
 from __future__ import absolute_import
 
 import collections
+import itertools
 
 from mercurial.i18n import _
 from mercurial import (
@@ -662,16 +663,19 @@
 4. call commit, to commit changes to hg database
 """
 
-def __init__(self, stack, ui=None, opts=None):
+def __init__(self, stack, fixuptargets=[], ui=None, opts=None):
 """([ctx], ui or None) -> None
 
 stack: should be linear, and sorted by topo order - oldest first.
+fixuptargets: changeset contexts that need to be fixed up, but are not
+used for fixup computation.
 all commits in stack are considered mutable.
 """
 assert stack
 self.ui = ui or nullui()
 self.opts = opts or {}
 self.stack = stack
+self.fixuptargets = fixuptargets
 self.repo = stack[-1].repo().unfiltered()
 
 # following fields will be filled later
@@ -777,7 +781,7 @@
 # p1 which overrides the parent of the next commit, "None" means use
 # the original parent unchanged
 nextp1 = None
-for ctx in self.stack:
+for ctx in itertools.chain(self.stack, self.fixuptargets):
 memworkingcopy = self._getnewfilecontents(ctx)
 if not memworkingcopy and not lastcommitted:
 # nothing changed, nothing commited
@@ -1011,7 +1015,10 @@
 pats = ()
 if opts is None:
 opts = {}
-state = fixupstate(stack, ui=ui, opts=opts)
+fixuptargets = []
+if targetctx.rev() is not None:
+fixuptargets.append(targetctx)
+state = fixupstate(stack, fixuptargets=fixuptargets, ui=ui, opts=opts)
 matcher = scmutil.match(targetctx, pats, opts)
 if opts.get(b'interactive'):
 diff = patch.diff(repo, stack[-1].node(), targetctx.node(), matcher)



To: rdamazio, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D7705: phases: make the working directory consistently a draft

2019-12-27 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In D7705#113845 , @marmoute 
wrote:
  
  > I simply sent this. If am I following your changeset right, we should have 
`wdir()` match `draft()` or `secret()` according to the projected phase (config 
+ parent)
  
  I don't understand what you're asking me to do here, can you clarify?

REPOSITORY
  rHG Mercurial

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

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

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


D7705: phases: make the working directory consistently a draft

2019-12-27 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  > commitablectx code seems wrong here. I am sending a patch.
  
  Sure. Let me know if your patch is going to somehow cover the use case I'm 
trying to address here, or what else you'd like me to do with this patch (is it 
just a matter of adding more tests here to account for the config option mix as 
well, once you add that?).

REPOSITORY
  rHG Mercurial

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

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

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


D7705: phases: make the working directory consistently a draft

2019-12-23 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In D7705#113383 , @marmoute 
wrote:
  
  > The working copy is not necessarly draft phase. For example, it will be 
secret is the working copy parent is secret. One can also control it using the 
`phases.new-commit` config.
  > The `mercurial.phases.newcommitphase(ui)` function can help you there.
  
  Thanks.
  About `newcommitphase` - that only accounts for the config option, and it 
seems that the working directory doesn't change phase based on that in other 
parts of the code (e.g. in `commitablectx`), so I kept that consistent here.

REPOSITORY
  rHG Mercurial

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

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

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


D7705: phases: make the working directory consistently a draft

2019-12-23 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18921.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7705?vs=18878=18921

BRANCH
  default

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

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

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

CHANGE DETAILS

diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -48,13 +48,48 @@
   1 1 B
   0 1 A
 
-Draft commit are properly created over public one:
+Working directory phase is secret when its parent is secret.
+
+  $ hg phase --force --secret .
+  test-debug-phase: move rev 0: 1 -> 2
+  test-debug-phase: move rev 1: 1 -> 2
+  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:  draft -> 
secret
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  draft -> 
secret
+  $ hg log -r 'wdir()' -T '{phase}\n'
+  secret
+  $ hg log -r 'wdir() and public()' -T '{phase}\n'
+  $ hg log -r 'wdir() and draft()' -T '{phase}\n'
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n'
+  secret
+
+Working directory phase is draft when its parent is draft.
+
+  $ hg phase --draft .
+  test-debug-phase: move rev 1: 2 -> 1
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  secret -> 
draft
+  $ hg log -r 'wdir()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and public()' -T '{phase}\n'
+  $ hg log -r 'wdir() and draft()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n'
+
+Working directory phase is draft when its parent is public.
 
   $ hg phase --public .
   test-debug-phase: move rev 0: 1 -> 0
   test-debug-phase: move rev 1: 1 -> 0
   test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:  draft -> 
public
   test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  draft -> 
public
+  $ hg log -r 'wdir()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and public()' -T '{phase}\n'
+  $ hg log -r 'wdir() and draft()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n'
+
+Draft commit are properly created over public one:
+
   $ hg phase
   1: public
   $ hglog
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -112,6 +112,7 @@
 nullid,
 nullrev,
 short,
+wdirrev,
 )
 from .pycompat import (
 getattr,
@@ -242,6 +243,7 @@
 """return a smartset for the given phases"""
 self.loadphaserevs(repo)  # ensure phase's sets are loaded
 phases = set(phases)
+
 if public not in phases:
 # fast path: _phasesets contains the interesting sets,
 # might only need a union and post-filtering.
@@ -252,25 +254,44 @@
 revs = set.union(*[self._phasesets[p] for p in phases])
 if repo.changelog.filteredrevs:
 revs = revs - repo.changelog.filteredrevs
+
 if subset is None:
 return smartset.baseset(revs)
 else:
+if wdirrev in subset and repo[None].phase() in phases:
+# The working dir would never be in the cache, but it was
+# in the subset being filtered for its phase, so add it to
+# the output.
+revs.add(wdirrev)
+
 return subset & smartset.baseset(revs)
 else:
+# phases keeps all the *other* phases.
 phases = set(allphases).difference(phases)
 if not phases:
 return smartset.fullreposet(repo)
+
+# revs has the revisions in all *other* phases.
 if len(phases) == 1:
 [p] = phases
 revs = self._phasesets[p]
 else:
 revs = set.union(*[self._phasesets[p] for p in phases])
+
 if subset is None:
 subset = smartset.fullreposet(repo)
+
+if wdirrev in subset and repo[None].phase() in phases:
+# The working dir is in the subset being filtered, and its
+# phase is in the phases *not* being returned, so add it to the
+# set of revisions to filter out.
+revs.add(wdirrev)
+
 if not revs:
 return subset
 return subset.filter(lambda r: r not in revs)
 
+
 def copy(self):
 # Shallow copy meant to ensure isolation in
 # advance/retractboundary(), nothing more.



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


D7668: status: make unresolved files always be in the morestatus structured output

2019-12-19 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHG07ebb567e8bb: status: make unresolved files always be in 
the morestatus structured output (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7668?vs=18877=18881

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -591,6 +591,11 @@
 "itemtype": "file",
 "path": "foo",
 "status": "M"
+   },
+   {
+"itemtype": "file",
+"path": "a",
+"unresolved": true
}
   ]
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -811,9 +811,11 @@
 unfinishedmsg = attr.ib()
 activemerge = attr.ib()
 unresolvedpaths = attr.ib()
+_formattedpaths = attr.ib(init=False, default=set())
 _label = b'status.morestatus'
 
 def formatfile(self, path, fm):
+self._formattedpaths.add(path)
 if self.activemerge and path in self.unresolvedpaths:
 fm.data(unresolved=True)
 
@@ -832,6 +834,7 @@
 if self.unfinishedmsg:
 fm.data(unfinishedmsg=self.unfinishedmsg)
 
+# May also start new data items.
 self._formatconflicts(fm)
 
 if self.unfinishedmsg:
@@ -861,6 +864,19 @@
 )
 % mergeliststr
 )
+
+# If any paths with unresolved conflicts were not previously
+# formatted, output them now.
+for f in self.unresolvedpaths:
+if f in self._formattedpaths:
+# Already output.
+continue
+fm.startitem()
+# We can't claim to know the status of the file - it may just
+# have been in one of the states that were not requested for
+# display, so it could be anything.
+fm.data(itemtype=b'file', path=f, unresolved=True)
+
 else:
 msg = _(b'No unresolved merge conflicts.')
 



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


D7704: status: make morestatus call out unresolved conflicts after update

2019-12-19 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHG489fdf27769c: status: make morestatus call out unresolved 
conflicts after update (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7704?vs=18876=18880

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -252,6 +252,12 @@
   $ hg st
   M a
   ? a.orig
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ cat a
   <<< working copy: 6efa171f091b - test: 3
   three
@@ -315,6 +321,12 @@
   $ rm a.orig
   $ hg status
   M a
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ hg resolve -l
   U a
 
@@ -553,6 +565,12 @@
   $ hg status
   M a
   M foo
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
 
   $ hg revert -r . a
 
@@ -561,6 +579,12 @@
   U a
   $ hg status
   M foo
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ hg status -Tjson
   [
{
@@ -577,6 +601,8 @@
   R a
   $ hg status
   M foo
+  # No unresolved merge conflicts.
+  
   $ hg status -Tjson
   [
{
@@ -589,6 +615,8 @@
 Test that 4 is detected as the no-argument destination from 3 and also moves
 the bookmark with it
   $ hg up --quiet 0  # we should be able to update to 3 directly
+  $ hg status
+  M foo
   $ hg up --quiet --hidden 3 # but not implemented yet.
   updated to hidden changeset 6efa171f091b
   (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -818,20 +818,22 @@
 fm.data(unresolved=True)
 
 def formatfooter(self, fm):
-fm.startitem()
-fm.data(
-itemtype=b'morestatus',
-unfinished=self.unfinishedop,
-unfinishedmsg=self.unfinishedmsg,
-)
-
-statemsg = (
-_(b'The repository is in an unfinished *%s* state.')
-% self.unfinishedop
-)
-fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+if self.unfinishedop or self.unfinishedmsg:
+fm.startitem()
+fm.data(itemtype=b'morestatus')
+
+if self.unfinishedop:
+fm.data(unfinished=self.unfinishedop)
+statemsg = (
+_(b'The repository is in an unfinished *%s* state.')
+% self.unfinishedop
+)
+fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+if self.unfinishedmsg:
+fm.data(unfinishedmsg=self.unfinishedmsg)
 
 self._formatconflicts(fm)
+
 if self.unfinishedmsg:
 fm.plain(
 b'%s\n' % _commentlines(self.unfinishedmsg), label=self._label
@@ -870,12 +872,12 @@
 statetuple = statemod.getrepostate(repo)
 mergestate = mergemod.mergestate.read(repo)
 activemerge = mergestate.active()
-if not statetuple:
+if not statetuple and not activemerge:
 return None
 
-unfinishedop, unfinishedmsg = statetuple
-mergestate = mergemod.mergestate.read(repo)
-unresolved = None
+unfinishedop = unfinishedmsg = unresolved = None
+if statetuple:
+unfinishedop, unfinishedmsg = statetuple
 if activemerge:
 unresolved = sorted(mergestate.unresolved())
 return morestatus(



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


D7667: status: extract active-merge state for reuse

2019-12-19 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHG4ca89cc20d02: status: extract active-merge state for reuse 
(authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D7667?vs=18875=18879#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7667?vs=18875=18879

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

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

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
@@ -809,12 +809,12 @@
 reporoot = attr.ib()
 unfinishedop = attr.ib()
 unfinishedmsg = attr.ib()
-inmergestate = attr.ib()
+activemerge = attr.ib()
 unresolvedpaths = attr.ib()
 _label = b'status.morestatus'
 
 def formatfile(self, path, fm):
-if self.inmergestate and path in self.unresolvedpaths:
+if self.activemerge and path in self.unresolvedpaths:
 fm.data(unresolved=True)
 
 def formatfooter(self, fm):
@@ -838,7 +838,7 @@
 )
 
 def _formatconflicts(self, fm):
-if not self.inmergestate:
+if not self.activemerge:
 return
 
 if self.unresolvedpaths:
@@ -868,20 +868,18 @@
 def readmorestatus(repo):
 """Returns a morestatus object if the repo has unfinished state."""
 statetuple = statemod.getrepostate(repo)
+mergestate = mergemod.mergestate.read(repo)
+activemerge = mergestate.active()
 if not statetuple:
 return None
 
 unfinishedop, unfinishedmsg = statetuple
 mergestate = mergemod.mergestate.read(repo)
 unresolved = None
-if mergestate.active():
+if activemerge:
 unresolved = sorted(mergestate.unresolved())
 return morestatus(
-repo.root,
-unfinishedop,
-unfinishedmsg,
-unresolved is not None,
-unresolved,
+repo.root, unfinishedop, unfinishedmsg, activemerge, unresolved
 )
 
 



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


D7705: phases: make the working directory consistently a draft

2019-12-19 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Before this change, `hg log -r 'wdir() and public()'` would return it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -48,6 +48,15 @@
   1 1 B
   0 1 A
 
+Working directory is a draft.
+
+  $ hg log -r 'wdir()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and public()' -T '{phase}\n'
+  $ hg log -r 'wdir() and draft()' -T '{phase}\n'
+  draft
+  $ hg log -r 'wdir() and secret()' -T '{phase}\n'
+
 Draft commit are properly created over public one:
 
   $ hg phase --public .
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -112,6 +112,7 @@
 nullid,
 nullrev,
 short,
+wdirrev,
 )
 from .pycompat import (
 getattr,
@@ -252,25 +253,43 @@
 revs = set.union(*[self._phasesets[p] for p in phases])
 if repo.changelog.filteredrevs:
 revs = revs - repo.changelog.filteredrevs
+
 if subset is None:
 return smartset.baseset(revs)
 else:
+if wdirrev in subset and draft in phases:
+# The working dir would never be in the cache, but it 
should
+# be considered a draft - if it's in the subset being
+# filtered for drafts, add it to the output.
+revs.add(wdirrev)
+
 return subset & smartset.baseset(revs)
 else:
+# phases keeps all the *other* phases.
 phases = set(allphases).difference(phases)
 if not phases:
 return smartset.fullreposet(repo)
+
+# revs has the revisions in all *other* phases.
 if len(phases) == 1:
 [p] = phases
 revs = self._phasesets[p]
 else:
 revs = set.union(*[self._phasesets[p] for p in phases])
+
 if subset is None:
 subset = smartset.fullreposet(repo)
 if not revs:
 return subset
+if wdirrev in subset and draft in phases:
+# The working dir is in the subset being filtered, and draft is
+# in the phases *not* being returned, so add it to the set of
+# revisions to filter out.
+revs.add(wdirrev)
+
 return subset.filter(lambda r: r not in revs)
 
+
 def copy(self):
 # Shallow copy meant to ensure isolation in
 # advance/retractboundary(), nothing more.



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


D7668: status: make unresolved files always be in the morestatus structured output

2019-12-19 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio marked an inline comment as done.
rdamazio updated this revision to Diff 18877.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7668?vs=18846=18877

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -591,6 +591,11 @@
 "itemtype": "file",
 "path": "foo",
 "status": "M"
+   },
+   {
+"itemtype": "file",
+"path": "a",
+"unresolved": true
}
   ]
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -810,9 +810,11 @@
 unfinishedmsg = attr.ib()
 activemerge = attr.ib()
 unresolvedpaths = attr.ib()
+_formattedpaths = attr.ib(init=False, default=set())
 _label = b'status.morestatus'
 
 def formatfile(self, path, fm):
+self._formattedpaths.add(path)
 if self.activemerge and path in self.unresolvedpaths:
 fm.data(unresolved=True)
 
@@ -831,6 +833,7 @@
 if self.unfinishedmsg:
 fm.data(unfinishedmsg=self.unfinishedmsg)
 
+# May also start new data items.
 self._formatconflicts(fm)
 
 if self.unfinishedmsg:
@@ -860,6 +863,19 @@
 )
 % mergeliststr
 )
+
+# If any paths with unresolved conflicts were not previously
+# formatted, output them now.
+for f in self.unresolvedpaths:
+if f in self._formattedpaths:
+# Already output.
+continue
+fm.startitem()
+# We can't claim to know the status of the file - it may just
+# have been in one of the states that were not requested for
+# display, so it could be anything.
+fm.data(itemtype=b'file', path=f, unresolved=True)
+
 else:
 msg = _(b'No unresolved merge conflicts.')
 



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


D7704: status: make morestatus call out unresolved conflicts after update

2019-12-19 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -252,6 +252,12 @@
   $ hg st
   M a
   ? a.orig
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ cat a
   <<< working copy: 6efa171f091b - test: 3
   three
@@ -315,6 +321,12 @@
   $ rm a.orig
   $ hg status
   M a
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ hg resolve -l
   U a
 
@@ -553,6 +565,12 @@
   $ hg status
   M a
   M foo
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
 
   $ hg revert -r . a
 
@@ -561,6 +579,12 @@
   U a
   $ hg status
   M foo
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ hg status -Tjson
   [
{
@@ -577,6 +601,8 @@
   R a
   $ hg status
   M foo
+  # No unresolved merge conflicts.
+  
   $ hg status -Tjson
   [
{
@@ -589,6 +615,8 @@
 Test that 4 is detected as the no-argument destination from 3 and also moves
 the bookmark with it
   $ hg up --quiet 0  # we should be able to update to 3 directly
+  $ hg status
+  M foo
   $ hg up --quiet --hidden 3 # but not implemented yet.
   updated to hidden changeset 6efa171f091b
   (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -817,20 +817,22 @@
 fm.data(unresolved=True)
 
 def formatfooter(self, fm):
-fm.startitem()
-fm.data(
-itemtype=b'morestatus',
-unfinished=self.unfinishedop,
-unfinishedmsg=self.unfinishedmsg,
-)
-
-statemsg = (
-_(b'The repository is in an unfinished *%s* state.')
-% self.unfinishedop
-)
-fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+if self.unfinishedop or self.unfinishedmsg:
+fm.startitem()
+fm.data(itemtype=b'morestatus')
+
+if self.unfinishedop:
+fm.data(unfinished=self.unfinishedop)
+statemsg = (
+_(b'The repository is in an unfinished *%s* state.')
+% self.unfinishedop
+)
+fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+if self.unfinishedmsg:
+fm.data(unfinishedmsg=self.unfinishedmsg)
 
 self._formatconflicts(fm)
+
 if self.unfinishedmsg:
 fm.plain(
 b'%s\n' % _commentlines(self.unfinishedmsg), label=self._label
@@ -869,12 +871,12 @@
 statetuple = statemod.getrepostate(repo)
 mergestate = mergemod.mergestate.read(repo)
 activemerge = mergestate.active()
-if not statetuple:
+if not statetuple and not activemerge:
 return None
 
-unfinishedop, unfinishedmsg = statetuple
-mergestate = mergemod.mergestate.read(repo)
-unresolved = None
+unfinishedop = unfinishedmsg = unresolved = None
+if statetuple:
+unfinishedop, unfinishedmsg = statetuple
 if activemerge:
 unresolved = sorted(mergestate.unresolved())
 return morestatus(



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


D7667: status: extract active-merge state for reuse

2019-12-19 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio retitled this revision from "status: make morestatus call out 
unresolved conflicts after update" to "status: extract active-merge state for 
reuse".
rdamazio updated this revision to Diff 18875.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7667?vs=18845=18875

BRANCH
  default

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

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

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
@@ -808,12 +808,12 @@
 reporoot = attr.ib()
 unfinishedop = attr.ib()
 unfinishedmsg = attr.ib()
-inmergestate = attr.ib()
+activemerge = attr.ib()
 unresolvedpaths = attr.ib()
 _label = b'status.morestatus'
 
 def formatfile(self, path, fm):
-if self.inmergestate and path in self.unresolvedpaths:
+if self.activemerge and path in self.unresolvedpaths:
 fm.data(unresolved=True)
 
 def formatfooter(self, fm):
@@ -837,7 +837,7 @@
 )
 
 def _formatconflicts(self, fm):
-if not self.inmergestate:
+if not self.activemerge:
 return
 
 if self.unresolvedpaths:
@@ -867,21 +867,22 @@
 def readmorestatus(repo):
 """Returns a morestatus object if the repo has unfinished state."""
 statetuple = statemod.getrepostate(repo)
+mergestate = mergemod.mergestate.read(repo)
+activemerge = mergestate.active()
 if not statetuple:
 return None
 
 unfinishedop, unfinishedmsg = statetuple
 mergestate = mergemod.mergestate.read(repo)
 unresolved = None
-if mergestate.active():
+if activemerge:
 unresolved = sorted(mergestate.unresolved())
 return morestatus(
 repo.root,
 unfinishedop,
 unfinishedmsg,
-unresolved is not None,
-unresolved,
-)
+activemerge,
+unresolved)
 
 
 def findpossible(cmd, table, strict=False):



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


D7667: status: extract active-merge state for reuse

2019-12-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  > Can we split them up?
  
  Done. Kept this review as the first of the chain.

REPOSITORY
  rHG Mercurial

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

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

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


D7668: status: make unresolved files always be in the morestatus structured output

2019-12-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added inline comments.
rdamazio marked an inline comment as done.

INLINE COMMENTS

> pulkit wrote in cmdutil.py:876
> IIUC,  if it's in one of the states that were not requested for display, then 
> we should not display the file, right?

We don't display its status indeed.
They did request morestatus / verbose output, so plain old `hg status` still 
won't output it.

REPOSITORY
  rHG Mercurial

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

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

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


D7631: absorb: allowing committed changes to be absorbed into their ancestors

2019-12-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio marked 2 inline comments as done.
rdamazio updated this revision to Diff 18873.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7631?vs=18843=18873

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  relnotes/next
  tests/test-absorb-rev.t
  tests/test-absorb.t

CHANGE DETAILS

diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -143,7 +143,7 @@
   nothing applied
   [1]
 
-Insertaions:
+Insertions:
 
   $ cat > a << EOF
   > insert before 2b
diff --git a/tests/test-absorb.t b/tests/test-absorb-rev.t
copy from tests/test-absorb.t
copy to tests/test-absorb-rev.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb-rev.t
@@ -1,26 +1,14 @@
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > absorb=
+  > rebase=
+  > [experimental]
+  > evolution=createmarkers
   > EOF
 
-  $ sedi() { # workaround check-code
-  > pattern="$1"
-  > shift
-  > for i in "$@"; do
-  > sed "$pattern" "$i" > "$i".tmp
-  > mv "$i".tmp "$i"
-  > done
-  > }
-
   $ hg init repo1
   $ cd repo1
 
-Do not crash with empty repo:
-
-  $ hg absorb
-  abort: no mutable changeset to change
-  [255]
-
 Make some commits:
 
   $ for i in 1 2 3 4 5; do
@@ -45,9 +33,13 @@
   > 5e
   > EOF
 
+Commit that, too.
+
+  $ hg commit -qm "commit to absorb"
+
 Preview absorb changes:
 
-  $ hg absorb --print-changes --dry-run
+  $ hg absorb --print-changes --dry-run -s .
   showing changes for a
   @@ -0,2 +0,2 @@
   4ec16f8 -1
@@ -66,462 +58,120 @@
   5c5f952 commit 2
   4ec16f8 commit 1
 
+Add an uncommitted working directory change:
+
+  $ echo 6 >> a
+
 Run absorb:
 
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
+  $ hg absorb --apply-changes -s .
+  1 new orphan changesets
   2 of 2 chunk(s) applied
-  $ hg annotate a
-  0: 1a
-  1: 2b
-  2: 3
-  3: 4d
-  4: 5e
-
-Delete a few lines and related commits will be removed if they will be empty:
-
-  $ cat > a < 2b
-  > 4d
-  > EOF
-  $ echo y | hg absorb --config ui.interactive=1
-  showing changes for a
-  @@ -0,1 +0,0 @@
-  f548282 -1a
-  @@ -2,1 +1,0 @@
-  ff5d556 -3
-  @@ -4,1 +2,0 @@
-  84e5416 -5e
-  
-  3 changesets affected
-  84e5416 commit 5
-  ff5d556 commit 3
-  f548282 commit 1
-  apply changes (yn)?  y
-  saved backup bundle to * (glob)
-  3 of 3 chunk(s) applied
-  $ hg annotate a
-  1: 2b
-  2: 4d
-  $ hg log -T '{rev} {desc}\n' -Gp
-  @  2 commit 4
-  |  diff -r 1cae118c7ed8 -r 58a62bade1c6 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -1,1 +1,2 @@
-  |   2b
-  |  +4d
-  |
-  o  1 commit 2
-  |  diff -r 84add69aeac0 -r 1cae118c7ed8 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -0,0 +1,1 @@
-  |  +2b
-  |
-  o  0 commit 1
-  
-
-Non 1:1 map changes will be ignored:
-
-  $ echo 1 > a
-  $ hg absorb --apply-changes
-  nothing applied
-  [1]
-
-The prompt is not given if there are no changes to be applied, even if there
-are some changes that won't be applied:
-
-  $ hg absorb
-  showing changes for a
-  @@ -0,2 +0,1 @@
-  -2b
-  -4d
-  +1
-  
-  0 changesets affected
-  nothing applied
-  [1]
-
-Insertaions:
-
-  $ cat > a << EOF
-  > insert before 2b
-  > 2b
-  > 4d
-  > insert aftert 4d
-  > EOF
-  $ hg absorb -q --apply-changes
-  $ hg status
-  $ hg annotate a
-  1: insert before 2b
-  1: 2b
-  2: 4d
-  2: insert aftert 4d
-
-Bookmarks are moved:
-
-  $ hg bookmark -r 1 b1
-  $ hg bookmark -r 2 b2
-  $ hg bookmark ba
-  $ hg bookmarks
- b11:b35060a57a50
- b22:946e4bc87915
-   * ba2:946e4bc87915
-  $ sedi 's/insert/INSERT/' a
-  $ hg absorb -q --apply-changes
-  $ hg status
-  $ hg bookmarks
- b11:a4183e9b3d31
- b22:c9b20c925790
-   * ba2:c9b20c925790
-
-Non-modified files are ignored:
 
-  $ touch b
-  $ hg commit -A b -m b
-  $ touch c
-  $ hg add c
-  $ hg rm b
-  $ hg absorb --apply-changes
-  nothing applied
-  [1]
-  $ sedi 's/INSERT/Insert/' a
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
-  2 of 2 chunk(s) applied
-  $ hg status
-  A c
-  R b
-
-Public commits will not be changed:
-
-  $ hg phase -p 1
-  $ sedi 's/Insert/insert/' a
-  $ hg absorb -pn
-  showing changes for a
-  @@ -0,1 +0,1 @@
-  -Insert before 2b
-  +insert before 2b
-  @@ -3,1 +3,1 @@
-  85b4e0e -Insert aftert 4d
-  85b4e0e +insert aftert 4d
-  
-  1 changesets affected
-  85b4e0e commit 4
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
-  1 of 2 chunk(s) applied
-  $ hg diff -U 0
-  diff -r 1c8eadede62a a
-  --- a/a  Thu Jan 01 00:00:00 1970 

D7630: absorb: make the absorbed changeset be automatically "evolved"

2019-12-18 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18874.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7630?vs=18844=18874

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t

CHANGE DETAILS

diff --git a/tests/test-absorb-rev.t b/tests/test-absorb-rev.t
--- a/tests/test-absorb-rev.t
+++ b/tests/test-absorb-rev.t
@@ -65,10 +65,10 @@
 Run absorb:
 
   $ hg absorb --apply-changes -s .
-  1 new orphan changesets
   2 of 2 chunk(s) applied
 
 Check that the pending wdir change was left alone:
+TODO: The absorbed commit should have disappeared when it became empty.
 
   $ hg status
   M a
@@ -81,19 +81,11 @@
4d
5e
   +6
-  $ hg update -Cq .
-
-Rebase the absorbed revision on top of the destination (as evolve would):
-TODO: the evolve-type operation should happen automatically for the changeset
-being absorbed, and even through that the pending wdir change should be left
-alone.
-
-  $ hg rebase -d tip -r .
-  rebasing 5:1631091f9648 "commit to absorb"
-  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
-  @  2f7ba78d6abc commit 5
+  @  9a0ec5cae1a1 commit to absorb
+  |
+  o  2f7ba78d6abc commit 5
   |
   o  04c8ba6df782 commit 4
   |
@@ -103,12 +95,15 @@
   |
   o  241ace8326d0 commit 1
   
-  $ hg annotate -c a
-  241ace8326d0: 1a
-  9b19176bb127: 2b
-  484c6ac0cea3: 3
-  04c8ba6df782: 4d
-  2f7ba78d6abc: 5e
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  9b19176bb127 : 2b
+  484c6ac0cea3 : 3
+  04c8ba6df782 : 4d
+  2f7ba78d6abc : 5e
+  9a0ec5cae1a1+: 6
+
+  $ hg diff -c .
 
 Do it again, but this time with an unrelated commit checked out (plus working
 directory changes on top):
@@ -139,7 +134,6 @@
   2 changesets affected
   2f7ba78 commit 5
   04c8ba6 commit 4
-  1 new orphan changesets
   1 of 1 chunk(s) applied
 
   $ hg annotate -c a -r 'wdir()'
@@ -147,19 +141,16 @@
   dbce69d9fe03 : committed unrelated
   dbce69d9fe03+: pending wdir change
 
-
-  $ hg update -Cq .
-
-  $ hg rebase -d tip -r ${TOABSORB}
-  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
-  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+  $ hg update -Cq tip
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  59655ff113fb commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
-  | @  dbce69d9fe03 unrelated commit
+  | o  dbce69d9fe03 unrelated commit
   | |
   o |  484c6ac0cea3 commit 3
   | |
@@ -168,7 +159,7 @@
   o  241ace8326d0 commit 1
   
 
-  $ hg annotate -c a -r tip
+  $ hg annotate -c a
   241ace8326d0: 1a
   9b19176bb127: 2b
   484c6ac0cea3: 3
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -34,6 +34,7 @@
 from __future__ import absolute_import
 
 import collections
+import itertools
 
 from mercurial.i18n import _
 from mercurial import (
@@ -662,16 +663,19 @@
 4. call commit, to commit changes to hg database
 """
 
-def __init__(self, stack, ui=None, opts=None):
+def __init__(self, stack, fixuptargets=[], ui=None, opts=None):
 """([ctx], ui or None) -> None
 
 stack: should be linear, and sorted by topo order - oldest first.
+fixuptargets: changeset contexts that need to be fixed up, but are not
+used for fixup computation.
 all commits in stack are considered mutable.
 """
 assert stack
 self.ui = ui or nullui()
 self.opts = opts or {}
 self.stack = stack
+self.fixuptargets = fixuptargets
 self.repo = stack[-1].repo().unfiltered()
 
 # following fields will be filled later
@@ -777,7 +781,7 @@
 # p1 which overrides the parent of the next commit, "None" means use
 # the original parent unchanged
 nextp1 = None
-for ctx in self.stack:
+for ctx in itertools.chain(self.stack, self.fixuptargets):
 memworkingcopy = self._getnewfilecontents(ctx)
 if not memworkingcopy and not lastcommitted:
 # nothing changed, nothing commited
@@ -1011,7 +1015,10 @@
 pats = ()
 if opts is None:
 opts = {}
-state = fixupstate(stack, ui=ui, opts=opts)
+fixuptargets = []
+if targetctx.rev() is not None:
+fixuptargets.append(targetctx)
+state = fixupstate(stack, fixuptargets=fixuptargets, ui=ui, opts=opts)
 matcher = scmutil.match(targetctx, pats, opts)
 if opts.get(b'interactive'):
 diff = patch.diff(repo, stack[-1].node(), targetctx.node(), matcher)



To: rdamazio, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D7668: status: make unresolved files always be in the morestatus structured output

2019-12-17 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18846.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7668?vs=18725=18846

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -591,6 +591,11 @@
 "itemtype": "file",
 "path": "foo",
 "status": "M"
+   },
+   {
+"itemtype": "file",
+"path": "a",
+"unresolved": true
}
   ]
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -833,6 +833,7 @@
 if self.unfinishedmsg:
 fm.data(unfinishedmsg=self.unfinishedmsg)
 
+# May also start new data items.
 self._formatconflicts(fm)
 
 if self.unfinishedmsg:
@@ -862,6 +863,19 @@
 )
 % mergeliststr
 )
+
+# If any paths with unresolved conflicts were not previously
+# formatted, output them now.
+for f in self.unresolvedpaths:
+if f in self._formattedpaths:
+# Already output.
+continue
+fm.startitem()
+# We can't claim to know the status of the file - it may just
+# have been in one of the states that were not requested for
+# display, so it could be anything.
+fm.data(itemtype=b'file', path=f, unresolved=True)
+
 else:
 msg = _(b'No unresolved merge conflicts.')
 



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


D7667: status: make morestatus call out unresolved conflicts after update

2019-12-17 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18845.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7667?vs=18724=18845

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -252,6 +252,12 @@
   $ hg st
   M a
   ? a.orig
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ cat a
   <<< working copy: 6efa171f091b - test: 3
   three
@@ -315,6 +321,12 @@
   $ rm a.orig
   $ hg status
   M a
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ hg resolve -l
   U a
 
@@ -553,6 +565,12 @@
   $ hg status
   M a
   M foo
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
 
   $ hg revert -r . a
 
@@ -561,6 +579,12 @@
   U a
   $ hg status
   M foo
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ hg status -Tjson
   [
{
@@ -577,6 +601,8 @@
   R a
   $ hg status
   M foo
+  # No unresolved merge conflicts.
+  
   $ hg status -Tjson
   [
{
@@ -589,6 +615,8 @@
 Test that 4 is detected as the no-argument destination from 3 and also moves
 the bookmark with it
   $ hg up --quiet 0  # we should be able to update to 3 directly
+  $ hg status
+  M foo
   $ hg up --quiet --hidden 3 # but not implemented yet.
   updated to hidden changeset 6efa171f091b
   (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -808,36 +808,40 @@
 reporoot = attr.ib()
 unfinishedop = attr.ib()
 unfinishedmsg = attr.ib()
-inmergestate = attr.ib()
+activemerge = attr.ib()
 unresolvedpaths = attr.ib()
+_formattedpaths = attr.ib(init=False, default=set())
 _label = b'status.morestatus'
 
 def formatfile(self, path, fm):
-if self.inmergestate and path in self.unresolvedpaths:
+self._formattedpaths.add(path)
+if self.activemerge and path in self.unresolvedpaths:
 fm.data(unresolved=True)
 
 def formatfooter(self, fm):
-fm.startitem()
-fm.data(
-itemtype=b'morestatus',
-unfinished=self.unfinishedop,
-unfinishedmsg=self.unfinishedmsg,
-)
-
-statemsg = (
-_(b'The repository is in an unfinished *%s* state.')
-% self.unfinishedop
-)
-fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+if self.unfinishedop or self.unfinishedmsg:
+fm.startitem()
+fm.data(itemtype=b'morestatus')
+
+if self.unfinishedop:
+fm.data(unfinished=self.unfinishedop)
+statemsg = (
+_(b'The repository is in an unfinished *%s* state.')
+% self.unfinishedop
+)
+fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+if self.unfinishedmsg:
+fm.data(unfinishedmsg=self.unfinishedmsg)
 
 self._formatconflicts(fm)
+
 if self.unfinishedmsg:
 fm.plain(
 b'%s\n' % _commentlines(self.unfinishedmsg), label=self._label
 )
 
 def _formatconflicts(self, fm):
-if not self.inmergestate:
+if not self.activemerge:
 return
 
 if self.unresolvedpaths:
@@ -867,21 +871,22 @@
 def readmorestatus(repo):
 """Returns a morestatus object if the repo has unfinished state."""
 statetuple = statemod.getrepostate(repo)
-if not statetuple:
+mergestate = mergemod.mergestate.read(repo)
+activemerge = mergestate.active()
+if not statetuple and not activemerge:
 return None
 
-unfinishedop, unfinishedmsg = statetuple
-mergestate = mergemod.mergestate.read(repo)
-unresolved = None
-if mergestate.active():
+unfinishedop = unfinishedmsg = unresolved = None
+if statetuple:
+unfinishedop, unfinishedmsg = statetuple
+if activemerge:
 unresolved = sorted(mergestate.unresolved())
 return morestatus(
 repo.root,
 unfinishedop,
 unfinishedmsg,
-unresolved is not None,
-unresolved,
-)
+activemerge,
+unresolved)
 
 
 def findpossible(cmd, table, strict=False):



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


D7631: absorb: allowing committed changes to be absorbed into their ancestors

2019-12-17 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18843.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7631?vs=18841=18843

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  relnotes/next
  tests/test-absorb-rev.t
  tests/test-absorb.t

CHANGE DETAILS

diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -143,7 +143,7 @@
   nothing applied
   [1]
 
-Insertaions:
+Insertions:
 
   $ cat > a << EOF
   > insert before 2b
diff --git a/tests/test-absorb.t b/tests/test-absorb-rev.t
copy from tests/test-absorb.t
copy to tests/test-absorb-rev.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb-rev.t
@@ -1,26 +1,14 @@
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > absorb=
+  > rebase=
+  > [experimental]
+  > evolution=createmarkers
   > EOF
 
-  $ sedi() { # workaround check-code
-  > pattern="$1"
-  > shift
-  > for i in "$@"; do
-  > sed "$pattern" "$i" > "$i".tmp
-  > mv "$i".tmp "$i"
-  > done
-  > }
-
   $ hg init repo1
   $ cd repo1
 
-Do not crash with empty repo:
-
-  $ hg absorb
-  abort: no mutable changeset to change
-  [255]
-
 Make some commits:
 
   $ for i in 1 2 3 4 5; do
@@ -45,9 +33,13 @@
   > 5e
   > EOF
 
+Commit that, too.
+
+  $ hg commit -qm "commit to absorb"
+
 Preview absorb changes:
 
-  $ hg absorb --print-changes --dry-run
+  $ hg absorb --print-changes --dry-run -s .
   showing changes for a
   @@ -0,2 +0,2 @@
   4ec16f8 -1
@@ -66,462 +58,120 @@
   5c5f952 commit 2
   4ec16f8 commit 1
 
+Add an uncommitted working directory change:
+
+  $ echo 6 >> a
+
 Run absorb:
 
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
+  $ hg absorb --apply-changes -s .
+  1 new orphan changesets
   2 of 2 chunk(s) applied
-  $ hg annotate a
-  0: 1a
-  1: 2b
-  2: 3
-  3: 4d
-  4: 5e
-
-Delete a few lines and related commits will be removed if they will be empty:
-
-  $ cat > a < 2b
-  > 4d
-  > EOF
-  $ echo y | hg absorb --config ui.interactive=1
-  showing changes for a
-  @@ -0,1 +0,0 @@
-  f548282 -1a
-  @@ -2,1 +1,0 @@
-  ff5d556 -3
-  @@ -4,1 +2,0 @@
-  84e5416 -5e
-  
-  3 changesets affected
-  84e5416 commit 5
-  ff5d556 commit 3
-  f548282 commit 1
-  apply changes (yn)?  y
-  saved backup bundle to * (glob)
-  3 of 3 chunk(s) applied
-  $ hg annotate a
-  1: 2b
-  2: 4d
-  $ hg log -T '{rev} {desc}\n' -Gp
-  @  2 commit 4
-  |  diff -r 1cae118c7ed8 -r 58a62bade1c6 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -1,1 +1,2 @@
-  |   2b
-  |  +4d
-  |
-  o  1 commit 2
-  |  diff -r 84add69aeac0 -r 1cae118c7ed8 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -0,0 +1,1 @@
-  |  +2b
-  |
-  o  0 commit 1
-  
-
-Non 1:1 map changes will be ignored:
-
-  $ echo 1 > a
-  $ hg absorb --apply-changes
-  nothing applied
-  [1]
-
-The prompt is not given if there are no changes to be applied, even if there
-are some changes that won't be applied:
-
-  $ hg absorb
-  showing changes for a
-  @@ -0,2 +0,1 @@
-  -2b
-  -4d
-  +1
-  
-  0 changesets affected
-  nothing applied
-  [1]
-
-Insertaions:
-
-  $ cat > a << EOF
-  > insert before 2b
-  > 2b
-  > 4d
-  > insert aftert 4d
-  > EOF
-  $ hg absorb -q --apply-changes
-  $ hg status
-  $ hg annotate a
-  1: insert before 2b
-  1: 2b
-  2: 4d
-  2: insert aftert 4d
-
-Bookmarks are moved:
-
-  $ hg bookmark -r 1 b1
-  $ hg bookmark -r 2 b2
-  $ hg bookmark ba
-  $ hg bookmarks
- b11:b35060a57a50
- b22:946e4bc87915
-   * ba2:946e4bc87915
-  $ sedi 's/insert/INSERT/' a
-  $ hg absorb -q --apply-changes
-  $ hg status
-  $ hg bookmarks
- b11:a4183e9b3d31
- b22:c9b20c925790
-   * ba2:c9b20c925790
-
-Non-modified files are ignored:
 
-  $ touch b
-  $ hg commit -A b -m b
-  $ touch c
-  $ hg add c
-  $ hg rm b
-  $ hg absorb --apply-changes
-  nothing applied
-  [1]
-  $ sedi 's/INSERT/Insert/' a
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
-  2 of 2 chunk(s) applied
-  $ hg status
-  A c
-  R b
-
-Public commits will not be changed:
-
-  $ hg phase -p 1
-  $ sedi 's/Insert/insert/' a
-  $ hg absorb -pn
-  showing changes for a
-  @@ -0,1 +0,1 @@
-  -Insert before 2b
-  +insert before 2b
-  @@ -3,1 +3,1 @@
-  85b4e0e -Insert aftert 4d
-  85b4e0e +insert aftert 4d
-  
-  1 changesets affected
-  85b4e0e commit 4
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
-  1 of 2 chunk(s) applied
-  $ hg diff -U 0
-  diff -r 1c8eadede62a a
-  --- a/a  Thu Jan 01 00:00:00 1970 +
-  +++ b/a  * (glob)
-  @@ -1,1 +1,1 

D7630: absorb: make the absorbed changeset be automatically "evolved"

2019-12-17 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18844.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7630?vs=18842=18844

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t

CHANGE DETAILS

diff --git a/tests/test-absorb-rev.t b/tests/test-absorb-rev.t
--- a/tests/test-absorb-rev.t
+++ b/tests/test-absorb-rev.t
@@ -65,10 +65,10 @@
 Run absorb:
 
   $ hg absorb --apply-changes -s .
-  1 new orphan changesets
   2 of 2 chunk(s) applied
 
 Check that the pending wdir change was left alone:
+TODO: The absorbed commit should have disappeared when it became empty.
 
   $ hg status
   M a
@@ -81,19 +81,11 @@
4d
5e
   +6
-  $ hg update -Cq .
-
-Rebase the absorbed revision on top of the destination (as evolve would):
-TODO: the evolve-type operation should happen automatically for the changeset
-being absorbed, and even through that the pending wdir change should be left
-alone.
-
-  $ hg rebase -d tip -r .
-  rebasing 5:1631091f9648 "commit to absorb"
-  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
-  @  2f7ba78d6abc commit 5
+  @  9a0ec5cae1a1 commit to absorb
+  |
+  o  2f7ba78d6abc commit 5
   |
   o  04c8ba6df782 commit 4
   |
@@ -103,12 +95,15 @@
   |
   o  241ace8326d0 commit 1
   
-  $ hg annotate -c a
-  241ace8326d0: 1a
-  9b19176bb127: 2b
-  484c6ac0cea3: 3
-  04c8ba6df782: 4d
-  2f7ba78d6abc: 5e
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  9b19176bb127 : 2b
+  484c6ac0cea3 : 3
+  04c8ba6df782 : 4d
+  2f7ba78d6abc : 5e
+  9a0ec5cae1a1+: 6
+
+  $ hg diff -c .
 
 Do it again, but this time with an unrelated commit checked out (plus working
 directory changes on top):
@@ -139,7 +134,6 @@
   2 changesets affected
   2f7ba78 commit 5
   04c8ba6 commit 4
-  1 new orphan changesets
   1 of 1 chunk(s) applied
 
   $ hg annotate -c a -r 'wdir()'
@@ -147,19 +141,16 @@
   dbce69d9fe03 : committed unrelated
   dbce69d9fe03+: pending wdir change
 
-
-  $ hg update -Cq .
-
-  $ hg rebase -d tip -r ${TOABSORB}
-  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
-  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+  $ hg update -Cq tip
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  59655ff113fb commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
-  | @  dbce69d9fe03 unrelated commit
+  | o  dbce69d9fe03 unrelated commit
   | |
   o |  484c6ac0cea3 commit 3
   | |
@@ -168,7 +159,7 @@
   o  241ace8326d0 commit 1
   
 
-  $ hg annotate -c a -r tip
+  $ hg annotate -c a
   241ace8326d0: 1a
   9b19176bb127: 2b
   484c6ac0cea3: 3
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -34,6 +34,7 @@
 from __future__ import absolute_import
 
 import collections
+import itertools
 
 from mercurial.i18n import _
 from mercurial import (
@@ -662,16 +663,19 @@
 4. call commit, to commit changes to hg database
 """
 
-def __init__(self, stack, ui=None, opts=None):
+def __init__(self, stack, fixuptargets=[], ui=None, opts=None):
 """([ctx], ui or None) -> None
 
 stack: should be linear, and sorted by topo order - oldest first.
+fixuptargets: changeset contexts that need to be fixed up, but are not
+used for fixup computation.
 all commits in stack are considered mutable.
 """
 assert stack
 self.ui = ui or nullui()
 self.opts = opts or {}
 self.stack = stack
+self.fixuptargets = fixuptargets
 self.repo = stack[-1].repo().unfiltered()
 
 # following fields will be filled later
@@ -777,7 +781,7 @@
 # p1 which overrides the parent of the next commit, "None" means use
 # the original parent unchanged
 nextp1 = None
-for ctx in self.stack:
+for ctx in itertools.chain(self.stack, self.fixuptargets):
 memworkingcopy = self._getnewfilecontents(ctx)
 if not memworkingcopy and not lastcommitted:
 # nothing changed, nothing commited
@@ -1011,7 +1015,10 @@
 pats = ()
 if opts is None:
 opts = {}
-state = fixupstate(stack, ui=ui, opts=opts)
+fixuptargets = []
+if targetctx.rev() is not None:
+fixuptargets.append(targetctx)
+state = fixupstate(stack, fixuptargets=fixuptargets, ui=ui, opts=opts)
 matcher = scmutil.match(targetctx, pats, opts)
 if opts.get(b'interactive'):
 diff = patch.diff(repo, stack[-1].node(), targetctx.node(), matcher)



To: rdamazio, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D7631: absorb: allowing committed changes to be absorbed into their ancestors

2019-12-17 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  > Can you describe the feature a bit in the commit message. Specific things 
which I feel are missing:
  
  Done
  
  > Also, it will be nice if you add an entry in releasenotes.
  
  Done

INLINE COMMENTS

> pulkit wrote in absorb.py:993
> need to do more checks here about being public commit etc. 
> `rewriteutil.precheck` should help.

Done. Notice that *technically* the user could do such an absorb while in the 
middle of a merge, but it sounds like a bad idea and inviting troubles, so I'm 
letting it also disallow that case. I'll be surprised if anyone even notices.

REPOSITORY
  rHG Mercurial

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

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

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


D7631: absorb: allowing committed changes to be absorbed into their ancestors

2019-12-17 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio edited the summary of this revision.
rdamazio marked 2 inline comments as done.
rdamazio updated this revision to Diff 18841.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7631?vs=18728=18841

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  relnotes/next
  tests/test-absorb-rev.t
  tests/test-absorb.t

CHANGE DETAILS

diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -143,7 +143,7 @@
   nothing applied
   [1]
 
-Insertaions:
+Insertions:
 
   $ cat > a << EOF
   > insert before 2b
diff --git a/tests/test-absorb.t b/tests/test-absorb-rev.t
copy from tests/test-absorb.t
copy to tests/test-absorb-rev.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb-rev.t
@@ -1,26 +1,14 @@
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > absorb=
+  > rebase=
+  > [experimental]
+  > evolution=createmarkers
   > EOF
 
-  $ sedi() { # workaround check-code
-  > pattern="$1"
-  > shift
-  > for i in "$@"; do
-  > sed "$pattern" "$i" > "$i".tmp
-  > mv "$i".tmp "$i"
-  > done
-  > }
-
   $ hg init repo1
   $ cd repo1
 
-Do not crash with empty repo:
-
-  $ hg absorb
-  abort: no mutable changeset to change
-  [255]
-
 Make some commits:
 
   $ for i in 1 2 3 4 5; do
@@ -45,9 +33,13 @@
   > 5e
   > EOF
 
+Commit that, too.
+
+  $ hg commit -qm "commit to absorb"
+
 Preview absorb changes:
 
-  $ hg absorb --print-changes --dry-run
+  $ hg absorb --print-changes --dry-run -s .
   showing changes for a
   @@ -0,2 +0,2 @@
   4ec16f8 -1
@@ -66,462 +58,111 @@
   5c5f952 commit 2
   4ec16f8 commit 1
 
+Add an uncommitted working directory change:
+
+  $ echo 6 >> a
+
 Run absorb:
 
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
+  $ hg absorb --apply-changes -s .
+  1 new orphan changesets
   2 of 2 chunk(s) applied
-  $ hg annotate a
-  0: 1a
-  1: 2b
-  2: 3
-  3: 4d
-  4: 5e
+
+Check that the pending wdir change was left alone:
+
+  $ grep 6 a
+  6
+  $ hg update -Cq .
+
+Rebase the absorbed revision on top of the destination (as evolve would):
+TODO: the evolve-type operation should happen automatically for the changeset
+being absorbed, and even through that the pending wdir change should be left
+alone.
+
+  $ hg rebase -d tip -r .
+  rebasing 5:1631091f9648 "commit to absorb"
+  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
-Delete a few lines and related commits will be removed if they will be empty:
+  $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  2f7ba78d6abc commit 5
+  |
+  o  04c8ba6df782 commit 4
+  |
+  o  484c6ac0cea3 commit 3
+  |
+  o  9b19176bb127 commit 2
+  |
+  o  241ace8326d0 commit 1
+  
+  $ hg annotate -c a
+  241ace8326d0: 1a
+  9b19176bb127: 2b
+  484c6ac0cea3: 3
+  04c8ba6df782: 4d
+  2f7ba78d6abc: 5e
+
+Do it again, but this time with an unrelated commit checked out (plus working
+directory changes on top):
 
   $ cat > a < 1a
   > 2b
-  > 4d
+  > 3
+  > 4f
+  > 5g
   > EOF
-  $ echo y | hg absorb --config ui.interactive=1
+  $ hg commit -qm "commit to absorb 2"
+  $ TOABSORB=$(hg id -i)
+
+  $ hg update -q 241ace8326d0
+  $ echo committed unrelated >> a
+  $ hg commit -qm "unrelated commit"
+  $ echo pending wdir change >> a
+
+  $ hg absorb --apply-changes --print-changes -s ${TOABSORB}
   showing changes for a
-  @@ -0,1 +0,0 @@
-  f548282 -1a
-  @@ -2,1 +1,0 @@
-  ff5d556 -3
-  @@ -4,1 +2,0 @@
-  84e5416 -5e
+  @@ -3,2 +3,2 @@
+  04c8ba6 -4d
+  2f7ba78 -5e
+  04c8ba6 +4f
+  2f7ba78 +5g
   
-  3 changesets affected
-  84e5416 commit 5
-  ff5d556 commit 3
-  f548282 commit 1
-  apply changes (yn)?  y
-  saved backup bundle to * (glob)
-  3 of 3 chunk(s) applied
-  $ hg annotate a
-  1: 2b
-  2: 4d
-  $ hg log -T '{rev} {desc}\n' -Gp
-  @  2 commit 4
-  |  diff -r 1cae118c7ed8 -r 58a62bade1c6 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -1,1 +1,2 @@
-  |   2b
-  |  +4d
+  2 changesets affected
+  2f7ba78 commit 5
+  04c8ba6 commit 4
+  1 new orphan changesets
+  1 of 1 chunk(s) applied
+
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  dbce69d9fe03 : committed unrelated
+  dbce69d9fe03+: pending wdir change
+
+
+  $ hg update -Cq .
+
+  $ hg rebase -d tip -r ${TOABSORB}
+  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
+  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+
+  $ hg log -G -T '{node|short} {desc} {instabilities}'
+  o  789b01face13 commit 5
   |
-  o  1 commit 2
-  |  diff -r 84add69aeac0 -r 1cae118c7ed8 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -0,0 +1,1 @@
-  |  +2b
+  o  9c83c60f49f2 commit 4
   |
-  o  0 commit 1
+  | @  

D7630: absorb: make the absorbed changeset be automatically "evolved"

2019-12-17 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18842.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7630?vs=18729=18842

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t

CHANGE DETAILS

diff --git a/tests/test-absorb-rev.t b/tests/test-absorb-rev.t
--- a/tests/test-absorb-rev.t
+++ b/tests/test-absorb-rev.t
@@ -65,26 +65,18 @@
 Run absorb:
 
   $ hg absorb --apply-changes -s .
-  1 new orphan changesets
   2 of 2 chunk(s) applied
 
 Check that the pending wdir change was left alone:
+TODO: The absorbed commit should have disappeared when it became empty.
 
   $ grep 6 a
   6
-  $ hg update -Cq .
-
-Rebase the absorbed revision on top of the destination (as evolve would):
-TODO: the evolve-type operation should happen automatically for the changeset
-being absorbed, and even through that the pending wdir change should be left
-alone.
-
-  $ hg rebase -d tip -r .
-  rebasing 5:1631091f9648 "commit to absorb"
-  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
-  @  2f7ba78d6abc commit 5
+  @  9a0ec5cae1a1 commit to absorb
+  |
+  o  2f7ba78d6abc commit 5
   |
   o  04c8ba6df782 commit 4
   |
@@ -94,12 +86,15 @@
   |
   o  241ace8326d0 commit 1
   
-  $ hg annotate -c a
-  241ace8326d0: 1a
-  9b19176bb127: 2b
-  484c6ac0cea3: 3
-  04c8ba6df782: 4d
-  2f7ba78d6abc: 5e
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  9b19176bb127 : 2b
+  484c6ac0cea3 : 3
+  04c8ba6df782 : 4d
+  2f7ba78d6abc : 5e
+  9a0ec5cae1a1+: 6
+
+  $ hg diff -c .
 
 Do it again, but this time with an unrelated commit checked out (plus working
 directory changes on top):
@@ -130,7 +125,6 @@
   2 changesets affected
   2f7ba78 commit 5
   04c8ba6 commit 4
-  1 new orphan changesets
   1 of 1 chunk(s) applied
 
   $ hg annotate -c a -r 'wdir()'
@@ -138,19 +132,16 @@
   dbce69d9fe03 : committed unrelated
   dbce69d9fe03+: pending wdir change
 
-
-  $ hg update -Cq .
-
-  $ hg rebase -d tip -r ${TOABSORB}
-  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
-  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+  $ hg update -Cq tip
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  59655ff113fb commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
-  | @  dbce69d9fe03 unrelated commit
+  | o  dbce69d9fe03 unrelated commit
   | |
   o |  484c6ac0cea3 commit 3
   | |
@@ -159,7 +150,7 @@
   o  241ace8326d0 commit 1
   
 
-  $ hg annotate -c a -r tip
+  $ hg annotate -c a
   241ace8326d0: 1a
   9b19176bb127: 2b
   484c6ac0cea3: 3
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -34,6 +34,7 @@
 from __future__ import absolute_import
 
 import collections
+import itertools
 
 from mercurial.i18n import _
 from mercurial import (
@@ -662,16 +663,19 @@
 4. call commit, to commit changes to hg database
 """
 
-def __init__(self, stack, ui=None, opts=None):
+def __init__(self, stack, fixuptargets=[], ui=None, opts=None):
 """([ctx], ui or None) -> None
 
 stack: should be linear, and sorted by topo order - oldest first.
+fixuptargets: changeset contexts that need to be fixed up, but are not
+used for fixup computation.
 all commits in stack are considered mutable.
 """
 assert stack
 self.ui = ui or nullui()
 self.opts = opts or {}
 self.stack = stack
+self.fixuptargets = fixuptargets
 self.repo = stack[-1].repo().unfiltered()
 
 # following fields will be filled later
@@ -777,7 +781,7 @@
 # p1 which overrides the parent of the next commit, "None" means use
 # the original parent unchanged
 nextp1 = None
-for ctx in self.stack:
+for ctx in itertools.chain(self.stack, self.fixuptargets):
 memworkingcopy = self._getnewfilecontents(ctx)
 if not memworkingcopy and not lastcommitted:
 # nothing changed, nothing commited
@@ -1011,7 +1015,10 @@
 pats = ()
 if opts is None:
 opts = {}
-state = fixupstate(stack, ui=ui, opts=opts)
+fixuptargets = []
+if targetctx.rev() is not None:
+fixuptargets.append(targetctx)
+state = fixupstate(stack, fixuptargets=fixuptargets, ui=ui, opts=opts)
 matcher = scmutil.match(targetctx, pats, opts)
 if opts.get(b'interactive'):
 diff = patch.diff(repo, stack[-1].node(), targetctx.node(), matcher)



To: rdamazio, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D7666: update: add some tests for the status quo of morestatus on update conflicts

2019-12-15 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHG5709a9992c2a: update: add some tests for the status quo of 
morestatus on update conflicts (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7666?vs=18723=18753

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

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

AFFECTED FILES
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -1,3 +1,8 @@
+  $ cat >> $HGRCPATH < [commands]
+  > status.verbose=1
+  > EOF
+
 # Construct the following history tree:
 #
 # @  5:e1bb631146ca  b1
@@ -308,6 +313,10 @@
   use 'hg resolve' to retry unresolved file merges
   [1]
   $ rm a.orig
+  $ hg status
+  M a
+  $ hg resolve -l
+  U a
 
 Change/delete conflict is not allowed
   $ hg up -qC 3
@@ -536,10 +545,47 @@
   updated to hidden changeset 6efa171f091b
   (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
   [1]
+
+Test that statuses are reported properly before and after merge resolution.
+  $ rm a.orig
+  $ hg resolve -l
+  U a
+  $ hg status
+  M a
+  M foo
+
   $ hg revert -r . a
+
+  $ rm a.orig
+  $ hg resolve -l
+  U a
+  $ hg status
+  M foo
+  $ hg status -Tjson
+  [
+   {
+"itemtype": "file",
+"path": "foo",
+"status": "M"
+   }
+  ]
+
   $ hg resolve -m
   (no more unresolved files)
 
+  $ hg resolve -l
+  R a
+  $ hg status
+  M foo
+  $ hg status -Tjson
+  [
+   {
+"itemtype": "file",
+"path": "foo",
+"status": "M"
+   }
+  ]
+
 Test that 4 is detected as the no-argument destination from 3 and also moves
 the bookmark with it
   $ hg up --quiet 0  # we should be able to update to 3 directly



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


D7631: absorb: allowing committed changes to be absorbed into their ancestors

2019-12-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18728.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7631?vs=18726=18728

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t
  tests/test-absorb.t

CHANGE DETAILS

diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -143,7 +143,7 @@
   nothing applied
   [1]
 
-Insertaions:
+Insertions:
 
   $ cat > a << EOF
   > insert before 2b
diff --git a/tests/test-absorb.t b/tests/test-absorb-rev.t
copy from tests/test-absorb.t
copy to tests/test-absorb-rev.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb-rev.t
@@ -1,26 +1,14 @@
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > absorb=
+  > rebase=
+  > [experimental]
+  > evolution=createmarkers
   > EOF
 
-  $ sedi() { # workaround check-code
-  > pattern="$1"
-  > shift
-  > for i in "$@"; do
-  > sed "$pattern" "$i" > "$i".tmp
-  > mv "$i".tmp "$i"
-  > done
-  > }
-
   $ hg init repo1
   $ cd repo1
 
-Do not crash with empty repo:
-
-  $ hg absorb
-  abort: no mutable changeset to change
-  [255]
-
 Make some commits:
 
   $ for i in 1 2 3 4 5; do
@@ -45,9 +33,13 @@
   > 5e
   > EOF
 
+Commit that, too.
+
+  $ hg commit -qm "commit to absorb"
+
 Preview absorb changes:
 
-  $ hg absorb --print-changes --dry-run
+  $ hg absorb --print-changes --dry-run -s .
   showing changes for a
   @@ -0,2 +0,2 @@
   4ec16f8 -1
@@ -66,462 +58,111 @@
   5c5f952 commit 2
   4ec16f8 commit 1
 
+Add an uncommitted working directory change:
+
+  $ echo 6 >> a
+
 Run absorb:
 
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
+  $ hg absorb --apply-changes -s .
+  1 new orphan changesets
   2 of 2 chunk(s) applied
-  $ hg annotate a
-  0: 1a
-  1: 2b
-  2: 3
-  3: 4d
-  4: 5e
+
+Check that the pending wdir change was left alone:
+
+  $ grep 6 a
+  6
+  $ hg update -Cq .
+
+Rebase the absorbed revision on top of the destination (as evolve would):
+TODO: the evolve-type operation should happen automatically for the changeset
+being absorbed, and even through that the pending wdir change should be left
+alone.
+
+  $ hg rebase -d tip -r .
+  rebasing 5:1631091f9648 "commit to absorb"
+  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
-Delete a few lines and related commits will be removed if they will be empty:
+  $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  2f7ba78d6abc commit 5
+  |
+  o  04c8ba6df782 commit 4
+  |
+  o  484c6ac0cea3 commit 3
+  |
+  o  9b19176bb127 commit 2
+  |
+  o  241ace8326d0 commit 1
+  
+  $ hg annotate -c a
+  241ace8326d0: 1a
+  9b19176bb127: 2b
+  484c6ac0cea3: 3
+  04c8ba6df782: 4d
+  2f7ba78d6abc: 5e
+
+Do it again, but this time with an unrelated commit checked out (plus working
+directory changes on top):
 
   $ cat > a < 1a
   > 2b
-  > 4d
+  > 3
+  > 4f
+  > 5g
   > EOF
-  $ echo y | hg absorb --config ui.interactive=1
+  $ hg commit -qm "commit to absorb 2"
+  $ TOABSORB=$(hg id -i)
+
+  $ hg update -q 241ace8326d0
+  $ echo committed unrelated >> a
+  $ hg commit -qm "unrelated commit"
+  $ echo pending wdir change >> a
+
+  $ hg absorb --apply-changes --print-changes -s ${TOABSORB}
   showing changes for a
-  @@ -0,1 +0,0 @@
-  f548282 -1a
-  @@ -2,1 +1,0 @@
-  ff5d556 -3
-  @@ -4,1 +2,0 @@
-  84e5416 -5e
+  @@ -3,2 +3,2 @@
+  04c8ba6 -4d
+  2f7ba78 -5e
+  04c8ba6 +4f
+  2f7ba78 +5g
   
-  3 changesets affected
-  84e5416 commit 5
-  ff5d556 commit 3
-  f548282 commit 1
-  apply changes (yn)?  y
-  saved backup bundle to * (glob)
-  3 of 3 chunk(s) applied
-  $ hg annotate a
-  1: 2b
-  2: 4d
-  $ hg log -T '{rev} {desc}\n' -Gp
-  @  2 commit 4
-  |  diff -r 1cae118c7ed8 -r 58a62bade1c6 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -1,1 +1,2 @@
-  |   2b
-  |  +4d
+  2 changesets affected
+  2f7ba78 commit 5
+  04c8ba6 commit 4
+  1 new orphan changesets
+  1 of 1 chunk(s) applied
+
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  dbce69d9fe03 : committed unrelated
+  dbce69d9fe03+: pending wdir change
+
+
+  $ hg update -Cq .
+
+  $ hg rebase -d tip -r ${TOABSORB}
+  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
+  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+
+  $ hg log -G -T '{node|short} {desc} {instabilities}'
+  o  789b01face13 commit 5
   |
-  o  1 commit 2
-  |  diff -r 84add69aeac0 -r 1cae118c7ed8 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -0,0 +1,1 @@
-  |  +2b
+  o  9c83c60f49f2 commit 4
   |
-  o  0 commit 1
+  | @  dbce69d9fe03 unrelated commit
+  | |
+  o |  484c6ac0cea3 commit 3
+  | |
+  o |  9b19176bb127 commit 2
+  

D7630: absorb: make the absorbed changeset be automatically "evolved"

2019-12-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18729.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7630?vs=18727=18729

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t

CHANGE DETAILS

diff --git a/tests/test-absorb-rev.t b/tests/test-absorb-rev.t
--- a/tests/test-absorb-rev.t
+++ b/tests/test-absorb-rev.t
@@ -65,26 +65,18 @@
 Run absorb:
 
   $ hg absorb --apply-changes -s .
-  1 new orphan changesets
   2 of 2 chunk(s) applied
 
 Check that the pending wdir change was left alone:
+TODO: The absorbed commit should have disappeared when it became empty.
 
   $ grep 6 a
   6
-  $ hg update -Cq .
-
-Rebase the absorbed revision on top of the destination (as evolve would):
-TODO: the evolve-type operation should happen automatically for the changeset
-being absorbed, and even through that the pending wdir change should be left
-alone.
-
-  $ hg rebase -d tip -r .
-  rebasing 5:1631091f9648 "commit to absorb"
-  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
-  @  2f7ba78d6abc commit 5
+  @  9a0ec5cae1a1 commit to absorb
+  |
+  o  2f7ba78d6abc commit 5
   |
   o  04c8ba6df782 commit 4
   |
@@ -94,12 +86,15 @@
   |
   o  241ace8326d0 commit 1
   
-  $ hg annotate -c a
-  241ace8326d0: 1a
-  9b19176bb127: 2b
-  484c6ac0cea3: 3
-  04c8ba6df782: 4d
-  2f7ba78d6abc: 5e
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  9b19176bb127 : 2b
+  484c6ac0cea3 : 3
+  04c8ba6df782 : 4d
+  2f7ba78d6abc : 5e
+  9a0ec5cae1a1+: 6
+
+  $ hg diff -c .
 
 Do it again, but this time with an unrelated commit checked out (plus working
 directory changes on top):
@@ -130,7 +125,6 @@
   2 changesets affected
   2f7ba78 commit 5
   04c8ba6 commit 4
-  1 new orphan changesets
   1 of 1 chunk(s) applied
 
   $ hg annotate -c a -r 'wdir()'
@@ -138,19 +132,16 @@
   dbce69d9fe03 : committed unrelated
   dbce69d9fe03+: pending wdir change
 
-
-  $ hg update -Cq .
-
-  $ hg rebase -d tip -r ${TOABSORB}
-  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
-  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+  $ hg update -Cq tip
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  59655ff113fb commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
-  | @  dbce69d9fe03 unrelated commit
+  | o  dbce69d9fe03 unrelated commit
   | |
   o |  484c6ac0cea3 commit 3
   | |
@@ -159,7 +150,7 @@
   o  241ace8326d0 commit 1
   
 
-  $ hg annotate -c a -r tip
+  $ hg annotate -c a
   241ace8326d0: 1a
   9b19176bb127: 2b
   484c6ac0cea3: 3
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -34,6 +34,7 @@
 from __future__ import absolute_import
 
 import collections
+import itertools
 
 from mercurial.i18n import _
 from mercurial import (
@@ -661,16 +662,19 @@
 4. call commit, to commit changes to hg database
 """
 
-def __init__(self, stack, ui=None, opts=None):
+def __init__(self, stack, fixuptargets=[], ui=None, opts=None):
 """([ctx], ui or None) -> None
 
 stack: should be linear, and sorted by topo order - oldest first.
+fixuptargets: changeset contexts that need to be fixed up, but are not
+used for fixup computation.
 all commits in stack are considered mutable.
 """
 assert stack
 self.ui = ui or nullui()
 self.opts = opts or {}
 self.stack = stack
+self.fixuptargets = fixuptargets
 self.repo = stack[-1].repo().unfiltered()
 
 # following fields will be filled later
@@ -776,7 +780,7 @@
 # p1 which overrides the parent of the next commit, "None" means use
 # the original parent unchanged
 nextp1 = None
-for ctx in self.stack:
+for ctx in itertools.chain(self.stack, self.fixuptargets):
 memworkingcopy = self._getnewfilecontents(ctx)
 if not memworkingcopy and not lastcommitted:
 # nothing changed, nothing commited
@@ -1008,7 +1012,10 @@
 pats = ()
 if opts is None:
 opts = {}
-state = fixupstate(stack, ui=ui, opts=opts)
+fixuptargets = []
+if targetctx.rev() is not None:
+fixuptargets.append(targetctx)
+state = fixupstate(stack, fixuptargets=fixuptargets, ui=ui, opts=opts)
 matcher = scmutil.match(targetctx, pats, opts)
 if opts.get(b'interactive'):
 diff = patch.diff(repo, stack[-1].node(), targetctx.node(), matcher)



To: rdamazio, #hg-reviewers
Cc: martinvonz, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D7631: absorb: allowing committed changes to be absorbed into their ancestors

2019-12-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio retitled this revision from "RFC: absorb: allowing committed changes 
to be absorbed into their ancestors" to "absorb: allowing committed changes to 
be absorbed into their ancestors".
rdamazio updated this revision to Diff 18726.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7631?vs=18666=18726

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t
  tests/test-absorb.t

CHANGE DETAILS

diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -143,7 +143,7 @@
   nothing applied
   [1]
 
-Insertaions:
+Insertions:
 
   $ cat > a << EOF
   > insert before 2b
diff --git a/tests/test-absorb.t b/tests/test-absorb-rev.t
copy from tests/test-absorb.t
copy to tests/test-absorb-rev.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb-rev.t
@@ -1,26 +1,14 @@
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > absorb=
+  > rebase=
+  > [experimental]
+  > evolution=createmarkers
   > EOF
 
-  $ sedi() { # workaround check-code
-  > pattern="$1"
-  > shift
-  > for i in "$@"; do
-  > sed "$pattern" "$i" > "$i".tmp
-  > mv "$i".tmp "$i"
-  > done
-  > }
-
   $ hg init repo1
   $ cd repo1
 
-Do not crash with empty repo:
-
-  $ hg absorb
-  abort: no mutable changeset to change
-  [255]
-
 Make some commits:
 
   $ for i in 1 2 3 4 5; do
@@ -45,9 +33,13 @@
   > 5e
   > EOF
 
+Commit that, too.
+
+  $ hg commit -qm "commit to absorb"
+
 Preview absorb changes:
 
-  $ hg absorb --print-changes --dry-run
+  $ hg absorb --print-changes --dry-run -r .
   showing changes for a
   @@ -0,2 +0,2 @@
   4ec16f8 -1
@@ -66,462 +58,111 @@
   5c5f952 commit 2
   4ec16f8 commit 1
 
+Add an uncommitted working directory change:
+
+  $ echo 6 >> a
+
 Run absorb:
 
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
+  $ hg absorb --apply-changes -r .
+  1 new orphan changesets
   2 of 2 chunk(s) applied
-  $ hg annotate a
-  0: 1a
-  1: 2b
-  2: 3
-  3: 4d
-  4: 5e
+
+Check that the pending wdir change was left alone:
+
+  $ grep 6 a
+  6
+  $ hg update -Cq .
+
+Rebase the absorbed revision on top of the destination (as evolve would):
+TODO: the evolve-type operation should happen automatically for the changeset
+being absorbed, and even through that the pending wdir change should be left
+alone.
+
+  $ hg rebase -d tip -r .
+  rebasing 5:1631091f9648 "commit to absorb"
+  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
-Delete a few lines and related commits will be removed if they will be empty:
+  $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  2f7ba78d6abc commit 5
+  |
+  o  04c8ba6df782 commit 4
+  |
+  o  484c6ac0cea3 commit 3
+  |
+  o  9b19176bb127 commit 2
+  |
+  o  241ace8326d0 commit 1
+  
+  $ hg annotate -c a
+  241ace8326d0: 1a
+  9b19176bb127: 2b
+  484c6ac0cea3: 3
+  04c8ba6df782: 4d
+  2f7ba78d6abc: 5e
+
+Do it again, but this time with an unrelated commit checked out (plus working
+directory changes on top):
 
   $ cat > a < 1a
   > 2b
-  > 4d
+  > 3
+  > 4f
+  > 5g
   > EOF
-  $ echo y | hg absorb --config ui.interactive=1
+  $ hg commit -qm "commit to absorb 2"
+  $ TOABSORB=$(hg id -i)
+
+  $ hg update -q 241ace8326d0
+  $ echo committed unrelated >> a
+  $ hg commit -qm "unrelated commit"
+  $ echo pending wdir change >> a
+
+  $ hg absorb --apply-changes --print-changes -r ${TOABSORB}
   showing changes for a
-  @@ -0,1 +0,0 @@
-  f548282 -1a
-  @@ -2,1 +1,0 @@
-  ff5d556 -3
-  @@ -4,1 +2,0 @@
-  84e5416 -5e
+  @@ -3,2 +3,2 @@
+  04c8ba6 -4d
+  2f7ba78 -5e
+  04c8ba6 +4f
+  2f7ba78 +5g
   
-  3 changesets affected
-  84e5416 commit 5
-  ff5d556 commit 3
-  f548282 commit 1
-  apply changes (yn)?  y
-  saved backup bundle to * (glob)
-  3 of 3 chunk(s) applied
-  $ hg annotate a
-  1: 2b
-  2: 4d
-  $ hg log -T '{rev} {desc}\n' -Gp
-  @  2 commit 4
-  |  diff -r 1cae118c7ed8 -r 58a62bade1c6 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -1,1 +1,2 @@
-  |   2b
-  |  +4d
+  2 changesets affected
+  2f7ba78 commit 5
+  04c8ba6 commit 4
+  1 new orphan changesets
+  1 of 1 chunk(s) applied
+
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  dbce69d9fe03 : committed unrelated
+  dbce69d9fe03+: pending wdir change
+
+
+  $ hg update -Cq .
+
+  $ hg rebase -d tip -r ${TOABSORB}
+  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
+  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+
+  $ hg log -G -T '{node|short} {desc} {instabilities}'
+  o  789b01face13 commit 5
   |
-  o  1 commit 2
-  |  diff -r 84add69aeac0 -r 1cae118c7ed8 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  | 

D7630: absorb: make the absorbed changeset be automatically "evolved"

2019-12-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio retitled this revision from "RFC: absorb: make the absorbed changeset 
be automatically "evolved"" to "absorb: make the absorbed changeset be 
automatically "evolved"".
rdamazio marked 2 inline comments as done.
rdamazio updated this revision to Diff 18727.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7630?vs=18665=18727

BRANCH
  default

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

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t

CHANGE DETAILS

diff --git a/tests/test-absorb-rev.t b/tests/test-absorb-rev.t
--- a/tests/test-absorb-rev.t
+++ b/tests/test-absorb-rev.t
@@ -65,26 +65,18 @@
 Run absorb:
 
   $ hg absorb --apply-changes -r .
-  1 new orphan changesets
   2 of 2 chunk(s) applied
 
 Check that the pending wdir change was left alone:
+TODO: The absorbed commit should have disappeared when it became empty.
 
   $ grep 6 a
   6
-  $ hg update -Cq .
-
-Rebase the absorbed revision on top of the destination (as evolve would):
-TODO: the evolve-type operation should happen automatically for the changeset
-being absorbed, and even through that the pending wdir change should be left
-alone.
-
-  $ hg rebase -d tip -r .
-  rebasing 5:1631091f9648 "commit to absorb"
-  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
-  @  2f7ba78d6abc commit 5
+  @  9a0ec5cae1a1 commit to absorb
+  |
+  o  2f7ba78d6abc commit 5
   |
   o  04c8ba6df782 commit 4
   |
@@ -94,12 +86,15 @@
   |
   o  241ace8326d0 commit 1
   
-  $ hg annotate -c a
-  241ace8326d0: 1a
-  9b19176bb127: 2b
-  484c6ac0cea3: 3
-  04c8ba6df782: 4d
-  2f7ba78d6abc: 5e
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  9b19176bb127 : 2b
+  484c6ac0cea3 : 3
+  04c8ba6df782 : 4d
+  2f7ba78d6abc : 5e
+  9a0ec5cae1a1+: 6
+
+  $ hg diff -c .
 
 Do it again, but this time with an unrelated commit checked out (plus working
 directory changes on top):
@@ -130,7 +125,6 @@
   2 changesets affected
   2f7ba78 commit 5
   04c8ba6 commit 4
-  1 new orphan changesets
   1 of 1 chunk(s) applied
 
   $ hg annotate -c a -r 'wdir()'
@@ -138,19 +132,16 @@
   dbce69d9fe03 : committed unrelated
   dbce69d9fe03+: pending wdir change
 
-
-  $ hg update -Cq .
-
-  $ hg rebase -d tip -r ${TOABSORB}
-  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
-  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+  $ hg update -Cq tip
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  59655ff113fb commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
-  | @  dbce69d9fe03 unrelated commit
+  | o  dbce69d9fe03 unrelated commit
   | |
   o |  484c6ac0cea3 commit 3
   | |
@@ -159,7 +150,7 @@
   o  241ace8326d0 commit 1
   
 
-  $ hg annotate -c a -r tip
+  $ hg annotate -c a
   241ace8326d0: 1a
   9b19176bb127: 2b
   484c6ac0cea3: 3
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -34,6 +34,7 @@
 from __future__ import absolute_import
 
 import collections
+import itertools
 
 from mercurial.i18n import _
 from mercurial import (
@@ -661,16 +662,19 @@
 4. call commit, to commit changes to hg database
 """
 
-def __init__(self, stack, ui=None, opts=None):
+def __init__(self, stack, fixuptargets=[], ui=None, opts=None):
 """([ctx], ui or None) -> None
 
 stack: should be linear, and sorted by topo order - oldest first.
+fixuptargets: changeset contexts that need to be fixed up, but are not
+used for fixup computation.
 all commits in stack are considered mutable.
 """
 assert stack
 self.ui = ui or nullui()
 self.opts = opts or {}
 self.stack = stack
+self.fixuptargets = fixuptargets
 self.repo = stack[-1].repo().unfiltered()
 
 # following fields will be filled later
@@ -776,7 +780,7 @@
 # p1 which overrides the parent of the next commit, "None" means use
 # the original parent unchanged
 nextp1 = None
-for ctx in self.stack:
+for ctx in itertools.chain(self.stack, self.fixuptargets):
 memworkingcopy = self._getnewfilecontents(ctx)
 if not memworkingcopy and not lastcommitted:
 # nothing changed, nothing commited
@@ -1008,7 +1012,10 @@
 pats = ()
 if opts is None:
 opts = {}
-state = fixupstate(stack, ui=ui, opts=opts)
+fixuptargets = []
+if targetctx.rev() is not None:
+fixuptargets.append(targetctx)
+state = fixupstate(stack, fixuptargets=fixuptargets, ui=ui, opts=opts)
 matcher = scmutil.match(targetctx, pats, opts)
 if opts.get(b'interactive'):
 diff = patch.diff(repo, stack[-1].node(), targetctx.node(), matcher)



To: 

D7631: absorb: allowing committed changes to be absorbed into their ancestors

2019-12-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In D7631#112414 , @quark wrote:
  
  > `--rev` seems ambiguous since there might be different kinds of revisions 
to specify - target and revisions to edit. Maybe something like `--source`, 
`--from`, `--target`?
  
  Done. Used `--source` to match `rebase`.
  
  I'm assuming no fundamental objections then? Removing the "RFC" part so it 
gets a proper review then.

REPOSITORY
  rHG Mercurial

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

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

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


D7630: absorb: make the absorbed changeset be automatically "evolved"

2019-12-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  Sorry for the upload mess (though it's arguably a `phabsend` bug :) ). Tried 
uploading the "right" way now.

REPOSITORY
  rHG Mercurial

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

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

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


D7668: status: make unresolved files always be in the morestatus structured output

2019-12-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We don't know the status of those files, only that they're unresolved, so
  we don't output the status for those - any code parsing this will have to be
  tolerant to that.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -591,6 +591,11 @@
 "itemtype": "file",
 "path": "foo",
 "status": "M"
+   },
+   {
+"itemtype": "file",
+"path": "a",
+"unresolved": true
}
   ]
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -809,6 +809,7 @@
 if self.unfinishedmsg:
 fm.data(unfinishedmsg=self.unfinishedmsg)
 
+# May also start new data items.
 self._formatconflicts(fm)
 
 if self.unfinishedmsg:
@@ -838,6 +839,19 @@
 )
 % mergeliststr
 )
+
+# If any paths with unresolved conflicts were not previously
+# formatted, output them now.
+for f in self.unresolvedpaths:
+if f in self._formattedpaths:
+# Already output.
+continue
+fm.startitem()
+# We can't claim to know the status of the file - it may just
+# have been in one of the states that were not requested for
+# display, so it could be anything.
+fm.data(itemtype=b'file', path=f, unresolved=True)
+
 else:
 msg = _(b'No unresolved merge conflicts.')
 



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


D7667: status: make morestatus call out unresolved conflicts after update

2019-12-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -252,6 +252,12 @@
   $ hg st
   M a
   ? a.orig
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ cat a
   <<< working copy: 6efa171f091b - test: 3
   three
@@ -315,6 +321,12 @@
   $ rm a.orig
   $ hg status
   M a
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ hg resolve -l
   U a
 
@@ -553,6 +565,12 @@
   $ hg status
   M a
   M foo
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
 
   $ hg revert -r . a
 
@@ -561,6 +579,12 @@
   U a
   $ hg status
   M foo
+  # Unresolved merge conflicts:
+  # 
+  # a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ hg status -Tjson
   [
{
@@ -577,6 +601,8 @@
   R a
   $ hg status
   M foo
+  # No unresolved merge conflicts.
+  
   $ hg status -Tjson
   [
{
@@ -589,6 +615,8 @@
 Test that 4 is detected as the no-argument destination from 3 and also moves
 the bookmark with it
   $ hg up --quiet 0  # we should be able to update to 3 directly
+  $ hg status
+  M foo
   $ hg up --quiet --hidden 3 # but not implemented yet.
   updated to hidden changeset 6efa171f091b
   (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -784,36 +784,40 @@
 reporoot = attr.ib()
 unfinishedop = attr.ib()
 unfinishedmsg = attr.ib()
-inmergestate = attr.ib()
+activemerge = attr.ib()
 unresolvedpaths = attr.ib()
+_formattedpaths = attr.ib(init=False, default=set())
 _label = b'status.morestatus'
 
 def formatfile(self, path, fm):
-if self.inmergestate and path in self.unresolvedpaths:
+self._formattedpaths.add(path)
+if self.activemerge and path in self.unresolvedpaths:
 fm.data(unresolved=True)
 
 def formatfooter(self, fm):
-fm.startitem()
-fm.data(
-itemtype=b'morestatus',
-unfinished=self.unfinishedop,
-unfinishedmsg=self.unfinishedmsg,
-)
-
-statemsg = (
-_(b'The repository is in an unfinished *%s* state.')
-% self.unfinishedop
-)
-fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+if self.unfinishedop or self.unfinishedmsg:
+fm.startitem()
+fm.data(itemtype=b'morestatus')
+
+if self.unfinishedop:
+fm.data(unfinished=self.unfinishedop)
+statemsg = (
+_(b'The repository is in an unfinished *%s* state.')
+% self.unfinishedop
+)
+fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+if self.unfinishedmsg:
+fm.data(unfinishedmsg=self.unfinishedmsg)
 
 self._formatconflicts(fm)
+
 if self.unfinishedmsg:
 fm.plain(
 b'%s\n' % _commentlines(self.unfinishedmsg), label=self._label
 )
 
 def _formatconflicts(self, fm):
-if not self.inmergestate:
+if not self.activemerge:
 return
 
 if self.unresolvedpaths:
@@ -843,21 +847,22 @@
 def readmorestatus(repo):
 """Returns a morestatus object if the repo has unfinished state."""
 statetuple = statemod.getrepostate(repo)
-if not statetuple:
+mergestate = mergemod.mergestate.read(repo)
+activemerge = mergestate.active()
+if not statetuple and not activemerge:
 return None
 
-unfinishedop, unfinishedmsg = statetuple
-mergestate = mergemod.mergestate.read(repo)
-unresolved = None
-if mergestate.active():
+unfinishedop = unfinishedmsg = unresolved = None
+if statetuple:
+unfinishedop, unfinishedmsg = statetuple
+if activemerge:
 unresolved = sorted(mergestate.unresolved())
 return morestatus(
 repo.root,
 unfinishedop,
 unfinishedmsg,
-unresolved is not None,
-unresolved,
-)
+activemerge,
+unresolved)
 
 
 def findpossible(cmd, table, strict=False):



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


D7666: update: add some tests for the status quo of morestatus on update conflicts

2019-12-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -1,3 +1,8 @@
+  $ cat >> $HGRCPATH < [commands]
+  > status.verbose=1
+  > EOF
+
 # Construct the following history tree:
 #
 # @  5:e1bb631146ca  b1
@@ -308,6 +313,10 @@
   use 'hg resolve' to retry unresolved file merges
   [1]
   $ rm a.orig
+  $ hg status
+  M a
+  $ hg resolve -l
+  U a
 
 Change/delete conflict is not allowed
   $ hg up -qC 3
@@ -536,10 +545,47 @@
   updated to hidden changeset 6efa171f091b
   (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
   [1]
+
+Test that statuses are reported properly before and after merge resolution.
+  $ rm a.orig
+  $ hg resolve -l
+  U a
+  $ hg status
+  M a
+  M foo
+
   $ hg revert -r . a
+
+  $ rm a.orig
+  $ hg resolve -l
+  U a
+  $ hg status
+  M foo
+  $ hg status -Tjson
+  [
+   {
+"itemtype": "file",
+"path": "foo",
+"status": "M"
+   }
+  ]
+
   $ hg resolve -m
   (no more unresolved files)
 
+  $ hg resolve -l
+  R a
+  $ hg status
+  M foo
+  $ hg status -Tjson
+  [
+   {
+"itemtype": "file",
+"path": "foo",
+"status": "M"
+   }
+  ]
+
 Test that 4 is detected as the no-argument destination from 3 and also moves
 the bookmark with it
   $ hg up --quiet 0  # we should be able to update to 3 directly



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


D7630: RFC: absorb: make the absorbed changeset be automatically "evolved"

2019-12-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  (on mobile) I think it was `hg phabsend -r .+.^`
  
  - F454947: smime.p7s 

REPOSITORY
  rHG Mercurial

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

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

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


D7631: RFC: absorb: allowing committed changes to be absorbed into their ancestors

2019-12-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This can also be combined with --interactive to absorb just part of a
  commit into its parents.
  
  This initial implementation has the shortcoming that it does not do anything
  with the absorbed commit:
  
  - With obsmarkers, this means the user still needs to evolve/rebase manually
  - Without obsmarkers, the old commits would not be stripped at all because 
their child was not replaced

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t
  tests/test-absorb.t

CHANGE DETAILS

diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -143,7 +143,7 @@
   nothing applied
   [1]
 
-Insertaions:
+Insertions:
 
   $ cat > a << EOF
   > insert before 2b
diff --git a/tests/test-absorb.t b/tests/test-absorb-rev.t
copy from tests/test-absorb.t
copy to tests/test-absorb-rev.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb-rev.t
@@ -1,26 +1,14 @@
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > absorb=
+  > rebase=
+  > [experimental]
+  > evolution=createmarkers
   > EOF
 
-  $ sedi() { # workaround check-code
-  > pattern="$1"
-  > shift
-  > for i in "$@"; do
-  > sed "$pattern" "$i" > "$i".tmp
-  > mv "$i".tmp "$i"
-  > done
-  > }
-
   $ hg init repo1
   $ cd repo1
 
-Do not crash with empty repo:
-
-  $ hg absorb
-  abort: no mutable changeset to change
-  [255]
-
 Make some commits:
 
   $ for i in 1 2 3 4 5; do
@@ -45,9 +33,13 @@
   > 5e
   > EOF
 
+Commit that, too.
+
+  $ hg commit -qm "commit to absorb"
+
 Preview absorb changes:
 
-  $ hg absorb --print-changes --dry-run
+  $ hg absorb --print-changes --dry-run -r .
   showing changes for a
   @@ -0,2 +0,2 @@
   4ec16f8 -1
@@ -66,462 +58,111 @@
   5c5f952 commit 2
   4ec16f8 commit 1
 
+Add an uncommitted working directory change:
+
+  $ echo 6 >> a
+
 Run absorb:
 
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
+  $ hg absorb --apply-changes -r .
+  1 new orphan changesets
   2 of 2 chunk(s) applied
-  $ hg annotate a
-  0: 1a
-  1: 2b
-  2: 3
-  3: 4d
-  4: 5e
+
+Check that the pending wdir change was left alone:
+
+  $ grep 6 a
+  6
+  $ hg update -Cq .
+
+Rebase the absorbed revision on top of the destination (as evolve would):
+TODO: the evolve-type operation should happen automatically for the changeset
+being absorbed, and even through that the pending wdir change should be left
+alone.
+
+  $ hg rebase -d tip -r .
+  rebasing 5:1631091f9648 "commit to absorb"
+  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
-Delete a few lines and related commits will be removed if they will be empty:
+  $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  2f7ba78d6abc commit 5
+  |
+  o  04c8ba6df782 commit 4
+  |
+  o  484c6ac0cea3 commit 3
+  |
+  o  9b19176bb127 commit 2
+  |
+  o  241ace8326d0 commit 1
+  
+  $ hg annotate -c a
+  241ace8326d0: 1a
+  9b19176bb127: 2b
+  484c6ac0cea3: 3
+  04c8ba6df782: 4d
+  2f7ba78d6abc: 5e
+
+Do it again, but this time with an unrelated commit checked out (plus working
+directory changes on top):
 
   $ cat > a < 1a
   > 2b
-  > 4d
+  > 3
+  > 4f
+  > 5g
   > EOF
-  $ echo y | hg absorb --config ui.interactive=1
+  $ hg commit -qm "commit to absorb 2"
+  $ TOABSORB=$(hg id -i)
+
+  $ hg update -q 241ace8326d0
+  $ echo committed unrelated >> a
+  $ hg commit -qm "unrelated commit"
+  $ echo pending wdir change >> a
+
+  $ hg absorb --apply-changes --print-changes -r ${TOABSORB}
   showing changes for a
-  @@ -0,1 +0,0 @@
-  f548282 -1a
-  @@ -2,1 +1,0 @@
-  ff5d556 -3
-  @@ -4,1 +2,0 @@
-  84e5416 -5e
+  @@ -3,2 +3,2 @@
+  04c8ba6 -4d
+  2f7ba78 -5e
+  04c8ba6 +4f
+  2f7ba78 +5g
   
-  3 changesets affected
-  84e5416 commit 5
-  ff5d556 commit 3
-  f548282 commit 1
-  apply changes (yn)?  y
-  saved backup bundle to * (glob)
-  3 of 3 chunk(s) applied
-  $ hg annotate a
-  1: 2b
-  2: 4d
-  $ hg log -T '{rev} {desc}\n' -Gp
-  @  2 commit 4
-  |  diff -r 1cae118c7ed8 -r 58a62bade1c6 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -1,1 +1,2 @@
-  |   2b
-  |  +4d
+  2 changesets affected
+  2f7ba78 commit 5
+  04c8ba6 commit 4
+  1 new orphan changesets
+  1 of 1 chunk(s) applied
+
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  dbce69d9fe03 : committed unrelated
+  dbce69d9fe03+: pending wdir change
+
+
+  $ hg update -Cq .
+
+  $ hg rebase -d tip -r ${TOABSORB}
+  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
+  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+
+  $ hg log -G -T '{node|short} {desc} {instabilities}'
+  o  789b01face13 commit 5
   |
-  o  1 commit 2
-  | 

D7630: RFC: absorb: make the absorbed changeset be automatically "evolved"

2019-12-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When a committed changeset is absorbed, this will make it so it's not used for
  computing the absorption, but is still recreated at the destination.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t

CHANGE DETAILS

diff --git a/tests/test-absorb-rev.t b/tests/test-absorb-rev.t
--- a/tests/test-absorb-rev.t
+++ b/tests/test-absorb-rev.t
@@ -65,26 +65,18 @@
 Run absorb:
 
   $ hg absorb --apply-changes -r .
-  1 new orphan changesets
   2 of 2 chunk(s) applied
 
 Check that the pending wdir change was left alone:
+TODO: The absorbed commit should have disappeared when it became empty.
 
   $ grep 6 a
   6
-  $ hg update -Cq .
-
-Rebase the absorbed revision on top of the destination (as evolve would):
-TODO: the evolve-type operation should happen automatically for the changeset
-being absorbed, and even through that the pending wdir change should be left
-alone.
-
-  $ hg rebase -d tip -r .
-  rebasing 5:1631091f9648 "commit to absorb"
-  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
-  @  2f7ba78d6abc commit 5
+  @  9a0ec5cae1a1 commit to absorb
+  |
+  o  2f7ba78d6abc commit 5
   |
   o  04c8ba6df782 commit 4
   |
@@ -94,12 +86,15 @@
   |
   o  241ace8326d0 commit 1
   
-  $ hg annotate -c a
-  241ace8326d0: 1a
-  9b19176bb127: 2b
-  484c6ac0cea3: 3
-  04c8ba6df782: 4d
-  2f7ba78d6abc: 5e
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  9b19176bb127 : 2b
+  484c6ac0cea3 : 3
+  04c8ba6df782 : 4d
+  2f7ba78d6abc : 5e
+  9a0ec5cae1a1+: 6
+
+  $ hg diff -c .
 
 Do it again, but this time with an unrelated commit checked out (plus working
 directory changes on top):
@@ -130,7 +125,6 @@
   2 changesets affected
   2f7ba78 commit 5
   04c8ba6 commit 4
-  1 new orphan changesets
   1 of 1 chunk(s) applied
 
   $ hg annotate -c a -r 'wdir()'
@@ -138,19 +132,16 @@
   dbce69d9fe03 : committed unrelated
   dbce69d9fe03+: pending wdir change
 
-
-  $ hg update -Cq .
-
-  $ hg rebase -d tip -r ${TOABSORB}
-  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
-  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+  $ hg update -Cq tip
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  59655ff113fb commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
-  | @  dbce69d9fe03 unrelated commit
+  | o  dbce69d9fe03 unrelated commit
   | |
   o |  484c6ac0cea3 commit 3
   | |
@@ -159,7 +150,7 @@
   o  241ace8326d0 commit 1
   
 
-  $ hg annotate -c a -r tip
+  $ hg annotate -c a
   241ace8326d0: 1a
   9b19176bb127: 2b
   484c6ac0cea3: 3
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -34,6 +34,7 @@
 from __future__ import absolute_import
 
 import collections
+import itertools
 
 from mercurial.i18n import _
 from mercurial import (
@@ -661,16 +662,19 @@
 4. call commit, to commit changes to hg database
 """
 
-def __init__(self, stack, ui=None, opts=None):
+def __init__(self, stack, fixuptargets=[], ui=None, opts=None):
 """([ctx], ui or None) -> None
 
 stack: should be linear, and sorted by topo order - oldest first.
+fixuptargets: changeset contexts that need to be fixed up, but are not
+used for fixup computation.
 all commits in stack are considered mutable.
 """
 assert stack
 self.ui = ui or nullui()
 self.opts = opts or {}
 self.stack = stack
+self.fixuptargets = fixuptargets
 self.repo = stack[-1].repo().unfiltered()
 
 # following fields will be filled later
@@ -776,7 +780,7 @@
 # p1 which overrides the parent of the next commit, "None" means use
 # the original parent unchanged
 nextp1 = None
-for ctx in self.stack:
+for ctx in itertools.chain(self.stack, self.fixuptargets):
 memworkingcopy = self._getnewfilecontents(ctx)
 if not memworkingcopy and not lastcommitted:
 # nothing changed, nothing commited
@@ -1008,7 +1012,10 @@
 pats = ()
 if opts is None:
 opts = {}
-state = fixupstate(stack, ui=ui, opts=opts)
+fixuptargets = []
+if targetctx.rev() is not None:
+fixuptargets.append(targetctx)
+state = fixupstate(stack, fixuptargets=fixuptargets, ui=ui, opts=opts)
 matcher = scmutil.match(targetctx, pats, opts)
 if opts.get(b'interactive'):
 diff = patch.diff(repo, stack[-1].node(), targetctx.node(), matcher)



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list

D7595: status: outputting structured unfinished-operation information

2019-12-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHGaac921f54554: status: outputting structured 
unfinished-operation information (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D7595?vs=18638=18639#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7595?vs=18638=18639

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-conflict.t
  tests/test-status.t

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -254,35 +254,43 @@
   $ hg status -A -Tjson
   [
{
+"itemtype": "file",
 "path": "added",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "copied",
 "source": "modified",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "removed",
 "status": "R"
},
{
+"itemtype": "file",
 "path": "deleted",
 "status": "!"
},
{
+"itemtype": "file",
 "path": "unknown",
 "status": "?"
},
{
+"itemtype": "file",
 "path": "ignored",
 "status": "I"
},
{
+"itemtype": "file",
 "path": ".hgignore",
 "status": "C"
},
{
+"itemtype": "file",
 "path": "modified",
 "status": "C"
}
@@ -558,6 +566,7 @@
   $ hg status --config ui.formatdebug=True --rev 1 1
   status = [
   {
+  'itemtype': 'file',
   'path': '1/2/3/4/5/b.txt',
   'status': 'R'
   },
diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -63,13 +63,20 @@
   $ hg status -Tjson
   [
{
+"itemtype": "file",
 "path": "a",
 "status": "M",
 "unresolved": true
},
{
+"itemtype": "file",
 "path": "a.orig",
 "status": "?"
+   },
+   {
+"itemtype": "morestatus",
+"unfinished": "merge",
+"unfinishedmsg": "To continue:hg commit\nTo abort:   hg merge 
--abort"
}
   ]
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6884,7 +6884,7 @@
 for f in files:
 fm.startitem()
 fm.context(ctx=ctx2)
-fm.data(path=f)
+fm.data(itemtype=b'file', path=f)
 fm.condwrite(showchar, b'status', b'%s ', char, label=label)
 fm.plain(fmt % uipathfn(f), label=label)
 if f in copy:
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -793,6 +793,13 @@
 fm.data(unresolved=True)
 
 def formatfooter(self, fm):
+fm.startitem()
+fm.data(
+itemtype=b'morestatus',
+unfinished=self.unfinishedop,
+unfinishedmsg=self.unfinishedmsg,
+)
+
 statemsg = (
 _(b'The repository is in an unfinished *%s* state.')
 % self.unfinishedop



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


D7595: status: outputting structured unfinished-operation information

2019-12-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18638.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7595?vs=18625=18638

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-conflict.t
  tests/test-status.t

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -254,35 +254,43 @@
   $ hg status -A -Tjson
   [
{
+"itemtype": "file",
 "path": "added",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "copied",
 "source": "modified",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "removed",
 "status": "R"
},
{
+"itemtype": "file",
 "path": "deleted",
 "status": "!"
},
{
+"itemtype": "file",
 "path": "unknown",
 "status": "?"
},
{
+"itemtype": "file",
 "path": "ignored",
 "status": "I"
},
{
+"itemtype": "file",
 "path": ".hgignore",
 "status": "C"
},
{
+"itemtype": "file",
 "path": "modified",
 "status": "C"
}
@@ -558,6 +566,7 @@
   $ hg status --config ui.formatdebug=True --rev 1 1
   status = [
   {
+  'itemtype': 'file',
   'path': '1/2/3/4/5/b.txt',
   'status': 'R'
   },
diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -63,13 +63,20 @@
   $ hg status -Tjson
   [
{
+"itemtype": "file",
 "path": "a",
 "status": "M",
 "unresolved": true
},
{
+"itemtype": "file",
 "path": "a.orig",
 "status": "?"
+   },
+   {
+"itemtype": "morestatus",
+"unfinished": "merge",
+"unfinishedmsg": "To continue:hg commit\nTo abort:   hg merge 
--abort"
}
   ]
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6884,7 +6884,7 @@
 for f in files:
 fm.startitem()
 fm.context(ctx=ctx2)
-fm.data(path=f)
+fm.data(itemtype=b'file', path=f)
 fm.condwrite(showchar, b'status', b'%s ', char, label=label)
 fm.plain(fmt % uipathfn(f), label=label)
 if f in copy:
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -793,6 +793,10 @@
 fm.data(unresolved=True)
 
 def formatfooter(self, fm):
+fm.startitem()
+fm.data(itemtype=b'morestatus', unfinished=self.unfinishedop,
+unfinishedmsg=self.unfinishedmsg)
+
 statemsg = (
 _(b'The repository is in an unfinished *%s* state.')
 % self.unfinishedop



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


D7595: status: outputting structured unfinished-operation information

2019-12-11 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio edited the summary of this revision.
rdamazio marked an inline comment as done.
rdamazio updated this revision to Diff 18625.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7595?vs=18588=18625

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-conflict.t
  tests/test-status.t

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -254,35 +254,43 @@
   $ hg status -A -Tjson
   [
{
+"itemtype": "file",
 "path": "added",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "copied",
 "source": "modified",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "removed",
 "status": "R"
},
{
+"itemtype": "file",
 "path": "deleted",
 "status": "!"
},
{
+"itemtype": "file",
 "path": "unknown",
 "status": "?"
},
{
+"itemtype": "file",
 "path": "ignored",
 "status": "I"
},
{
+"itemtype": "file",
 "path": ".hgignore",
 "status": "C"
},
{
+"itemtype": "file",
 "path": "modified",
 "status": "C"
}
@@ -558,6 +566,7 @@
   $ hg status --config ui.formatdebug=True --rev 1 1
   status = [
   {
+  'itemtype': 'file',
   'path': '1/2/3/4/5/b.txt',
   'status': 'R'
   },
diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -63,13 +63,20 @@
   $ hg status -Tjson
   [
{
+"itemtype": "file",
 "path": "a",
 "status": "M",
 "unresolved": true
},
{
+"itemtype": "file",
 "path": "a.orig",
 "status": "?"
+   },
+   {
+"itemtype": "morestatus",
+"unfinished": "merge",
+"unfinishedmsg": "To continue:hg commit\nTo abort:   hg merge 
--abort"
}
   ]
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6884,7 +6884,7 @@
 for f in files:
 fm.startitem()
 fm.context(ctx=ctx2)
-fm.data(path=f)
+fm.data(itemtype=b'file', path=f)
 fm.condwrite(showchar, b'status', b'%s ', char, label=label)
 fm.plain(fmt % uipathfn(f), label=label)
 if f in copy:
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -793,6 +793,10 @@
 fm.data(unresolved=True)
 
 def formatfooter(self, fm):
+fm.startitem()
+fm.data(itemtype=b'morestatus', unfinished=self.unfinishedop,
+unfinishedmsg=self.unfinishedmsg)
+
 statemsg = _(b'The repository is in an unfinished *%s* state.'
  ) % self.unfinishedop
 fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)



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


D7594: status: add template/json data about whether a file has unresolved conflicts

2019-12-11 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added inline comments.

INLINE COMMENTS

> martinvonz wrote in cmdutil.py:792
> That's an O(n) lookup. Probably fine since you very rarely have thousands of 
> conflicts...

Yes, I thought of storing it as a set, but then thought that it either didn't 
matter or would be slower because there are so few items.

REPOSITORY
  rHG Mercurial

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

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

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


D7593: status: split morestatus data loading from display

2019-12-11 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHGfb4a6d584756: status: split morestatus data loading from 
display (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7593?vs=18586=18605

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6867,6 +6867,12 @@
 ) and not opts.get(b'no_status'):
 copy = copies.pathcopies(ctx1, ctx2, m)
 
+morestatus = None
+if (
+ui.verbose or ui.configbool(b'commands', b'status.verbose')
+) and not ui.plain():
+morestatus = cmdutil.readmorestatus(repo)
+
 ui.pager(b'status')
 fm = ui.formatter(b'status', opts)
 fmt = b'%s' + end
@@ -6888,10 +6894,8 @@
 label=b'status.copied',
 )
 
-if (
-ui.verbose or ui.configbool(b'commands', b'status.verbose')
-) and not ui.plain():
-cmdutil.morestatus(repo, fm)
+if morestatus:
+morestatus.formatfooter(fm)
 fm.end()
 
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -24,6 +24,7 @@
 open,
 setattr,
 )
+from .thirdparty import attr
 
 from . import (
 bookmarks,
@@ -778,47 +779,66 @@
 return b'\n'.join(commentedlines) + b'\n'
 
 
-def _conflictsmsg(repo):
-mergestate = mergemod.mergestate.read(repo)
-if not mergestate.active():
-return
-
-unresolvedlist = sorted(mergestate.unresolved())
-if unresolvedlist:
-mergeliststr = b'\n'.join(
-[
-b'%s' % util.pathto(repo.root, encoding.getcwd(), path)
-for path in unresolvedlist
-]
-)
-msg = (
-_(
-'''Unresolved merge conflicts:
+@attr.s(frozen=True)
+class morestatus(object):
+reporoot = attr.ib()
+unfinishedop = attr.ib()
+unfinishedmsg = attr.ib()
+inmergestate = attr.ib()
+unresolvedpaths = attr.ib()
+_label = b'status.morestatus'
+
+def formatfooter(self, fm):
+statemsg = _(b'The repository is in an unfinished *%s* state.'
+ ) % self.unfinishedop
+fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+
+self._formatconflicts(fm)
+if self.unfinishedmsg:
+fm.plain(b'%s\n' % _commentlines(self.unfinishedmsg),
+ label=self._label)
+
+def _formatconflicts(self, fm):
+if not self.inmergestate:
+return
+
+if self.unresolvedpaths:
+mergeliststr = b'\n'.join(
+[
+b'%s' % util.pathto(self.reporoot, encoding.getcwd(),
+path)
+for path in self.unresolvedpaths
+]
+)
+msg = (
+_(
+'''Unresolved merge conflicts:
 
 %s
 
 To mark files as resolved:  hg resolve --mark FILE'''
+)
+% mergeliststr
 )
-% mergeliststr
-)
-else:
-msg = _(b'No unresolved merge conflicts.')
-
-return _commentlines(msg)
-
-
-def morestatus(repo, fm):
+else:
+msg = _(b'No unresolved merge conflicts.')
+
+fm.plain(b'%s\n' % _commentlines(msg), label=self._label)
+
+
+def readmorestatus(repo):
+"""Returns a morestatus object if the repo has unfinished state."""
 statetuple = statemod.getrepostate(repo)
-label = b'status.morestatus'
-if statetuple:
-state, helpfulmsg = statetuple
-statemsg = _(b'The repository is in an unfinished *%s* state.') % state
-fm.plain(b'%s\n' % _commentlines(statemsg), label=label)
-conmsg = _conflictsmsg(repo)
-if conmsg:
-fm.plain(b'%s\n' % conmsg, label=label)
-if helpfulmsg:
-fm.plain(b'%s\n' % _commentlines(helpfulmsg), label=label)
+if not statetuple:
+return None
+
+unfinishedop, unfinishedmsg = statetuple
+mergestate = mergemod.mergestate.read(repo)
+unresolved = None
+if mergestate.active():
+unresolved = sorted(mergestate.unresolved())
+return morestatus(repo.root, unfinishedop, unfinishedmsg,
+  unresolved is not None, unresolved)
 
 
 def findpossible(cmd, table, strict=False):



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


D7594: status: add template/json data about whether a file has unresolved conflicts

2019-12-11 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHG7315464f0613: status: add template/json data about whether 
a file has unresolved conflicts (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7594?vs=18587=18606

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-conflict.t

CHANGE DETAILS

diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -64,7 +64,8 @@
   [
{
 "path": "a",
-"status": "M"
+"status": "M",
+"unresolved": true
},
{
 "path": "a.orig",
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6893,6 +6893,8 @@
 (b'  %s' + end) % uipathfn(copy[f]),
 label=b'status.copied',
 )
+if morestatus:
+morestatus.formatfile(f, fm)
 
 if morestatus:
 morestatus.formatfooter(fm)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -788,6 +788,10 @@
 unresolvedpaths = attr.ib()
 _label = b'status.morestatus'
 
+def formatfile(self, path, fm):
+if self.inmergestate and path in self.unresolvedpaths:
+fm.data(unresolved=True)
+
 def formatfooter(self, fm):
 statemsg = _(b'The repository is in an unfinished *%s* state.'
  ) % self.unfinishedop



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


D7595: status: outputting structured unfinished-operation information

2019-12-10 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18588.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7595?vs=18562=18588

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/configitems.py
  tests/test-conflict.t
  tests/test-status.t

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -254,35 +254,43 @@
   $ hg status -A -Tjson
   [
{
+"itemtype": "file",
 "path": "added",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "copied",
 "source": "modified",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "removed",
 "status": "R"
},
{
+"itemtype": "file",
 "path": "deleted",
 "status": "!"
},
{
+"itemtype": "file",
 "path": "unknown",
 "status": "?"
},
{
+"itemtype": "file",
 "path": "ignored",
 "status": "I"
},
{
+"itemtype": "file",
 "path": ".hgignore",
 "status": "C"
},
{
+"itemtype": "file",
 "path": "modified",
 "status": "C"
}
@@ -558,6 +566,7 @@
   $ hg status --config ui.formatdebug=True --rev 1 1
   status = [
   {
+  'itemtype': 'file',
   'path': '1/2/3/4/5/b.txt',
   'status': 'R'
   },
diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -63,16 +63,38 @@
   $ hg status -Tjson
   [
{
+"itemtype": "file",
 "path": "a",
 "status": "M",
 "unresolved": true
},
{
+"itemtype": "file",
 "path": "a.orig",
 "status": "?"
}
   ]
 
+  $ hg status -Tjson --config commands.status.morestatus-item=1
+  [
+   {
+"itemtype": "file",
+"path": "a",
+"status": "M",
+"unresolved": true
+   },
+   {
+"itemtype": "file",
+"path": "a.orig",
+"status": "?"
+   },
+   {
+"itemtype": "morestatus",
+"unfinished": "merge",
+"unfinishedmsg": "To continue:hg commit\nTo abort:   hg merge 
--abort"
+   }
+  ]
+
   $ cat a
   Small Mathematical Series.
   1
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -244,6 +244,9 @@
 b'commands', b'show.aliasprefix', default=list,
 )
 coreconfigitem(
+b'commands', b'status.morestatus-item', default=False,
+)
+coreconfigitem(
 b'commands', b'status.relative', default=False,
 )
 coreconfigitem(
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6884,7 +6884,7 @@
 for f in files:
 fm.startitem()
 fm.context(ctx=ctx2)
-fm.data(path=f)
+fm.data(itemtype=b'file', path=f)
 fm.condwrite(showchar, b'status', b'%s ', char, label=label)
 fm.plain(fmt % uipathfn(f), label=label)
 if f in copy:
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -786,6 +786,7 @@
 unfinishedmsg = attr.ib()
 inmergestate = attr.ib()
 unresolvedpaths = attr.ib()
+adddataitem = attr.ib()
 _label = b'status.morestatus'
 
 def formatfile(self, path, fm):
@@ -797,6 +798,11 @@
  ) % self.unfinishedop
 fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
 
+if self.adddataitem:
+fm.startitem()
+fm.data(itemtype=b'morestatus', unfinished=self.unfinishedop,
+unfinishedmsg=self.unfinishedmsg)
+
 self._formatconflicts(fm)
 if self.unfinishedmsg:
 fm.plain(b'%s\n' % _commentlines(self.unfinishedmsg),
@@ -841,8 +847,9 @@
 unresolved = None
 if mergestate.active():
 unresolved = sorted(mergestate.unresolved())
+dataitem = repo.ui.config(b'commands', b'status.morestatus-item')
 return morestatus(repo.root, unfinishedop, unfinishedmsg,
-  unresolved is not None, unresolved)
+  unresolved is not None, unresolved, dataitem)
 
 
 def findpossible(cmd, table, strict=False):



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


D7593: status: split morestatus data loading from display

2019-12-10 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18586.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7593?vs=18560=18586

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6867,6 +6867,12 @@
 ) and not opts.get(b'no_status'):
 copy = copies.pathcopies(ctx1, ctx2, m)
 
+morestatus = None
+if (
+ui.verbose or ui.configbool(b'commands', b'status.verbose')
+) and not ui.plain():
+morestatus = cmdutil.readmorestatus(repo)
+
 ui.pager(b'status')
 fm = ui.formatter(b'status', opts)
 fmt = b'%s' + end
@@ -6888,10 +6894,8 @@
 label=b'status.copied',
 )
 
-if (
-ui.verbose or ui.configbool(b'commands', b'status.verbose')
-) and not ui.plain():
-cmdutil.morestatus(repo, fm)
+if morestatus:
+morestatus.formatfooter(fm)
 fm.end()
 
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -24,6 +24,7 @@
 open,
 setattr,
 )
+from .thirdparty import attr
 
 from . import (
 bookmarks,
@@ -778,47 +779,66 @@
 return b'\n'.join(commentedlines) + b'\n'
 
 
-def _conflictsmsg(repo):
-mergestate = mergemod.mergestate.read(repo)
-if not mergestate.active():
-return
-
-unresolvedlist = sorted(mergestate.unresolved())
-if unresolvedlist:
-mergeliststr = b'\n'.join(
-[
-b'%s' % util.pathto(repo.root, encoding.getcwd(), path)
-for path in unresolvedlist
-]
-)
-msg = (
-_(
-'''Unresolved merge conflicts:
+@attr.s(frozen=True)
+class morestatus(object):
+reporoot = attr.ib()
+unfinishedop = attr.ib()
+unfinishedmsg = attr.ib()
+inmergestate = attr.ib()
+unresolvedpaths = attr.ib()
+_label = b'status.morestatus'
+
+def formatfooter(self, fm):
+statemsg = _(b'The repository is in an unfinished *%s* state.'
+ ) % self.unfinishedop
+fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+
+self._formatconflicts(fm)
+if self.unfinishedmsg:
+fm.plain(b'%s\n' % _commentlines(self.unfinishedmsg),
+ label=self._label)
+
+def _formatconflicts(self, fm):
+if not self.inmergestate:
+return
+
+if self.unresolvedpaths:
+mergeliststr = b'\n'.join(
+[
+b'%s' % util.pathto(self.reporoot, encoding.getcwd(),
+path)
+for path in self.unresolvedpaths
+]
+)
+msg = (
+_(
+'''Unresolved merge conflicts:
 
 %s
 
 To mark files as resolved:  hg resolve --mark FILE'''
+)
+% mergeliststr
 )
-% mergeliststr
-)
-else:
-msg = _(b'No unresolved merge conflicts.')
-
-return _commentlines(msg)
-
-
-def morestatus(repo, fm):
+else:
+msg = _(b'No unresolved merge conflicts.')
+
+fm.plain(b'%s\n' % _commentlines(msg), label=self._label)
+
+
+def readmorestatus(repo):
+"""Returns a morestatus object if the repo has unfinished state."""
 statetuple = statemod.getrepostate(repo)
-label = b'status.morestatus'
-if statetuple:
-state, helpfulmsg = statetuple
-statemsg = _(b'The repository is in an unfinished *%s* state.') % state
-fm.plain(b'%s\n' % _commentlines(statemsg), label=label)
-conmsg = _conflictsmsg(repo)
-if conmsg:
-fm.plain(b'%s\n' % conmsg, label=label)
-if helpfulmsg:
-fm.plain(b'%s\n' % _commentlines(helpfulmsg), label=label)
+if not statetuple:
+return None
+
+unfinishedop, unfinishedmsg = statetuple
+mergestate = mergemod.mergestate.read(repo)
+unresolved = None
+if mergestate.active():
+unresolved = sorted(mergestate.unresolved())
+return morestatus(repo.root, unfinishedop, unfinishedmsg,
+  unresolved is not None, unresolved)
 
 
 def findpossible(cmd, table, strict=False):



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


D7594: status: add template/json data about whether a file has unresolved conflicts

2019-12-10 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18587.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7594?vs=18561=18587

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-conflict.t

CHANGE DETAILS

diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -64,7 +64,8 @@
   [
{
 "path": "a",
-"status": "M"
+"status": "M",
+"unresolved": true
},
{
 "path": "a.orig",
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6893,6 +6893,8 @@
 (b'  %s' + end) % uipathfn(copy[f]),
 label=b'status.copied',
 )
+if morestatus:
+morestatus.formatfile(f, fm)
 
 if morestatus:
 morestatus.formatfooter(fm)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -788,6 +788,10 @@
 unresolvedpaths = attr.ib()
 _label = b'status.morestatus'
 
+def formatfile(self, path, fm):
+if self.inmergestate and path in self.unresolvedpaths:
+fm.data(unresolved=True)
+
 def formatfooter(self, fm):
 statemsg = _(b'The repository is in an unfinished *%s* state.'
  ) % self.unfinishedop



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


D7593: status: split morestatus data loading from display

2019-12-10 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  Just phabsended after a rebase onto hg-committed, let me know if that's not 
what you expected.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

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


D7593: status: split morestatus data loading from display

2019-12-10 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In D7593#111696 , @pulkit wrote:
  
  > I pushed @martinvonz D7591 , so these 
need to be rebased. Thanks!
  
  Are you asking me to do something, or are you going to?
  This supersedes his change completely.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

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


D7595: status: outputting structured unfinished-operation information

2019-12-10 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added inline comments.

INLINE COMMENTS

> pulkit wrote in configitems.py:247
> IMO the whole morestatus functionality is already behind a config option, so 
> lets not have a config option just for that.
> 
> But I am not sure whether this change is a BC or not. I believe @yuja might 
> have thoughts here.

I'm fine with removing the config option, but will let yuja reply first.
About being BC or not - it depends on how people are parsing the JSON output :) 
If they're either turning off morestatus for -Tjson calls, or they're ok with 
an entry with no path, then it should work, but I won't be surprised if it 
breaks some callers.

REPOSITORY
  rHG Mercurial

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

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

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


D7595: status: outputting structured unfinished-operation information

2019-12-09 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This adds a new item in the json/template output for morestatus. For backwards
  compatibility, I put this behind a config option (but I'd be happy to remove
  that if nobody thinks it's a concern), and added item types to all entries.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/configitems.py
  tests/test-conflict.t
  tests/test-status.t

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -254,35 +254,43 @@
   $ hg status -A -Tjson
   [
{
+"itemtype": "file",
 "path": "added",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "copied",
 "source": "modified",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "removed",
 "status": "R"
},
{
+"itemtype": "file",
 "path": "deleted",
 "status": "!"
},
{
+"itemtype": "file",
 "path": "unknown",
 "status": "?"
},
{
+"itemtype": "file",
 "path": "ignored",
 "status": "I"
},
{
+"itemtype": "file",
 "path": ".hgignore",
 "status": "C"
},
{
+"itemtype": "file",
 "path": "modified",
 "status": "C"
}
@@ -558,6 +566,7 @@
   $ hg status --config ui.formatdebug=True --rev 1 1
   status = [
   {
+  'itemtype': 'file',
   'path': '1/2/3/4/5/b.txt',
   'status': 'R'
   },
diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -63,16 +63,38 @@
   $ hg status -Tjson
   [
{
+"itemtype": "file",
 "path": "a",
 "status": "M",
 "unresolved": true
},
{
+"itemtype": "file",
 "path": "a.orig",
 "status": "?"
}
   ]
 
+  $ hg status -Tjson --config commands.status.morestatus-item=1
+  [
+   {
+"itemtype": "file",
+"path": "a",
+"status": "M",
+"unresolved": true
+   },
+   {
+"itemtype": "file",
+"path": "a.orig",
+"status": "?"
+   },
+   {
+"itemtype": "morestatus",
+"unfinished": "merge",
+"unfinishedmsg": "To continue:hg commit\nTo abort:   hg merge 
--abort"
+   }
+  ]
+
   $ cat a
   Small Mathematical Series.
   1
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -244,6 +244,9 @@
 b'commands', b'show.aliasprefix', default=list,
 )
 coreconfigitem(
+b'commands', b'status.morestatus-item', default=False,
+)
+coreconfigitem(
 b'commands', b'status.relative', default=False,
 )
 coreconfigitem(
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6884,7 +6884,7 @@
 for f in files:
 fm.startitem()
 fm.context(ctx=ctx2)
-fm.data(path=f)
+fm.data(itemtype=b'file', path=f)
 fm.condwrite(showchar, b'status', b'%s ', char, label=label)
 fm.plain(fmt % uipathfn(f), label=label)
 if f in copy:
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -786,6 +786,7 @@
 unfinishedmsg = attr.ib()
 inmergestate = attr.ib()
 unresolvedpaths = attr.ib()
+adddataitem = attr.ib()
 _label = b'status.morestatus'
 
 def formatfile(self, path, fm):
@@ -797,6 +798,11 @@
  ) % self.unfinishedop
 fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
 
+if self.adddataitem:
+fm.startitem()
+fm.data(itemtype=b'morestatus', unfinished=self.unfinishedop,
+unfinishedmsg=self.unfinishedmsg)
+
 self._formatconflicts(fm)
 if self.unfinishedmsg:
 fm.plain(b'%s\n' % _commentlines(self.unfinishedmsg),
@@ -841,8 +847,9 @@
 unresolved = None
 if mergestate.active():
 unresolved = sorted(mergestate.unresolved())
+dataitem = repo.ui.config(b'commands', b'status.morestatus-item')
 return morestatus(repo.root, unfinishedop, unfinishedmsg,
-  unresolved is not None, unresolved)
+  unresolved is not None, unresolved, dataitem)
 
 
 def findpossible(cmd, table, strict=False):



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


D7594: status: add template/json data about whether a file has unresolved conflicts

2019-12-09 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-conflict.t

CHANGE DETAILS

diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -64,7 +64,8 @@
   [
{
 "path": "a",
-"status": "M"
+"status": "M",
+"unresolved": true
},
{
 "path": "a.orig",
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6893,6 +6893,8 @@
 (b'  %s' + end) % uipathfn(copy[f]),
 label=b'status.copied',
 )
+if morestatus:
+morestatus.formatfile(f, fm)
 
 if morestatus:
 morestatus.formatfooter(fm)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -788,6 +788,10 @@
 unresolvedpaths = attr.ib()
 _label = b'status.morestatus'
 
+def formatfile(self, path, fm):
+if self.inmergestate and path in self.unresolvedpaths:
+fm.data(unresolved=True)
+
 def formatfooter(self, fm):
 statemsg = _(b'The repository is in an unfinished *%s* state.'
  ) % self.unfinishedop



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


D7593: status: split morestatus data loading from display

2019-12-09 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is a small refactoring in preparation for adding more morestatus
  functionality (notably for templated/JSON output) - the goal is to
  use the data inside the status display loop, as well as output the
  overall state in a templatable/structured way.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6867,6 +6867,12 @@
 ) and not opts.get(b'no_status'):
 copy = copies.pathcopies(ctx1, ctx2, m)
 
+morestatus = None
+if (
+ui.verbose or ui.configbool(b'commands', b'status.verbose')
+) and not ui.plain():
+morestatus = cmdutil.readmorestatus(repo)
+
 ui.pager(b'status')
 fm = ui.formatter(b'status', opts)
 fmt = b'%s' + end
@@ -6888,10 +6894,8 @@
 label=b'status.copied',
 )
 
-if (
-ui.verbose or ui.configbool(b'commands', b'status.verbose')
-) and not ui.plain():
-cmdutil.morestatus(repo, fm)
+if morestatus:
+morestatus.formatfooter(fm)
 fm.end()
 
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -24,6 +24,7 @@
 open,
 setattr,
 )
+from .thirdparty import attr
 
 from . import (
 bookmarks,
@@ -778,48 +779,66 @@
 return b'\n'.join(commentedlines) + b'\n'
 
 
-def _conflictsmsg(repo):
-mergestate = mergemod.mergestate.read(repo)
-if not mergestate.active():
-return
-
-m = scmutil.match(repo[None])
-unresolvedlist = [f for f in mergestate.unresolved() if m(f)]
-if unresolvedlist:
-mergeliststr = b'\n'.join(
-[
-b'%s' % util.pathto(repo.root, encoding.getcwd(), path)
-for path in sorted(unresolvedlist)
-]
-)
-msg = (
-_(
-'''Unresolved merge conflicts:
+@attr.s(frozen=True)
+class morestatus(object):
+reporoot = attr.ib()
+unfinishedop = attr.ib()
+unfinishedmsg = attr.ib()
+inmergestate = attr.ib()
+unresolvedpaths = attr.ib()
+_label = b'status.morestatus'
+
+def formatfooter(self, fm):
+statemsg = _(b'The repository is in an unfinished *%s* state.'
+ ) % self.unfinishedop
+fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+
+self._formatconflicts(fm)
+if self.unfinishedmsg:
+fm.plain(b'%s\n' % _commentlines(self.unfinishedmsg),
+ label=self._label)
+
+def _formatconflicts(self, fm):
+if not self.inmergestate:
+return
+
+if self.unresolvedpaths:
+mergeliststr = b'\n'.join(
+[
+b'%s' % util.pathto(self.reporoot, encoding.getcwd(),
+path)
+for path in self.unresolvedpaths
+]
+)
+msg = (
+_(
+'''Unresolved merge conflicts:
 
 %s
 
 To mark files as resolved:  hg resolve --mark FILE'''
+)
+% mergeliststr
 )
-% mergeliststr
-)
-else:
-msg = _(b'No unresolved merge conflicts.')
-
-return _commentlines(msg)
-
-
-def morestatus(repo, fm):
+else:
+msg = _(b'No unresolved merge conflicts.')
+
+fm.plain(b'%s\n' % _commentlines(msg), label=self._label)
+
+
+def readmorestatus(repo):
+"""Returns a morestatus object if the repo has unfinished state."""
 statetuple = statemod.getrepostate(repo)
-label = b'status.morestatus'
-if statetuple:
-state, helpfulmsg = statetuple
-statemsg = _(b'The repository is in an unfinished *%s* state.') % state
-fm.plain(b'%s\n' % _commentlines(statemsg), label=label)
-conmsg = _conflictsmsg(repo)
-if conmsg:
-fm.plain(b'%s\n' % conmsg, label=label)
-if helpfulmsg:
-fm.plain(b'%s\n' % _commentlines(helpfulmsg), label=label)
+if not statetuple:
+return None
+
+unfinishedop, unfinishedmsg = statetuple
+mergestate = mergemod.mergestate.read(repo)
+unresolved = None
+if mergestate.active():
+unresolved = sorted(mergestate.unresolved())
+return morestatus(repo.root, unfinishedop, unfinishedmsg,
+  unresolved is not None, unresolved)
 
 
 def findpossible(cmd, table, strict=False):



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D7591: status: remove pointless filtering by alwaysmatcher in morestatus

2019-12-09 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In D7591#111570 , @martinvonz 
wrote:
  
  > In D7591#111569 , @rdamazio 
wrote:
  >
  >> FYI I'm going to send a chain that rewrites a lot of this
  >
  > To be clear, are you telling reviewers not to queue this one because you 
will be rewriting the *patch* or you're saying that you will later be sending 
patches on top of this one?
  
  I'm writing a larger change which includes this change, I don't mind merging 
the conflict if you want to go ahead and queue this.

REPOSITORY
  rHG Mercurial

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

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

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


D7591: status: remove pointless filtering by alwaysmatcher in morestatus

2019-12-09 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  FYI I'm going to send a chain that rewrites a lot of this

REPOSITORY
  rHG Mercurial

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

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

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


D6998: help: adding a help category to narrow and remotefilelog commands

2019-10-11 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHG5ff32fdf0b0b: help: adding a help category to narrow and 
remotefilelog commands (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6998?vs=17087=17088

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

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

AFFECTED FILES
  hgext/narrow/narrowcommands.py
  hgext/remotefilelog/__init__.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -1234,6 +1234,7 @@
 ]
 + commands.walkopts,
 _(b'hg prefetch [OPTIONS] [FILE...]'),
+helpcategory=command.CATEGORY_MAINTENANCE,
 )
 def prefetch(ui, repo, *pats, **opts):
 """prefetch file revisions from the server
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -445,6 +445,7 @@
 + commands.remoteopts,
 _(b'[OPTIONS]... [REMOTE]'),
 inferrepo=True,
+helpcategory=command.CATEGORY_MAINTENANCE,
 )
 def trackedcmd(ui, repo, remotepath=None, *pats, **opts):
 """show or change the current narrowspec



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


D6998: help: adding a help category to narrow and remotefilelog commands

2019-10-11 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 17087.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6998?vs=16897=17087

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

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

AFFECTED FILES
  hgext/narrow/narrowcommands.py
  hgext/remotefilelog/__init__.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -1234,6 +1234,7 @@
 ]
 + commands.walkopts,
 _(b'hg prefetch [OPTIONS] [FILE...]'),
+helpcategory=command.CATEGORY_MAINTENANCE,
 )
 def prefetch(ui, repo, *pats, **opts):
 """prefetch file revisions from the server
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -445,6 +445,7 @@
 + commands.remoteopts,
 _(b'[OPTIONS]... [REMOTE]'),
 inferrepo=True,
+helpcategory=command.CATEGORY_MAINTENANCE,
 )
 def trackedcmd(ui, repo, remotepath=None, *pats, **opts):
 """show or change the current narrowspec



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


D6999: help: categorizing evolve and topic commands

2019-10-09 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.
rdamazio abandoned this revision.


  This will be reviewed via heptapod instead

REPOSITORY
  rHG Mercurial

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

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

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


D6999: help: categorizing evolve and topic commands

2019-10-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This makes them show up under the right categories in 'hg help'.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext3rd/evolve/__init__.py
  hgext3rd/evolve/cmdrewrite.py
  hgext3rd/evolve/evolvecmd.py
  hgext3rd/evolve/obshistory.py
  hgext3rd/evolve/rewind.py
  hgext3rd/topic/__init__.py

CHANGE DETAILS

diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -634,7 +634,8 @@
 (b'', b'age', False, b'show when you last touched the topics'),
 (b'', b'current', None, b'display the current topic only'),
 ] + commands.formatteropts,
-_(b'hg topics [TOPIC]'))
+_(b'hg topics [TOPIC]'),
+helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
 def topics(ui, repo, topic=None, **opts):
 """View current topic, set current topic, change topic for a set of 
revisions, or see all topics.
 
@@ -777,7 +778,8 @@
 (b'c', b'children', None,
 _(b'display data about children outside of the stack'))
 ] + commands.formatteropts,
-_(b'hg stack [TOPIC]'))
+_(b'hg stack [TOPIC]'),
+helpcategory=command.CATEGORY_CHANGE_ORGANIZATION)
 def cmdstack(ui, repo, topic=b'', **opts):
 """list all changesets in a topic and other information
 
diff --git a/hgext3rd/evolve/rewind.py b/hgext3rd/evolve/rewind.py
--- a/hgext3rd/evolve/rewind.py
+++ b/hgext3rd/evolve/rewind.py
@@ -9,6 +9,7 @@
 hg,
 obsolete,
 obsutil,
+registrar,
 scmutil,
 )
 
@@ -36,7 +37,8 @@
   _(b"do not modify working directory during rewind")),
  ],
 _(b'[--as-divergence] [--exact] [--keep] [--to REV]... [--from REV]...'),
-helpbasic=True)
+helpbasic=True,
+helpcategory=registrar.command.CATEGORY_CHANGE_MANAGEMENT)
 def rewind(ui, repo, **opts):
 """rewind a stack of changesets to a previous state
 
diff --git a/hgext3rd/evolve/obshistory.py b/hgext3rd/evolve/obshistory.py
--- a/hgext3rd/evolve/obshistory.py
+++ b/hgext3rd/evolve/obshistory.py
@@ -17,6 +17,7 @@
 obsutil,
 node as nodemod,
 pycompat,
+registrar,
 scmutil,
 util,
 )
@@ -50,7 +51,8 @@
  (b'p', b'patch', False, _(b'show the patch between two obs versions')),
  (b'f', b'filternonlocal', False, _(b'filter out non local commits')),
  ] + commands.formatteropts,
-_(b'hg olog [OPTION]... [REV]'))
+_(b'hg olog [OPTION]... [REV]'),
+helpcategory=registrar.command.CATEGORY_CHANGE_NAVIGATION)
 def cmdobshistory(ui, repo, *revs, **opts):
 """show the obsolescence history of the specified revisions
 
diff --git a/hgext3rd/evolve/evolvecmd.py b/hgext3rd/evolve/evolvecmd.py
--- a/hgext3rd/evolve/evolvecmd.py
+++ b/hgext3rd/evolve/evolvecmd.py
@@ -27,6 +27,7 @@
 obsutil,
 phases,
 pycompat,
+registrar,
 repair,
 scmutil,
 simplemerge,
@@ -1505,7 +1506,8 @@
   b' in the repo')),
  ] + mergetoolopts,
 _(b'[OPTIONS]...'),
-helpbasic=True
+helpbasic=True,
+helpcategory=registrar.command.CATEGORY_CHANGE_MANAGEMENT
 )
 def evolve(ui, repo, **opts):
 """solve troubled changesets in your repository
diff --git a/hgext3rd/evolve/cmdrewrite.py b/hgext3rd/evolve/cmdrewrite.py
--- a/hgext3rd/evolve/cmdrewrite.py
+++ b/hgext3rd/evolve/cmdrewrite.py
@@ -30,6 +30,7 @@
 patch,
 phases,
 pycompat,
+registrar,
 scmutil,
 util,
 )
@@ -109,7 +110,8 @@
  (b'n', b'note', b'', _(b'store a note on amend'), _(b'TEXT')),
  ] + walkopts + commitopts + commitopts2 + commitopts3 + interactiveopt,
 _(b'[OPTION]... [FILE]...'),
-helpbasic=True)
+helpbasic=True,
+helpcategory=registrar.command.CATEGORY_COMMITTING)
 def amend(ui, repo, *pats, **opts):
 """combine a changeset with updates and replace it with a new one
 
@@ -454,7 +456,8 @@
  (b'', b'revert', False, _(b'discard working directory changes after 
uncommit')),
  (b'n', b'note', b'', _(b'store a note on uncommit'), _(b'TEXT')),
  ] + commands.walkopts + commitopts + commitopts2 + commitopts3,
-_(b'[OPTION]... [NAME]'))
+_(b'[OPTION]... [NAME]'),
+helpcategory=registrar.command.CATEGORY_COMMITTING)
 def uncommit(ui, repo, *pats, **opts):
 """move changes from parent revision to working directory
 
@@ -690,7 +693,8 @@
  (b'n', b'note', b'', _(b'store a note on fold'), _(b'TEXT')),
  ] + commitopts + commitopts2 + commitopts3,
 _(b'hg fold [OPTION]... [-r] REV'),
-helpbasic=True)
+helpbasic=True,
+helpcategory=registrar.command.CATEGORY_CHANGE_MANAGEMENT)
 def fold(ui, repo, *revs, **opts):
 """fold multiple revisions into a single one
 
@@ -820,7 +824,8 @@
  (b'', b'fold', None, _(b"also fold specified revisions into one")),
  (b'n', b'note', b'', _(b'store a note on 

D6998: help: adding a help category to narrow and remotefilelog commands

2019-10-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio 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.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowcommands.py
  hgext/remotefilelog/__init__.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -1072,7 +1072,8 @@
 ('r', 'rev', [], _('prefetch the specified revisions'), _('REV')),
 ('', 'repack', False, _('run repack after prefetch')),
 ('b', 'base', '', _("rev that is assumed to already be local")),
-] + commands.walkopts, _('hg prefetch [OPTIONS] [FILE...]'))
+] + commands.walkopts, _('hg prefetch [OPTIONS] [FILE...]'),
+helpcategory=command.CATEGORY_MAINTENANCE)
 def prefetch(ui, repo, *pats, **opts):
 """prefetch file revisions from the server
 
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -340,7 +340,8 @@
   _('update working copy when the store has changed')),
 ] + commands.remoteopts,
 _('[OPTIONS]... [REMOTE]'),
-inferrepo=True)
+inferrepo=True,
+helpcategory=command.CATEGORY_MAINTENANCE)
 def trackedcmd(ui, repo, remotepath=None, *pats, **opts):
 """show or change the current narrowspec
 



To: rdamazio, 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


D6848: narrow: add option for automatically removing unused includes

2019-09-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added inline comments.

INLINE COMMENTS

> martinvonz wrote in test-narrow.t:457
> > This obsolete commit is completely lost afterwards, which kind of violates 
> > the principle of "all changes are kept forever" - should it dump this 
> > somewhere for safekeeping?
> 
> Yes, it does dump it to a backup bundle (see output on line 474).
> 
> > Also, what if you just don't get rid of the files, and simply remove it 
> > from the narrowspec? It'll stop processing/pulling/pushing the directory, 
> > but no data is lost.
> 
> That's just about the working directory, right? This file is unchanged in the 
> working directory at the time of `hg tracked --auto-remove-includes`...

> That's just about the working directory, right? This file is unchanged in the 
> working directory at the time of hg tracked --auto-remove-includes...

No, I meant what if you don't get rid of the .i files.
But you raise a good point - shouldn't you also clean up the working directory?

Alternatively, or in addition, maybe a confirmation prompt pointing out which 
commits and narrowspec entries will be dropped may be useful.

REPOSITORY
  rHG Mercurial

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

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

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


D6848: narrow: add option for automatically removing unused includes

2019-09-13 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added inline comments.

INLINE COMMENTS

> test-narrow.t:457
> +  $ echo a >> d0/f
> +  $ hg ci -m 'local change to d0'
> +  $ hg co '.^'

This obsolete commit is completely lost afterwards, which kind of violates the 
principle of "all changes are kept forever" - should it dump this somewhere for 
safekeeping?
Also, what if you just don't get rid of the files, and simply remove it from 
the narrowspec? It'll stop processing/pulling/pushing the directory, but no 
data is lost.

REPOSITORY
  rHG Mercurial

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

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

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


D6575: pycompat: make fewer assumptions about sys.executable

2019-06-27 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHG49998d5ba66a: pycompat: make fewer assumptions about 
sys.executable (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6575?vs=15663=15675

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

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

AFFECTED FILES
  mercurial/chgserver.py
  mercurial/debugcommands.py
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -282,7 +282,16 @@
 
 return p
 
-PYTHON = _bytespath(sys.executable.replace('\\', '/'))
+if sys.executable:
+sysexecutable = sys.executable
+elif os.environ.get('PYTHONEXECUTABLE'):
+sysexecutable = os.environ['PYTHONEXECUTABLE']
+elif os.environ.get('PYTHON'):
+sysexecutable = os.environ['PYTHON']
+else:
+raise AssertionError('Could not find Python interpreter')
+
+PYTHON = _bytespath(sysexecutable.replace('\\', '/'))
 IMPL_PATH = b'PYTHONPATH'
 if 'java' in sys.platform:
 IMPL_PATH = b'JYTHONPATH'
@@ -1094,7 +1103,7 @@
 env["HGRCPATH"] = _strpath(os.path.join(self._threadtmp, b'.hgrc'))
 env["DAEMON_PIDS"] = _strpath(os.path.join(self._threadtmp,
b'daemon.pids'))
-env["HGEDITOR"] = ('"' + sys.executable + '"'
+env["HGEDITOR"] = ('"' + sysexecutable + '"'
+ ' -c "import sys; sys.exit(0)"')
 env["HGUSER"]   = "test"
 env["HGENCODING"] = "ascii"
@@ -2349,7 +2358,7 @@
 withhg = self._runner.options.with_hg
 if withhg:
 opts += ' --with-hg=%s ' % shellquote(_strpath(withhg))
-rtc = '%s %s %s %s' % (sys.executable, sys.argv[0], opts,
+rtc = '%s %s %s %s' % (sysexecutable, sys.argv[0], opts,
test)
 data = pread(bisectcmd + ['--command', rtc])
 m = re.search(
@@ -3003,25 +3012,25 @@
 # Administrator rights.
 if getattr(os, 'symlink', None) and os.name != 'nt':
 vlog("# Making python executable in test path a symlink to '%s'" %
- sys.executable)
+ sysexecutable)
 mypython = os.path.join(self._tmpbindir, pyexename)
 try:
-if os.readlink(mypython) == sys.executable:
+if os.readlink(mypython) == sysexecutable:
 return
 os.unlink(mypython)
 except OSError as err:
 if err.errno != errno.ENOENT:
 raise
-if self._findprogram(pyexename) != sys.executable:
+if self._findprogram(pyexename) != sysexecutable:
 try:
-os.symlink(sys.executable, mypython)
+os.symlink(sysexecutable, mypython)
 self._createdfiles.append(mypython)
 except OSError as err:
 # child processes may race, which is harmless
 if err.errno != errno.EEXIST:
 raise
 else:
-exedir, exename = os.path.split(sys.executable)
+exedir, exename = os.path.split(sysexecutable)
 vlog("# Modifying search path to find %s as %s in '%s'" %
  (exename, pyexename, exedir))
 path = os.environ['PATH'].split(os.pathsep)
@@ -3048,7 +3057,7 @@
 
 # Run installer in hg root
 script = os.path.realpath(sys.argv[0])
-exe = sys.executable
+exe = sysexecutable
 if PYTHON3:
 compiler = _bytespath(compiler)
 script = _bytespath(script)
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1240,7 +1240,7 @@
 
 # Python
 fm.write('pythonexe', _("checking Python executable (%s)\n"),
- pycompat.sysexecutable)
+ pycompat.sysexecutable or _("unknown"))
 fm.write('pythonver', _("checking Python version (%s)\n"),
  ("%d.%d.%d" % sys.version_info[:3]))
 fm.write('pythonlib', _("checking Python lib (%s)...\n"),
diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -138,7 +138,9 @@
 modules.append(__version__)
 except ImportError:
 pass
-files = [pycompat.sysexecutable]
+files = []
+if pycompat.sysexecutable:
+files.append(pycompat.sysexecutable)
 for m in modules:
 try:
 files.append(pycompat.fsencode(inspect.getabsfile(m)))



To: rdamazio, #hg-reviewers, pulkit
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D6577: py3: make catapult usable from the test runner in py3

2019-06-27 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHG9913fffd744b: py3: make catapult usable from the test 
runner in py3 (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6577?vs=15662=15677

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

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1474,6 +1474,12 @@
 script.append(b'alias pwd="pwd -W"\n')
 
 if hgcatapult and hgcatapult != os.devnull:
+if PYTHON3:
+hgcatapult = hgcatapult.encode('utf8')
+cataname = self.name.encode('utf8')
+else:
+cataname = self.name
+
 # Kludge: use a while loop to keep the pipe from getting
 # closed by our echo commands. The still-running file gets
 # reaped at the end of the script, which causes the while
@@ -1490,9 +1496,9 @@
 b'HGCATAPULTSESSION=%(session)s ; export HGCATAPULTSESSION\n'
 b'echo START %(session)s %(name)s >> %(catapult)s\n'
 % {
-'name': self.name,
-'session': session,
-'catapult': hgcatapult,
+b'name': cataname,
+b'session': session,
+b'catapult': hgcatapult,
 }
 )
 



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


D6576: py3: use integer division for the value passed to xrange

2019-06-27 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHGf3fa10a5877d: py3: use integer division for the value 
passed to xrange (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6576?vs=15659=15676

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

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

AFFECTED FILES
  mercurial/pure/osutil.py

CHANGE DETAILS

diff --git a/mercurial/pure/osutil.py b/mercurial/pure/osutil.py
--- a/mercurial/pure/osutil.py
+++ b/mercurial/pure/osutil.py
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-from __future__ import absolute_import
+from __future__ import absolute_import, division
 
 import ctypes
 import ctypes.util
@@ -149,7 +149,7 @@
 cmsg.cmsg_type != _SCM_RIGHTS):
 return []
 rfds = ctypes.cast(cmsg.cmsg_data, ctypes.POINTER(ctypes.c_int))
-rfdscount = ((cmsg.cmsg_len - _cmsghdr.cmsg_data.offset) /
+rfdscount = ((cmsg.cmsg_len - _cmsghdr.cmsg_data.offset) //
  ctypes.sizeof(ctypes.c_int))
 return [rfds[i] for i in pycompat.xrange(rfdscount)]
 



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


D6575: pycompat: make fewer assumptions about sys.executable

2019-06-25 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 15663.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6575?vs=15658=15663

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

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

AFFECTED FILES
  mercurial/chgserver.py
  mercurial/debugcommands.py
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -282,7 +282,16 @@
 
 return p
 
-PYTHON = _bytespath(sys.executable.replace('\\', '/'))
+if sys.executable:
+sysexecutable = sys.executable
+elif os.environ.get('PYTHONEXECUTABLE'):
+sysexecutable = os.environ['PYTHONEXECUTABLE']
+elif os.environ.get('PYTHON'):
+sysexecutable = os.environ['PYTHON']
+else:
+raise AssertionError('Could not find Python interpreter')
+
+PYTHON = _bytespath(sysexecutable.replace('\\', '/'))
 IMPL_PATH = b'PYTHONPATH'
 if 'java' in sys.platform:
 IMPL_PATH = b'JYTHONPATH'
@@ -1094,7 +1103,7 @@
 env["HGRCPATH"] = _strpath(os.path.join(self._threadtmp, b'.hgrc'))
 env["DAEMON_PIDS"] = _strpath(os.path.join(self._threadtmp,
b'daemon.pids'))
-env["HGEDITOR"] = ('"' + sys.executable + '"'
+env["HGEDITOR"] = ('"' + sysexecutable + '"'
+ ' -c "import sys; sys.exit(0)"')
 env["HGUSER"]   = "test"
 env["HGENCODING"] = "ascii"
@@ -2349,7 +2358,7 @@
 withhg = self._runner.options.with_hg
 if withhg:
 opts += ' --with-hg=%s ' % shellquote(_strpath(withhg))
-rtc = '%s %s %s %s' % (sys.executable, sys.argv[0], opts,
+rtc = '%s %s %s %s' % (sysexecutable, sys.argv[0], opts,
test)
 data = pread(bisectcmd + ['--command', rtc])
 m = re.search(
@@ -3003,25 +3012,25 @@
 # Administrator rights.
 if getattr(os, 'symlink', None) and os.name != 'nt':
 vlog("# Making python executable in test path a symlink to '%s'" %
- sys.executable)
+ sysexecutable)
 mypython = os.path.join(self._tmpbindir, pyexename)
 try:
-if os.readlink(mypython) == sys.executable:
+if os.readlink(mypython) == sysexecutable:
 return
 os.unlink(mypython)
 except OSError as err:
 if err.errno != errno.ENOENT:
 raise
-if self._findprogram(pyexename) != sys.executable:
+if self._findprogram(pyexename) != sysexecutable:
 try:
-os.symlink(sys.executable, mypython)
+os.symlink(sysexecutable, mypython)
 self._createdfiles.append(mypython)
 except OSError as err:
 # child processes may race, which is harmless
 if err.errno != errno.EEXIST:
 raise
 else:
-exedir, exename = os.path.split(sys.executable)
+exedir, exename = os.path.split(sysexecutable)
 vlog("# Modifying search path to find %s as %s in '%s'" %
  (exename, pyexename, exedir))
 path = os.environ['PATH'].split(os.pathsep)
@@ -3048,7 +3057,7 @@
 
 # Run installer in hg root
 script = os.path.realpath(sys.argv[0])
-exe = sys.executable
+exe = sysexecutable
 if PYTHON3:
 compiler = _bytespath(compiler)
 script = _bytespath(script)
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1240,7 +1240,7 @@
 
 # Python
 fm.write('pythonexe', _("checking Python executable (%s)\n"),
- pycompat.sysexecutable)
+ pycompat.sysexecutable or _("unknown"))
 fm.write('pythonver', _("checking Python version (%s)\n"),
  ("%d.%d.%d" % sys.version_info[:3]))
 fm.write('pythonlib', _("checking Python lib (%s)...\n"),
diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -138,7 +138,9 @@
 modules.append(__version__)
 except ImportError:
 pass
-files = [pycompat.sysexecutable]
+files = []
+if pycompat.sysexecutable:
+files.append(pycompat.sysexecutable)
 for m in modules:
 try:
 files.append(pycompat.fsencode(inspect.getabsfile(m)))



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


D6577: py3: make catapult usable from the test runner in py3

2019-06-25 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 15662.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6577?vs=15661=15662

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

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1474,6 +1474,12 @@
 script.append(b'alias pwd="pwd -W"\n')
 
 if hgcatapult and hgcatapult != os.devnull:
+if PYTHON3:
+hgcatapult = hgcatapult.encode('utf8')
+cataname = self.name.encode('utf8')
+else:
+cataname = self.name
+
 # Kludge: use a while loop to keep the pipe from getting
 # closed by our echo commands. The still-running file gets
 # reaped at the end of the script, which causes the while
@@ -1490,9 +1496,9 @@
 b'HGCATAPULTSESSION=%(session)s ; export HGCATAPULTSESSION\n'
 b'echo START %(session)s %(name)s >> %(catapult)s\n'
 % {
-'name': self.name,
-'session': session,
-'catapult': hgcatapult,
+b'name': cataname,
+b'session': session,
+b'catapult': hgcatapult,
 }
 )
 



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


D6577: py3: make catapult usable from the test runner in py3

2019-06-25 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 15661.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6577?vs=15660=15661

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

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

AFFECTED FILES
  mercurial/debugcommands.py
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1474,6 +1474,12 @@
 script.append(b'alias pwd="pwd -W"\n')
 
 if hgcatapult and hgcatapult != os.devnull:
+if PYTHON3:
+hgcatapult = hgcatapult.encode('utf8')
+cataname = self.name.encode('utf8')
+else:
+cataname = self.name
+
 # Kludge: use a while loop to keep the pipe from getting
 # closed by our echo commands. The still-running file gets
 # reaped at the end of the script, which causes the while
@@ -1490,9 +1496,9 @@
 b'HGCATAPULTSESSION=%(session)s ; export HGCATAPULTSESSION\n'
 b'echo START %(session)s %(name)s >> %(catapult)s\n'
 % {
-'name': self.name,
-'session': session,
-'catapult': hgcatapult,
+b'name': cataname,
+b'session': session,
+b'catapult': hgcatapult,
 }
 )
 
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1240,7 +1240,7 @@
 
 # Python
 fm.write('pythonexe', _("checking Python executable (%s)\n"),
- pycompat.sysexecutable or "unknown")
+ pycompat.sysexecutable or _("unknown"))
 fm.write('pythonver', _("checking Python version (%s)\n"),
  ("%d.%d.%d" % sys.version_info[:3]))
 fm.write('pythonlib', _("checking Python lib (%s)...\n"),



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


D6575: pycompat: make fewer assumptions about sys.executable

2019-06-25 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  There are many Python "bundlers" which create an archive to run a Python 
binary
  from, and they may not set sys.executable at all - handle that case properly,
  especially to run tests.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/chgserver.py
  mercurial/debugcommands.py
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -282,7 +282,16 @@
 
 return p
 
-PYTHON = _bytespath(sys.executable.replace('\\', '/'))
+if sys.executable:
+sysexecutable = sys.executable
+elif os.environ.get('PYTHONEXECUTABLE'):
+sysexecutable = os.environ['PYTHONEXECUTABLE']
+elif os.environ.get('PYTHON'):
+sysexecutable = os.environ['PYTHON']
+else:
+raise AssertionError('Could not find Python interpreter')
+
+PYTHON = _bytespath(sysexecutable.replace('\\', '/'))
 IMPL_PATH = b'PYTHONPATH'
 if 'java' in sys.platform:
 IMPL_PATH = b'JYTHONPATH'
@@ -1094,7 +1103,7 @@
 env["HGRCPATH"] = _strpath(os.path.join(self._threadtmp, b'.hgrc'))
 env["DAEMON_PIDS"] = _strpath(os.path.join(self._threadtmp,
b'daemon.pids'))
-env["HGEDITOR"] = ('"' + sys.executable + '"'
+env["HGEDITOR"] = ('"' + sysexecutable + '"'
+ ' -c "import sys; sys.exit(0)"')
 env["HGUSER"]   = "test"
 env["HGENCODING"] = "ascii"
@@ -2349,7 +2358,7 @@
 withhg = self._runner.options.with_hg
 if withhg:
 opts += ' --with-hg=%s ' % shellquote(_strpath(withhg))
-rtc = '%s %s %s %s' % (sys.executable, sys.argv[0], opts,
+rtc = '%s %s %s %s' % (sysexecutable, sys.argv[0], opts,
test)
 data = pread(bisectcmd + ['--command', rtc])
 m = re.search(
@@ -3003,25 +3012,25 @@
 # Administrator rights.
 if getattr(os, 'symlink', None) and os.name != 'nt':
 vlog("# Making python executable in test path a symlink to '%s'" %
- sys.executable)
+ sysexecutable)
 mypython = os.path.join(self._tmpbindir, pyexename)
 try:
-if os.readlink(mypython) == sys.executable:
+if os.readlink(mypython) == sysexecutable:
 return
 os.unlink(mypython)
 except OSError as err:
 if err.errno != errno.ENOENT:
 raise
-if self._findprogram(pyexename) != sys.executable:
+if self._findprogram(pyexename) != sysexecutable:
 try:
-os.symlink(sys.executable, mypython)
+os.symlink(sysexecutable, mypython)
 self._createdfiles.append(mypython)
 except OSError as err:
 # child processes may race, which is harmless
 if err.errno != errno.EEXIST:
 raise
 else:
-exedir, exename = os.path.split(sys.executable)
+exedir, exename = os.path.split(sysexecutable)
 vlog("# Modifying search path to find %s as %s in '%s'" %
  (exename, pyexename, exedir))
 path = os.environ['PATH'].split(os.pathsep)
@@ -3048,7 +3057,7 @@
 
 # Run installer in hg root
 script = os.path.realpath(sys.argv[0])
-exe = sys.executable
+exe = sysexecutable
 if PYTHON3:
 compiler = _bytespath(compiler)
 script = _bytespath(script)
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1240,7 +1240,7 @@
 
 # Python
 fm.write('pythonexe', _("checking Python executable (%s)\n"),
- pycompat.sysexecutable)
+ pycompat.sysexecutable or "unknown")
 fm.write('pythonver', _("checking Python version (%s)\n"),
  ("%d.%d.%d" % sys.version_info[:3]))
 fm.write('pythonlib', _("checking Python lib (%s)...\n"),
diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -138,7 +138,9 @@
 modules.append(__version__)
 except ImportError:
 pass
-files = [pycompat.sysexecutable]
+files = []
+if pycompat.sysexecutable:
+files.append(pycompat.sysexecutable)
 for m in modules:
 try:
 files.append(pycompat.fsencode(inspect.getabsfile(m)))



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


D6577: py3: make catapult usable from the test runner in py3

2019-06-25 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio 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/D6577

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1474,6 +1474,12 @@
 script.append(b'alias pwd="pwd -W"\n')
 
 if hgcatapult and hgcatapult != os.devnull:
+if PYTHON3:
+hgcatapult = hgcatapult.encode('utf8')
+cataname = self.name.encode('utf8')
+else:
+cataname = self.name
+
 # Kludge: use a while loop to keep the pipe from getting
 # closed by our echo commands. The still-running file gets
 # reaped at the end of the script, which causes the while
@@ -1490,9 +1496,9 @@
 b'HGCATAPULTSESSION=%(session)s ; export HGCATAPULTSESSION\n'
 b'echo START %(session)s %(name)s >> %(catapult)s\n'
 % {
-'name': self.name,
-'session': session,
-'catapult': hgcatapult,
+b'name': cataname,
+b'session': session,
+b'catapult': hgcatapult,
 }
 )
 



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


D6576: py3: use integer division for the value passed to xrange

2019-06-25 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio 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/D6576

AFFECTED FILES
  mercurial/pure/osutil.py

CHANGE DETAILS

diff --git a/mercurial/pure/osutil.py b/mercurial/pure/osutil.py
--- a/mercurial/pure/osutil.py
+++ b/mercurial/pure/osutil.py
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-from __future__ import absolute_import
+from __future__ import absolute_import, division
 
 import ctypes
 import ctypes.util
@@ -149,7 +149,7 @@
 cmsg.cmsg_type != _SCM_RIGHTS):
 return []
 rfds = ctypes.cast(cmsg.cmsg_data, ctypes.POINTER(ctypes.c_int))
-rfdscount = ((cmsg.cmsg_len - _cmsghdr.cmsg_data.offset) /
+rfdscount = ((cmsg.cmsg_len - _cmsghdr.cmsg_data.offset) //
  ctypes.sizeof(ctypes.c_int))
 return [rfds[i] for i in pycompat.xrange(rfdscount)]
 



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


D6436: narrow: use narrow_widen wireproto command to widen in case of ellipses

2019-06-04 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  Hopefully not too late

INLINE COMMENTS

> pulkit wrote in narrowcommands.py:306
> I believe it streams rather than downloading the whole bundle into memory. 
> `getbundle()` uses the same function and I think we do streaming there. 
> https://www.mercurial-scm.org/repo/hg-committed/file/127937874395/mercurial/exchange.py#l1757
> 
> I also asked @marmoute and he also think that it does streaming.

The difference from the code you're pointing too is that you're calling 
.result() here, which blocks until the results are fully streamed in (see 
httppeer.py) - so I really think this is NOT streaming.

REPOSITORY
  rHG Mercurial

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

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


D6436: narrow: use narrow_widen wireproto command to widen in case of ellipses

2019-06-03 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added inline comments.

INLINE COMMENTS

> narrowcommands.py:306
> +'ellipses': True,
> +}).result()
> +trmanager = exchange.transactionmanager(repo, 'widen',

Being nosy here: does this mean that it'll download the whole bundle into 
memory before it starts applying it, rather than streaming it into the store? 
Bundles, especially in repos using narrow, can be very large, so that would not 
be ideal.

REPOSITORY
  rHG Mercurial

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

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


D6324: help: register the 'gpg' command category and give it a description

2019-05-06 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  In https://phab.mercurial-scm.org/D6324#92158, @martinvonz wrote:
  
  > This doesn't actually seem to work for making it appear in `hg help`. 
@rdamazio (who added the categories stuff), have you thought about a way of 
letting extensions add categories?
  
  
  I did, this was supposed to be it - maybe I missed something or it broke 
somehow? :/
  I need to migrate Google's extension out of the internal version of help (now 
that I've upstreamed the help changes), I'll definitely need to mess with 
categories for that, too.

INLINE COMMENTS

> martinvonz wrote in gpg.py:56
> This feels a little too specific, but we can come up with a better category 
> for it if we get other related commands.

"Security"?

REPOSITORY
  rHG Mercurial

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

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


  1   2   >