D9635: mergetools: add BeyondCompare 4 for Windows
mharbison72 created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is a copy of the TortoiseHg configuration, but dropping the 3-way diff and dirdiff settings (since those aren't supported in core Mercurial), and swapping the 'parent1', 'parent2', and 'base' literals for `$labellocal`, `$labelother, and `$labelbase` respectively. (That functionality was apparently never ported to TortoiseHg.) Additionally, the single quotes were removed from around these arguments, since none of the other configs have them. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D9635 AFFECTED FILES mercurial/defaultrc/mergetools.rc CHANGE DETAILS diff --git a/mercurial/defaultrc/mergetools.rc b/mercurial/defaultrc/mergetools.rc --- a/mercurial/defaultrc/mergetools.rc +++ b/mercurial/defaultrc/mergetools.rc @@ -44,6 +44,16 @@ beyondcompare3.regkeyalt=Software\Wow6432Node\Scooter Software\Beyond Compare 3 beyondcompare3.regname=ExePath +; Windows version of BeyondCompare 4 +beyondcompare4.args=$local $other $base /mergeoutput=$output /ro /lefttitle=$labellocal /centertitle=$labelbase /righttitle=$labelother /outputtitle=merged /automerge /reviewconflicts /solo +beyondcompare4.diffargs=/lro /lefttitle=$plabel1 /righttitle=$clabel /solo /expandall $parent $child +beyondcompare4.gui=True +beyondcompare4.premerge=False +beyondcompare4.priority=-1 +beyondcompare4.regkey=Software\Scooter Software\Beyond Compare 4 +beyondcompare4.regkeyalt=Software\Wow6432Node\Scooter Software\Beyond Compare 4 +beyondcompare4.regname=ExePath + diffmerge.args=-nosplash -merge -title1=$labellocal -title2=merged -title3=$labelother $local $base $other -result=$output diffmerge.check=changed diffmerge.diffargs=--nosplash --title1=$plabel1 --title2=$clabel $parent $child To: mharbison72, #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
D9634: mergetools: add support for 32-bit BeyondCompare 3 on 64-bit Windows
mharbison72 created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Again, marginal usefulness, but other tools have this config and it eliminates a diff from the TortoiseHg file. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D9634 AFFECTED FILES mercurial/defaultrc/mergetools.rc CHANGE DETAILS diff --git a/mercurial/defaultrc/mergetools.rc b/mercurial/defaultrc/mergetools.rc --- a/mercurial/defaultrc/mergetools.rc +++ b/mercurial/defaultrc/mergetools.rc @@ -41,6 +41,7 @@ beyondcompare3.gui=True beyondcompare3.priority=-2 beyondcompare3.regkey=Software\Scooter Software\Beyond Compare 3 +beyondcompare3.regkeyalt=Software\Wow6432Node\Scooter Software\Beyond Compare 3 beyondcompare3.regname=ExePath diffmerge.args=-nosplash -merge -title1=$labellocal -title2=merged -title3=$labelother $local $base $other -result=$output To: mharbison72, #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
D9632: mergetools: sync up comments with the TortoiseHg copy of the config file
mharbison72 created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY It's of limited value, but a step towards making the diff between the two less noisy. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D9632 AFFECTED FILES mercurial/defaultrc/mergetools.rc CHANGE DETAILS diff --git a/mercurial/defaultrc/mergetools.rc b/mercurial/defaultrc/mergetools.rc --- a/mercurial/defaultrc/mergetools.rc +++ b/mercurial/defaultrc/mergetools.rc @@ -1,6 +1,18 @@ # Some default global settings for common merge tools [merge-tools] + +; The Araxis Merge tool is configured to work with newer versions of Araxis Merge +; if you are using Araxis Merge 2008 or earlier, create a [merge-tools] section +; in your mercurial.ini file, and add one of the two following "araxis.executable" +; lines, depending on whether you have installed a 32 or a 64 bit version +; of Araxis Merge and whether you are on a 32 or 64 bit version of windows +; +;araxis.executable=${ProgramFiles}/Araxis/Araxis Merge/ConsoleCompare.exe +;araxis.executable=${ProgramFiles(x86)}/Araxis/Araxis Merge/ConsoleCompare.exe +; +; Please remember to remove the leading ";" to uncomment the line +; araxis.args=/3 /a2 /wait /merge /title1:"Other" /title2:"Base" /title3:"Local :"$local $other $base $local $output araxis.binary=True araxis.checkconflict=True @@ -10,7 +22,7 @@ araxis.regappend=\ConsoleCompare.exe araxis.regkey=SOFTWARE\Classes\TypeLib\{46799e0a-7bd1-4330-911c-9660bb964ea2}\7.0\HELPDIR -; Linux version of Beyond Compare +; Linux version of BeyondCompare 3 and 4 (dirdiff is version 4 only) bcompare.args=$local $other $base -mergeoutput=$output -ro -lefttitle=$labellocal -centertitle=$labelbase -righttitle=$labelother -outputtitle=merged -automerge -reviewconflicts -solo bcompare.diffargs=-lro -lefttitle=$plabel1 -righttitle=$clabel -solo -expandall $parent $child bcompare.gui=True @@ -23,7 +35,7 @@ bcomposx.gui=True bcomposx.priority=-1 -; Windows version of Beyond Compare +; Windows version of BeyondCompare 3 beyondcompare3.args=$local $other $base $output /ro /lefttitle=$labellocal /centertitle=$labelbase /righttitle=$labelother /automerge /reviewconflicts /solo beyondcompare3.diffargs=/lro /lefttitle=$plabel1 /righttitle=$clabel /solo /expandall $parent $child beyondcompare3.gui=True To: mharbison72, #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
D9633: mergetools: enable the `checkconflicts` option for Araxis Merge
mharbison72 created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This must have been a typo. This matches the config read in filemerge, as well as the TortoiseHg config file. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D9633 AFFECTED FILES mercurial/defaultrc/mergetools.rc CHANGE DETAILS diff --git a/mercurial/defaultrc/mergetools.rc b/mercurial/defaultrc/mergetools.rc --- a/mercurial/defaultrc/mergetools.rc +++ b/mercurial/defaultrc/mergetools.rc @@ -15,7 +15,7 @@ ; araxis.args=/3 /a2 /wait /merge /title1:"Other" /title2:"Base" /title3:"Local :"$local $other $base $local $output araxis.binary=True -araxis.checkconflict=True +araxis.checkconflicts=True araxis.diffargs=/2 /wait /title1:$plabel1 /title2:$clabel $parent $child araxis.gui=True araxis.priority=-2 To: mharbison72, #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
[PATCH 2 of 2] chg: format code by clang-format version 11.0.1-+rc1-1
# HG changeset patch # User Yuya Nishihara # Date 1608347244 -32400 # Sat Dec 19 12:07:24 2020 +0900 # Node ID babd57945ad10283f753b25d15ab593811959a70 # Parent 5db45dfd6206490f8668559838cc4d4ca9ac chg: format code by clang-format version 11.0.1-+rc1-1 test-check-clang-format.t started failing on my Debian sid environment, and new style looks slightly better. So let's bump the required clang-format version to 11. diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c --- a/contrib/chg/chg.c +++ b/contrib/chg/chg.c @@ -451,9 +451,10 @@ static int runinstructions(struct cmdser */ static int isunsupported(int argc, const char *argv[]) { - enum { SERVE = 1, - DAEMON = 2, - SERVEDAEMON = SERVE | DAEMON, + enum { + SERVE = 1, + DAEMON = 2, + SERVEDAEMON = SERVE | DAEMON, }; unsigned int state = 0; int i; diff --git a/contrib/chg/hgclient.c b/contrib/chg/hgclient.c --- a/contrib/chg/hgclient.c +++ b/contrib/chg/hgclient.c @@ -26,15 +26,16 @@ #include "procutil.h" #include "util.h" -enum { CAP_GETENCODING = 0x0001, - CAP_RUNCOMMAND = 0x0002, - /* cHg extension: */ - CAP_ATTACHIO = 0x0100, - CAP_CHDIR = 0x0200, - CAP_SETENV = 0x0800, - CAP_SETUMASK2 = 0x1000, - CAP_VALIDATE = 0x2000, - CAP_SETPROCNAME = 0x4000, +enum { + CAP_GETENCODING = 0x0001, + CAP_RUNCOMMAND = 0x0002, + /* cHg extension: */ + CAP_ATTACHIO = 0x0100, + CAP_CHDIR = 0x0200, + CAP_SETENV = 0x0800, + CAP_SETUMASK2 = 0x1000, + CAP_VALIDATE = 0x2000, + CAP_SETPROCNAME = 0x4000, }; typedef struct { diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -592,8 +592,8 @@ def has_pylint(): @check("clang-format", "clang-format C code formatter") def has_clang_format(): m = matchoutput('clang-format --version', br'clang-format version (\d+)') -# style changed somewhere between 4.x and 6.x -return m and int(m.group(1)) >= 6 +# style changed somewhere between 10.x and 11.x +return m and int(m.group(1)) >= 11 @check("jshint", "JSHint static code analysis tool") ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 2] test-check-interface: do not expect bare "python" executable exists
# HG changeset patch # User Yuya Nishihara # Date 1608346918 -32400 # Sat Dec 19 12:01:58 2020 +0900 # Node ID 5db45dfd6206490f8668559838cc4d4ca9ac # Parent 09beb9a133f168111fbef4a729f1c0cc2bfb87ce test-check-interface: do not expect bare "python" executable exists The test would crash if python executable had version suffix. diff --git a/tests/test-check-interfaces.py b/tests/test-check-interfaces.py --- a/tests/test-check-interfaces.py +++ b/tests/test-check-interfaces.py @@ -12,7 +12,7 @@ import sys # Only run if tests are run in a repo if subprocess.call( -['python', '%s/hghave' % os.environ['TESTDIR'], 'test-repo'] +[sys.executable, '%s/hghave' % os.environ['TESTDIR'], 'test-repo'] ): sys.exit(80) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D9059: procutil: assign stdio objects if they are None
As Pulkit pointed out, I and Pulkit made another version in parallel. https://patchwork.mercurial-scm.org/patch/47937/ https://patchwork.mercurial-scm.org/patch/47938/ https://patchwork.mercurial-scm.org/patch/47939/ `sys.std*` are left unmodified. `procutil.std*` are fixed up to raise EBADF. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 4 of 4 V2] procutil: assign pseudo file object if sys.stdout/stderr is missing
# HG changeset patch # User Yuya Nishihara # Date 1608289751 -32400 # Fri Dec 18 20:09:11 2020 +0900 # Node ID 09beb9a133f168111fbef4a729f1c0cc2bfb87ce # Parent ca07a5705bf78401bf7c910b9be9a6c5a16ceb64 procutil: assign pseudo file object if sys.stdout/stderr is missing This basically simulates the Python 2 behavior. If libc stdio were used, these file objects would be available and raise EBADF. There is subtle difference between py2 and py3, but I think py3 behavior (i.e. exit 255) is more correct. "if" conditions are adjust so that they look similar to dispatch.initstdio(). diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py +++ b/mercurial/utils/procutil.py @@ -131,17 +131,25 @@ def _make_write_all(stream): if pycompat.ispy3: -# Python 3 implements its own I/O streams. +# Python 3 implements its own I/O streams. Unlike stdio of C library, +# sys.stdin/stdout/stderr may be None if underlying fd is closed. + # TODO: .buffer might not exist if std streams were replaced; we'll need # a silly wrapper to make a bytes stream backed by a unicode one. -# sys.stdin can be None -if sys.stdin: +if sys.stdin is None: +stdin = BadFile() +else: stdin = sys.stdin.buffer +if sys.stdout is None: +stdout = BadFile() else: -stdin = BadFile() -stdout = _make_write_all(sys.stdout.buffer) -stderr = _make_write_all(sys.stderr.buffer) +stdout = _make_write_all(sys.stdout.buffer) +if sys.stderr is None: +stderr = BadFile() +else: +stderr = _make_write_all(sys.stderr.buffer) + if pycompat.iswindows: # Work around Windows bugs. stdout = platform.winstdout(stdout) diff --git a/tests/test-basic.t b/tests/test-basic.t --- a/tests/test-basic.t +++ b/tests/test-basic.t @@ -49,6 +49,31 @@ Writes to stdio succeed and fail appropr [255] #endif +On Python 3, stdio may be None: + + $ hg debuguiprompt --config ui.interactive=true 0<&- + abort: Bad file descriptor + [255] + $ hg version -q 0<&- + Mercurial Distributed SCM * (glob) + +#if py3 + $ hg version -q 1>&- + abort: Bad file descriptor + [255] +#else + $ hg version -q 1>&- +#endif + $ hg unknown -q 1>&- + hg: unknown command 'unknown' + (did you mean debugknown?) + [255] + + $ hg version -q 2>&- + Mercurial Distributed SCM * (glob) + $ hg unknown -q 2>&- + [255] + $ hg commit -m test This command is ancient: ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 3 of 4 V2] procutil: introduce pseudo file object that just raises EBADF
# HG changeset patch # User Yuya Nishihara # Date 1608343818 -32400 # Sat Dec 19 11:10:18 2020 +0900 # Node ID ca07a5705bf78401bf7c910b9be9a6c5a16ceb64 # Parent a5fa4ea662d52a6eccb538e79ca36b2a4745a9b8 procutil: introduce pseudo file object that just raises EBADF This should be safer than closing underlying fd as the fd may be reused. On Python 2, closed sys.stdin could be redirected to a random file having fd=0, but we'd be better not copying this behavior. Only readinto() and write() are implemented according to the following ABC table. fileno() is not implemented since fd=0/1/2 may be assigned later to other files. https://docs.python.org/3/library/io.html#class-hierarchy diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py +++ b/mercurial/utils/procutil.py @@ -50,6 +50,16 @@ def isatty(fp): return False +class BadFile(io.RawIOBase): +"""Dummy file object to simulate closed stdio behavior""" + +def readinto(self, b): +raise IOError(errno.EBADF, 'Bad file descriptor') + +def write(self, b): +raise IOError(errno.EBADF, 'Bad file descriptor') + + class LineBufferedWrapper(object): def __init__(self, orig): self.orig = orig @@ -129,8 +139,7 @@ if pycompat.ispy3: if sys.stdin: stdin = sys.stdin.buffer else: -stdin = open(os.devnull, 'rb') -os.close(stdin.fileno()) +stdin = BadFile() stdout = _make_write_all(sys.stdout.buffer) stderr = _make_write_all(sys.stderr.buffer) if pycompat.iswindows: ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 4 V2] dispatch: gate against missing stdout/stderr
# HG changeset patch # User Yuya Nishihara # Date 1608290094 -32400 # Fri Dec 18 20:14:54 2020 +0900 # Node ID a5fa4ea662d52a6eccb538e79ca36b2a4745a9b8 # Parent a05f8740ce1faeda3f6299c3cbf961be48652a06 dispatch: gate against missing stdout/stderr We do need procutil.stdin/stdout/stderr, but we don't care much for sys.std*. Let's leave them be None as it is the Python 3 way. diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -166,26 +166,34 @@ if pycompat.ispy3: # "just work," here we change the sys.* streams to disable line ending # normalization, ensuring compatibility with our ui type. -# write_through is new in Python 3.7. -kwargs = { -"newline": "\n", -"line_buffering": sys.stdout.line_buffering, -} -if util.safehasattr(sys.stdout, "write_through"): -kwargs["write_through"] = sys.stdout.write_through -sys.stdout = io.TextIOWrapper( -sys.stdout.buffer, sys.stdout.encoding, sys.stdout.errors, **kwargs -) +if sys.stdout is not None: +# write_through is new in Python 3.7. +kwargs = { +"newline": "\n", +"line_buffering": sys.stdout.line_buffering, +} +if util.safehasattr(sys.stdout, "write_through"): +kwargs["write_through"] = sys.stdout.write_through +sys.stdout = io.TextIOWrapper( +sys.stdout.buffer, +sys.stdout.encoding, +sys.stdout.errors, +**kwargs +) -kwargs = { -"newline": "\n", -"line_buffering": sys.stderr.line_buffering, -} -if util.safehasattr(sys.stderr, "write_through"): -kwargs["write_through"] = sys.stderr.write_through -sys.stderr = io.TextIOWrapper( -sys.stderr.buffer, sys.stderr.encoding, sys.stderr.errors, **kwargs -) +if sys.stderr is not None: +kwargs = { +"newline": "\n", +"line_buffering": sys.stderr.line_buffering, +} +if util.safehasattr(sys.stderr, "write_through"): +kwargs["write_through"] = sys.stderr.write_through +sys.stderr = io.TextIOWrapper( +sys.stderr.buffer, +sys.stderr.encoding, +sys.stderr.errors, +**kwargs +) if sys.stdin is not None: # No write_through on read-only stream. @@ -200,6 +208,8 @@ if pycompat.ispy3: def _silencestdio(): for fp in (sys.stdout, sys.stderr): +if fp is None: +continue # Check if the file is okay try: fp.flush() ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 4 V2] dispatch: remove stale comment about fdopen()-ed stdio
# HG changeset patch # User Yuya Nishihara # Date 1608291311 -32400 # Fri Dec 18 20:35:11 2020 +0900 # Node ID a05f8740ce1faeda3f6299c3cbf961be48652a06 # Parent d109dda4a3e7bb1c6fa7de98b6872ddb80ec3827 dispatch: remove stale comment about fdopen()-ed stdio On Python 3, stdout is just wrapped by LineBufferedWrapper. diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -207,9 +207,7 @@ if pycompat.ispy3: except IOError: pass # Otherwise mark it as closed to silence "Exception ignored in" -# message emitted by the interpreter finalizer. Be careful to -# not close procutil.stdout, which may be a fdopen-ed file object -# and its close() actually closes the underlying file descriptor. +# message emitted by the interpreter finalizer. try: fp.close() except IOError: ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 3] dispatch: gate against missing stdout/stderr
On Fri, Dec 18, 2020 at 6:26 PM Yuya Nishihara wrote: > > # HG changeset patch > # User Yuya Nishihara > # Date 1608290094 -32400 > # Fri Dec 18 20:14:54 2020 +0900 > # Node ID 47ce0f83ffad4fd66e4f76ea54733756398a98ba > # Parent d109dda4a3e7bb1c6fa7de98b6872ddb80ec3827 > dispatch: gate against missing stdout/stderr I was reviewing patches on phabricator and stumbled upon this: https://phab.mercurial-scm.org/D9059 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D9631: branchmap: avoid ancestor computations for absent non-continous branches
joerg.sonnenberger created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY The branchhead computation is one of the more heavy operations for bigger repositories as it has to scan all changesets and potentially involves the expensive computation of the ancestor sets. Redo the computation to handle the common cases directly and use tighter conditions for when the ancestor scan is necessary. Most importantly, avoid it completely if the non-continous branches are processed in one update as seen in the initial computation after a clone. For the Mercurial repository, it gives a small 2-3% performance boost. For the NetBSD test repository, it cuts the time in half. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D9631 AFFECTED FILES mercurial/branchmap.py CHANGE DETAILS diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -443,33 +443,65 @@ if closesbranch: self._closednodes.add(cl.node(r)) -# fetch current topological heads to speed up filtering -topoheads = set(cl.headrevs()) - # new tip revision which we found after iterating items from new # branches ntiprev = self.tiprev -# if older branchheads are reachable from new ones, they aren't -# really branchheads. Note checking parents is insufficient: -# 1 (branch a) -> 2 (branch b) -> 3 (branch a) +# Delay fetching the topological heads until they are needed. +# A repository without non-continous branches can skip this part. +topoheads = None + +# If a changeset is visible, its parents must be visible too, so +# use the faster unfiltered parent accessor. +parentrevs = repo.unfiltered().changelog.parentrevs + for branch, newheadrevs in pycompat.iteritems(newbranches): +# The set of branchheads is the union of the existing branchheads +# with the heads of new revisions of that branch, but without +# existing branchheads that are ancestors of new revisions. +# The latter condition is necessary for non-continous branches, +# i.e. 1 (branch a) -> 2 (branch b) -> 3 (branch a). +# +# The newrev loop processes all new revisions in order and updates +# the branchheads for the simple case of continous branches. +# The sorting ensures that parents are processed first and the root +# of a potential non-continous branch is seen first. +# It followes that all revisions that are not a child of the branch +# are candidates for such branches and therefore kept on the +# uncertain set. The exception is a local branch root with no +# pre-existing branchheads. This is the initial start of a branch +# and safe. +# +# If the newrev loop left any uncertain candidates for potential +# non-continous branches around, further checks are necessary. +# If all the remaining pre-existing branchheads (i.e. those without +# a child in the new revision set) are still topological heads, +# they are automatically also branchheads. Otherwise a full +# ancestor check is necessary to filter out obsoleted branchheads. + bheads = self._entries.setdefault(branch, []) bheadset = {cl.rev(node) for node in bheads} - -# This have been tested True on all internal usage of this function. -# run it again in case of doubt -# assert not (set(bheadrevs) & set(newheadrevs)) -bheadset.update(newheadrevs) +uncertain = set() +for newrev in sorted(newheadrevs): +parents = [p for p in parentrevs(newrev) if p != nullrev] +gotit = False +for p in parents: +if p in bheadset: +bheadset.remove(p) +gotit = True +elif getbranchinfo(p)[0] == branch: +gotit = True +if not gotit and bheadset: +uncertain.add(newrev) +bheadset.add(newrev) -# This prunes out two kinds of heads - heads that are superseded by -# a head in newheadrevs, and newheadrevs that are not heads because -# an existing head is their descendant. -uncertain = bheadset - topoheads if uncertain: -floorrev = min(uncertain) -ancestors = set(cl.ancestors(newheadrevs, floorrev)) -bheadset -= ancestors +if topoheads is None: +topoheads = set(cl.headrevs()) +if bheadset - topoheads:
[PATCH 3 of 3] dispatch: remove stale comment about fdopen()-ed stdio
# HG changeset patch # User Yuya Nishihara # Date 1608291311 -32400 # Fri Dec 18 20:35:11 2020 +0900 # Node ID 567d926ac2b6abfdcd0367540921dfccf8709c71 # Parent bd4e513e64c974c38963b60fc14d4bbce6d574fe dispatch: remove stale comment about fdopen()-ed stdio On Python 3, stdout is just wrapped by LineBufferedWrapper. diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -217,9 +217,7 @@ if pycompat.ispy3: except IOError: pass # Otherwise mark it as closed to silence "Exception ignored in" -# message emitted by the interpreter finalizer. Be careful to -# not close procutil.stdout, which may be a fdopen-ed file object -# and its close() actually closes the underlying file descriptor. +# message emitted by the interpreter finalizer. try: fp.close() except IOError: ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 3] procutil: create dummy file object if sys.stdout/stderr is missing
# HG changeset patch # User Yuya Nishihara # Date 1608289751 -32400 # Fri Dec 18 20:09:11 2020 +0900 # Node ID bd4e513e64c974c38963b60fc14d4bbce6d574fe # Parent 47ce0f83ffad4fd66e4f76ea54733756398a98ba procutil: create dummy file object if sys.stdout/stderr is missing This basically simulates the Python 2 behavior. If libc stdio were used, these file objects would be available and raise EBADF. There is subtle difference between py2 and py3, but I think py3 behavior (i.e. exit 255) is more correct. "if" conditions are adjust so that they look similar to dispatch.initstdio(). diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py +++ b/mercurial/utils/procutil.py @@ -120,19 +120,36 @@ def _make_write_all(stream): return WriteAllWrapper(stream) +def _make_bad_file(mode): +"""Creates a file which will raise EBADF for any I/O operation + +This simulates the Python 2 behavior of closed stdio. +""" +f = open(os.devnull, mode) +os.close(f.fileno()) +return f + + if pycompat.ispy3: -# Python 3 implements its own I/O streams. +# Python 3 implements its own I/O streams. Unlike stdio of C library, +# sys.stdin/stdout/stderr may be None if underlying fd is closed. + # TODO: .buffer might not exist if std streams were replaced; we'll need # a silly wrapper to make a bytes stream backed by a unicode one. -# sys.stdin can be None -if sys.stdin: +if sys.stdin is None: +stdin = _make_bad_file('rb') +else: stdin = sys.stdin.buffer +if sys.stdout is None: +stdout = _make_bad_file('wb') else: -stdin = open(os.devnull, 'rb') -os.close(stdin.fileno()) -stdout = _make_write_all(sys.stdout.buffer) -stderr = _make_write_all(sys.stderr.buffer) +stdout = _make_write_all(sys.stdout.buffer) +if sys.stderr is None: +stderr = _make_bad_file('wb') +else: +stderr = _make_write_all(sys.stderr.buffer) + if pycompat.iswindows: # Work around Windows bugs. stdout = platform.winstdout(stdout) diff --git a/tests/test-basic.t b/tests/test-basic.t --- a/tests/test-basic.t +++ b/tests/test-basic.t @@ -49,6 +49,26 @@ Writes to stdio succeed and fail appropr [255] #endif +On Python 3, stdio may be None: + + $ hg version -q 0<&- + Mercurial Distributed SCM * (glob) +#if py3 + $ hg version -q 1>&- + abort: Bad file descriptor + [255] +#else + $ hg version -q 1>&- +#endif + $ hg version -q 2>&- + Mercurial Distributed SCM * (glob) + $ hg unknown -q 1>&- + hg: unknown command 'unknown' + (did you mean debugknown?) + [255] + $ hg unknown -q 2>&- + [255] + $ hg commit -m test This command is ancient: ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 3] dispatch: gate against missing stdout/stderr
# HG changeset patch # User Yuya Nishihara # Date 1608290094 -32400 # Fri Dec 18 20:14:54 2020 +0900 # Node ID 47ce0f83ffad4fd66e4f76ea54733756398a98ba # Parent d109dda4a3e7bb1c6fa7de98b6872ddb80ec3827 dispatch: gate against missing stdout/stderr diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -166,26 +166,34 @@ if pycompat.ispy3: # "just work," here we change the sys.* streams to disable line ending # normalization, ensuring compatibility with our ui type. -# write_through is new in Python 3.7. -kwargs = { -"newline": "\n", -"line_buffering": sys.stdout.line_buffering, -} -if util.safehasattr(sys.stdout, "write_through"): -kwargs["write_through"] = sys.stdout.write_through -sys.stdout = io.TextIOWrapper( -sys.stdout.buffer, sys.stdout.encoding, sys.stdout.errors, **kwargs -) +if sys.stdout is not None: +# write_through is new in Python 3.7. +kwargs = { +"newline": "\n", +"line_buffering": sys.stdout.line_buffering, +} +if util.safehasattr(sys.stdout, "write_through"): +kwargs["write_through"] = sys.stdout.write_through +sys.stdout = io.TextIOWrapper( +sys.stdout.buffer, +sys.stdout.encoding, +sys.stdout.errors, +**kwargs +) -kwargs = { -"newline": "\n", -"line_buffering": sys.stderr.line_buffering, -} -if util.safehasattr(sys.stderr, "write_through"): -kwargs["write_through"] = sys.stderr.write_through -sys.stderr = io.TextIOWrapper( -sys.stderr.buffer, sys.stderr.encoding, sys.stderr.errors, **kwargs -) +if sys.stderr is not None: +kwargs = { +"newline": "\n", +"line_buffering": sys.stderr.line_buffering, +} +if util.safehasattr(sys.stderr, "write_through"): +kwargs["write_through"] = sys.stderr.write_through +sys.stderr = io.TextIOWrapper( +sys.stderr.buffer, +sys.stderr.encoding, +sys.stderr.errors, +**kwargs +) if sys.stdin is not None: # No write_through on read-only stream. @@ -200,6 +208,8 @@ if pycompat.ispy3: def _silencestdio(): for fp in (sys.stdout, sys.stderr): +if fp is None: +continue # Check if the file is okay try: fp.flush() ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
mercurial-devel | Pipeline #14887 has failed for branch/default | fb810130
Your pipeline has failed. Project: mercurial-devel ( https://foss.heptapod.net/octobus/mercurial-devel ) Branch: branch/default ( https://foss.heptapod.net/octobus/mercurial-devel/-/commits/branch/default ) Commit: fb810130 ( https://foss.heptapod.net/octobus/mercurial-devel/-/commit/fb8101300167af0d0989e0adc366dbb552aadbaf ) Commit Message: contrib: run python3+chg tests too in heptapod ... Commit Author: Pulkit Goyal ( https://foss.heptapod.net/pulkit.goyal ) Pipeline #14887 ( https://foss.heptapod.net/octobus/mercurial-devel/-/pipelines/14887 ) triggered by Pierre-Yves David ( https://foss.heptapod.net/marmoute ) had 1 failed build. Job #137938 ( https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/137938/raw ) Stage: tests Name: test-py2-chg -- You're receiving this email because of your account on foss.heptapod.net. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
mercurial@46144: 4 new changesets
4 new changesets in mercurial: https://www.mercurial-scm.org/repo/hg/rev/41733a1c3532 changeset: 46141:41733a1c3532 user:Joerg Sonnenberger date:Sat Nov 28 22:27:12 2020 +0100 summary: cext: isolate hash size in the revlog handling in a single place https://www.mercurial-scm.org/repo/hg/rev/634cea2c247f changeset: 46142:634cea2c247f user:Matt Harbison date:Thu Dec 17 13:33:27 2020 -0500 summary: relnotes: document automatically setting `HGPLAIN=1` for external hooks https://www.mercurial-scm.org/repo/hg/rev/dadca47e3d4d changeset: 46143:dadca47e3d4d user:Martin von Zweigbergk date:Thu Dec 17 10:43:43 2020 -0800 summary: errors: respect ui.detailed-exit-code in chg https://www.mercurial-scm.org/repo/hg/rev/e4f6dae01b3b changeset: 46144:e4f6dae01b3b bookmark:@ tag: tip user:Joerg Sonnenberger date:Thu Dec 17 18:08:25 2020 +0100 summary: cext: shut-up sign compare warnings -- Repository URL: https://www.mercurial-scm.org/repo/hg ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 2 of 3 chg] procutil: use os.devnull if sys.stdout/err is None
On Fri, 18 Dec 2020 14:16:20 +0530, Pulkit Goyal wrote: > # HG changeset patch > # User Pulkit Goyal <7895pul...@gmail.com> > # Date 1607427603 -19800 > # Tue Dec 08 17:10:03 2020 +0530 > # Node ID 9f0555329584b3e91e74e0606d66d16dd7a4c82f > # Parent e40f52691dac94d70a251b65806a4d1f4d2b5f19 > # EXP-Topic chg-test > procutil: use os.devnull if sys.stdout/err is None > > According to Yuya, it's better to make `procutil.stdin/err/out` always > available. > > This is a bandaid until someone suggests something better. > > diff -r e40f52691dac -r 9f0555329584 mercurial/utils/procutil.py > --- a/mercurial/utils/procutil.py Fri Apr 03 20:30:36 2020 +0530 > +++ b/mercurial/utils/procutil.py Tue Dec 08 17:10:03 2020 +0530 > @@ -131,8 +131,16 @@ > else: > stdin = open(os.devnull, 'rb') > os.close(stdin.fileno()) > -stdout = _make_write_all(sys.stdout.buffer) > -stderr = _make_write_all(sys.stderr.buffer) > +if sys.stdout: > +stdout = _make_write_all(sys.stdout.buffer) > +else: > +stdout = open(os.devnull, 'rb') > +os.close(stdout.fileno()) > +if sys.stderr: > +stderr = _make_write_all(sys.stderr.buffer) > +else: > +stderr = open(os.devnull, 'rb') stdout/stderr should theoretically be 'wb'. I'll send a reworked version. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 3 chg] contrib: run python3+chg tests too in heptapod CI
On Fri, 18 Dec 2020 14:16:19 +0530, Pulkit Goyal wrote: > # HG changeset patch > # User Pulkit Goyal <7895pul...@gmail.com> > # Date 1607767078 -19800 > # Sat Dec 12 15:27:58 2020 +0530 > # Node ID 5179a4bd4fc35890cbfd962e0a8960a2f74720a1 > # Parent e4f6dae01b3bc94b0198722522a13c914ab848cd > # EXP-Topic chg-test > contrib: run python3+chg tests too in heptapod CI Queued 1 and 3, thanks. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 3 chg] procutil: use os.devnull if sys.stdout/err is None
# HG changeset patch # User Pulkit Goyal <7895pul...@gmail.com> # Date 1607427603 -19800 # Tue Dec 08 17:10:03 2020 +0530 # Node ID 9f0555329584b3e91e74e0606d66d16dd7a4c82f # Parent e40f52691dac94d70a251b65806a4d1f4d2b5f19 # EXP-Topic chg-test procutil: use os.devnull if sys.stdout/err is None According to Yuya, it's better to make `procutil.stdin/err/out` always available. This is a bandaid until someone suggests something better. diff -r e40f52691dac -r 9f0555329584 mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py Fri Apr 03 20:30:36 2020 +0530 +++ b/mercurial/utils/procutil.py Tue Dec 08 17:10:03 2020 +0530 @@ -131,8 +131,16 @@ else: stdin = open(os.devnull, 'rb') os.close(stdin.fileno()) -stdout = _make_write_all(sys.stdout.buffer) -stderr = _make_write_all(sys.stderr.buffer) +if sys.stdout: +stdout = _make_write_all(sys.stdout.buffer) +else: +stdout = open(os.devnull, 'rb') +os.close(stdout.fileno()) +if sys.stderr: +stderr = _make_write_all(sys.stderr.buffer) +else: +stderr = open(os.devnull, 'rb') +os.close(stderr.fileno()) if pycompat.iswindows: # Work around Windows bugs. stdout = platform.winstdout(stdout) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 3 of 3 chg] chgserver: respect detailed exit code in case of ConfigError
# HG changeset patch # User Pulkit Goyal <7895pul...@gmail.com> # Date 1608279806 -19800 # Fri Dec 18 13:53:26 2020 +0530 # Node ID f928cc73e4fea7c16462ea20895f8dfd650d4b90 # Parent 9f0555329584b3e91e74e0606d66d16dd7a4c82f # EXP-Topic chg-test chgserver: respect detailed exit code in case of ConfigError This effectively backs out 60523483897cf8caf7718aaf81c58d4d9fd5e1fa which was a bandaid. Martin yesterday fixed a similar failure which motivated me to fix it the correct way. diff -r 9f0555329584 -r f928cc73e4fe mercurial/chgserver.py --- a/mercurial/chgserver.pyTue Dec 08 17:10:03 2020 +0530 +++ b/mercurial/chgserver.pyFri Dec 18 13:53:26 2020 +0530 @@ -518,6 +518,8 @@ except error.Abort as inst: if isinstance(inst, error.InputError): detailed_exit_code = 10 +elif isinstance(inst, error.ConfigError): +detailed_exit_code = 30 self.ui.error(inst.format()) errorraised = True diff -r 9f0555329584 -r f928cc73e4fe tests/test-chg.t --- a/tests/test-chg.t Tue Dec 08 17:10:03 2020 +0530 +++ b/tests/test-chg.t Fri Dec 18 13:53:26 2020 +0530 @@ -30,7 +30,7 @@ $ echo '=brokenconfig' >> $HGRCPATH $ chg status config error at * =brokenconfig (glob) - [255] + [30] $ cp $HGRCPATH.orig $HGRCPATH diff -r 9f0555329584 -r f928cc73e4fe tests/test-config.t --- a/tests/test-config.t Tue Dec 08 17:10:03 2020 +0530 +++ b/tests/test-config.t Fri Dec 18 13:53:26 2020 +0530 @@ -6,59 +6,35 @@ $ cat > .hg/hgrc << EOF > novaluekey > EOF -#if chg - $ hg showconfig - config error at $TESTTMP/.hg/hgrc:1: novaluekey - [255] -#else $ hg showconfig config error at $TESTTMP/.hg/hgrc:1: novaluekey [30] -#endif Invalid syntax: no key $ cat > .hg/hgrc << EOF > =nokeyvalue > EOF -#if chg - $ hg showconfig - config error at $TESTTMP/.hg/hgrc:1: =nokeyvalue - [255] -#else $ hg showconfig config error at $TESTTMP/.hg/hgrc:1: =nokeyvalue [30] -#endif Test hint about invalid syntax from leading white space $ cat > .hg/hgrc << EOF > key=value > EOF -#if chg - $ hg showconfig - config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: key=value - [255] -#else $ hg showconfig config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: key=value [30] -#endif $ cat > .hg/hgrc << EOF > [section] > key=value > EOF -#if chg - $ hg showconfig - config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: [section] - [255] -#else $ hg showconfig config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: [section] [30] -#endif Reset hgrc ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 3 chg] contrib: run python3+chg tests too in heptapod CI
# HG changeset patch # User Pulkit Goyal <7895pul...@gmail.com> # Date 1607767078 -19800 # Sat Dec 12 15:27:58 2020 +0530 # Node ID 5179a4bd4fc35890cbfd962e0a8960a2f74720a1 # Parent e4f6dae01b3bc94b0198722522a13c914ab848cd # EXP-Topic chg-test contrib: run python3+chg tests too in heptapod CI Recent patches made the CI on python3+chg green. Let's enable this before there are more failures to fix. Differential Revision: https://phab.mercurial-scm.org/D9569 diff -r e4f6dae01b3b -r 5179a4bd4fc3 contrib/heptapod-ci.yml --- a/contrib/heptapod-ci.yml Thu Dec 17 18:08:25 2020 +0100 +++ b/contrib/heptapod-ci.yml Sat Dec 12 15:27:58 2020 +0530 @@ -114,3 +114,10 @@ variables: RUNTEST_ARGS: "--blacklist /tmp/check-tests.txt --chg" TEST_HGMODULEPOLICY: "c" + +test-py3-chg: +<<: *runtests +variables: +PYTHON: python3 +RUNTEST_ARGS: "--blacklist /tmp/check-tests.txt --chg" +TEST_HGMODULEPOLICY: "c" ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel