Re: [PATCH] tests: replace `cd ..` with an absolute path in a couple ssh tests
On Sat, 13 Oct 2018 22:40:36 -0400, Matt Harbison wrote: > # HG changeset patch > # User Matt Harbison > # Date 1539474573 14400 > # Sat Oct 13 19:49:33 2018 -0400 > # Node ID fb97b23d9256601538396ea49c8284219992fe99 > # Parent 83dab13d625cd3fa2ce24801c9ee962d695045b8 > tests: replace `cd ..` with an absolute path in a couple ssh tests Queued, thanks. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] run-tests: restore quoting the python executable for running *.py tests
On Sat, 13 Oct 2018 23:10:49 -0400, Matt Harbison wrote: > # HG changeset patch > # User Matt Harbison > # Date 1539486509 14400 > # Sat Oct 13 23:08:29 2018 -0400 > # Node ID b94bd76195a7474b2493b362f47550b179d79aa3 > # Parent fb97b23d9256601538396ea49c8284219992fe99 > run-tests: restore quoting the python executable for running *.py tests Queued, thanks. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 2 V4] revlog: allow flag processors to be applied via store options
On Sat, 13 Oct 2018 13:30:08 -0400, Matt Harbison wrote: > # HG changeset patch > # User Matt Harbison > # Date 1539136401 14400 > # Tue Oct 09 21:53:21 2018 -0400 > # Node ID 222cf88a686a2fb818c4c440250be10625b4fdeb > # Parent 8f192f2c4a1e04ac69dec66c48efcb96bc738533 > revlog: allow flag processors to be applied via store options Queued, many thanks. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH V2] py3: use str to query registry values on Windows
On Sat, 13 Oct 2018 13:44:25 -0400, Matt Harbison wrote: > # HG changeset patch > # User Matt Harbison > # Date 1539380085 14400 > # Fri Oct 12 17:34:45 2018 -0400 > # Node ID 83dab13d625cd3fa2ce24801c9ee962d695045b8 > # Parent d6b7c4e77bb414fa27fed41e834423fca7d6ce63 > py3: use str to query registry values on Windows Queued, thanks. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH] run-tests: restore quoting the python executable for running *.py tests
# HG changeset patch # User Matt Harbison # Date 1539486509 14400 # Sat Oct 13 23:08:29 2018 -0400 # Node ID b94bd76195a7474b2493b362f47550b179d79aa3 # Parent fb97b23d9256601538396ea49c8284219992fe99 run-tests: restore quoting the python executable for running *.py tests This was accidentally dropped in 8cf459d8b111. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -1219,7 +1219,8 @@ class PythonTest(Test): def _run(self, env): py3switch = self._py3warnings and b' -3' or b'' -cmd = b'%s%s "%s"' % (PYTHON, py3switch, self.path) +# Quote the python(3) executable for Windows +cmd = b'"%s"%s "%s"' % (PYTHON, py3switch, self.path) vlog("# Running", cmd) normalizenewlines = os.name == 'nt' result = self._runcommand(cmd, env, ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH] tests: replace `cd ..` with an absolute path in a couple ssh tests
# HG changeset patch # User Matt Harbison # Date 1539474573 14400 # Sat Oct 13 19:49:33 2018 -0400 # Node ID fb97b23d9256601538396ea49c8284219992fe99 # Parent 83dab13d625cd3fa2ce24801c9ee962d695045b8 tests: replace `cd ..` with an absolute path in a couple ssh tests These tests are broken under py3 on Windows to the point where the `cd ..` was actually escaping into the system wide $TEMP. The subsequent `hg init` created a repo there, and then added a local extension to the hgrc. This breaks every single subsequent test when it tries to `hg init` in its $TESTTMP, and can't load the localwrite.py extension. And since I botched this the first time and replaced the wrong `cd ..`, this just replaces all of them. I've noticed test garbage in $TEMP recently, and maybe this will help. Perhaps `hg init` shouldn't load the config for the local repo, but this is an easy enough workaround for now. diff --git a/tests/test-ssh-bundle1.t b/tests/test-ssh-bundle1.t --- a/tests/test-ssh-bundle1.t +++ b/tests/test-ssh-bundle1.t @@ -48,7 +48,7 @@ configure for serving > [hooks] > changegroup = sh -c "printenv.py changegroup-in-remote 0 ../dummylog" > EOF - $ cd .. + $ cd $TESTTMP repo not found error @@ -87,7 +87,7 @@ clone remote via stream checked 3 changesets with 2 changes to 2 files $ hg branches default0:1160648e36ce - $ cd .. + $ cd $TESTTMP clone bookmarks via stream @@ -103,7 +103,7 @@ clone bookmarks via stream $ cd stream2 $ hg book mybook0:1160648e36ce - $ cd .. + $ cd $TESTTMP $ rm -rf local-stream stream2 #endif @@ -210,7 +210,7 @@ push remote: adding manifests remote: adding file changes remote: added 1 changesets with 1 changes to 1 files - $ cd ../remote + $ cd $TESTTMP/remote check remote tip @@ -236,7 +236,7 @@ check remote tip test pushkeys and bookmarks - $ cd ../local + $ cd $TESTTMP/local $ hg debugpushkey --config ui.ssh="\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote namespaces bookmarks namespaces @@ -343,7 +343,7 @@ results here) abort: password in URL not supported! [255] - $ cd .. + $ cd $TESTTMP hide outer repo $ hg init @@ -433,7 +433,7 @@ Test hg-ssh in read-only mode: updating 6c0482d977a3 to public failed! [1] - $ cd .. + $ cd $TESTTMP stderr from remote commands should be printed before stdout from local code (issue4336) @@ -500,7 +500,7 @@ debug output received listkey for "phases": 15 bytes checking for updated bookmarks - $ cd .. + $ cd $TESTTMP $ cat dummylog Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio diff --git a/tests/test-ssh.t b/tests/test-ssh.t --- a/tests/test-ssh.t +++ b/tests/test-ssh.t @@ -38,7 +38,7 @@ configure for serving > [hooks] > changegroup = sh -c "printenv.py changegroup-in-remote 0 ../dummylog" > EOF - $ cd .. + $ cd $TESTTMP repo not found error @@ -73,7 +73,7 @@ clone remote via stream checked 3 changesets with 2 changes to 2 files $ hg branches default0:1160648e36ce - $ cd .. + $ cd $TESTTMP clone bookmarks via stream @@ -87,7 +87,7 @@ clone bookmarks via stream $ cd stream2 $ hg book mybook0:1160648e36ce - $ cd .. + $ cd $TESTTMP $ rm -rf local-stream stream2 #endif @@ -194,7 +194,7 @@ push remote: adding manifests remote: adding file changes remote: added 1 changesets with 1 changes to 1 files - $ cd ../remote + $ cd $TESTTMP/remote check remote tip @@ -220,7 +220,7 @@ check remote tip test pushkeys and bookmarks - $ cd ../local + $ cd $TESTTMP/local $ hg debugpushkey --config ui.ssh="\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote namespaces bookmarks namespaces @@ -359,7 +359,7 @@ results here) abort: password in URL not supported! [255] - $ cd .. + $ cd $TESTTMP hide outer repo $ hg init @@ -460,7 +460,7 @@ Test hg-ssh in read-only mode: abort: push failed on remote [255] - $ cd .. + $ cd $TESTTMP stderr from remote commands should be printed before stdout from local code (issue4336) @@ -549,7 +549,7 @@ debug output bundle2-input-bundle: 2 parts total checking for updated bookmarks - $ cd .. + $ cd $TESTTMP $ cat dummylog Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH V2] py3: use str to query registry values on Windows
# HG changeset patch # User Matt Harbison # Date 1539380085 14400 # Fri Oct 12 17:34:45 2018 -0400 # Node ID 83dab13d625cd3fa2ce24801c9ee962d695045b8 # Parent d6b7c4e77bb414fa27fed41e834423fca7d6ce63 py3: use str to query registry values on Windows This blew up launching any command if extdiff processed a tool with a regkey config. diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -583,7 +583,8 @@ def lookupreg(key, valname=None, scope=N for s in scope: try: with winreg.OpenKey(s, encoding.strfromlocal(key)) as hkey: -val = winreg.QueryValueEx(hkey, valname)[0] +name = valname and encoding.strfromlocal(valname) or valname +val = winreg.QueryValueEx(hkey, name)[0] # never let a Unicode string escape into the wild return encoding.unitolocal(val) except EnvironmentError: ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 2 V4] revlog: allow flag processors to be applied via store options
# HG changeset patch # User Matt Harbison # Date 1539136401 14400 # Tue Oct 09 21:53:21 2018 -0400 # Node ID 222cf88a686a2fb818c4c440250be10625b4fdeb # Parent 8f192f2c4a1e04ac69dec66c48efcb96bc738533 revlog: allow flag processors to be applied via store options This allows flag processors to be registered to specific repos in an extension by wrapping localrepo.resolverevlogstorevfsoptions(). I wanted to add the processors via a function on localrepo, but some of the places where the processors are globally registered don't have a repository available. This makes targeting specific repos in the wrapper awkward, but still manageable. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -708,6 +708,7 @@ def resolverevlogstorevfsoptions(ui, req """Resolve opener options specific to revlogs.""" options = {} +options[b'flagprocessors'] = {} if b'revlogv1' in requirements: options[b'revlogv1'] = True diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -151,16 +151,19 @@ def addflagprocessor(flag, processor): debug commands. In this case the transform only indicates whether the contents can be used for hash integrity checks. """ +_insertflagprocessor(flag, processor, _flagprocessors) + +def _insertflagprocessor(flag, processor, flagprocessors): if not flag & REVIDX_KNOWN_FLAGS: msg = _("cannot register processor on unknown flag '%#x'.") % (flag) raise error.ProgrammingError(msg) if flag not in REVIDX_FLAGS_ORDER: msg = _("flag '%#x' undefined in REVIDX_FLAGS_ORDER.") % (flag) raise error.ProgrammingError(msg) -if flag in _flagprocessors: +if flag in flagprocessors: msg = _("cannot register multiple processors on flag '%#x'.") % (flag) raise error.Abort(msg) -_flagprocessors[flag] = processor +flagprocessors[flag] = processor def getoffset(q): return int(q >> 16) @@ -408,6 +411,10 @@ class revlog(object): if opts.get('enableellipsis'): self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor +# revlog v0 doesn't have flag processors +for flag, processor in opts.get(b'flagprocessors', {}).iteritems(): +_insertflagprocessor(flag, processor, self._flagprocessors) + if self._chunkcachesize <= 0: raise error.RevlogError(_('revlog chunk cache size %r is not ' 'greater than 0') % self._chunkcachesize) diff --git a/tests/test-flagprocessor.t b/tests/test-flagprocessor.t --- a/tests/test-flagprocessor.t +++ b/tests/test-flagprocessor.t @@ -206,6 +206,8 @@ Ensure the data got to the server OK File "*/tests/flagprocessorext.py", line *, in extsetup (glob) validatehash, File "*/mercurial/revlog.py", line *, in addflagprocessor (glob) + _insertflagprocessor(flag, processor, _flagprocessors) +File "*/mercurial/revlog.py", line *, in _insertflagprocessor (glob) raise error.Abort(msg) Abort: cannot register multiple processors on flag '0x8'. *** failed to set up extension duplicate: cannot register multiple processors on flag '0x8'. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 2 V4] lfs: register the flag processors per repository
# HG changeset patch # User Matt Harbison # Date 1538626646 14400 # Thu Oct 04 00:17:26 2018 -0400 # Node ID b382006ec3f07f3e21dc55870c2d8a9100528a4b # Parent 222cf88a686a2fb818c4c440250be10625b4fdeb lfs: register the flag processors per repository Previously, enabling the extension for any repo in commandserver or hgweb would enable the flags on all repos. Since localrepo.resolverevlogstorevfsoptions() is called so early, the check to see if the extension is enabled on the repo (which hasn't been instantiated yet) is a bit awkward. But I don't see a better way. diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py --- a/hgext/lfs/__init__.py +++ b/hgext/lfs/__init__.py @@ -124,6 +124,8 @@ Configs:: from __future__ import absolute_import +import sys + from mercurial.i18n import _ from mercurial import ( @@ -204,6 +206,12 @@ command = registrar.command(cmdtable) templatekeyword = registrar.templatekeyword() filesetpredicate = registrar.filesetpredicate() +lfsprocessor = ( +wrapper.readfromstore, +wrapper.writetostore, +wrapper.bypasscheckhash, +) + def featuresetup(ui, supported): # don't die on seeing a repo with the lfs requirement supported |= {'lfs'} @@ -302,12 +310,28 @@ def wrapfilelog(filelog): wrapfunction(filelog, 'renamed', wrapper.filelogrenamed) wrapfunction(filelog, 'size', wrapper.filelogsize) +def _resolverevlogstorevfsoptions(orig, ui, requirements, features): +opts = orig(ui, requirements, features) +for name, module in extensions.extensions(ui): +if module is sys.modules[__name__]: +if revlog.REVIDX_EXTSTORED in opts[b'flagprocessors']: +msg = (_(b"cannot register multiple processors on flag '%#x'.") + % revlog.REVIDX_EXTSTORED) +raise error.Abort(msg) + +opts[b'flagprocessors'][revlog.REVIDX_EXTSTORED] = lfsprocessor +break + +return opts + def extsetup(ui): wrapfilelog(filelog.filelog) wrapfunction = extensions.wrapfunction wrapfunction(localrepo, 'makefilestorage', wrapper.localrepomakefilestorage) +wrapfunction(localrepo, 'resolverevlogstorevfsoptions', + _resolverevlogstorevfsoptions) wrapfunction(cmdutil, '_updatecatformatter', wrapper._updatecatformatter) wrapfunction(scmutil, 'wrapconvertsink', wrapper.convertsink) @@ -334,15 +358,6 @@ def extsetup(ui): wrapfunction(context.basefilectx, 'isbinary', wrapper.filectxisbinary) context.basefilectx.islfs = wrapper.filectxislfs -revlog.addflagprocessor( -revlog.REVIDX_EXTSTORED, -( -wrapper.readfromstore, -wrapper.writetostore, -wrapper.bypasscheckhash, -), -) - scmutil.fileprefetchhooks.add('lfs', wrapper._prefetchfiles) # Make bundle choose changegroup3 instead of changegroup2. This affects diff --git a/tests/test-lfs-serve.t b/tests/test-lfs-serve.t --- a/tests/test-lfs-serve.t +++ b/tests/test-lfs-serve.t @@ -35,6 +35,26 @@ make command server magic visible $ hg init server $ SERVER_REQUIRES="$TESTTMP/server/.hg/requires" + $ cat > $TESTTMP/debugprocessors.py < from mercurial import ( + > cmdutil, + > commands, + > pycompat, + > registrar, + > ) + > cmdtable = {} + > command = registrar.command(cmdtable) + > @command(b'debugprocessors', [], b'FILE') + > def debugprocessors(ui, repo, file_=None, **opts): + > opts = pycompat.byteskwargs(opts) + > opts[b'changelog'] = False + > opts[b'manifest'] = False + > opts[b'dir'] = False + > rl = cmdutil.openrevlog(repo, b'debugprocessors', file_, opts) + > for flag, proc in rl._flagprocessors.iteritems(): + > ui.status(b"registered processor '%#x'\n" % (flag)) + > EOF + Skip the experimental.changegroup3=True config. Failure to agree on this comes first, and causes a "ValueError: no common changegroup version" or "abort: HTTP Error 500: Internal Server Error", if the extension is only loaded on one @@ -42,6 +62,8 @@ side. If that *is* enabled, the subsequ for flag '0x2000'!" if the extension is only loaded on one side (possibly also masked by the Internal Server Error message). $ cat >> $HGRCPATH < [extensions] + > debugprocessors = $TESTTMP/debugprocessors.py > [experimental] > lfs.disableusercache = True > [lfs] @@ -51,6 +73,8 @@ masked by the Internal Server Error mess > push_ssl=False > EOF + $ cp $HGRCPATH $HGRCPATH.orig + #if lfsremote-on $ hg --config extensions.lfs= -R server \ >serve -p $HGPORT -d --pid-file=hg.pid --errorlog=$TESTTMP/errors.log @@ -307,6 +331,103 @@ lfs content, and the extension enabled. $ hg identify http://localhost:$HGPORT c729025cc5e3 + $ mv $HGRCPATH $HGRCPATH.tmp + $ cp $HGRCPATH.orig $HGRCPATH + + >>> from __future__ import absolute_import + >>> from hgclient import check, readchannel, runcommand + >>> @check + ... def
mercurial@40170: 19 new changesets
19 new changesets in mercurial: https://www.mercurial-scm.org/repo/hg/rev/adbf8ca239e4 changeset: 40152:adbf8ca239e4 user:Yuya Nishihara date:Fri Oct 12 06:22:43 2018 +0200 summary: revlog: optimize ancestors() to not check filtered revisions for each https://www.mercurial-scm.org/repo/hg/rev/0ae20d2141ed changeset: 40153:0ae20d2141ed user:Gregory Szorc date:Thu Oct 11 21:05:03 2018 +0200 summary: py3: use b'' in test-check-interfaces.py https://www.mercurial-scm.org/repo/hg/rev/fe11fc7e541f changeset: 40154:fe11fc7e541f user:Gregory Szorc date:Thu Oct 11 21:18:58 2018 +0200 summary: py3: encode JSON str to bytes https://www.mercurial-scm.org/repo/hg/rev/0199fb5dde20 changeset: 40155:0199fb5dde20 user:Gregory Szorc date:Thu Oct 11 21:22:43 2018 +0200 summary: py3: byteify hgweberror.py https://www.mercurial-scm.org/repo/hg/rev/5716d48b2a5b changeset: 40156:5716d48b2a5b user:Gregory Szorc date:Thu Oct 11 22:01:54 2018 +0200 summary: py3: convert diff opcode name to bytes https://www.mercurial-scm.org/repo/hg/rev/a8be613391d1 changeset: 40157:a8be613391d1 user:Gregory Szorc date:Thu Oct 11 22:27:52 2018 +0200 summary: py3: use bytes literal in test-hgweb-json.t https://www.mercurial-scm.org/repo/hg/rev/9310037f0636 changeset: 40158:9310037f0636 user:Gregory Szorc date:Thu Oct 11 21:47:39 2018 +0200 summary: py3: pass str and return bytes from mimetypes.guess_type() https://www.mercurial-scm.org/repo/hg/rev/5774fc623a18 changeset: 40159:5774fc623a18 user:Gregory Szorc date:Thu Oct 11 22:26:12 2018 +0200 summary: py3: coerce bytestr to bytes to appease urllib.parse.quote_from_bytes() https://www.mercurial-scm.org/repo/hg/rev/6037c49b8964 changeset: 40160:6037c49b8964 user:Gregory Szorc date:Thu Oct 11 22:53:44 2018 +0200 summary: py3: use .+ instead of .* in regexp pattern https://www.mercurial-scm.org/repo/hg/rev/3eea8e83c261 changeset: 40161:3eea8e83c261 user:Gregory Szorc date:Thu Oct 11 23:07:23 2018 +0200 summary: py3: tweak stdout writing in test-hgweb-no-path-info.t https://www.mercurial-scm.org/repo/hg/rev/80a4c60513bc changeset: 40162:80a4c60513bc user:Augie Fackler date:Fri Oct 12 06:35:33 2018 -0400 summary: py3: sort passing test list https://www.mercurial-scm.org/repo/hg/rev/9f0ee4a60d65 changeset: 40163:9f0ee4a60d65 user:Augie Fackler date:Fri Oct 12 06:39:32 2018 -0400 summary: tests: ensure the python 3 passing test list stays sorted https://www.mercurial-scm.org/repo/hg/rev/fee616937ef3 changeset: 40164:fee616937ef3 user:Augie Fackler date:Fri Oct 12 06:22:15 2018 -0400 summary: obsolete: convert error string to a sysstr https://www.mercurial-scm.org/repo/hg/rev/7d1ba539bbb6 changeset: 40165:7d1ba539bbb6 user:Augie Fackler date:Fri Oct 12 06:35:55 2018 -0400 summary: py3: whitelist another passing test https://www.mercurial-scm.org/repo/hg/rev/11727e38a920 changeset: 40166:11727e38a920 user:Augie Fackler date:Fri Oct 12 06:50:46 2018 -0400 summary: py3: more passing tests https://www.mercurial-scm.org/repo/hg/rev/c554dc0cc16e changeset: 40167:c554dc0cc16e user:Augie Fackler date:Fri Oct 12 06:50:01 2018 -0400 summary: scmutil: wrap locker information in bytestr before repr()ing it https://www.mercurial-scm.org/repo/hg/rev/5b8bab9a7e07 changeset: 40168:5b8bab9a7e07 user:Augie Fackler date:Fri Oct 12 06:55:11 2018 -0400 summary: py3: one more passing test https://www.mercurial-scm.org/repo/hg/rev/461583f2125b changeset: 40169:461583f2125b user:Augie Fackler date:Fri Oct 12 09:23:55 2018 -0400 summary: py3: another one started passing https://www.mercurial-scm.org/repo/hg/rev/f7ff5b4fe745 changeset: 40170:f7ff5b4fe745 bookmark:@ tag: tip user:Gregory Szorc date:Thu Oct 11 09:26:05 2018 +0200 summary: tests: use baseurl instead of advertisedbaseurl -- 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
D5086: churn: remove redundant round()
yuja added a comment. > def charnum(count): > > - return int(round(count * width // maxcount)) +return int(count * width // maxcount) We're doing floating-point division as `maxcount` is float. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5086 To: durin42, #hg-reviewers, pulkit Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D5086: churn: remove redundant round()
> def charnum(count): > -return int(round(count * width // maxcount)) > +return int(count * width // maxcount) We're doing floating-point division as `maxcount` is float. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5089: py3: fix test-status.t
pulkit added inline comments. INLINE COMMENTS > test-status.t:540 >status = [ > - {*'path': '1/2/3/4/5/b.txt'*}, (glob) > + {*'path': *'1/2/3/4/5/b.txt'*}, (glob) >] are we hiding a b'' prefix here? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5089 To: mbthomas, #hg-reviewers, pulkit Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5089: py3: fix test-status.t
mbthomas updated this revision to Diff 12098. mbthomas added a comment. Herald added a reviewer: pulkit. Add to whitelist REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5089?vs=12097=12098 BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D5089 AFFECTED FILES contrib/python3-whitelist 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 @@ -272,8 +272,17 @@ $ hg status -A -Tpickle > pickle >>> from __future__ import print_function >>> import pickle - >>> print(sorted((x['status'], x['path']) for x in pickle.load(open("pickle" - [('!', 'deleted'), ('?', 'pickle'), ('?', 'unknown'), ('A', 'added'), ('A', 'copied'), ('C', '.hgignore'), ('C', 'modified'), ('I', 'ignored'), ('R', 'removed')] + >>> data = sorted((x[b'status'].decode(), x[b'path'].decode()) for x in pickle.load(open("pickle", r"rb"))) + >>> for s, p in data: print("%s %s" % (s, p)) + ! deleted + ? pickle + ? unknown + A added + A copied + C .hgignore + C modified + I ignored + R removed $ rm pickle $ echo "^ignoreddir$" > .hgignore @@ -528,7 +537,7 @@ $ hg status --config ui.formatdebug=True --rev 1 1 status = [ - {*'path': '1/2/3/4/5/b.txt'*}, (glob) + {*'path': *'1/2/3/4/5/b.txt'*}, (glob) ] #if windows diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -529,6 +529,7 @@ test-status-inprocess.py test-status-rev.t test-status-terse.t +test-status.t test-storage.py test-stream-bundle-v2.t test-strict.t To: mbthomas, #hg-reviewers, pulkit Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5089: py3: fix test-status.t
mbthomas 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/D5089 AFFECTED FILES 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 @@ -272,8 +272,17 @@ $ hg status -A -Tpickle > pickle >>> from __future__ import print_function >>> import pickle - >>> print(sorted((x['status'], x['path']) for x in pickle.load(open("pickle" - [('!', 'deleted'), ('?', 'pickle'), ('?', 'unknown'), ('A', 'added'), ('A', 'copied'), ('C', '.hgignore'), ('C', 'modified'), ('I', 'ignored'), ('R', 'removed')] + >>> data = sorted((x[b'status'].decode(), x[b'path'].decode()) for x in pickle.load(open("pickle", r"rb"))) + >>> for s, p in data: print("%s %s" % (s, p)) + ! deleted + ? pickle + ? unknown + A added + A copied + C .hgignore + C modified + I ignored + R removed $ rm pickle $ echo "^ignoreddir$" > .hgignore @@ -528,7 +537,7 @@ $ hg status --config ui.formatdebug=True --rev 1 1 status = [ - {*'path': '1/2/3/4/5/b.txt'*}, (glob) + {*'path': *'1/2/3/4/5/b.txt'*}, (glob) ] #if windows To: mbthomas, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] py3: convert "usage" literal to bytes
On Sat, Oct 13, 2018 at 6:10 PM Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara > # Date 1539442648 -7200 > # Sat Oct 13 16:57:28 2018 +0200 > # Node ID e0182e9af70995e3a08d5c04f3384a275f9d8092 > # Parent c8f1640612121c04c8971a8357a5b978bfbde0f9 > py3: convert "usage" literal to bytes > > Here _() is practically an identity function, but we shouldn't pass in > unicode to _(). > Queued this patch, many thanks! ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH] py3: convert "usage" literal to bytes
# HG changeset patch # User Yuya Nishihara # Date 1539442648 -7200 # Sat Oct 13 16:57:28 2018 +0200 # Node ID e0182e9af70995e3a08d5c04f3384a275f9d8092 # Parent c8f1640612121c04c8971a8357a5b978bfbde0f9 py3: convert "usage" literal to bytes Here _() is practically an identity function, but we shouldn't pass in unicode to _(). diff --git a/contrib/simplemerge b/contrib/simplemerge --- a/contrib/simplemerge +++ b/contrib/simplemerge @@ -28,7 +28,7 @@ options = [(b'L', b'label', [], _(b'labe (b'h', b'help', None, _(b'display help and exit')), (b'q', b'quiet', None, _(b'suppress output'))] -usage = _('''simplemerge [OPTS] LOCAL BASE OTHER +usage = _(b'''simplemerge [OPTS] LOCAL BASE OTHER Simple three-way file merge utility with a minimal feature set. @@ -41,7 +41,7 @@ class ParseError(Exception): """Exception raised on errors in parsing the command line.""" def showhelp(): -pycompat.stdout.write(usage.encode('utf8')) +pycompat.stdout.write(usage) pycompat.stdout.write(b'\noptions:\n') out_opts = [] ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5088: hghave: add pyXY features for Python version numbers
indygreg updated this revision to Diff 12096. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5088?vs=12095=12096 REVISION DETAIL https://phab.mercurial-scm.org/D5088 AFFECTED FILES tests/hghave.py CHANGE DETAILS diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -641,6 +641,13 @@ # chg disables demandimport intentionally for performance wins. return ((not has_chg()) and os.environ.get('HGDEMANDIMPORT') != 'disable') +@checkvers("py", "Python >= %s", (2.7, 3.5, 3.6, 3.7, 3.8, 3.9)) +def has_python_range(v): +major, minor = v.split('.')[0:2] +py_major, py_minor = sys.version_info.major, sys.version_info.minor + +return (py_major, py_minor) >= (int(major), int(minor)) + @check("py3", "running with Python 3.x") def has_py3(): return 3 == sys.version_info[0] To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5088: hghave: add pyXY features for Python version numbers
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This will allow us to sniff for Python >= versions in tests. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5088 AFFECTED FILES tests/hghave.py CHANGE DETAILS diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -641,6 +641,13 @@ # chg disables demandimport intentionally for performance wins. return ((not has_chg()) and os.environ.get('HGDEMANDIMPORT') != 'disable') +@checkvers("py", "Python >= %s", (2.7, 3.5, 3.6, 3.7, 3.8, 3.9)) +def has_python_range(v): +major, minor = v.split('.')[0:2] +py_major, py_minor = sys.version_info.major, sys.version_info.minor + +return (py_major, py_minor) >= (int(major), int(minor)) + @check("py3k", "running with Python 3.x") def has_py3k(): return 3 == sys.version_info[0] To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5075: tests: accept slightly different zip file in Python 3
indygreg added a comment. https://github.com/python/cpython/commit/44989bc2696320cf55ae6f329aaf58edd49d792a is likely the commit introducing the divergence. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5075 To: durin42, pulkit, #hg-reviewers Cc: indygreg, yuja, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5086: churn: remove redundant round()
This revision was automatically updated to reflect the committed changes. Closed by commit rHG12e2e5cd5777: churn: remove redundant round() (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5086?vs=12090=12094 REVISION DETAIL https://phab.mercurial-scm.org/D5086 AFFECTED FILES hgext/churn.py CHANGE DETAILS diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -205,7 +205,7 @@ '*' * charnum(sum(count))) def charnum(count): -return int(round(count * width // maxcount)) +return int(count * width // maxcount) for name, count in rate: ui.write(format(name, count)) To: durin42, #hg-reviewers, pulkit Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5075: tests: accept slightly different zip file in Python 3
indygreg added a comment. Behavior changed between Python 3.6 and Python 3.7. We should add `pyXX` hghave capabilities to differentiate on Python versions. Or we could annotate all possible lines with `(?)` (optional output). The hghave approach is better. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5075 To: durin42, pulkit, #hg-reviewers Cc: indygreg, yuja, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5079: py3: use py3 as the test tag, dropping the k
This revision was automatically updated to reflect the committed changes. Closed by commit rHG8cf459d8b111: py3: use py3 as the test tag, dropping the k (authored by mjpieters, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5079?vs=12091=12093 REVISION DETAIL https://phab.mercurial-scm.org/D5079 AFFECTED FILES mercurial/help.py tests/hghave.py tests/run-tests.py tests/test-archive.t tests/test-bad-extension.t tests/test-check-py3-compat.t tests/test-debugcommands.t tests/test-extension.t tests/test-globalopts.t CHANGE DETAILS diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t --- a/tests/test-globalopts.t +++ b/tests/test-globalopts.t @@ -267,7 +267,7 @@ #if no-chg $ hg --cwd c --config x --traceback id 2>&1 | grep -i 'traceback' Traceback (most recent call last): - Traceback (most recent call last): (py3k !) + Traceback (most recent call last): (py3 !) #else Traceback for '--config' errors not supported with chg. $ hg --cwd c --config x --traceback id 2>&1 | grep -i 'traceback' diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -222,7 +222,7 @@ ambigabs.s=libroot/ambig.py $TESTTMP/a -#if no-py3k +#if no-py3 $ cat > $TESTTMP/libroot/mod/ambigrel.py < from __future__ import print_function > import ambig # should load "libroot/mod/ambig.py" @@ -290,7 +290,7 @@ (extroot) import extroot.bar in func(): this is extroot.bar $TESTTMP/a -#if no-py3k +#if no-py3 $ rm "$TESTTMP"/extroot/foo.* $ rm -Rf "$TESTTMP/extroot/__pycache__" $ cat > $TESTTMP/extroot/foo.py < -X hgdemandimport/demandimportpy2.py \ > -X mercurial/thirdparty/cbor \ @@ -24,7 +24,7 @@ setup.py not using absolute_import #endif -#if py3k +#if py3 $ testrepohg files 'set:(**.py) - grep(pygments)' \ > -X hgdemandimport/demandimportpy2.py \ > -X hgext/fsmonitor/pywatchman \ @@ -41,7 +41,7 @@ mercurial/scmposix.py: error importing: No module named 'fcntl' (error at scmposix.py:*) (windows !) #endif -#if py3k pygments +#if py3 pygments $ testrepohg files 'set:(**.py) and grep(pygments)' | sed 's|\\|/|g' \ > | xargs "$PYTHON" contrib/check-py3-compat.py \ > | sed 's/[0-9][0-9]*)$/*)/' diff --git a/tests/test-bad-extension.t b/tests/test-bad-extension.t --- a/tests/test-bad-extension.t +++ b/tests/test-bad-extension.t @@ -57,12 +57,12 @@ Exception: bit bucket overflow *** failed to import extension badext2: No module named *badext2* (glob) Traceback (most recent call last): - ImportError: No module named badext2 (no-py3k !) - ModuleNotFoundError: No module named 'hgext.badext2' (py3k !) - Traceback (most recent call last): (py3k !) - ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3k !) - Traceback (most recent call last): (py3k !) - ModuleNotFoundError: No module named 'badext2' (py3k !) + ImportError: No module named badext2 (no-py3 !) + ModuleNotFoundError: No module named 'hgext.badext2' (py3 !) + Traceback (most recent call last): (py3 !) + ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3 !) + Traceback (most recent call last): (py3 !) + ModuleNotFoundError: No module named 'badext2' (py3 !) names of extensions failed to load can be accessed via extensions.notloaded() @@ -102,22 +102,22 @@ debug.extensions: - loading extension: 'badext2' debug.extensions: - could not import hgext.badext2 (No module named *badext2*): trying hgext3rd.badext2 (glob) Traceback (most recent call last): - ImportError: No module named badext2 (no-py3k !) - ModuleNotFoundError: No module named 'hgext.badext2' (py3k !) + ImportError: No module named badext2 (no-py3 !) + ModuleNotFoundError: No module named 'hgext.badext2' (py3 !) debug.extensions: - could not import hgext3rd.badext2 (No module named *badext2*): trying badext2 (glob) Traceback (most recent call last): - ImportError: No module named badext2 (no-py3k !) - ModuleNotFoundError: No module named 'hgext.badext2' (py3k !) - Traceback (most recent call last): (py3k !) - ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3k !) + ImportError: No module named badext2 (no-py3 !) + ModuleNotFoundError: No module named 'hgext.badext2' (py3 !) + Traceback (most recent call last): (py3 !) + ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3 !) *** failed to import extension badext2: No module named *badext2* (glob) Traceback (most recent call last): - ModuleNotFoundError: No module named 'hgext.badext2' (py3k !) - Traceback (most recent call last): (py3k !) - ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3k !) - Traceback (most recent call last): (py3k !) - ModuleNotFoundError: No module named 'badext2' (py3k !) - ImportError: No module named badext2 (no-py3k !) + ModuleNotFoundError: No module named 'hgext.badext2' (py3 !) + Traceback (most recent call
D5079: py3: use py3 as the test tag, dropping the k
mjpieters added a comment. Note: I undid the change to `mercurial/thirdparty/zope/interface/_compat.py` as it should not have been changed to begin with. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5079 To: mjpieters, #hg-reviewers, pulkit, durin42 Cc: durin42, pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5079: py3: use py3 as the test tag, dropping the k
mjpieters updated this revision to Diff 12091. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5079?vs=12068=12091 REVISION DETAIL https://phab.mercurial-scm.org/D5079 AFFECTED FILES mercurial/help.py tests/hghave.py tests/run-tests.py tests/test-archive.t tests/test-bad-extension.t tests/test-check-py3-compat.t tests/test-debugcommands.t tests/test-extension.t tests/test-globalopts.t CHANGE DETAILS diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t --- a/tests/test-globalopts.t +++ b/tests/test-globalopts.t @@ -267,7 +267,7 @@ #if no-chg $ hg --cwd c --config x --traceback id 2>&1 | grep -i 'traceback' Traceback (most recent call last): - Traceback (most recent call last): (py3k !) + Traceback (most recent call last): (py3 !) #else Traceback for '--config' errors not supported with chg. $ hg --cwd c --config x --traceback id 2>&1 | grep -i 'traceback' diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -222,7 +222,7 @@ ambigabs.s=libroot/ambig.py $TESTTMP/a -#if no-py3k +#if no-py3 $ cat > $TESTTMP/libroot/mod/ambigrel.py < from __future__ import print_function > import ambig # should load "libroot/mod/ambig.py" @@ -290,7 +290,7 @@ (extroot) import extroot.bar in func(): this is extroot.bar $TESTTMP/a -#if no-py3k +#if no-py3 $ rm "$TESTTMP"/extroot/foo.* $ rm -Rf "$TESTTMP/extroot/__pycache__" $ cat > $TESTTMP/extroot/foo.py < -X hgdemandimport/demandimportpy2.py \ > -X mercurial/thirdparty/cbor \ @@ -24,7 +24,7 @@ setup.py not using absolute_import #endif -#if py3k +#if py3 $ testrepohg files 'set:(**.py) - grep(pygments)' \ > -X hgdemandimport/demandimportpy2.py \ > -X hgext/fsmonitor/pywatchman \ @@ -41,7 +41,7 @@ mercurial/scmposix.py: error importing: No module named 'fcntl' (error at scmposix.py:*) (windows !) #endif -#if py3k pygments +#if py3 pygments $ testrepohg files 'set:(**.py) and grep(pygments)' | sed 's|\\|/|g' \ > | xargs "$PYTHON" contrib/check-py3-compat.py \ > | sed 's/[0-9][0-9]*)$/*)/' diff --git a/tests/test-bad-extension.t b/tests/test-bad-extension.t --- a/tests/test-bad-extension.t +++ b/tests/test-bad-extension.t @@ -57,12 +57,12 @@ Exception: bit bucket overflow *** failed to import extension badext2: No module named *badext2* (glob) Traceback (most recent call last): - ImportError: No module named badext2 (no-py3k !) - ModuleNotFoundError: No module named 'hgext.badext2' (py3k !) - Traceback (most recent call last): (py3k !) - ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3k !) - Traceback (most recent call last): (py3k !) - ModuleNotFoundError: No module named 'badext2' (py3k !) + ImportError: No module named badext2 (no-py3 !) + ModuleNotFoundError: No module named 'hgext.badext2' (py3 !) + Traceback (most recent call last): (py3 !) + ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3 !) + Traceback (most recent call last): (py3 !) + ModuleNotFoundError: No module named 'badext2' (py3 !) names of extensions failed to load can be accessed via extensions.notloaded() @@ -102,22 +102,22 @@ debug.extensions: - loading extension: 'badext2' debug.extensions: - could not import hgext.badext2 (No module named *badext2*): trying hgext3rd.badext2 (glob) Traceback (most recent call last): - ImportError: No module named badext2 (no-py3k !) - ModuleNotFoundError: No module named 'hgext.badext2' (py3k !) + ImportError: No module named badext2 (no-py3 !) + ModuleNotFoundError: No module named 'hgext.badext2' (py3 !) debug.extensions: - could not import hgext3rd.badext2 (No module named *badext2*): trying badext2 (glob) Traceback (most recent call last): - ImportError: No module named badext2 (no-py3k !) - ModuleNotFoundError: No module named 'hgext.badext2' (py3k !) - Traceback (most recent call last): (py3k !) - ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3k !) + ImportError: No module named badext2 (no-py3 !) + ModuleNotFoundError: No module named 'hgext.badext2' (py3 !) + Traceback (most recent call last): (py3 !) + ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3 !) *** failed to import extension badext2: No module named *badext2* (glob) Traceback (most recent call last): - ModuleNotFoundError: No module named 'hgext.badext2' (py3k !) - Traceback (most recent call last): (py3k !) - ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3k !) - Traceback (most recent call last): (py3k !) - ModuleNotFoundError: No module named 'badext2' (py3k !) - ImportError: No module named badext2 (no-py3k !) + ModuleNotFoundError: No module named 'hgext.badext2' (py3 !) + Traceback (most recent call last): (py3 !) + ModuleNotFoundError: No module named 'hgext3rd.badext2' (py3 !) + Traceback (most recent call last): (py3 !) +
D5075: tests: accept slightly different zip file in Python 3
durin42 added a comment. In https://phab.mercurial-scm.org/D5075#76125, @pulkit wrote: > In https://phab.mercurial-scm.org/D5075#76117, @yuja wrote: > > > > - body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 + body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 (no-py3k !) + body: size=1461, sha1=be6d3983aa13dfe930361b2569291cdedd02b537 (py3k !) > > > > For some reason, my Python 3 says > > `size=1489, sha1=1897e496871aa89ad685a92b936f5fa0d008b9e8` > > > I suspect it's because we have different versions on Python 3. Ugh. Should we just glob the size and sha1 then? I'm a little hesitant to do that, but I don't see many other paths forward... REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5075 To: durin42, pulkit, #hg-reviewers Cc: yuja, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5087: help: displaying documented aliases by default
rdamazio created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This makes aliases be displayed in "hg help" when they have a :doc config entry, and also allows them to be assigned to a category with :category. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5087 AFFECTED FILES mercurial/dispatch.py mercurial/help.py tests/test-alias.t tests/test-help.t CHANGE DETAILS diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -823,18 +823,38 @@ > def uisetup(ui): > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext') > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext') + > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext') + > ui.setconfig(b'alias', b'hgalias:category', b'Change navigation', b'helpext') + > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext') > > EOF $ echo '[extensions]' >> $HGRCPATH $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH Test for aliases + $ hg help | grep hgalias + hgalias My doc + $ hg help hgalias hg hgalias [--remote] alias for: hg summary + My doc + + defined by: helpext + + options: + +--remote check for push and pull + + (some details hidden, use --verbose to show complete help) + $ hg help hgaliasnodoc + hg hgaliasnodoc [--remote] + + alias for: hg summary + summarize working directory state This generates a brief summary of the working directory state, including @@ -947,6 +967,7 @@ bisectsubdivision search of changesets heads show branch heads + hgalias My doc identify identify the working directory or specified revision log show revision history of entire repository or files @@ -2660,6 +2681,13 @@ hgalias + My doc + + + + hgaliasnodoc + + summarize working directory state diff --git a/tests/test-alias.t b/tests/test-alias.t --- a/tests/test-alias.t +++ b/tests/test-alias.t @@ -68,17 +68,17 @@ help $ hg help -c | grep myinit - myinit This is my documented alias for init. + myinit This is my documented alias for init. $ hg help -c | grep mycommit - mycommit This is my alias with only doc. + mycommit This is my alias with only doc. $ hg help -c | grep cleanstatus - cleanstatusshow changed files in the working directory + [1] $ hg help -c | grep lognull - lognullLogs the null rev + lognull Logs the null rev $ hg help -c | grep dln - dlnLogs the null rev + [1] $ hg help -c | grep recursivedoc - recursivedoc Logs the null rev in debug mode + recursivedoc Logs the null rev in debug mode $ hg help myinit hg myinit [OPTIONS] [BLA] [BLE] @@ -602,7 +602,7 @@ help for a shell alias $ hg help -c | grep rebate - rebate This is my alias which just prints something. + rebate This is my alias which just prints something. $ hg help rebate hg rebate [MYARGS] diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -172,12 +172,25 @@ if notomitted: rst.append('\n\n.. container:: notomitted\n\n%s\n\n' % notomitted) -def filtercmd(ui, cmd, kw, doc): +def filtercmd(ui, cmd, func, kw, doc): if not ui.debugflag and cmd.startswith("debug") and kw != "debug": +# Debug command, and user is not looking for those. return True -if not ui.verbose and doc and any(w in doc for w in _exclkeywords): +if not ui.verbose: +if not kw and not doc: +# Command had no documentation, no point in showing it by default. +return True +if getattr(func, 'alias', False) and not getattr(func, 'owndoc', False): +# Alias didn't have its own documentation. +return True +if doc and any(w in doc for w in _exclkeywords): +# Documentation has excluded keywords. +return True +if kw == "shortlist" and not getattr(func, 'helpbasic', False): +# We're presenting the short list but the command is not basic. return True if ui.configbool('help', 'hide.%s' % cmd): +# Configuration explicitly hides the command. return True return False @@ -213,13 +226,14 @@ else: summary = '' # translate docs *before* searching there -docs = _(pycompat.getdoc(entry[0])) or '' +func = entry[0] +docs = _(pycompat.getdoc(func)) or '' if kw in cmd or lowercontains(summary) or lowercontains(docs): doclines = docs.splitlines() if doclines: summary = doclines[0] cmdname = cmdutil.parsealiases(cmd)[0] -if filtercmd(ui,
D5075: tests: accept slightly different zip file in Python 3
pulkit added a comment. In https://phab.mercurial-scm.org/D5075#76117, @yuja wrote: > > - body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 + body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 (no-py3k !) + body: size=1461, sha1=be6d3983aa13dfe930361b2569291cdedd02b537 (py3k !) > > For some reason, my Python 3 says > `size=1489, sha1=1897e496871aa89ad685a92b936f5fa0d008b9e8` I suspect it's because we have different versions on Python 3. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5075 To: durin42, pulkit, #hg-reviewers Cc: yuja, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 5 of 5 V3] rust: rustlazyancestors.__contains__
# HG changeset patch # User Georges Racinet # Date 1539018701 -7200 # Mon Oct 08 19:11:41 2018 +0200 # Node ID 5c3f0974b9afb074df9acd626813064eb6f2ffec # Parent 98f0f668f63b143eba344a74c8b22a0588f46935 # EXP-Topic rustancestors-contains rust: rustlazyancestors.__contains__ This changeset provides a Rust implementation of the iteration performed by lazyancestor.__contains__ It has the advantage over the Python iteration to use the 'seen' set encapsuled into the dedicated iterator (self._containsiter), rather than storing emitted items in another set (self._containsseen), and hence should reduce the memory footprint. Also, there's no need to convert intermediate emitted revisions back into Python integers. At this point, it would be tempting to implement the whole lazyancestor object in Rust, but that would lead to more C wrapping code (two objects) for little expected benefits. diff -r 98f0f668f63b -r 5c3f0974b9af mercurial/ancestor.py --- a/mercurial/ancestor.py Thu Sep 27 16:55:44 2018 +0200 +++ b/mercurial/ancestor.py Mon Oct 08 19:11:41 2018 +0200 @@ -383,7 +383,7 @@ self._containsiter = None return False -class rustlazyancestors(lazyancestors): +class rustlazyancestors(object): def __init__(self, index, revs, stoprev=0, inclusive=False): self._index = index @@ -395,12 +395,26 @@ # constructor (from C code) doesn't understand anything else yet self._initrevs = initrevs = list(revs) -self._containsseen = set() self._containsiter = parsers.rustlazyancestors( index, initrevs, stoprev, inclusive) +def __nonzero__(self): +"""False if the set is empty, True otherwise. + +It's better to duplicate this essentially trivial method than +to subclass lazyancestors +""" +try: +next(iter(self)) +return True +except StopIteration: +return False + def __iter__(self): return parsers.rustlazyancestors(self._index, self._initrevs, self._stoprev, self._inclusive) + +def __contains__(self, target): +return target in self._containsiter diff -r 98f0f668f63b -r 5c3f0974b9af mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c Thu Sep 27 16:55:44 2018 +0200 +++ b/mercurial/cext/revlog.c Mon Oct 08 19:11:41 2018 +0200 @@ -2316,6 +2316,7 @@ int inclusive); void rustlazyancestors_drop(rustlazyancestorsObject *self); int rustlazyancestors_next(rustlazyancestorsObject *self); +int rustlazyancestors_contains(rustlazyancestorsObject *self, long rev); /* CPython instance methods */ static int rustla_init(rustlazyancestorsObject *self, @@ -2394,6 +2395,24 @@ return PyInt_FromLong(res); } +static int rustla_contains(rustlazyancestorsObject *self, PyObject *rev) { + if (!(PyInt_Check(rev))) { +return 0; + } + return rustlazyancestors_contains(self->iter, PyInt_AS_LONG(rev)); +} + +static PySequenceMethods rustla_sequence_methods = { +0, /* sq_length */ + 0, /* sq_concat */ + 0, /* sq_repeat */ + 0, /* sq_item */ + 0, /* sq_slice */ + 0, /* sq_ass_item */ + 0, /* sq_ass_slice */ + (objobjproc)rustla_contains, /* sq_contains */ +}; + static PyTypeObject rustlazyancestorsType = { PyVarObject_HEAD_INIT(NULL, 0) /* header */ "parsers.rustlazyancestors", /* tp_name */ @@ -2406,7 +2425,7 @@ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ - 0, /* tp_as_sequence */ + _sequence_methods, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ diff -r 98f0f668f63b -r 5c3f0974b9af rust/hg-core/src/ancestors.rs --- a/rust/hg-core/src/ancestors.rs Thu Sep 27 16:55:44 2018 +0200 +++ b/rust/hg-core/src/ancestors.rs Mon Oct 08 19:11:41 2018 +0200 @@ -81,6 +81,26 @@ self.conditionally_push_rev(parents.1); Ok(()) } + +/// Consumes partially the iterator to tell if the given target +/// revision +/// is in the ancestors it emits. +/// This is meant for iterators actually dedicated to that kind of +/// purpose +pub fn contains( self, target: Revision) -> bool { +if self.seen.contains() && target != NULL_REVISION { +return true; +} +for rev in self { +if rev == target { +return true; +} +if rev < target { +return false; +}
[PATCH 3 of 5 V3] rust: exposing in parsers module
# HG changeset patch # User Georges Racinet # Date 1538060175 -7200 # Thu Sep 27 16:56:15 2018 +0200 # Node ID b1d2b4a4684a51ba9bfc3ea5bc6e177be65e4b69 # Parent 4b490e500a3551b03c41dc06f16aa506523719c6 # EXP-Topic rustancestors-contains rust: exposing in parsers module To build with the Rust code, set the HGWITHRUSTEXT environment variable. At this point, it's possible to instantiate and use a rustlazyancestors object from a Python interpreter. The changes in setup.py are obviously a quick hack, just good enough to test/bench without much refactoring. We'd be happy to improve on that with help from the community. Rust bindings crate gets compiled as a static library, which in turn gets linked within 'parsers.so' With respect to the plans at https://www.mercurial-scm.org/wiki/OxidationPlan this would probably qualify as "roll our own FFI". Also, it doesn't quite meet the target of getting rid of C code, since it brings actually more, yet: - the new C code does nothing else than parsing arguments and calling Rust functions. In particular, there's no complex allocation involved. - subsequent changes could rewrite more of revlog.c, this time resulting in an overall decrease of C code and unsafety. diff -r 4b490e500a35 -r b1d2b4a4684a mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c Thu Sep 27 16:51:36 2018 +0200 +++ b/mercurial/cext/revlog.c Thu Sep 27 16:56:15 2018 +0200 @@ -2290,6 +2290,151 @@ return NULL; } +#ifdef WITH_RUST + +/* rustlazyancestors: iteration over ancestors implemented in Rust + * + * This class holds a reference to an index and to the Rust iterator. + */ +typedef struct rustlazyancestorsObjectStruct rustlazyancestorsObject; + +struct rustlazyancestorsObjectStruct { + PyObject_HEAD + /* Type-specific fields go here. */ + indexObject *index;/* Ref kept to avoid GC'ing the index */ + void *iter;/* Rust iterator */ +}; + +/* FFI exposed from Rust code */ +rustlazyancestorsObject *rustlazyancestors_init( + indexObject *index, + /* to pass index_get_parents() */ + int (*)(indexObject *, Py_ssize_t, int*, int), + /* intrevs vector */ + int initrevslen, long *initrevs, + long stoprev, + int inclusive); +void rustlazyancestors_drop(rustlazyancestorsObject *self); +int rustlazyancestors_next(rustlazyancestorsObject *self); + +/* CPython instance methods */ +static int rustla_init(rustlazyancestorsObject *self, + PyObject *args) { + PyObject *initrevsarg = NULL; + PyObject *inclusivearg = NULL; + long stoprev = 0; + long *initrevs = NULL; + int inclusive = 0; + Py_ssize_t i; + + indexObject *index; + if (!PyArg_ParseTuple(args, "O!O!lO!", + , , + _Type, , + , + _Type, )) + return -1; + + Py_INCREF(index); + self->index = index; + + if (inclusivearg == Py_True) + inclusive = 1; + + Py_ssize_t linit = PyList_GET_SIZE(initrevsarg); + + initrevs = (long*)calloc(linit, sizeof(long)); + + if (initrevs == NULL) { + PyErr_NoMemory(); + goto bail; + } + + for (i=0; iiter = rustlazyancestors_init(index, + index_get_parents, + linit, initrevs, + stoprev, inclusive); + if (self->iter == NULL) + /* if this is because of GraphError::ParentOutOfRange +* index_get_parents() has already set the proper ValueError */ + goto bail; + + free(initrevs); + return 0; + + bail: + free(initrevs); + return -1; +}; + +static void rustla_dealloc(rustlazyancestorsObject *self) +{ + Py_XDECREF(self->index); + if (self->iter != NULL) { /* can happen if rustla_init failed */ + rustlazyancestors_drop(self->iter); + } + PyObject_Del(self); +} + +static PyObject *rustla_next(rustlazyancestorsObject *self) { + int res = rustlazyancestors_next(self->iter); + if (res == -1) { + /* Setting an explicit exception seems unnecessary +* as examples from Python source code (Objects/rangeobjets.c and +* Modules/_io/stringio.c) seem to demonstrate. + */ + return NULL; + } + return PyInt_FromLong(res); +} + +static PyTypeObject rustlazyancestorsType = { + PyVarObject_HEAD_INIT(NULL, 0) /* header */ + "parsers.rustlazyancestors", /* tp_name */ + sizeof(rustlazyancestorsObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)rustla_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0,
[PATCH 4 of 5 V3] rust: hooking into Python code
# HG changeset patch # User Georges Racinet # Date 1538060144 -7200 # Thu Sep 27 16:55:44 2018 +0200 # Node ID 98f0f668f63b143eba344a74c8b22a0588f46935 # Parent b1d2b4a4684a51ba9bfc3ea5bc6e177be65e4b69 # EXP-Topic rustancestors-contains rust: hooking into Python code We introduce a new class called 'rustlazyancestors' in the ancestors module, which is used only if parsers.rustlazyancestors does exist. The implementation of __contains__ stays unchanged, but is now backed by the Rust iterator. It would probably be a good candidate for further development, though, as it is mostly looping, and duplicates the 'seen' set. The Rust code could be further optimized, however it already gives rise to performance improvements: median timing from hg perfancestors: - on pypy: before: 0.113749s after: 0.018628s -84% - on mozilla central: before: 0.329075s after: 0.083889s -75% - on a private repository (about one million revisions): before: 1.982365s after: 0.329907s -83% - on another private repository (about 400 000 revisions): before: 0.826686s after: 0.123760s -85% median timing for hg perfbranchmap base - on pypy: before: 1.808351s after: 0.480814s -73% - on mozilla central: before: 18.493269s after: 1.305514s -93% - on a private repository (about one million revisions): before: 9.153785s after: 3.662155s -60% - on another private repository (about 400 000 revisions): before: 98.034737s after: 18.109361s -81% diff -r b1d2b4a4684a -r 98f0f668f63b mercurial/ancestor.py --- a/mercurial/ancestor.py Thu Sep 27 16:56:15 2018 +0200 +++ b/mercurial/ancestor.py Thu Sep 27 16:55:44 2018 +0200 @@ -11,9 +11,12 @@ from .node import nullrev from . import ( +policy, pycompat, ) +parsers = policy.importmod(r'parsers') + def commonancestorsheads(pfunc, *nodes): """Returns a set with the heads of all common ancestors of all nodes, heads(::nodes[0] and ::nodes[1] and ...) . @@ -379,3 +382,25 @@ # free up memory. self._containsiter = None return False + +class rustlazyancestors(lazyancestors): + +def __init__(self, index, revs, stoprev=0, inclusive=False): +self._index = index +self._stoprev = stoprev +self._inclusive = inclusive +# no need to prefilter out init revs that are smaller than stoprev, +# it's done by rustlazyancestors constructor. +# we need to convert to a list, because our ruslazyancestors +# constructor (from C code) doesn't understand anything else yet +self._initrevs = initrevs = list(revs) + +self._containsseen = set() +self._containsiter = parsers.rustlazyancestors( +index, initrevs, stoprev, inclusive) + +def __iter__(self): +return parsers.rustlazyancestors(self._index, + self._initrevs, + self._stoprev, + self._inclusive) diff -r b1d2b4a4684a -r 98f0f668f63b mercurial/changelog.py --- a/mercurial/changelog.pyThu Sep 27 16:56:15 2018 +0200 +++ b/mercurial/changelog.pyThu Sep 27 16:55:44 2018 +0200 @@ -20,14 +20,18 @@ from . import ( encoding, error, +policy, pycompat, revlog, +util, ) from .utils import ( dateutil, stringutil, ) +parsers = policy.importmod(r'parsers') + _defaultextra = {'branch': 'default'} def _string_escape(text): @@ -343,6 +347,14 @@ if i not in self.filteredrevs: yield i +def ancestors(self, revs, *args, **kwargs): +if util.safehasattr(parsers, 'rustlazyancestors') and self.filteredrevs: +missing = self.filteredrevs.difference(revs) +if missing: +# raise the lookup error +self.rev(min(missing)) +return super(changelog, self).ancestors(revs, *args, **kwargs) + def reachableroots(self, minroot, heads, roots, includepath=False): return self.index.reachableroots2(minroot, heads, roots, includepath) diff -r b1d2b4a4684a -r 98f0f668f63b mercurial/revlog.py --- a/mercurial/revlog.py Thu Sep 27 16:56:15 2018 +0200 +++ b/mercurial/revlog.py Thu Sep 27 16:55:44 2018 +0200 @@ -747,6 +747,10 @@ See the documentation for ancestor.lazyancestors for more details.""" +if util.safehasattr(parsers, 'rustlazyancestors'): +return ancestor.rustlazyancestors( +self.index, revs, +stoprev=stoprev, inclusive=inclusive) return ancestor.lazyancestors(self.parentrevs, revs, stoprev=stoprev, inclusive=inclusive) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 5 V3] rust: iterator bindings to C code
# HG changeset patch # User Georges Racinet # Date 1538059896 -7200 # Thu Sep 27 16:51:36 2018 +0200 # Node ID 4b490e500a3551b03c41dc06f16aa506523719c6 # Parent 41b32e06629466bbe671c6ebfc1c5a4133c8af99 # EXP-Topic rustancestors-contains rust: iterator bindings to C code In this changeset, still made of Rust code only, we expose the Rust iterator for instantiation and consumption from C code. The idea is that both the index and index_get_parents() will be passed from the C extension, hence avoiding a hard link dependency to parsers.so, so that the crate can still be built and tested independently. On the other hand, parsers.so will use the symbols defined in this changeset. diff -r 41b32e066294 -r 4b490e500a35 rust/Cargo.lock --- a/rust/Cargo.lock Thu Sep 27 17:03:16 2018 +0200 +++ b/rust/Cargo.lock Thu Sep 27 16:51:36 2018 +0200 @@ -30,6 +30,14 @@ ] [[package]] +name = "hgdirectffi" +version = "0.1.0" +dependencies = [ + "hg-core 0.1.0", + "libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "kernel32-sys" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index; diff -r 41b32e066294 -r 4b490e500a35 rust/Cargo.toml --- a/rust/Cargo.toml Thu Sep 27 17:03:16 2018 +0200 +++ b/rust/Cargo.toml Thu Sep 27 16:51:36 2018 +0200 @@ -1,3 +1,3 @@ [workspace] -members = ["hgcli", "hg-core"] +members = ["hgcli", "hg-core", "hg-direct-ffi"] exclude = ["chg"] diff -r 41b32e066294 -r 4b490e500a35 rust/hg-direct-ffi/Cargo.toml --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/rust/hg-direct-ffi/Cargo.toml Thu Sep 27 16:51:36 2018 +0200 @@ -0,0 +1,12 @@ +[package] +name = "hgdirectffi" +version = "0.1.0" +authors = ["Georges Racinet "] +description = "Low level Python bindings for hg-core, going through existing C extensions" + +[dependencies] +libc = "*" +hg-core = { path = "../hg-core" } + +[lib] +crate-type = ["staticlib"] diff -r 41b32e066294 -r 4b490e500a35 rust/hg-direct-ffi/src/ancestors.rs --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/rust/hg-direct-ffi/src/ancestors.rs Thu Sep 27 16:51:36 2018 +0200 @@ -0,0 +1,229 @@ +// Copyright 2018 Georges Racinet +// +// This software may be used and distributed according to the terms of the +// GNU General Public License version 2 or any later version. + +//! Bindings for CPython extension code +//! +//! This exposes methods to build and use a `rustlazyancestors` iterator +//! from C code, using an index and its parents function that are passed +//! from the caller at instantiation. + +use hg::AncestorsIterator; +use hg::{Graph, GraphError, Revision, NULL_REVISION}; +use libc::{c_int, c_long, c_void, ssize_t}; +use std::ptr::null_mut; +use std::slice; + +type IndexPtr = *mut c_void; +type IndexParentsFn = +unsafe extern "C" fn(index: IndexPtr, rev: ssize_t, ps: *mut [c_int; 2], max_rev: c_int) +-> c_int; + +/// A Graph backed up by objects and functions from revlog.c +/// +/// This implementation of the Graph trait, relies on (pointers to) +/// - the C index object (`index` member) +/// - the `index_get_parents()` function (`parents` member) +pub struct Index { +index: IndexPtr, +parents: IndexParentsFn, +} + +impl Index { +pub fn new(index: IndexPtr, parents: IndexParentsFn) -> Self { +Index { +index: index, +parents: parents, +} +} +} + +impl Graph for Index { +/// wrap a call to the C extern parents function +fn parents(, rev: Revision) -> Result<(Revision, Revision), GraphError> { +let mut res: [c_int; 2] = [0; 2]; +let code = +unsafe { (self.parents)(self.index, rev as ssize_t, res as *mut [c_int; 2], rev) }; +match code { +0 => Ok((res[0], res[1])), +_ => Err(GraphError::ParentOutOfRange(rev)), +} +} +} + +/// Wrapping of AncestorsIterator constructor, for C callers. +/// +/// Besides `initrevs`, `stoprev` and `inclusive`, that are converted +/// we receive the index and the parents function as pointers +#[no_mangle] +pub extern "C" fn rustlazyancestors_init( +index: IndexPtr, +parents: IndexParentsFn, +initrevslen: usize, +initrevs: *mut c_long, +stoprev: c_long, +inclusive: c_int, +) -> *mut AncestorsIterator { +unsafe { +raw_init( +Index::new(index, parents), +initrevslen, +initrevs, +stoprev, +inclusive, +) +} +} + +/// Testable (for any Graph) version of rustlazyancestors_init +#[inline] +unsafe fn raw_init( +graph: G, +initrevslen: usize, +initrevs: *mut c_long, +stoprev: c_long, +inclusive: c_int, +) -> *mut AncestorsIterator { +let inclb = match inclusive { +0 => false, +1 => true, +_ => { +return null_mut(); +} +}; + +let slice = slice::from_raw_parts(initrevs, initrevslen); + +Box::into_raw(Box::new(match
[PATCH 1 of 5 V3] rust: pure Rust lazyancestors iterator
# HG changeset patch # User Georges Racinet # Date 1538060596 -7200 # Thu Sep 27 17:03:16 2018 +0200 # Node ID 41b32e06629466bbe671c6ebfc1c5a4133c8af99 # Parent 38ac525b44c93fcadb3680d4ded56f1e5a0029b2 # EXP-Topic rustancestors-contains rust: pure Rust lazyancestors iterator This is the first of a patch series aiming to provide an alternative implementation in the Rust programming language of the _lazyancestorsiter from the ancestor module. This iterator has been brought to our attention by the people at Octobus, as a potential good candidate for incremental "oxydation" (rewriting in Rust), because it has shown performance issues lately and it merely deals with ints (revision numbers) obtained by calling the index, whih should be directly callable from Rust code, being itself implemented as a C extension. The idea behind this series is to provide a minimal example of Rust code collaborating with existing C and Python code. To open the way to gradually rewriting more of Mercurial's Python code in Rust, without being forced to pay a large initial cost of rewriting the existing fast core into Rust. This patch does not introduce any bindings to other Mercurial code yet. Instead, it introduces the necessary abstractions to address the problem independently, and unit-test it. Since this is the first use of Rust as a Python module within Mercurial, the hg-core crate gets created within this patch. See its Cargo.toml for more details. Someone with a rustc/cargo installation may chdir into rust/hg-core and run the tests by issuing: cargo test --lib The algorithm is a bit simplified (see details in docstrings), and at its simplest becomes rather trivial, showcasing that Rust has batteries included too: BinaryHeap, the Rust analog of Python's heapq does actually all the work. The implementation can be further optimized and probably be made more idiomatic Rust. diff -r 38ac525b44c9 -r 41b32e066294 rust/Cargo.lock --- a/rust/Cargo.lock Thu Oct 11 21:51:17 2018 -0400 +++ b/rust/Cargo.lock Thu Sep 27 17:03:16 2018 +0200 @@ -17,6 +17,10 @@ ] [[package]] +name = "hg-core" +version = "0.1.0" + +[[package]] name = "hgcli" version = "0.1.0" dependencies = [ diff -r 38ac525b44c9 -r 41b32e066294 rust/Cargo.toml --- a/rust/Cargo.toml Thu Oct 11 21:51:17 2018 -0400 +++ b/rust/Cargo.toml Thu Sep 27 17:03:16 2018 +0200 @@ -1,3 +1,3 @@ [workspace] -members = ["hgcli"] +members = ["hgcli", "hg-core"] exclude = ["chg"] diff -r 38ac525b44c9 -r 41b32e066294 rust/hg-core/Cargo.toml --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/rust/hg-core/Cargo.toml Thu Sep 27 17:03:16 2018 +0200 @@ -0,0 +1,8 @@ +[package] +name = "hg-core" +version = "0.1.0" +authors = ["Georges Racinet "] +description = "Mercurial pure Rust core library, with no assumption on Python bindings (FFI)" + +[lib] +name = "hg" diff -r 38ac525b44c9 -r 41b32e066294 rust/hg-core/rustfmt.toml --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/rust/hg-core/rustfmt.toml Thu Sep 27 17:03:16 2018 +0200 @@ -0,0 +1,3 @@ +max_width = 79 +wrap_comments = true +error_on_line_overflow = true diff -r 38ac525b44c9 -r 41b32e066294 rust/hg-core/src/ancestors.rs --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/rust/hg-core/src/ancestors.rs Thu Sep 27 17:03:16 2018 +0200 @@ -0,0 +1,239 @@ +// ancestors.rs +// +// Copyright 2018 Georges Racinet +// +// This software may be used and distributed according to the terms of the +// GNU General Public License version 2 or any later version. + +//! Rust versions of generic DAG ancestors algorithms for Mercurial + +use super::{Graph, GraphError, Revision, NULL_REVISION}; +use std::collections::{BinaryHeap, HashSet}; +use std::iter::Iterator; + +/// Iterator over the ancestors of a given list of revisions +/// This is a generic type, defined and implemented for any Graph, so that +/// it's easy to +/// +/// - unit test in pure Rust +/// - bind to main Mercurial code, potentially in several ways and have these +/// bindings evolve over time +pub struct AncestorsIterator { +graph: G, +visit: BinaryHeap, +seen: HashSet, +stoprev: Revision, +} + +impl AncestorsIterator { +/// Constructor. +/// +/// if `inclusive` is true, then the init revisions are emitted in +/// particular, otherwise iteration starts from their parents. +pub fn new( +graph: G, +initrevs: I, +stoprev: Revision, +inclusive: bool, +) -> Result +where +I: IntoIterator, +{ +let filtered_initrevs = initrevs.into_iter().filter(|| r >= stoprev); +if inclusive { +let visit: BinaryHeap = filtered_initrevs.collect(); +let seen = visit.iter().map(|| x).collect(); +return Ok(AncestorsIterator { +visit: visit, +seen: seen, +stoprev: stoprev, +graph: graph, +}); +} +let mut this = AncestorsIterator { +
D5086: churn: remove redundant round()
durin42 updated this revision to Diff 12090. durin42 edited the summary of this revision. durin42 retitled this revision from "churn: remove redundant int() and round()" to "churn: remove redundant round()". REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5086?vs=12083=12090 REVISION DETAIL https://phab.mercurial-scm.org/D5086 AFFECTED FILES hgext/churn.py CHANGE DETAILS diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -205,7 +205,7 @@ '*' * charnum(sum(count))) def charnum(count): -return int(round(count * width // maxcount)) +return int(count * width // maxcount) for name, count in rate: ui.write(format(name, count)) To: durin42, #hg-reviewers, pulkit Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5075: tests: accept slightly different zip file in Python 3
yuja added a comment. > - body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 + body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 (no-py3k !) + body: size=1461, sha1=be6d3983aa13dfe930361b2569291cdedd02b537 (py3k !) For some reason, my Python 3 says `size=1489, sha1=1897e496871aa89ad685a92b936f5fa0d008b9e8` REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5075 To: durin42, pulkit, #hg-reviewers Cc: yuja, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D5075: tests: accept slightly different zip file in Python 3
> - body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 > + body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 (no-py3k !) > + body: size=1461, sha1=be6d3983aa13dfe930361b2569291cdedd02b537 (py3k !) For some reason, my Python 3 says `size=1489, sha1=1897e496871aa89ad685a92b936f5fa0d008b9e8` ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5083: tests: fix inline extension in test-fncache.t for Python 3
This revision was automatically updated to reflect the committed changes. Closed by commit rHGc8f164061212: tests: fix inline extension in test-fncache.t for Python 3 (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5083?vs=12077=12089 REVISION DETAIL https://phab.mercurial-scm.org/D5083 AFFECTED FILES contrib/python3-whitelist tests/test-fncache.t CHANGE DETAILS diff --git a/tests/test-fncache.t b/tests/test-fncache.t --- a/tests/test-fncache.t +++ b/tests/test-fncache.t @@ -305,13 +305,13 @@ > def trwrapper(orig, self, *args, **kwargs): > tr = orig(self, *args, **kwargs) > def fail(tr): - > raise error.Abort("forced transaction failure") + > raise error.Abort(b"forced transaction failure") > # zzz prefix to ensure it sorted after store.write - > tr.addfinalize('zzz-forcefails', fail) + > tr.addfinalize(b'zzz-forcefails', fail) > return tr > > def abortwrapper(orig, self, *args, **kwargs): - > raise error.Abort("forced transaction failure") + > raise error.Abort(b"forced transaction failure") > > def uisetup(ui): > extensions.wrapfunction(localrepo.localrepository, 'transaction', @@ -453,15 +453,15 @@ > def extsetup(ui): > def wrapstore(orig, requirements, *args): > store = orig(requirements, *args) - > if 'store' in requirements and 'fncache' in requirements: + > if b'store' in requirements and b'fncache' in requirements: > instrumentfncachestore(store, ui) > return store > extensions.wrapfunction(localrepo, 'makestore', wrapstore) > > def instrumentfncachestore(fncachestore, ui): > class instrumentedfncache(type(fncachestore.fncache)): > def _load(self): - > ui.warn('fncache load triggered!\n') + > ui.warn(b'fncache load triggered!\n') > super(instrumentedfncache, self)._load() > fncachestore.fncache.__class__ = instrumentedfncache > EOF diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -200,6 +200,7 @@ test-fix-topology.t test-fix.t test-flags.t +test-fncache.t test-generaldelta.t test-getbundle.t test-git-export.t To: durin42, #hg-reviewers, pulkit Cc: mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5080: context: open files in bytes mode
This revision was automatically updated to reflect the committed changes. Closed by commit rHG2f47703c5489: context: open files in bytes mode (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5080?vs=12072=12085 REVISION DETAIL https://phab.mercurial-scm.org/D5080 AFFECTED FILES mercurial/context.py CHANGE DETAILS diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -2433,5 +2433,5 @@ def write(self, data, flags, **kwargs): assert not flags -with open(self._path, "w") as f: +with open(self._path, "wb") as f: f.write(data) To: durin42, #hg-reviewers, pulkit Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5081: simplemerge: port to Python 3
This revision was automatically updated to reflect the committed changes. Closed by commit rHGb54d93fc3ba8: simplemerge: port to Python 3 (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5081?vs=12073=12087 REVISION DETAIL https://phab.mercurial-scm.org/D5081 AFFECTED FILES contrib/simplemerge CHANGE DETAILS diff --git a/contrib/simplemerge b/contrib/simplemerge --- a/contrib/simplemerge +++ b/contrib/simplemerge @@ -41,44 +41,47 @@ """Exception raised on errors in parsing the command line.""" def showhelp(): -sys.stdout.write(usage) -sys.stdout.write(b'\noptions:\n') +pycompat.stdout.write(usage.encode('utf8')) +pycompat.stdout.write(b'\noptions:\n') out_opts = [] for shortopt, longopt, default, desc in options: out_opts.append((b'%2s%s' % (shortopt and b'-%s' % shortopt, longopt and b' --%s' % longopt), b'%s' % desc)) opts_len = max([len(opt[0]) for opt in out_opts]) for first, second in out_opts: -sys.stdout.write(b' %-*s %s\n' % (opts_len, first, second)) +pycompat.stdout.write(b' %-*s %s\n' % (opts_len, first, second)) try: -for fp in (sys.stdin, sys.stdout, sys.stderr): +for fp in (sys.stdin, pycompat.stdout, sys.stderr): procutil.setbinary(fp) opts = {} try: -args = fancyopts.fancyopts(sys.argv[1:], options, opts) +bargv = [a.encode('utf8') for a in sys.argv[1:]] +args = fancyopts.fancyopts(bargv, options, opts) except getopt.GetoptError as e: raise ParseError(e) if opts[b'help']: showhelp() sys.exit(0) if len(args) != 3: -raise ParseError(_(b'wrong number of arguments')) +raise ParseError(_(b'wrong number of arguments').decode('utf8')) local, base, other = args sys.exit(simplemerge.simplemerge(uimod.ui.load(), context.arbitraryfilectx(local), context.arbitraryfilectx(base), context.arbitraryfilectx(other), **pycompat.strkwargs(opts))) except ParseError as e: -sys.stdout.write(b"%s: %s\n" % (sys.argv[0], e)) +if pycompat.ispy3: +e = str(e).encode('utf8') +pycompat.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e)) showhelp() sys.exit(1) except error.Abort as e: -sys.stderr.write(b"abort: %s\n" % e) +pycompat.stderr.write(b"abort: %s\n" % e) sys.exit(255) except KeyboardInterrupt: sys.exit(255) To: durin42, #hg-reviewers, pulkit Cc: mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5082: py3: 3 more passing tests
This revision was automatically updated to reflect the committed changes. Closed by commit rHG4b5d9eb1428f: py3: 3 more passing tests (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5082?vs=12074=12088 REVISION DETAIL https://phab.mercurial-scm.org/D5082 AFFECTED FILES contrib/python3-whitelist CHANGE DETAILS diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -60,6 +60,7 @@ test-check-code.t test-check-commit.t test-check-config.py +test-check-config.t test-check-execute.t test-check-interfaces.py test-check-module-imports.t @@ -95,6 +96,7 @@ test-contrib-perf.t test-contrib-relnotes.t test-contrib-testparseutil.t +test-contrib.t test-convert-authormap.t test-convert-clonebranches.t test-convert-cvs-branch.t @@ -196,6 +198,7 @@ test-fileset-generated.t test-fileset.t test-fix-topology.t +test-fix.t test-flags.t test-generaldelta.t test-getbundle.t To: durin42, pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5059: contrib: fix up output in check-config.py to use strs to avoid b prefixes
This revision was automatically updated to reflect the committed changes. Closed by commit rHG5519697b71b3: contrib: fix up output in check-config.py to use strs to avoid b prefixes (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5059?vs=12071=12086 REVISION DETAIL https://phab.mercurial-scm.org/D5059 AFFECTED FILES contrib/check-config.py contrib/python3-whitelist CHANGE DETAILS diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -59,6 +59,7 @@ test-changelog-exec.t test-check-code.t test-check-commit.t +test-check-config.py test-check-execute.t test-check-interfaces.py test-check-module-imports.t diff --git a/contrib/check-config.py b/contrib/check-config.py --- a/contrib/check-config.py +++ b/contrib/check-config.py @@ -42,6 +42,14 @@ config:\s(?P\S+\.\S+)$ ''', re.VERBOSE | re.MULTILINE) +if sys.version_info[0] > 2: +def mkstr(b): +if isinstance(b, str): +return b +return b.decode('utf8') +else: +mkstr = lambda x: x + def main(args): for f in args: sect = b'' @@ -92,7 +100,7 @@ # look for ignore markers m = ignorere.search(l) if m: -if m.group('reason') == 'inconsistent': +if m.group('reason') == b'inconsistent': allowinconsistent.add(m.group('config')) else: documented[m.group('config')] = 1 @@ -106,16 +114,20 @@ ctype = 'str' name = m.group('section') + b"." + m.group('option') default = m.group('default') -if default in (None, 'False', 'None', '0', '[]', '""', "''"): +if default in ( +None, b'False', b'None', b'0', b'[]', b'""', b"''"): default = b'' if re.match(b'[a-z.]+$', default): default = b'' if (name in foundopts and (ctype, default) != foundopts[name] and name not in allowinconsistent): -print(l.rstrip()) -print("conflict on %s: %r != %r" % (name, (ctype, default), -foundopts[name])) -print("at %s:%d:" % (f, linenum)) +print(mkstr(l.rstrip())) +fctype, fdefault = foundopts[name] +print("conflict on %s: %r != %r" % ( +mkstr(name), +(mkstr(ctype), mkstr(default)), +(mkstr(fctype), mkstr(fdefault +print("at %s:%d:" % (mkstr(f), linenum)) foundopts[name] = (ctype, default) carryover = b'' else: @@ -132,8 +144,13 @@ name.startswith(b"debug.")): ctype, default = foundopts[name] if default: +if isinstance(default, bytes): +default = mkstr(default) default = ' [%s]' % default -print("undocumented: %s (%s)%s" % (name, ctype, default)) +elif isinstance(default, bytes): +default = mkstr(default) +print("undocumented: %s (%s)%s" % ( +mkstr(name), mkstr(ctype), default)) if __name__ == "__main__": if len(sys.argv) > 1: To: durin42, pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5086: churn: remove redundant int() and round()
durin42 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Spotted by Mads when he reviewed https://phab.mercurial-scm.org/D5063. Thanks! REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5086 AFFECTED FILES hgext/churn.py CHANGE DETAILS diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -205,7 +205,7 @@ '*' * charnum(sum(count))) def charnum(count): -return int(round(count * width // maxcount)) +return count * width // maxcount for name, count in rate: ui.write(format(name, count)) To: durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] obsolete: don't translate internal error message
> On Oct 12, 2018, at 17:08, Yuya Nishihara wrote: > > # HG changeset patch > # User Yuya Nishihara > # Date 1539355871 -7200 > # Fri Oct 12 16:51:11 2018 +0200 > # Node ID 21a0028bb28eeb4c3d2af807934fd22382594ce2 > # Parent 5b8bab9a7e07692e8d827c5315502301a11e4803 > obsolete: don't translate internal error message queued, thanks ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] py3: get around unicode docstrings in test-encoding-textwrap.t and test-help.t
> On Oct 12, 2018, at 19:36, Yuya Nishihara wrote: > > # HG changeset patch > # User Yuya Nishihara > # Date 1539365108 -7200 > # Fri Oct 12 19:25:08 2018 +0200 > # Node ID fc11940aeb629be72d144cf77cea245c3369c850 > # Parent ba70e3acf58a6a929a23f5b80e08c98a4ad776d4 > py3: get around unicode docstrings in test-encoding-textwrap.t and test-help.t queued, thanks ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5085: tests: fix up test-hghave for recent run-tests change to use more CPUs
durin42 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5085 AFFECTED FILES tests/test-hghave.t CHANGE DETAILS diff --git a/tests/test-hghave.t b/tests/test-hghave.t --- a/tests/test-hghave.t +++ b/tests/test-hghave.t @@ -22,8 +22,10 @@ > EOF $ ( \ > testrepohgenv; \ - > "$PYTHON" $TESTDIR/run-tests.py $HGTEST_RUN_TESTS_PURE test-hghaveaddon.t \ + > "$PYTHON" $TESTDIR/run-tests.py -j 1 \ + >$HGTEST_RUN_TESTS_PURE test-hghaveaddon.t \ > ) + running 1 tests using 1 parallel processes . # Ran 1 tests, 0 skipped, 0 failed. To: durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] crecord: make enter move cursor down to the next item of the same type
> On Oct 13, 2018, at 12:08, Anton Shestakov wrote: > > # HG changeset patch > # User Anton Shestakov > # Date 1539424350 -7200 > # Sat Oct 13 11:52:30 2018 +0200 > # Node ID 652b73cc2aa892cf2c2a5988a339ee242d2e1696 > # Parent 8278491d01838a2062ba7202be9b79cc6b243c83 > crecord: make enter move cursor down to the next item of the same type queued, very nice ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5084: py3: fix test-parse-date.t
This revision was automatically updated to reflect the committed changes. Closed by commit rHGd4d2c567bb72: py3: fix test-parse-date.t (authored by mbthomas, committed by ). CHANGED PRIOR TO COMMIT https://phab.mercurial-scm.org/D5084?vs=12080=12081#toc REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5084?vs=12080=12081 REVISION DETAIL https://phab.mercurial-scm.org/D5084 AFFECTED FILES contrib/python3-whitelist mercurial/utils/dateutil.py CHANGE DETAILS diff --git a/mercurial/utils/dateutil.py b/mercurial/utils/dateutil.py --- a/mercurial/utils/dateutil.py +++ b/mercurial/utils/dateutil.py @@ -303,17 +303,17 @@ if not date: raise error.Abort(_("dates cannot consist entirely of whitespace")) -elif date[0] == "<": +elif date[0:1] == b"<": if not date[1:]: raise error.Abort(_("invalid day spec, use '": if not date[1:]: raise error.Abort(_("invalid day spec, use '>DATE'")) when = lower(date[1:]) return lambda x: x >= when -elif date[0] == "-": +elif date[0:1] == b"-": try: days = int(date[1:]) except ValueError: @@ -323,8 +323,8 @@ % date[1:]) when = makedate()[0] - days * 3600 * 24 return lambda x: x >= when -elif " to " in date: -a, b = date.split(" to ") +elif b" to " in date: +a, b = date.split(b" to ") start, stop = lower(a), upper(b) return lambda x: x >= start and x <= stop else: diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -405,6 +405,7 @@ test-pager-legacy.t test-pager.t test-parents.t +test-parse-date.t test-parseindex2.py test-patch-offset.t test-patch.t To: mbthomas, #hg-reviewers, pulkit Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 2 of 2] py3: build help of compression engines in bytes
> On Oct 13, 2018, at 14:28, Yuya Nishihara wrote: > > # HG changeset patch > # User Yuya Nishihara > # Date 1539433045 -7200 > # Sat Oct 13 14:17:25 2018 +0200 > # Node ID 921feabe152110773b8b85818b149a99166b9f74 > # Parent b8a16cf84c34d254df7ff276e49e6d5fd327eb8b > py3: build help of compression engines in bytes queued, thanks ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5084: py3: fix test-parse-date.t
mbthomas updated this revision to Diff 12080. mbthomas added a comment. Herald added a reviewer: pulkit. Add to whilelist REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5084?vs=12079=12080 BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D5084 AFFECTED FILES contrib/python3-whitelist mercurial/utils/dateutil.py CHANGE DETAILS diff --git a/mercurial/utils/dateutil.py b/mercurial/utils/dateutil.py --- a/mercurial/utils/dateutil.py +++ b/mercurial/utils/dateutil.py @@ -303,17 +303,17 @@ if not date: raise error.Abort(_("dates cannot consist entirely of whitespace")) -elif date[0] == "<": +elif date[0:1] == b"<": if not date[1:]: raise error.Abort(_("invalid day spec, use '": if not date[1:]: raise error.Abort(_("invalid day spec, use '>DATE'")) when = lower(date[1:]) return lambda x: x >= when -elif date[0] == "-": +elif date[0:1] == b"-": try: days = int(date[1:]) except ValueError: @@ -323,8 +323,8 @@ % date[1:]) when = makedate()[0] - days * 3600 * 24 return lambda x: x >= when -elif " to " in date: -a, b = date.split(" to ") +elif b" to " in date: +a, b = date.split(b" to ") start, stop = lower(a), upper(b) return lambda x: x >= start and x <= stop else: diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -386,6 +386,7 @@ test-obsolete-tag-cache.t test-pager.t test-parents.t +test-parse-date.t test-parseindex2.py test-patch-offset.t test-patch.t To: mbthomas, #hg-reviewers, pulkit Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5079: py3: use py3 as the test tag, dropping the k
durin42 requested changes to this revision. durin42 added a comment. This revision now requires changes to proceed. (Requesting changes per new instances of py3k in the tests since you wrote this - it's a heckuva treadmill right now.) REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5079 To: mjpieters, #hg-reviewers, pulkit, durin42 Cc: durin42, pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5084: py3: fix test-parse-date.t
mbthomas 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/D5084 AFFECTED FILES mercurial/utils/dateutil.py CHANGE DETAILS diff --git a/mercurial/utils/dateutil.py b/mercurial/utils/dateutil.py --- a/mercurial/utils/dateutil.py +++ b/mercurial/utils/dateutil.py @@ -303,17 +303,17 @@ if not date: raise error.Abort(_("dates cannot consist entirely of whitespace")) -elif date[0] == "<": +elif date[0:1] == b"<": if not date[1:]: raise error.Abort(_("invalid day spec, use '": if not date[1:]: raise error.Abort(_("invalid day spec, use '>DATE'")) when = lower(date[1:]) return lambda x: x >= when -elif date[0] == "-": +elif date[0:1] == b"-": try: days = int(date[1:]) except ValueError: @@ -323,8 +323,8 @@ % date[1:]) when = makedate()[0] - days * 3600 * 24 return lambda x: x >= when -elif " to " in date: -a, b = date.split(" to ") +elif b" to " in date: +a, b = date.split(b" to ") start, stop = lower(a), upper(b) return lambda x: x >= start and x <= stop else: To: mbthomas, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5064: style: run black on a subset of mercurial
indygreg added inline comments. INLINE COMMENTS > check-commit:43 > -(r"\n\+\n( |\+)\n", "adds double empty line"), > -(r"\n \n\+\n", "adds double empty line"), > # Forbid "_" in function name. I think we'll want to send this chunk as a separate commit, as it is a policy change. I'd be happy to accept that patch today. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5064 To: mjpieters, indygreg, durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5039: py3: add more py3 specific output to test
durin42 requested changes to this revision. durin42 added a comment. This revision now requires changes to proceed. In https://phab.mercurial-scm.org/D5039#75559, @yuja wrote: > > - a/tests/test-custom-filters.t +++ b/tests/test-custom-filters.t @@ -52,6 +52,7 @@ $ echo "Very very carefully." >> stuff.txt $ hg stat M stuff.txt + ? __pycache__/prefix.cpython-3*.pyc (glob) (py3k !) > > It's probably better to add `__pycache__` to .hgignore as we do for > `prefix.py[c]`. +1 REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5039 To: pulkit, #hg-reviewers, durin42 Cc: durin42, yuja, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5078: py3: fix infinitepush extension tests
This revision was automatically updated to reflect the committed changes. Closed by commit rHG090e5f3900b7: py3: fix infinitepush extension tests (authored by mbthomas, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5078?vs=12075=12078 REVISION DETAIL https://phab.mercurial-scm.org/D5078 AFFECTED FILES contrib/python3-whitelist hgext/infinitepush/__init__.py hgext/infinitepush/common.py hgext/infinitepush/store.py CHANGE DETAILS diff --git a/hgext/infinitepush/store.py b/hgext/infinitepush/store.py --- a/hgext/infinitepush/store.py +++ b/hgext/infinitepush/store.py @@ -12,6 +12,7 @@ import tempfile from mercurial import ( +node, pycompat, ) from mercurial.utils import ( @@ -80,7 +81,7 @@ return os.path.join(self._dirpath(filename), filename) def write(self, data): -filename = hashlib.sha1(data).hexdigest() +filename = node.hex(hashlib.sha1(data).digest()) dirpath = self._dirpath(filename) if not os.path.exists(dirpath): diff --git a/hgext/infinitepush/common.py b/hgext/infinitepush/common.py --- a/hgext/infinitepush/common.py +++ b/hgext/infinitepush/common.py @@ -33,7 +33,7 @@ fd, bundlefile = pycompat.mkstemp() try: # guards bundlefile try: # guards fp -fp = os.fdopen(fd, 'wb') +fp = os.fdopen(fd, r'wb') fp.write(data) finally: fp.close() diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py --- a/hgext/infinitepush/__init__.py +++ b/hgext/infinitepush/__init__.py @@ -357,8 +357,7 @@ if not self.capable('pushkey'): yield {}, None f = wireprotov1peer.future() -self.ui.debug('preparing listkeys for "%s" with pattern "%s"\n' % - (namespace, patterns)) +self.ui.debug('preparing listkeys for "%s"\n' % namespace) yield { 'namespace': encoding.fromlocal(namespace), 'patterns': wireprototypes.encodelist(patterns) @@ -696,8 +695,8 @@ return common, True, remoteheads def _push(orig, ui, repo, dest=None, *args, **opts): - -bookmark = opts.get(r'bookmark') +opts = pycompat.byteskwargs(opts) +bookmark = opts.get('bookmark') # we only support pushing one infinitepush bookmark at once if len(bookmark) == 1: bookmark = bookmark[0] @@ -718,7 +717,7 @@ if scratchpush: # this is an infinitepush, we don't want the bookmark to be applied # rather that should be stored in the bundlestore -opts[r'bookmark'] = [] +opts['bookmark'] = [] ui.setconfig(experimental, configscratchpush, True) oldphasemove = extensions.wrapfunction(exchange, '_localphasemove', @@ -732,7 +731,7 @@ # Remote scratch bookmarks will be deleted because remotenames doesn't # know about them. Let's save it before push and restore after remotescratchbookmarks = _readscratchremotebookmarks(ui, repo, destpath) -result = orig(ui, repo, dest, *args, **opts) +result = orig(ui, repo, dest, *args, **pycompat.strkwargs(opts)) if common.isremotebooksenabled(ui): if bookmark and scratchpush: other = hg.peer(repo, opts, destpath) @@ -899,7 +898,7 @@ if part.type in ('pushkey', 'changegroup'): if op.reply is not None: rpart = op.reply.newpart('reply:%s' % part.type) -rpart.addparam('in-reply-to', str(part.id), +rpart.addparam('in-reply-to', b'%d' % part.id, mandatory=False) rpart.addparam('return', '1', mandatory=False) diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -255,6 +255,9 @@ test-import.t test-imports-checker.t test-incoming-outgoing.t +test-infinitepush-bundlestore.t +test-infinitepush-ci.t +test-infinitepush.t test-inherit-mode.t test-init.t test-issue1089.t To: mbthomas, pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5079: py3: use py3 as the test tag, dropping the k
pulkit added a comment. There are few more occurences of py3k if you rebase it on @, can you please have a look. :) REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5079 To: mjpieters, #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
D5083: tests: fix inline extension in test-fncache.t for Python 3
durin42 updated this revision to Diff 12077. Herald added a reviewer: pulkit. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5083?vs=12076=12077 REVISION DETAIL https://phab.mercurial-scm.org/D5083 AFFECTED FILES contrib/python3-whitelist tests/test-fncache.t CHANGE DETAILS diff --git a/tests/test-fncache.t b/tests/test-fncache.t --- a/tests/test-fncache.t +++ b/tests/test-fncache.t @@ -305,13 +305,13 @@ > def trwrapper(orig, self, *args, **kwargs): > tr = orig(self, *args, **kwargs) > def fail(tr): - > raise error.Abort("forced transaction failure") + > raise error.Abort(b"forced transaction failure") > # zzz prefix to ensure it sorted after store.write - > tr.addfinalize('zzz-forcefails', fail) + > tr.addfinalize(b'zzz-forcefails', fail) > return tr > > def abortwrapper(orig, self, *args, **kwargs): - > raise error.Abort("forced transaction failure") + > raise error.Abort(b"forced transaction failure") > > def uisetup(ui): > extensions.wrapfunction(localrepo.localrepository, 'transaction', @@ -453,15 +453,15 @@ > def extsetup(ui): > def wrapstore(orig, requirements, *args): > store = orig(requirements, *args) - > if 'store' in requirements and 'fncache' in requirements: + > if b'store' in requirements and b'fncache' in requirements: > instrumentfncachestore(store, ui) > return store > extensions.wrapfunction(localrepo, 'makestore', wrapstore) > > def instrumentfncachestore(fncachestore, ui): > class instrumentedfncache(type(fncachestore.fncache)): > def _load(self): - > ui.warn('fncache load triggered!\n') + > ui.warn(b'fncache load triggered!\n') > super(instrumentedfncache, self)._load() > fncachestore.fncache.__class__ = instrumentedfncache > EOF diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -201,6 +201,7 @@ test-fix-topology.t test-fix.t test-flags.t +test-fncache.t test-generaldelta.t test-getbundle.t test-git-export.t To: durin42, #hg-reviewers, pulkit Cc: mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5079: py3: use py3 as the test tag, dropping the k
pulkit accepted this revision. pulkit added a comment. I feel priviliged to review my mentors patch and push it. :) REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5079 To: mjpieters, #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
D5083: tests: fix inline extension in test-fncache.t for Python 3
durin42 created this revision. Herald added subscribers: mercurial-devel, mjpieters. Herald added a reviewer: hg-reviewers. REVISION SUMMARY 1. skip-blame just some b prefixing REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5083 AFFECTED FILES tests/test-fncache.t CHANGE DETAILS diff --git a/tests/test-fncache.t b/tests/test-fncache.t --- a/tests/test-fncache.t +++ b/tests/test-fncache.t @@ -453,15 +453,15 @@ > def extsetup(ui): > def wrapstore(orig, requirements, *args): > store = orig(requirements, *args) - > if 'store' in requirements and 'fncache' in requirements: + > if b'store' in requirements and b'fncache' in requirements: > instrumentfncachestore(store, ui) > return store > extensions.wrapfunction(localrepo, 'makestore', wrapstore) > > def instrumentfncachestore(fncachestore, ui): > class instrumentedfncache(type(fncachestore.fncache)): > def _load(self): - > ui.warn('fncache load triggered!\n') + > ui.warn(b'fncache load triggered!\n') > super(instrumentedfncache, self)._load() > fncachestore.fncache.__class__ = instrumentedfncache > EOF To: durin42, #hg-reviewers Cc: mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5078: py3: fix infinitepush extension tests
mbthomas updated this revision to Diff 12075. mbthomas added a comment. Use a different function for getting hexdigest as bytes REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5078?vs=12067=12075 BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D5078 AFFECTED FILES contrib/python3-whitelist hgext/infinitepush/__init__.py hgext/infinitepush/common.py hgext/infinitepush/store.py CHANGE DETAILS diff --git a/hgext/infinitepush/store.py b/hgext/infinitepush/store.py --- a/hgext/infinitepush/store.py +++ b/hgext/infinitepush/store.py @@ -12,6 +12,7 @@ import tempfile from mercurial import ( +node, pycompat, ) from mercurial.utils import ( @@ -80,7 +81,7 @@ return os.path.join(self._dirpath(filename), filename) def write(self, data): -filename = hashlib.sha1(data).hexdigest() +filename = node.hex(hashlib.sha1(data).digest()) dirpath = self._dirpath(filename) if not os.path.exists(dirpath): diff --git a/hgext/infinitepush/common.py b/hgext/infinitepush/common.py --- a/hgext/infinitepush/common.py +++ b/hgext/infinitepush/common.py @@ -33,7 +33,7 @@ fd, bundlefile = pycompat.mkstemp() try: # guards bundlefile try: # guards fp -fp = os.fdopen(fd, 'wb') +fp = os.fdopen(fd, r'wb') fp.write(data) finally: fp.close() diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py --- a/hgext/infinitepush/__init__.py +++ b/hgext/infinitepush/__init__.py @@ -357,8 +357,7 @@ if not self.capable('pushkey'): yield {}, None f = wireprotov1peer.future() -self.ui.debug('preparing listkeys for "%s" with pattern "%s"\n' % - (namespace, patterns)) +self.ui.debug('preparing listkeys for "%s"\n' % namespace) yield { 'namespace': encoding.fromlocal(namespace), 'patterns': wireprototypes.encodelist(patterns) @@ -696,8 +695,8 @@ return common, True, remoteheads def _push(orig, ui, repo, dest=None, *args, **opts): - -bookmark = opts.get(r'bookmark') +opts = pycompat.byteskwargs(opts) +bookmark = opts.get('bookmark') # we only support pushing one infinitepush bookmark at once if len(bookmark) == 1: bookmark = bookmark[0] @@ -718,7 +717,7 @@ if scratchpush: # this is an infinitepush, we don't want the bookmark to be applied # rather that should be stored in the bundlestore -opts[r'bookmark'] = [] +opts['bookmark'] = [] ui.setconfig(experimental, configscratchpush, True) oldphasemove = extensions.wrapfunction(exchange, '_localphasemove', @@ -732,7 +731,7 @@ # Remote scratch bookmarks will be deleted because remotenames doesn't # know about them. Let's save it before push and restore after remotescratchbookmarks = _readscratchremotebookmarks(ui, repo, destpath) -result = orig(ui, repo, dest, *args, **opts) +result = orig(ui, repo, dest, *args, **pycompat.strkwargs(opts)) if common.isremotebooksenabled(ui): if bookmark and scratchpush: other = hg.peer(repo, opts, destpath) @@ -899,7 +898,7 @@ if part.type in ('pushkey', 'changegroup'): if op.reply is not None: rpart = op.reply.newpart('reply:%s' % part.type) -rpart.addparam('in-reply-to', str(part.id), +rpart.addparam('in-reply-to', b'%d' % part.id, mandatory=False) rpart.addparam('return', '1', mandatory=False) diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -239,6 +239,9 @@ test-import.t test-imports-checker.t test-incoming-outgoing.t +test-infinitepush-bundlestore.t +test-infinitepush-ci.t +test-infinitepush.t test-inherit-mode.t test-init.t test-issue1089.t To: mbthomas, pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5081: simplemerge: port to Python 3
durin42 created this revision. Herald added subscribers: mercurial-devel, mjpieters. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5081 AFFECTED FILES contrib/simplemerge CHANGE DETAILS diff --git a/contrib/simplemerge b/contrib/simplemerge --- a/contrib/simplemerge +++ b/contrib/simplemerge @@ -41,44 +41,47 @@ """Exception raised on errors in parsing the command line.""" def showhelp(): -sys.stdout.write(usage) -sys.stdout.write(b'\noptions:\n') +pycompat.stdout.write(usage.encode('utf8')) +pycompat.stdout.write(b'\noptions:\n') out_opts = [] for shortopt, longopt, default, desc in options: out_opts.append((b'%2s%s' % (shortopt and b'-%s' % shortopt, longopt and b' --%s' % longopt), b'%s' % desc)) opts_len = max([len(opt[0]) for opt in out_opts]) for first, second in out_opts: -sys.stdout.write(b' %-*s %s\n' % (opts_len, first, second)) +pycompat.stdout.write(b' %-*s %s\n' % (opts_len, first, second)) try: -for fp in (sys.stdin, sys.stdout, sys.stderr): +for fp in (sys.stdin, pycompat.stdout, sys.stderr): procutil.setbinary(fp) opts = {} try: -args = fancyopts.fancyopts(sys.argv[1:], options, opts) +bargv = [a.encode('utf8') for a in sys.argv[1:]] +args = fancyopts.fancyopts(bargv, options, opts) except getopt.GetoptError as e: raise ParseError(e) if opts[b'help']: showhelp() sys.exit(0) if len(args) != 3: -raise ParseError(_(b'wrong number of arguments')) +raise ParseError(_(b'wrong number of arguments').decode('utf8')) local, base, other = args sys.exit(simplemerge.simplemerge(uimod.ui.load(), context.arbitraryfilectx(local), context.arbitraryfilectx(base), context.arbitraryfilectx(other), **pycompat.strkwargs(opts))) except ParseError as e: -sys.stdout.write(b"%s: %s\n" % (sys.argv[0], e)) +if pycompat.ispy3: +e = str(e).encode('utf8') +pycompat.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e)) showhelp() sys.exit(1) except error.Abort as e: -sys.stderr.write(b"abort: %s\n" % e) +pycompat.stderr.write(b"abort: %s\n" % e) sys.exit(255) except KeyboardInterrupt: sys.exit(255) To: durin42, #hg-reviewers Cc: mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5080: context: open files in bytes mode
durin42 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY I'm stunned this open() call has survived this long without the b in the mode - it seems like it should have been a source of bugs somewhere... REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5080 AFFECTED FILES mercurial/context.py CHANGE DETAILS diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -2433,5 +2433,5 @@ def write(self, data, flags, **kwargs): assert not flags -with open(self._path, "w") as f: +with open(self._path, "wb") as f: f.write(data) To: durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5082: py3: 3 more passing tests
durin42 created this revision. Herald added a reviewer: pulkit. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5082 AFFECTED FILES contrib/python3-whitelist CHANGE DETAILS diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -60,6 +60,7 @@ test-check-code.t test-check-commit.t test-check-config.py +test-check-config.t test-check-execute.t test-check-interfaces.py test-check-module-imports.t @@ -95,6 +96,7 @@ test-contrib-perf.t test-contrib-relnotes.t test-contrib-testparseutil.t +test-contrib.t test-convert-authormap.t test-convert-clonebranches.t test-convert-cvs-branch.t @@ -197,6 +199,7 @@ test-fileset-generated.t test-fileset.t test-fix-topology.t +test-fix.t test-flags.t test-generaldelta.t test-getbundle.t To: durin42, pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5059: contrib: fix up output in check-config.py to use strs to avoid b prefixes
durin42 updated this revision to Diff 12071. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5059?vs=12049=12071 REVISION DETAIL https://phab.mercurial-scm.org/D5059 AFFECTED FILES contrib/check-config.py contrib/python3-whitelist CHANGE DETAILS diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -59,6 +59,7 @@ test-changelog-exec.t test-check-code.t test-check-commit.t +test-check-config.py test-check-execute.t test-check-interfaces.py test-check-module-imports.t diff --git a/contrib/check-config.py b/contrib/check-config.py --- a/contrib/check-config.py +++ b/contrib/check-config.py @@ -42,6 +42,14 @@ config:\s(?P\S+\.\S+)$ ''', re.VERBOSE | re.MULTILINE) +if sys.version_info[0] > 2: +def mkstr(b): +if isinstance(b, str): +return b +return b.decode('utf8') +else: +mkstr = lambda x: x + def main(args): for f in args: sect = b'' @@ -92,7 +100,7 @@ # look for ignore markers m = ignorere.search(l) if m: -if m.group('reason') == 'inconsistent': +if m.group('reason') == b'inconsistent': allowinconsistent.add(m.group('config')) else: documented[m.group('config')] = 1 @@ -106,16 +114,20 @@ ctype = 'str' name = m.group('section') + b"." + m.group('option') default = m.group('default') -if default in (None, 'False', 'None', '0', '[]', '""', "''"): +if default in ( +None, b'False', b'None', b'0', b'[]', b'""', b"''"): default = b'' if re.match(b'[a-z.]+$', default): default = b'' if (name in foundopts and (ctype, default) != foundopts[name] and name not in allowinconsistent): -print(l.rstrip()) -print("conflict on %s: %r != %r" % (name, (ctype, default), -foundopts[name])) -print("at %s:%d:" % (f, linenum)) +print(mkstr(l.rstrip())) +fctype, fdefault = foundopts[name] +print("conflict on %s: %r != %r" % ( +mkstr(name), +(mkstr(ctype), mkstr(default)), +(mkstr(fctype), mkstr(fdefault +print("at %s:%d:" % (mkstr(f), linenum)) foundopts[name] = (ctype, default) carryover = b'' else: @@ -132,8 +144,13 @@ name.startswith(b"debug.")): ctype, default = foundopts[name] if default: +if isinstance(default, bytes): +default = mkstr(default) default = ' [%s]' % default -print("undocumented: %s (%s)%s" % (name, ctype, default)) +elif isinstance(default, bytes): +default = mkstr(default) +print("undocumented: %s (%s)%s" % ( +mkstr(name), mkstr(ctype), default)) if __name__ == "__main__": if len(sys.argv) > 1: To: durin42, pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5061: f: fix a Python 3 bytes/string issue
durin42 updated this revision to Diff 12070. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5061?vs=12026=12070 REVISION DETAIL https://phab.mercurial-scm.org/D5061 AFFECTED FILES tests/f CHANGE DETAILS diff --git a/tests/f b/tests/f --- a/tests/f +++ b/tests/f @@ -88,9 +88,11 @@ if opts.newer: # mtime might be in whole seconds so newer file might be same if stat.st_mtime >= os.stat(opts.newer).st_mtime: -facts.append(b'newer than %s' % opts.newer) +facts.append(b'newer than %s' % opts.newer.encode( +'utf8', 'replace')) else: -facts.append(b'older than %s' % opts.newer) +facts.append(b'older than %s' % opts.newer.encode( +'utf8', 'replace')) if opts.md5 and content is not None: h = hashlib.md5(content) facts.append(b'md5=%s' % binascii.hexlify(h.digest())[:opts.bytes]) To: durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D4995: tests: disable one check on Python 3
durin42 updated this revision to Diff 12069. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D4995?vs=12048=12069 REVISION DETAIL https://phab.mercurial-scm.org/D4995 AFFECTED FILES contrib/python3-whitelist tests/test-extension.t CHANGE DETAILS diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -531,6 +531,10 @@ Examine whether sub-module is imported relatively as expected. +#endif + +#if demandimport no-py3k + See also issue5208 for detail about example case on Python 3.x. $ f -q $TESTTMP/extlibroot/lsub1/lsub2/notexist.py diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -185,6 +185,7 @@ test-export.t test-extdata.t test-extdiff.t +test-extension.t test-extensions-afterloaded.t test-extensions-wrapfunction.py test-extra-filelog-entry.t To: durin42, pulkit, #hg-reviewers Cc: mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5078: py3: fix infinitepush extension tests
pulkit added inline comments. INLINE COMMENTS > store.py:83 > def write(self, data): > -filename = hashlib.sha1(data).hexdigest() > +filename = pycompat.sysbytes(hashlib.sha1(data).hexdigest()) > dirpath = self._dirpath(filename) We use `node.hex(sha1.digest())` in such cases. Sorry for having preferences here ;) REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5078 To: mbthomas, pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5079: py3: use py3 as the test tag, dropping the k
mjpieters 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/D5079 AFFECTED FILES mercurial/help.py mercurial/thirdparty/zope/interface/_compat.py tests/hghave.py tests/run-tests.py tests/test-check-py3-compat.t tests/test-debugcommands.t tests/test-extension.t tests/test-globalopts.t CHANGE DETAILS diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t --- a/tests/test-globalopts.t +++ b/tests/test-globalopts.t @@ -267,7 +267,7 @@ #if no-chg $ hg --cwd c --config x --traceback id 2>&1 | grep -i 'traceback' Traceback (most recent call last): - Traceback (most recent call last): (py3k !) + Traceback (most recent call last): (py3 !) #else Traceback for '--config' errors not supported with chg. $ hg --cwd c --config x --traceback id 2>&1 | grep -i 'traceback' diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -222,7 +222,7 @@ ambigabs.s=libroot/ambig.py $TESTTMP/a -#if no-py3k +#if no-py3 $ cat > $TESTTMP/libroot/mod/ambigrel.py < from __future__ import print_function > import ambig # should load "libroot/mod/ambig.py" @@ -290,7 +290,7 @@ (extroot) import extroot.bar in func(): this is extroot.bar $TESTTMP/a -#if no-py3k +#if no-py3 $ rm "$TESTTMP"/extroot/foo.* $ rm -Rf "$TESTTMP/extroot/__pycache__" $ cat > $TESTTMP/extroot/foo.py < -X hgdemandimport/demandimportpy2.py \ > -X mercurial/thirdparty/cbor \ @@ -24,7 +24,7 @@ setup.py not using absolute_import #endif -#if py3k +#if py3 $ testrepohg files 'set:(**.py) - grep(pygments)' \ > -X hgdemandimport/demandimportpy2.py \ > -X hgext/fsmonitor/pywatchman \ @@ -41,7 +41,7 @@ mercurial/scmposix.py: error importing: No module named 'fcntl' (error at scmposix.py:*) (windows !) #endif -#if py3k pygments +#if py3 pygments $ testrepohg files 'set:(**.py) and grep(pygments)' | sed 's|\\|/|g' \ > | xargs "$PYTHON" contrib/check-py3-compat.py \ > | sed 's/[0-9][0-9]*)$/*)/' diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -424,7 +424,7 @@ help="prefer IPv6 to IPv4 for network related tests") hgconf.add_argument("--pure", action="store_true", help="use pure Python code instead of C extensions") -hgconf.add_argument("-3", "--py3k-warnings", action="store_true", +hgconf.add_argument("-3", "--py3-warnings", action="store_true", help="enable Py3k warnings on Python 2.7+") hgconf.add_argument("--with-chg", metavar="CHG", help="use specified chg wrapper in place of hg") @@ -561,10 +561,10 @@ 'warning: --slowtimeout option ignored with --debug\n') options.timeout = 0 options.slowtimeout = 0 -if options.py3k_warnings: +if options.py3_warnings: if PYTHON3: parser.error( -'--py3k-warnings can only be used on Python 2.7') +'--py3-warnings can only be used on Python 2.7') if options.blacklist: options.blacklist = parselistfiles(options.blacklist, 'blacklist') @@ -688,7 +688,7 @@ first=False, timeout=None, startport=None, extraconfigopts=None, - py3kwarnings=False, shell=None, hgcommand=None, + py3warnings=False, shell=None, hgcommand=None, slowtimeout=None, usechg=False, useipv6=False): """Create a test from parameters. @@ -717,7 +717,7 @@ must have the form "key=value" (something understood by hgrc). Values of the form "foo.key=value" will result in "[foo] key=value". -py3kwarnings enables Py3k warnings. +py3warnings enables Py3k warnings. shell is the shell to execute tests in. """ @@ -743,7 +743,7 @@ self._slowtimeout = slowtimeout self._startport = startport self._extraconfigopts = extraconfigopts or [] -self._py3kwarnings = py3kwarnings +self._py3warnings = py3warnings self._shell = _bytespath(shell) self._hgcommand = hgcommand or b'hg' self._usechg = usechg @@ -1217,8 +1217,8 @@ return os.path.join(self._testdir, b'%s.out' % self.bname) def _run(self, env): -py3kswitch = self._py3kwarnings and b' -3' or b'' -cmd = b'"%s"%s "%s"' % (PYTHON, py3kswitch, self.path) +py3switch = self._py3warnings and b' -3' or b'' +cmd = b'%s%s "%s"' % (PYTHON, py3switch, self.path) vlog("# Running", cmd) normalizenewlines = os.name == 'nt' result = self._runcommand(cmd, env, @@ -2891,7 +2891,7 @@ timeout=self.options.timeout, startport=self._getport(count),
D5067: help: assigning categories to existing commands
rdamazio updated this revision to Diff 12062. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5067?vs=12041=12062 REVISION DETAIL https://phab.mercurial-scm.org/D5067 AFFECTED FILES hgext/absorb.py hgext/amend.py hgext/blackbox.py hgext/censor.py hgext/children.py hgext/churn.py hgext/closehead.py hgext/extdiff.py hgext/fetch.py hgext/fix.py hgext/githelp.py hgext/gpg.py hgext/graphlog.py hgext/hgk.py hgext/histedit.py hgext/journal.py hgext/mq.py hgext/patchbomb.py hgext/purge.py hgext/rebase.py hgext/record.py hgext/releasenotes.py hgext/relink.py hgext/share.py hgext/shelve.py hgext/show.py hgext/split.py hgext/strip.py hgext/transplant.py hgext/uncommit.py mercurial/commands.py mercurial/help.py tests/test-globalopts.t tests/test-help.t tests/test-mq.t CHANGE DETAILS diff --git a/tests/test-mq.t b/tests/test-mq.t --- a/tests/test-mq.t +++ b/tests/test-mq.t @@ -73,29 +73,46 @@ list of commands: + Repository creation: + + qcloneclone main and patch repository at same time + + Change creation: + + qnew create a new patch + qrefresh update the current patch + + Change manipulation: + + qfold fold the named patches into the current patch + + Change organization: + qapplied print the patches already applied - qcloneclone main and patch repository at same time qdelete remove patches from queue - qdiff diff of the current patch and subsequent modifications qfinish move applied patches into repository history - qfold fold the named patches into the current patch qgoto push or pop patches until named patch is at top of stack qguardset or print guards for a patch qheader print the header of the topmost or specified patch - qimport import a patch or existing changeset - qnew create a new patch qnext print the name of the next pushable patch qpop pop the current patch off the stack qprev print the name of the preceding applied patch qpush push the next patch onto the stack qqueuemanage multiple patch queues - qrefresh update the current patch qrename rename a patch qselect set or print guarded patches to push qseries print the entire series file qtop print the name of the current patch qunappliedprint the patches not yet applied + File content management: + + qdiff diff of the current patch and subsequent modifications + + Change import/export: + + qimport import a patch or existing changeset + (use 'hg help -v mq' to show built-in aliases and global options) $ hg init a diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -53,55 +53,87 @@ list of commands: - add add the specified files on the next commit - addremove add all new files, delete all missing files - annotate show changeset information by line for each file - archive create an unversioned archive of a repository revision + Repository creation: + + clone make a copy of an existing repository + init create a new repository in the given directory + + Remote repository management: + + incoming show new changesets found in source + outgoing show changesets not found in the destination + paths show aliases for remote repositories + pull pull changes from the specified source + push push changes to the specified destination + serve start stand-alone webserver + + Change creation: + + commitcommit the specified files or all outstanding changes + + Change manipulation: + backout reverse effect of earlier changeset - bisectsubdivision search of changesets + graft copy changes from other branches onto the current branch + merge merge another revision into working directory + + Change organization: + bookmarks create a new bookmark or list existing bookmarks branchset or show the current branch name branches list repository named branches - bundlecreate a bundle file + phase set or show the current phase name + tag add one or more tags for the current or given revision + tags list repository tags + + File content management: + + annotate show changeset information by line for each file cat output the current or given revision of files - clone make a copy of an existing repository - commitcommit the specified files or all outstanding changes - configshow combined config settings from all hgrc files copy mark files as copied for the next
D5069: help: adding a proper declaration for shortlist/basic commands
rdamazio updated this revision to Diff 12064. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5069?vs=12043=12064 REVISION DETAIL https://phab.mercurial-scm.org/D5069 AFFECTED FILES contrib/perf.py hgext/absorb.py hgext/blackbox.py hgext/fastannotate/commands.py hgext/githelp.py hgext/mq.py hgext/record.py hgext/sparse.py hgext/split.py hgext/uncommit.py mercurial/cmdutil.py mercurial/commands.py mercurial/help.py mercurial/hgweb/webcommands.py mercurial/registrar.py tests/test-completion.t CHANGE DETAILS diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -231,31 +231,18 @@ Show all commands + options $ hg debugcommands add: include, exclude, subrepos, dry-run + addremove: similarity, subrepos, include, exclude, dry-run annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template - clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure - commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos - diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos - export: bookmark, output, switch-parent, rev, text, git, binary, nodates, template - forget: interactive, include, exclude, dry-run - init: ssh, remotecmd, insecure - log: follow, follow-first, date, copies, keyword, rev, line-range, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude - merge: force, rev, preview, abort, tool - pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure - push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure - remove: after, force, subrepos, include, exclude, dry-run - serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, print-url, subrepos - status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template - summary: remote - update: clean, check, merge, date, rev, tool - addremove: similarity, subrepos, include, exclude, dry-run archive: no-decode, prefix, rev, type, subrepos, include, exclude backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user bisect: reset, good, bad, skip, extend, command, noupdate bookmarks: force, rev, delete, rename, inactive, list, template branch: force, clean, rev branches: active, closed, template bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure cat: output, rev, decode, include, exclude, template + clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure + commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos config: untrusted, edit, local, global, template copy: after, force, include, exclude, dry-run debugancestor: @@ -317,30 +304,43 @@ debugwhyunstable: debugwireargs: three, four, five, ssh, remotecmd, insecure debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure + diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos + export: bookmark, output, switch-parent, rev, text, git, binary, nodates, template files: rev, print0, include, exclude, template, subrepos + forget: interactive, include, exclude, dry-run graft: rev, continue, stop, abort, edit, log, no-commit, force, currentdate, currentuser, date, user, tool, dry-run grep: print0, all, diff, text, follow, ignore-case, files-with-matches, line-number, rev, all-files, user, date, template, include, exclude heads: rev, topo, active, closed, style, template help: extension, command, keyword, system identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos + init: ssh, remotecmd, insecure locate: rev, print0, fullpath, include, exclude + log: follow, follow-first, date,
D5078: py3: fix infinitepush extension tests
mbthomas created this revision. Herald added a reviewer: pulkit. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D5078 AFFECTED FILES contrib/python3-whitelist hgext/infinitepush/__init__.py hgext/infinitepush/common.py hgext/infinitepush/store.py CHANGE DETAILS diff --git a/hgext/infinitepush/store.py b/hgext/infinitepush/store.py --- a/hgext/infinitepush/store.py +++ b/hgext/infinitepush/store.py @@ -80,7 +80,7 @@ return os.path.join(self._dirpath(filename), filename) def write(self, data): -filename = hashlib.sha1(data).hexdigest() +filename = pycompat.sysbytes(hashlib.sha1(data).hexdigest()) dirpath = self._dirpath(filename) if not os.path.exists(dirpath): diff --git a/hgext/infinitepush/common.py b/hgext/infinitepush/common.py --- a/hgext/infinitepush/common.py +++ b/hgext/infinitepush/common.py @@ -33,7 +33,7 @@ fd, bundlefile = pycompat.mkstemp() try: # guards bundlefile try: # guards fp -fp = os.fdopen(fd, 'wb') +fp = os.fdopen(fd, r'wb') fp.write(data) finally: fp.close() diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py --- a/hgext/infinitepush/__init__.py +++ b/hgext/infinitepush/__init__.py @@ -357,8 +357,7 @@ if not self.capable('pushkey'): yield {}, None f = wireprotov1peer.future() -self.ui.debug('preparing listkeys for "%s" with pattern "%s"\n' % - (namespace, patterns)) +self.ui.debug('preparing listkeys for "%s"\n' % namespace) yield { 'namespace': encoding.fromlocal(namespace), 'patterns': wireprototypes.encodelist(patterns) @@ -696,8 +695,8 @@ return common, True, remoteheads def _push(orig, ui, repo, dest=None, *args, **opts): - -bookmark = opts.get(r'bookmark') +opts = pycompat.byteskwargs(opts) +bookmark = opts.get('bookmark') # we only support pushing one infinitepush bookmark at once if len(bookmark) == 1: bookmark = bookmark[0] @@ -718,7 +717,7 @@ if scratchpush: # this is an infinitepush, we don't want the bookmark to be applied # rather that should be stored in the bundlestore -opts[r'bookmark'] = [] +opts['bookmark'] = [] ui.setconfig(experimental, configscratchpush, True) oldphasemove = extensions.wrapfunction(exchange, '_localphasemove', @@ -732,7 +731,7 @@ # Remote scratch bookmarks will be deleted because remotenames doesn't # know about them. Let's save it before push and restore after remotescratchbookmarks = _readscratchremotebookmarks(ui, repo, destpath) -result = orig(ui, repo, dest, *args, **opts) +result = orig(ui, repo, dest, *args, **pycompat.strkwargs(opts)) if common.isremotebooksenabled(ui): if bookmark and scratchpush: other = hg.peer(repo, opts, destpath) @@ -899,7 +898,7 @@ if part.type in ('pushkey', 'changegroup'): if op.reply is not None: rpart = op.reply.newpart('reply:%s' % part.type) -rpart.addparam('in-reply-to', str(part.id), +rpart.addparam('in-reply-to', b'%d' % part.id, mandatory=False) rpart.addparam('return', '1', mandatory=False) diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -239,6 +239,9 @@ test-import.t test-imports-checker.t test-incoming-outgoing.t +test-infinitepush-bundlestore.t +test-infinitepush-ci.t +test-infinitepush.t test-inherit-mode.t test-init.t test-issue1089.t To: mbthomas, pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5077: help: allow hiding of help topics
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/D5077 AFFECTED FILES mercurial/help.py tests/test-help-hide.t CHANGE DETAILS diff --git a/tests/test-help-hide.t b/tests/test-help-hide.t --- a/tests/test-help-hide.t +++ b/tests/test-help-hide.t @@ -124,3 +124,130 @@ scripting Using Mercurial from scripts and automation (use 'hg help -v' to show built-in aliases and global options) + +Test hiding some topics. + + $ hg --config help.hide.deprecated=true --config help.hide.internals=true \ + > --config help.hide.scripting=true help + Mercurial Distributed SCM + + list of commands: + + Repository creation: + + clone make a copy of an existing repository + init create a new repository in the given directory + + Remote repository management: + + incoming show new changesets found in source + outgoing show changesets not found in the destination + paths show aliases for remote repositories + pull pull changes from the specified source + push push changes to the specified destination + serve start stand-alone webserver + + Change creation: + + commitcommit the specified files or all outstanding changes + + Change manipulation: + + backout reverse effect of earlier changeset + graft copy changes from other branches onto the current branch + merge merge another revision into working directory + + Change organization: + + bookmarks create a new bookmark or list existing bookmarks + branchset or show the current branch name + branches list repository named branches + phase set or show the current phase name + tag add one or more tags for the current or given revision + tags list repository tags + + File content management: + + annotate show changeset information by line for each file + cat output the current or given revision of files + copy mark files as copied for the next commit + diff diff repository (or selected files) + grep search revision history for a pattern in specified files + + Change navigation: + + bisectsubdivision search of changesets + heads show branch heads + identify identify the working directory or specified revision + log show revision history of entire repository or files + + Working directory management: + + add add the specified files on the next commit + addremove add all new files, delete all missing files + files list tracked files + forgetforget the specified files on the next commit + removeremove the specified files on the next commit + renamerename files; equivalent of copy + remove + resolve redo merges or set/view the merge status of files + revertrestore files to their checkout state + root print the root (top) of the current working directory + statusshow changed files in the working directory + summary summarize working directory state + updateupdate working directory (or switch revisions) + + Change import/export: + + archive create an unversioned archive of a repository revision + bundlecreate a bundle file + exportdump the header and diffs for one or more changesets + importimport an ordered set of patches + unbundle apply one or more bundle files + + Repository maintenance: + + manifest output the current or given revision of the project manifest + recover roll back an interrupted transaction + verifyverify the integrity of the repository + + Help: + + configshow combined config settings from all hgrc files + help show help for a given topic or a help overview + version output version and copyright information + + additional help topics: + + Mercurial identifiers: + + filesets Specifying File Sets + hgignore Syntax for Mercurial Ignore Files + patterns File Name Patterns + revisions Specifying Revisions + urls URL Paths + + Mercurial output: + + color Colorizing Outputs + dates Date Formats + diffs Diff Formats + templatingTemplate Usage + + Mercurial configuration: + + configConfiguration Files + environment Environment Variables + extensionsUsing Additional Features + flags Command-line flags + hgweb Configuring hgweb + merge-tools Merge Tools + pager Pager Support + + Concepts: + + bundlespecBundle File Formats + glossary Glossary + phasesWorking with Phases + subrepos Subrepositories + + (use 'hg help
D5076: help: allow commands to be hidden
rdamazio created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This is useful in enterprise environments where some workflows are discouraged. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5076 AFFECTED FILES mercurial/configitems.py mercurial/help.py tests/test-help-hide.t CHANGE DETAILS diff --git a/tests/test-help-hide.t b/tests/test-help-hide.t new file mode 100644 --- /dev/null +++ b/tests/test-help-hide.t @@ -0,0 +1,126 @@ +Test hiding some commands (which also happens to hide an entire category). + + $ hg --config help.hide.clone=true --config help.hide.init=true help + Mercurial Distributed SCM + + list of commands: + + Remote repository management: + + incoming show new changesets found in source + outgoing show changesets not found in the destination + paths show aliases for remote repositories + pull pull changes from the specified source + push push changes to the specified destination + serve start stand-alone webserver + + Change creation: + + commitcommit the specified files or all outstanding changes + + Change manipulation: + + backout reverse effect of earlier changeset + graft copy changes from other branches onto the current branch + merge merge another revision into working directory + + Change organization: + + bookmarks create a new bookmark or list existing bookmarks + branchset or show the current branch name + branches list repository named branches + phase set or show the current phase name + tag add one or more tags for the current or given revision + tags list repository tags + + File content management: + + annotate show changeset information by line for each file + cat output the current or given revision of files + copy mark files as copied for the next commit + diff diff repository (or selected files) + grep search revision history for a pattern in specified files + + Change navigation: + + bisectsubdivision search of changesets + heads show branch heads + identify identify the working directory or specified revision + log show revision history of entire repository or files + + Working directory management: + + add add the specified files on the next commit + addremove add all new files, delete all missing files + files list tracked files + forgetforget the specified files on the next commit + removeremove the specified files on the next commit + renamerename files; equivalent of copy + remove + resolve redo merges or set/view the merge status of files + revertrestore files to their checkout state + root print the root (top) of the current working directory + statusshow changed files in the working directory + summary summarize working directory state + updateupdate working directory (or switch revisions) + + Change import/export: + + archive create an unversioned archive of a repository revision + bundlecreate a bundle file + exportdump the header and diffs for one or more changesets + importimport an ordered set of patches + unbundle apply one or more bundle files + + Repository maintenance: + + manifest output the current or given revision of the project manifest + recover roll back an interrupted transaction + verifyverify the integrity of the repository + + Help: + + configshow combined config settings from all hgrc files + help show help for a given topic or a help overview + version output version and copyright information + + additional help topics: + + Mercurial identifiers: + + filesets Specifying File Sets + hgignore Syntax for Mercurial Ignore Files + patterns File Name Patterns + revisions Specifying Revisions + urls URL Paths + + Mercurial output: + + color Colorizing Outputs + dates Date Formats + diffs Diff Formats + templatingTemplate Usage + + Mercurial configuration: + + configConfiguration Files + environment Environment Variables + extensionsUsing Additional Features + flags Command-line flags + hgweb Configuring hgweb + merge-tools Merge Tools + pager Pager Support + + Concepts: + + bundlespecBundle File Formats + glossary Glossary + phasesWorking with Phases + subrepos Subrepositories + + Miscellaneous: + + deprecatedDeprecated Features + internals Technical implementation topics + scripting Using Mercurial from scripts and automation +
D5068: help: assigning topic categories
rdamazio updated this revision to Diff 12063. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5068?vs=12042=12063 REVISION DETAIL https://phab.mercurial-scm.org/D5068 AFFECTED FILES doc/gendoc.py mercurial/help.py tests/test-globalopts.t tests/test-help.t CHANGE DETAILS diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -138,29 +138,43 @@ additional help topics: - bundlespecBundle File Formats + Mercurial identifiers: + + filesets Specifying File Sets + hgignore Syntax for Mercurial Ignore Files + patterns File Name Patterns + revisions Specifying Revisions + urls URL Paths + + Mercurial output: + color Colorizing Outputs + dates Date Formats + diffs Diff Formats + templatingTemplate Usage + + Mercurial configuration: + configConfiguration Files - dates Date Formats - deprecatedDeprecated Features - diffs Diff Formats environment Environment Variables extensionsUsing Additional Features - filesets Specifying File Sets flags Command-line flags - glossary Glossary - hgignore Syntax for Mercurial Ignore Files hgweb Configuring hgweb - internals Technical implementation topics merge-tools Merge Tools pager Pager Support - patterns File Name Patterns + + Concepts: + + bundlespecBundle File Formats + glossary Glossary phasesWorking with Phases - revisions Specifying Revisions + subrepos Subrepositories + + Miscellaneous: + + deprecatedDeprecated Features + internals Technical implementation topics scripting Using Mercurial from scripts and automation - subrepos Subrepositories - templatingTemplate Usage - urls URL Paths (use 'hg help -v' to show built-in aliases and global options) @@ -250,29 +264,43 @@ additional help topics: - bundlespecBundle File Formats + Mercurial identifiers: + + filesets Specifying File Sets + hgignore Syntax for Mercurial Ignore Files + patterns File Name Patterns + revisions Specifying Revisions + urls URL Paths + + Mercurial output: + color Colorizing Outputs + dates Date Formats + diffs Diff Formats + templatingTemplate Usage + + Mercurial configuration: + configConfiguration Files - dates Date Formats - deprecatedDeprecated Features - diffs Diff Formats environment Environment Variables extensionsUsing Additional Features - filesets Specifying File Sets flags Command-line flags - glossary Glossary - hgignore Syntax for Mercurial Ignore Files hgweb Configuring hgweb - internals Technical implementation topics merge-tools Merge Tools pager Pager Support - patterns File Name Patterns + + Concepts: + + bundlespecBundle File Formats + glossary Glossary phasesWorking with Phases - revisions Specifying Revisions + subrepos Subrepositories + + Miscellaneous: + + deprecatedDeprecated Features + internals Technical implementation topics scripting Using Mercurial from scripts and automation - subrepos Subrepositories - templatingTemplate Usage - urls URL Paths Test extension help: $ hg help extensions --config extensions.rebase= --config extensions.children= @@ -963,29 +991,43 @@ additional help topics: - bundlespecBundle File Formats + Mercurial identifiers: + + filesets Specifying File Sets + hgignore Syntax for Mercurial Ignore Files + patterns File Name Patterns + revisions Specifying Revisions + urls URL Paths + + Mercurial output: + color Colorizing Outputs + dates Date Formats + diffs Diff Formats + templatingTemplate Usage + + Mercurial configuration: + configConfiguration Files - dates Date Formats - deprecatedDeprecated Features - diffs Diff Formats environment Environment Variables extensionsUsing Additional Features - filesets Specifying File Sets flags Command-line flags - glossary Glossary - hgignore Syntax for Mercurial Ignore Files hgweb Configuring hgweb - internals Technical implementation topics merge-tools Merge Tools pager Pager Support - patterns File Name Patterns + + Concepts: + + bundlespecBundle File Formats + glossary Glossary phasesWorking with Phases - revisions Specifying Revisions + subrepos Subrepositories + + Miscellaneous: +
D5066: help: splitting the topics by category
rdamazio updated this revision to Diff 12061. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5066?vs=12040=12061 REVISION DETAIL https://phab.mercurial-scm.org/D5066 AFFECTED FILES mercurial/help.py mercurial/hgweb/webcommands.py CHANGE DETAILS diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -1401,7 +1401,8 @@ topicname = web.req.qsparams.get('node') if not topicname: def topics(context): -for entries, summary, _doc in helpmod.helptable: +for h in helpmod.helptable: +entries, summary, _doc = h[0:3] yield {'topic': entries[0], 'summary': summary} early, other = [], [] diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -58,6 +58,17 @@ CATEGORY_NONE, ] +# Topic categories. +TOPIC_CATEGORY_NONE = _('Uncategorized topics') + +# The order in which topic categories will be displayed. +# Extensions with custom categories should insert them into this list +# after/before the appropriate item, rather than replacing the list or +# assuming absolute positions. +TOPIC_CATEGORY_ORDER = [ +TOPIC_CATEGORY_NONE, +] + def listexts(header, exts, indent=1, showdeprecated=False): '''return a text listing of the given extensions''' rst = [] @@ -148,7 +159,8 @@ 'extensions': [], 'extensioncommands': [], } -for names, header, doc in helptable: +for topic in helptable: +names, header, doc = topic[0:3] # Old extensions may use a str as doc. if (sum(map(lowercontains, names)) or lowercontains(header) @@ -514,12 +526,34 @@ rst.append('\n') rst.extend(exts) -rst.append(_("\nadditional help topics:\n\n")) -topics = [] -for names, header, doc in helptable: -topics.append((names[0], header)) -for t, desc in topics: -rst.append(" :%s: %s\n" % (t, desc)) +rst.append(_("\nadditional help topics:\n")) +# Group commands by category. +topiccats = {} +for topic in helptable: +names, header, doc = topic[0:3] +if len(topic) > 3 and topic[3]: +category = topic[3] +else: +category = TOPIC_CATEGORY_NONE + +topiccats.setdefault(category, []).append((names[0], header)) + +# Check that all categories have an order. +missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER) +if missing_order: +ui.develwarn( +'Help categories missing from TOPIC_CATEGORY_ORDER: %s' % +missing_order) + +# Output topics per category. +for cat in TOPIC_CATEGORY_ORDER: +topics = topiccats.get(cat, []) +if topics: +if len(topiccats) > 1: +rst.append("\n%s:\n" % cat) +rst.append("\n") +for t, desc in topics: +rst.append(" :%s: %s\n" % (t, desc)) if ui.quiet: pass @@ -554,7 +588,8 @@ break if not header: -for names, header, doc in helptable: +for topic in helptable: +names, header, doc = topic[0:3] if name in names: break else: 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
D5065: help: adding support for command categories
rdamazio updated this revision to Diff 12060. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5065?vs=12039=12060 REVISION DETAIL https://phab.mercurial-scm.org/D5065 AFFECTED FILES doc/gendoc.py mercurial/help.py mercurial/registrar.py CHANGE DETAILS diff --git a/mercurial/registrar.py b/mercurial/registrar.py --- a/mercurial/registrar.py +++ b/mercurial/registrar.py @@ -146,6 +146,10 @@ to prevent the command from running if the requested intent could not be fulfilled. +If `helpcategory` is set (usually to one of the constants in the help +module), the command will be displayed under that category in the help's +list of commands. + The following intents are defined: readonly @@ -166,12 +170,12 @@ def _doregister(self, func, name, options=(), synopsis=None, norepo=False, optionalrepo=False, inferrepo=False, -intents=None): - +intents=None, helpcategory=None): func.norepo = norepo func.optionalrepo = optionalrepo func.inferrepo = inferrepo func.intents = intents or set() +func.helpcategory = helpcategory if synopsis: self._table[name] = func, list(options), synopsis else: diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -47,6 +47,17 @@ _("(EXPERIMENTAL)"), } +# Command categories. +CATEGORY_NONE = _('Uncategorized commands') + +# The order in which command categories will be displayed. +# Extensions with custom categories should insert them into this list +# after/before the appropriate item, rather than replacing the list or +# assuming absolute positions. +CATEGORY_ORDER = [ +CATEGORY_NONE, +] + def listexts(header, exts, indent=1, showdeprecated=False): '''return a text listing of the given extensions''' rst = [] @@ -421,53 +432,79 @@ def helplist(select=None, **opts): -# list of commands -if name == "shortlist": -header = _('basic commands:\n\n') -elif name == "debug": -header = _('debug commands (internal and unsupported):\n\n') -else: -header = _('list of commands:\n\n') - +# Category -> list of commands +cats = {} +# Command -> short description h = {} -cmds = {} +# Command -> string showing synonyms +syns = {} for c, e in commands.table.iteritems(): fs = cmdutil.parsealiases(c) f = fs[0] +syns[f] = ', '.join(fs) +func = e[0] p = '' if c.startswith("^"): p = '^' if select and not select(p + f): continue if (not select and name != 'shortlist' and -e[0].__module__ != commands.__name__): +func.__module__ != commands.__name__): continue if name == "shortlist" and not p: continue -doc = pycompat.getdoc(e[0]) +doc = pycompat.getdoc(func) if filtercmd(ui, f, name, doc): continue doc = gettext(doc) if not doc: doc = _("(no help text available)") h[f] = doc.splitlines()[0].rstrip() -cmds[f] = '|'.join(fs) + +cat = getattr(func, 'helpcategory', None) or CATEGORY_NONE +cats.setdefault(cat, []).append(f) rst = [] if not h: if not ui.quiet: rst.append(_('no commands defined\n')) return rst +# Output top header. if not ui.quiet: -rst.append(header) -fns = sorted(h) -for f in fns: -if ui.verbose: -commacmds = cmds[f].replace("|",", ") -rst.append(" :%s: %s\n" % (commacmds, h[f])) +if name == "shortlist": +rst.append(_('basic commands:\n\n')) +elif name == "debug": +rst.append(_('debug commands (internal and unsupported):\n\n')) else: -rst.append(' :%s: %s\n' % (f, h[f])) +rst.append(_('list of commands:\n')) + +def appendcmds(cmds): +cmds = sorted(cmds) +for c in cmds: +if ui.verbose: +rst.append(" :%s: %s\n" % (syns[c], h[c])) +else: +rst.append(' :%s: %s\n' % (c, h[c])) + +if name in ('shortlist', 'debug'): +# List without categories. +appendcmds(h) +else: +# Check that all categories have an order. +missing_order = set(cats.keys()) - set(CATEGORY_ORDER) +if missing_order: +ui.develwarn('Help categories missing from CATEGORY_ORDER: %s' % +
D5064: style: run black on a subset of mercurial
mjpieters updated this revision to Diff 12059. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5064?vs=12047=12059 REVISION DETAIL https://phab.mercurial-scm.org/D5064 AFFECTED FILES contrib/check-commit contrib/import-checker.py mercurial/cacheutil.py mercurial/diffhelper.py mercurial/dirstateguard.py mercurial/httpconnection.py mercurial/i18n.py mercurial/lsprofcalltree.py mercurial/mergeutil.py mercurial/minifileset.py mercurial/node.py mercurial/policy.py mercurial/pushkey.py mercurial/rcutil.py mercurial/rewriteutil.py mercurial/scmposix.py mercurial/scmwindows.py mercurial/stack.py mercurial/state.py mercurial/txnutil.py pyproject.toml tests/test-check-code.t CHANGE DETAILS diff --git a/tests/test-check-code.t b/tests/test-check-code.t --- a/tests/test-check-code.t +++ b/tests/test-check-code.t @@ -50,6 +50,7 @@ hg hgeditor hgweb.cgi + pyproject.toml setup.py Prevent adding modules which could be shadowed by ancient .so/.dylib. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.black] +line-length = 80 +exclude = 'build/|wheelhouse/|dist/|packages/|\.hg/|\.mypy_cache/|\.venv/|mercurial/thirdparty/|hgext/fsmonitor/pywatchman/|contrib/python-zstandard/' diff --git a/mercurial/txnutil.py b/mercurial/txnutil.py --- a/mercurial/txnutil.py +++ b/mercurial/txnutil.py @@ -9,27 +9,27 @@ import errno -from . import ( -encoding, -) +from . import encoding + def mayhavepending(root): -'''return whether 'root' may have pending changes, which are +"""return whether 'root' may have pending changes, which are visible to this process. -''' -return root == encoding.environ.get('HG_PENDING') +""" +return root == encoding.environ.get("HG_PENDING") + def trypending(root, vfs, filename, **kwargs): -'''Open file to be read according to HG_PENDING environment variable +"""Open file to be read according to HG_PENDING environment variable This opens '.pending' of specified 'filename' only when HG_PENDING is equal to 'root'. This returns '(fp, is_pending_opened)' tuple. -''' +""" if mayhavepending(root): try: -return (vfs('%s.pending' % filename, **kwargs), True) +return (vfs("%s.pending" % filename, **kwargs), True) except IOError as inst: if inst.errno != errno.ENOENT: raise diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -19,13 +19,9 @@ from __future__ import absolute_import -from . import ( -error, -util, -) -from .utils import ( -cborutil, -) +from . import error, util +from .utils import cborutil + class cmdstate(object): """a wrapper class to store the state of commands like `rebase`, `graft`, @@ -58,23 +54,25 @@ we use third-party library cbor to serialize data to write in the file. """ if not isinstance(version, int): -raise error.ProgrammingError("version of state file should be" - " an integer") +raise error.ProgrammingError( +"version of state file should be" " an integer" +) -with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp: -fp.write('%d\n' % version) +with self._repo.vfs(self.fname, "wb", atomictemp=True) as fp: +fp.write("%d\n" % version) for chunk in cborutil.streamencode(data): fp.write(chunk) def _read(self): """reads the state file and returns a dictionary which contain data in the same format as it was before storing""" -with self._repo.vfs(self.fname, 'rb') as fp: +with self._repo.vfs(self.fname, "rb") as fp: try: int(fp.readline()) except ValueError: -raise error.CorruptedState("unknown version of state file" - " found") +raise error.CorruptedState( +"unknown version of state file" " found" +) return cborutil.decodeall(fp.read())[0] diff --git a/mercurial/stack.py b/mercurial/stack.py --- a/mercurial/stack.py +++ b/mercurial/stack.py @@ -7,10 +7,8 @@ from __future__ import absolute_import -from . import ( -revsetlang, -scmutil, -) +from . import revsetlang, scmutil + def getstack(repo, rev=None): """return a sorted smartrev of the stack containing either rev if it is @@ -20,9 +18,9 @@ the revision and are not merges. """ if rev is None: -rev = '.' +rev = "." -revspec = 'reverse(only(%s) and not public() and not ::merge())' +revspec = "reverse(only(%s) and not public() and not ::merge())" revset =
[PATCH 2 of 2] py3: build help of compression engines in bytes
# HG changeset patch # User Yuya Nishihara # Date 1539433045 -7200 # Sat Oct 13 14:17:25 2018 +0200 # Node ID 921feabe152110773b8b85818b149a99166b9f74 # Parent b8a16cf84c34d254df7ff276e49e6d5fd327eb8b py3: build help of compression engines in bytes Removes "b''" from help. diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -3867,11 +3867,10 @@ def bundlecompressiontopics(): if not bt or not bt[0]: continue -doc = pycompat.sysstr('``%s``\n%s') % ( -bt[0], engine.bundletype.__doc__) +doc = b'``%s``\n%s' % (bt[0], pycompat.getdoc(engine.bundletype)) value = docobject() -value.__doc__ = doc +value.__doc__ = pycompat.sysstr(doc) value._origdoc = engine.bundletype.__doc__ value._origfunc = engine.bundletype ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 2] py3: do I/O in bytes in test-help.t
# HG changeset patch # User Yuya Nishihara # Date 1539432672 -7200 # Sat Oct 13 14:11:12 2018 +0200 # Node ID b8a16cf84c34d254df7ff276e49e6d5fd327eb8b # Parent 8603435ad64c35c4472726350e391076ad25c3aa py3: do I/O in bytes in test-help.t diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -1799,13 +1799,13 @@ such str.lower(). $ "$PYTHON" < def escape(s): - > return ''.join('\u%x' % ord(uc) for uc in s.decode('cp932')) + > return b''.join(b'\\u%x' % ord(uc) for uc in s.decode('cp932')) > # translation of "record" in ja_JP.cp932 - > upper = "\x8bL\x98^" + > upper = b"\x8bL\x98^" > # str.lower()-ed section name should be treated as different one - > lower = "\x8bl\x98^" - > with open('ambiguous.py', 'w') as fp: - > fp.write("""# ambiguous section names in ja_JP.cp932 + > lower = b"\x8bl\x98^" + > with open('ambiguous.py', 'wb') as fp: + > fp.write(b"""# ambiguous section names in ja_JP.cp932 > u'''summary of extension > > %s @@ -1832,8 +1832,9 @@ such str.lower(). > EOF $ "$PYTHON" < upper = "\x8bL\x98^" - > print("hg --encoding cp932 help -e ambiguous.%s" % upper) + > from mercurial import pycompat + > upper = b"\x8bL\x98^" + > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper) > EOF \x8bL\x98^ (esc) @@ -1842,8 +1843,9 @@ such str.lower(). $ "$PYTHON" < lower = "\x8bl\x98^" - > print("hg --encoding cp932 help -e ambiguous.%s" % lower) + > from mercurial import pycompat + > lower = b"\x8bl\x98^" + > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower) > EOF \x8bl\x98^ (esc) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5075: tests: accept slightly different zip file in Python 3
This revision was automatically updated to reflect the committed changes. Closed by commit rHGc9e8c93e241c: tests: accept slightly different zip file in Python 3 (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5075?vs=12052=12058 REVISION DETAIL https://phab.mercurial-scm.org/D5075 AFFECTED FILES contrib/python3-whitelist tests/test-archive.t CHANGE DETAILS diff --git a/tests/test-archive.t b/tests/test-archive.t --- a/tests/test-archive.t +++ b/tests/test-archive.t @@ -187,7 +187,8 @@ server: testing stub value transfer-encoding: chunked - body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 + body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 (no-py3k !) + body: size=1461, sha1=be6d3983aa13dfe930361b2569291cdedd02b537 (py3k !) % tar.gz and tar.bz2 disallowed should both give 403 403 Archive type not allowed: gz content-type: text/html; charset=ascii @@ -274,7 +275,8 @@ server: testing stub value transfer-encoding: chunked - body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 + body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 (no-py3k !) + body: size=1461, sha1=be6d3983aa13dfe930361b2569291cdedd02b537 (py3k !) % tar.gz and tar.bz2 disallowed should both give 403 403 Archive type not allowed: gz content-type: text/html; charset=ascii diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -14,6 +14,7 @@ test-annotate.py test-annotate.t test-archive-symlinks.t +test-archive.t test-atomictempfile.py test-audit-path.t test-audit-subrepo.t To: durin42, pulkit, #hg-reviewers Cc: mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5074: webcommands: use stringutil.pprint() to repr invalid archive types
This revision was automatically updated to reflect the committed changes. Closed by commit rHGb24c23f7c1f9: webcommands: use stringutil.pprint() to repr invalid archive types (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5074?vs=12051=12057 REVISION DETAIL https://phab.mercurial-scm.org/D5074 AFFECTED FILES mercurial/hgweb/webcommands.py CHANGE DETAILS diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -1172,7 +1172,7 @@ key = web.req.qsparams['node'] if type_ not in webutil.archivespecs: -msg = 'Unsupported archive type: %s' % type_ +msg = 'Unsupported archive type: %s' % stringutil.pprint(type_) raise ErrorResponse(HTTP_NOT_FOUND, msg) if not ((type_ in allowed or To: durin42, #hg-reviewers, pulkit Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5073: archival: don't try and fsdecode non-{bytes,str} objects
This revision was automatically updated to reflect the committed changes. Closed by commit rHG844deb408a5b: archival: dont try and fsdecode non-{bytes,str} objects (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5073?vs=12050=12056 REVISION DETAIL https://phab.mercurial-scm.org/D5073 AFFECTED FILES mercurial/archival.py CHANGE DETAILS diff --git a/mercurial/archival.py b/mercurial/archival.py --- a/mercurial/archival.py +++ b/mercurial/archival.py @@ -203,7 +203,9 @@ or compressed with deflate.''' def __init__(self, dest, mtime, compress=True): -self.z = zipfile.ZipFile(pycompat.fsdecode(dest), r'w', +if isinstance(dest, bytes): +dest = pycompat.fsdecode(dest) +self.z = zipfile.ZipFile(dest, r'w', compress and zipfile.ZIP_DEFLATED or zipfile.ZIP_STORED) To: durin42, #hg-reviewers, pulkit Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5072: tests: fix last failure in test-tools.t
This revision was automatically updated to reflect the committed changes. Closed by commit rHGbe0a5d2d5c78: tests: fix last failure in test-tools.t (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5072?vs=12038=12055 REVISION DETAIL https://phab.mercurial-scm.org/D5072 AFFECTED FILES contrib/python3-whitelist tests/f CHANGE DETAILS diff --git a/tests/f b/tests/f --- a/tests/f +++ b/tests/f @@ -66,7 +66,7 @@ elif islink: if opts.type: facts.append(b'link') -content = os.readlink(f) +content = os.readlink(f).encode('utf8') elif isstdin: content = getattr(sys.stdin, 'buffer', sys.stdin).read() if opts.size: diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -573,6 +573,7 @@ test-template-functions.t test-template-keywords.t test-template-map.t +test-tools.t test-transplant.t test-treemanifest.t test-ui-color.py To: durin42, pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5071: run-tests: run tests with as many processes as cores by default
This revision was automatically updated to reflect the committed changes. Closed by commit rHGe7e70c033783: run-tests: run tests with as many processes as cores by default (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5071?vs=12037=12054 REVISION DETAIL https://phab.mercurial-scm.org/D5071 AFFECTED FILES tests/run-tests.py tests/test-run-tests.t CHANGE DETAILS diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t --- a/tests/test-run-tests.t +++ b/tests/test-run-tests.t @@ -15,7 +15,7 @@ = $ rt() > { - > "$PYTHON" $TESTDIR/run-tests.py --with-hg=`which hg` "$@" + > "$PYTHON" $TESTDIR/run-tests.py --with-hg=`which hg` -j1 "$@" > } error paths @@ -1329,7 +1329,7 @@ Add support for external test formatter === - $ CUSTOM_TEST_RESULT=basic_test_result "$PYTHON" $TESTDIR/run-tests.py --with-hg=`which hg` "$@" test-success.t test-failure.t + $ CUSTOM_TEST_RESULT=basic_test_result "$PYTHON" $TESTDIR/run-tests.py --with-hg=`which hg` -j1 "$@" test-success.t test-failure.t running 2 tests using 1 parallel processes # Ran 2 tests, 0 skipped, 0 failed. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -51,6 +51,7 @@ import distutils.version as version import errno import json +import multiprocessing import os import random import re @@ -287,7 +288,7 @@ IMPL_PATH = b'JYTHONPATH' defaults = { -'jobs': ('HGTEST_JOBS', 1), +'jobs': ('HGTEST_JOBS', multiprocessing.cpu_count()), 'timeout': ('HGTEST_TIMEOUT', 180), 'slowtimeout': ('HGTEST_SLOWTIMEOUT', 500), 'port': ('HGTEST_PORT', 20059), To: indygreg, #hg-reviewers, pulkit Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5070: run-tests: print number of tests and parallel process count
This revision was automatically updated to reflect the committed changes. Closed by commit rHG1039404c5e1d: run-tests: print number of tests and parallel process count (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5070?vs=12036=12053 REVISION DETAIL https://phab.mercurial-scm.org/D5070 AFFECTED FILES tests/run-tests.py tests/test-run-tests.t CHANGE DETAILS diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t --- a/tests/test-run-tests.t +++ b/tests/test-run-tests.t @@ -7,6 +7,7 @@ Smoke test with install $ "$PYTHON" $TESTDIR/run-tests.py $HGTEST_RUN_TESTS_PURE -l + running 0 tests using 0 parallel processes # Ran 0 tests, 0 skipped, 0 failed. @@ -23,6 +24,7 @@ $ ln -s `which true` hg $ "$PYTHON" $TESTDIR/run-tests.py --with-hg=./hg warning: --with-hg should specify an hg script + running 0 tests using 0 parallel processes # Ran 0 tests, 0 skipped, 0 failed. $ rm hg @@ -55,6 +57,7 @@ $ touch test-empty.t $ rt + running 1 tests using 1 parallel processes . # Ran 1 tests, 0 skipped, 0 failed. $ rm test-empty.t @@ -88,6 +91,7 @@ > EOF $ rt + running 1 tests using 1 parallel processes . # Ran 1 tests, 0 skipped, 0 failed. @@ -102,6 +106,7 @@ > | fo (re) > EOF $ rt test-failure.t + running 1 tests using 1 parallel processes --- $TESTTMP/test-failure.t +++ $TESTTMP/test-failure.t.err @@ -139,6 +144,7 @@ > value: * (glob) > EOF $ rt test-failure-globs.t + running 1 tests using 1 parallel processes --- $TESTTMP/test-failure-globs.t +++ $TESTTMP/test-failure-globs.t.err @@ -234,6 +240,7 @@ > missing (?) > EOF $ rt test-failure.t + running 1 tests using 1 parallel processes --- $TESTTMP/test-failure.t +++ $TESTTMP/test-failure.t.err @@ -292,6 +299,7 @@ >>> fh.write(u' l\u03b5\u03b5t\n'.encode('utf-8')) and None $ rt + running 3 tests using 1 parallel processes --- $TESTTMP/test-failure.t +++ $TESTTMP/test-failure.t.err @@ -323,6 +331,7 @@ test --outputdir $ mkdir output $ rt --outputdir output + running 3 tests using 1 parallel processes --- $TESTTMP/test-failure.t +++ $TESTTMP/output/test-failure.t.err @@ -359,6 +368,7 @@ test --xunit support $ rt --xunit=xunit.xml + running 3 tests using 1 parallel processes --- $TESTTMP/test-failure.t +++ $TESTTMP/test-failure.t.err @@ -481,6 +491,7 @@ $ rt --retest + running 2 tests using 1 parallel processes --- $TESTTMP/test-failure.t +++ $TESTTMP/test-failure.t.err @@ -504,6 +515,7 @@ $ mkdir output $ mv test-failure.t.err output $ rt --retest --outputdir output + running 2 tests using 1 parallel processes --- $TESTTMP/test-failure.t +++ $TESTTMP/output/test-failure.t.err @@ -528,17 +540,20 @@ successful $ rt test-success.t + running 1 tests using 1 parallel processes . # Ran 1 tests, 0 skipped, 0 failed. success w/ keyword $ rt -k xyzzy + running 2 tests using 1 parallel processes . # Ran 2 tests, 1 skipped, 0 failed. failed $ rt test-failure.t + running 1 tests using 1 parallel processes --- $TESTTMP/test-failure.t +++ $TESTTMP/test-failure.t.err @@ -559,6 +574,7 @@ failure w/ keyword $ rt -k rataxes + running 2 tests using 1 parallel processes --- $TESTTMP/test-failure.t +++ $TESTTMP/test-failure.t.err @@ -584,6 +600,7 @@ > $ echo 'abort: child process failed to start blah' > EOF $ rt test-serve-fail.t + running 1 tests using 1 parallel processes --- $TESTTMP/test-serve-fail.t +++ $TESTTMP/test-serve-fail.t.err @@ -614,6 +631,7 @@ > $ cat hg.pid >> \$DAEMON_PIDS > EOF $ rt test-serve-inuse.t + running 1 tests using 1 parallel processes . # Ran 1 tests, 0 skipped, 0 failed. $ rm test-serve-inuse.t @@ -623,6 +641,7 @@ == $ rt --debug 2>&1 | grep -v pwd + running 2 tests using 1 parallel processes + echo *SALT* 0 0 (glob) *SALT* 0 0 (glob) + echo babar @@ -661,6 +680,7 @@ $ cp test-failure.t test-failure-copy.t $ rt --jobs 2 test-failure*.t -n + running 2 tests using 2 parallel processes !! Failed test-failure*.t: output changed (glob) Failed test-failure*.t: output changed (glob) @@ -670,6 +690,7 @@ failures in parallel with --first should only print one failure $ rt --jobs 2 --first test-failure*.t + running 2 tests using 2 parallel processes --- $TESTTMP/test-failure*.t (glob) +++ $TESTTMP/test-failure*.t.err (glob) @@ -701,6 +722,7 @@ Refuse the fix $ echo 'n' | rt -i + running 2 tests using 1 parallel processes --- $TESTTMP/test-failure.t +++ $TESTTMP/test-failure.t.err @@ -734,6 +756,7 @@ Interactive with custom view $ echo 'n' | rt -i --view echo + running 2 tests using 1 parallel processes
D5075: tests: accept slightly different zip file in Python 3
durin42 created this revision. Herald added a reviewer: pulkit. Herald added subscribers: mercurial-devel, mjpieters. Herald added a reviewer: hg-reviewers. REVISION SUMMARY I added some `unzip -t` here and I *think* the only change is from Python 3 having more data in the zip file headers or something. Sigh. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5075 AFFECTED FILES contrib/python3-whitelist tests/test-archive.t CHANGE DETAILS diff --git a/tests/test-archive.t b/tests/test-archive.t --- a/tests/test-archive.t +++ b/tests/test-archive.t @@ -187,7 +187,8 @@ server: testing stub value transfer-encoding: chunked - body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 + body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 (no-py3k !) + body: size=1461, sha1=be6d3983aa13dfe930361b2569291cdedd02b537 (py3k !) % tar.gz and tar.bz2 disallowed should both give 403 403 Archive type not allowed: gz content-type: text/html; charset=ascii @@ -274,7 +275,8 @@ server: testing stub value transfer-encoding: chunked - body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 + body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 (no-py3k !) + body: size=1461, sha1=be6d3983aa13dfe930361b2569291cdedd02b537 (py3k !) % tar.gz and tar.bz2 disallowed should both give 403 403 Archive type not allowed: gz content-type: text/html; charset=ascii diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -14,6 +14,7 @@ test-annotate.py test-annotate.t test-archive-symlinks.t +test-archive.t test-atomictempfile.py test-audit-path.t test-audit-subrepo.t To: durin42, pulkit, #hg-reviewers Cc: mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5074: webcommands: use stringutil.pprint() to repr invalid archive types
durin42 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5074 AFFECTED FILES mercurial/hgweb/webcommands.py CHANGE DETAILS diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -1172,7 +1172,7 @@ key = web.req.qsparams['node'] if type_ not in webutil.archivespecs: -msg = 'Unsupported archive type: %s' % type_ +msg = 'Unsupported archive type: %s' % stringutil.pprint(type_) raise ErrorResponse(HTTP_NOT_FOUND, msg) if not ((type_ in allowed or To: durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5073: archival: don't try and fsdecode non-{bytes,str} objects
durin42 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This function accepts both bytes and file-like objects. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5073 AFFECTED FILES mercurial/archival.py CHANGE DETAILS diff --git a/mercurial/archival.py b/mercurial/archival.py --- a/mercurial/archival.py +++ b/mercurial/archival.py @@ -203,7 +203,9 @@ or compressed with deflate.''' def __init__(self, dest, mtime, compress=True): -self.z = zipfile.ZipFile(pycompat.fsdecode(dest), r'w', +if isinstance(dest, bytes): +dest = pycompat.fsdecode(dest) +self.z = zipfile.ZipFile(dest, r'w', compress and zipfile.ZIP_DEFLATED or zipfile.ZIP_STORED) To: durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5059: contrib: fix up output in check-config.py to use strs to avoid b prefixes
durin42 updated this revision to Diff 12049. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5059?vs=12027=12049 REVISION DETAIL https://phab.mercurial-scm.org/D5059 AFFECTED FILES contrib/check-config.py contrib/python3-whitelist CHANGE DETAILS diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -58,6 +58,7 @@ test-changelog-exec.t test-check-code.t test-check-commit.t +test-check-config.py test-check-execute.t test-check-interfaces.py test-check-module-imports.t diff --git a/contrib/check-config.py b/contrib/check-config.py --- a/contrib/check-config.py +++ b/contrib/check-config.py @@ -42,6 +42,14 @@ config:\s(?P\S+\.\S+)$ ''', re.VERBOSE | re.MULTILINE) +if sys.version_info[0] > 2: +def mkstr(b): +if isinstance(b, str): +return b +return b.decode('utf8') +else: +mkstr = lambda x: x + def main(args): for f in args: sect = b'' @@ -92,7 +100,7 @@ # look for ignore markers m = ignorere.search(l) if m: -if m.group('reason') == 'inconsistent': +if m.group('reason') == b'inconsistent': allowinconsistent.add(m.group('config')) else: documented[m.group('config')] = 1 @@ -106,16 +114,20 @@ ctype = 'str' name = m.group('section') + b"." + m.group('option') default = m.group('default') -if default in (None, 'False', 'None', '0', '[]', '""', "''"): +if default in ( +None, b'False', b'None', b'0', b'[]', b'""', b"''"): default = b'' if re.match(b'[a-z.]+$', default): default = b'' if (name in foundopts and (ctype, default) != foundopts[name] and name not in allowinconsistent): -print(l.rstrip()) -print("conflict on %s: %r != %r" % (name, (ctype, default), -foundopts[name])) -print("at %s:%d:" % (f, linenum)) +print(mkstr(l.rstrip())) +fctype, fdefault = foundopts[name] +print("conflict on %s: %r != %r" % ( +mkstr(name), +(mkstr(ctype), mkstr(default)), +(mkstr(fctype), mkstr(fdefault +print("at %s:%d:" % (mkstr(f), linenum)) foundopts[name] = (ctype, default) carryover = b'' else: @@ -132,8 +144,13 @@ name.startswith(b"debug.")): ctype, default = foundopts[name] if default: +if isinstance(default, bytes): +default = mkstr(default) default = ' [%s]' % default -print("undocumented: %s (%s)%s" % (name, ctype, default)) +elif isinstance(default, bytes): +default = mkstr(default) +print("undocumented: %s (%s)%s" % ( +mkstr(name), mkstr(ctype), default)) if __name__ == "__main__": if len(sys.argv) > 1: To: durin42, pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D4995: tests: disable one check on Python 3
durin42 updated this revision to Diff 12048. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D4995?vs=12025=12048 REVISION DETAIL https://phab.mercurial-scm.org/D4995 AFFECTED FILES contrib/python3-whitelist tests/test-extension.t CHANGE DETAILS diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -531,6 +531,10 @@ Examine whether sub-module is imported relatively as expected. +#endif + +#if demandimport no-py3k + See also issue5208 for detail about example case on Python 3.x. $ f -q $TESTTMP/extlibroot/lsub1/lsub2/notexist.py diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -184,6 +184,7 @@ test-export.t test-extdata.t test-extdiff.t +test-extension.t test-extensions-afterloaded.t test-extensions-wrapfunction.py test-extra-filelog-entry.t To: durin42, pulkit, #hg-reviewers Cc: mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5064: style: run black on a subset of mercurial
mjpieters updated this revision to Diff 12047. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5064?vs=12030=12047 REVISION DETAIL https://phab.mercurial-scm.org/D5064 AFFECTED FILES mercurial/cacheutil.py mercurial/diffhelper.py mercurial/dirstateguard.py mercurial/httpconnection.py mercurial/i18n.py mercurial/lsprofcalltree.py mercurial/mergeutil.py mercurial/minifileset.py mercurial/node.py mercurial/policy.py mercurial/pushkey.py mercurial/rcutil.py mercurial/rewriteutil.py mercurial/scmposix.py mercurial/scmwindows.py mercurial/stack.py mercurial/state.py mercurial/txnutil.py pyproject.toml CHANGE DETAILS diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.black] +line-length = 80 +exclude = 'build/|wheelhouse/|dist/|packages/|\.hg/|\.mypy_cache/|\.venv/|mercurial/thirdparty/|hgext/fsmonitor/pywatchman/|contrib/python-zstandard/' diff --git a/mercurial/txnutil.py b/mercurial/txnutil.py --- a/mercurial/txnutil.py +++ b/mercurial/txnutil.py @@ -9,27 +9,27 @@ import errno -from . import ( -encoding, -) +from . import encoding + def mayhavepending(root): -'''return whether 'root' may have pending changes, which are +"""return whether 'root' may have pending changes, which are visible to this process. -''' -return root == encoding.environ.get('HG_PENDING') +""" +return root == encoding.environ.get("HG_PENDING") + def trypending(root, vfs, filename, **kwargs): -'''Open file to be read according to HG_PENDING environment variable +"""Open file to be read according to HG_PENDING environment variable This opens '.pending' of specified 'filename' only when HG_PENDING is equal to 'root'. This returns '(fp, is_pending_opened)' tuple. -''' +""" if mayhavepending(root): try: -return (vfs('%s.pending' % filename, **kwargs), True) +return (vfs("%s.pending" % filename, **kwargs), True) except IOError as inst: if inst.errno != errno.ENOENT: raise diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -19,13 +19,9 @@ from __future__ import absolute_import -from . import ( -error, -util, -) -from .utils import ( -cborutil, -) +from . import error, util +from .utils import cborutil + class cmdstate(object): """a wrapper class to store the state of commands like `rebase`, `graft`, @@ -58,23 +54,25 @@ we use third-party library cbor to serialize data to write in the file. """ if not isinstance(version, int): -raise error.ProgrammingError("version of state file should be" - " an integer") +raise error.ProgrammingError( +"version of state file should be" " an integer" +) -with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp: -fp.write('%d\n' % version) +with self._repo.vfs(self.fname, "wb", atomictemp=True) as fp: +fp.write("%d\n" % version) for chunk in cborutil.streamencode(data): fp.write(chunk) def _read(self): """reads the state file and returns a dictionary which contain data in the same format as it was before storing""" -with self._repo.vfs(self.fname, 'rb') as fp: +with self._repo.vfs(self.fname, "rb") as fp: try: int(fp.readline()) except ValueError: -raise error.CorruptedState("unknown version of state file" - " found") +raise error.CorruptedState( +"unknown version of state file" " found" +) return cborutil.decodeall(fp.read())[0] diff --git a/mercurial/stack.py b/mercurial/stack.py --- a/mercurial/stack.py +++ b/mercurial/stack.py @@ -7,10 +7,8 @@ from __future__ import absolute_import -from . import ( -revsetlang, -scmutil, -) +from . import revsetlang, scmutil + def getstack(repo, rev=None): """return a sorted smartrev of the stack containing either rev if it is @@ -20,9 +18,9 @@ the revision and are not merges. """ if rev is None: -rev = '.' +rev = "." -revspec = 'reverse(only(%s) and not public() and not ::merge())' +revspec = "reverse(only(%s) and not public() and not ::merge())" revset = revsetlang.formatspec(revspec, rev) revisions = scmutil.revrange(repo, [revset]) revisions.sort() diff --git a/mercurial/scmwindows.py b/mercurial/scmwindows.py --- a/mercurial/scmwindows.py +++ b/mercurial/scmwindows.py @@ -2,60 +2,59 @@ import os -from . import ( -encoding, -pycompat, -util, -win32, -) +from . import encoding, pycompat,
D5058: match: optimize matcher when all patterns are of rootfilesin kind
This revision was automatically updated to reflect the committed changes. Closed by commit rHG19ed212de2d1: match: optimize matcher when all patterns are of rootfilesin kind (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5058?vs=12015=12046 REVISION DETAIL https://phab.mercurial-scm.org/D5058 AFFECTED FILES mercurial/match.py tests/test-walk.t CHANGE DETAILS diff --git a/tests/test-walk.t b/tests/test-walk.t --- a/tests/test-walk.t +++ b/tests/test-walk.t @@ -143,33 +143,33 @@ $ hg debugwalk -v 'rootfilesin:' * matcher: - + f fennel ../fennel f fenugreek ../fenugreek f fiddlehead ../fiddlehead $ hg debugwalk -v -I 'rootfilesin:' * matcher: - + f fennel ../fennel f fenugreek ../fenugreek f fiddlehead ../fiddlehead $ hg debugwalk -v 'rootfilesin:.' * matcher: - + f fennel ../fennel f fenugreek ../fenugreek f fiddlehead ../fiddlehead $ hg debugwalk -v -I 'rootfilesin:.' * matcher: - + f fennel ../fennel f fenugreek ../fenugreek f fiddlehead ../fiddlehead $ hg debugwalk -v -X 'rootfilesin:' * matcher: , -m2=> +m2=> f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney../beans/kidney @@ -182,55 +182,55 @@ f mammals/skunk skunk $ hg debugwalk -v 'rootfilesin:fennel' * matcher: - + $ hg debugwalk -v -I 'rootfilesin:fennel' * matcher: - + $ hg debugwalk -v 'rootfilesin:skunk' * matcher: - + $ hg debugwalk -v -I 'rootfilesin:skunk' * matcher: - + $ hg debugwalk -v 'rootfilesin:beans' * matcher: - + f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney../beans/kidney f beans/navy ../beans/navy f beans/pinto ../beans/pinto f beans/turtle../beans/turtle $ hg debugwalk -v -I 'rootfilesin:beans' * matcher: - + f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney../beans/kidney f beans/navy ../beans/navy f beans/pinto ../beans/pinto f beans/turtle../beans/turtle $ hg debugwalk -v 'rootfilesin:mammals' * matcher: - + f mammals/skunk skunk $ hg debugwalk -v -I 'rootfilesin:mammals' * matcher: - + f mammals/skunk skunk $ hg debugwalk -v 'rootfilesin:mammals/' * matcher: - + f mammals/skunk skunk $ hg debugwalk -v -I 'rootfilesin:mammals/' * matcher: - + f mammals/skunk skunk $ hg debugwalk -v -X 'rootfilesin:mammals' * matcher: , -m2=> +m2=> f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney../beans/kidney diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -1164,8 +1164,20 @@ regex = '' if kindpats: -regex, mf = _buildregexmatch(kindpats, globsuffix) -matchfuncs.append(mf) +if all(k == 'rootfilesin' for k, p, s in kindpats): +dirs = {p for k, p, s in kindpats} +def mf(f): +i = f.rfind('/') +if i >= 0: +dir = f[:i] +else: +dir = '.' +return dir in dirs +regex = b'rootfilesin: %s' % sorted(dirs) +matchfuncs.append(mf) +else: +regex, mf = _buildregexmatch(kindpats, globsuffix) +matchfuncs.append(mf) if len(matchfuncs) == 1: return regex, matchfuncs[0] To: martinvonz, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH] graft: introduce --base option for using custom base revision for merge
> On Oct 13, 2018, at 12:02, Mads Kiilerich wrote: > > # HG changeset patch > # User Mads Kiilerich > # Date 1539424786 -7200 > # Sat Oct 13 11:59:46 2018 +0200 > # Node ID 167e7e7bbead47fadfe4072143cc53b409e3d8b9 > # Parent 38ac525b44c93fcadb3680d4ded56f1e5a0029b2 > graft: introduce --base option for using custom base revision for merge > > The graft command usually merges with the graft revision using its p1 as base > for the merge. > > As a trivial extension of this, we introduce the --base option to allow for > using another base revision. > > This can be used as a building block for grafting and collapsing multiple > changesets at once, or for grafting the resulting change from a merge as a > single simple change. (This is kind of similar to backout --parent ... only > different: it must be an ancestor, but is usually *not* a parent.) > > This is probably an advanced use case, and we do thus not show it in the > non-verbose help. > > diff --git a/mercurial/commands.py b/mercurial/commands.py > --- a/mercurial/commands.py > +++ b/mercurial/commands.py > @@ -2223,6 +2223,7 @@ def forget(ui, repo, *pats, **opts): > @command( > 'graft', > [('r', 'rev', [], _('revisions to graft'), _('REV')), > + ('', 'base', '', _('base revision when doing the graft merge'), > _('REV')), > ('c', 'continue', False, _('resume interrupted graft')), > ('', 'stop', False, _('stop interrupted graft')), > ('', 'abort', False, _('abort interrupted graft')), > @@ -2267,6 +2268,12 @@ def graft(ui, repo, *revs, **opts): > > .. container:: verbose > > + The --base option can be used to specify another merge base than the > + first parent, thus allowing graft of the impact of a merge, or > + collapsing of multiple changesets. Perhaps: --- The --base option can be used to backport the result of a merge as a single commit (example command) --base can also be used to back out a commit like this: (example command) --base is flexible enough other interesting operations are possible. Please consider sending patches to document other useful operations. --- or something like that. Does that get you started? > + > +.. container:: verbose > + > Examples: > > - copy a single change to the stable branch and edit its description:: > @@ -2305,6 +2312,9 @@ def _dograft(ui, repo, *revs, **opts): > > revs = list(revs) > revs.extend(opts.get('rev')) > +basectx = None > +if opts.get('base'): > +basectx = scmutil.revsingle(repo, opts['base'], None) > # a dict of data to be stored in state file > statedata = {} > # list of new nodes created by ongoing graft > @@ -2384,13 +2394,16 @@ def _dograft(ui, repo, *revs, **opts): > revs = scmutil.revrange(repo, revs) > > skipped = set() > -# check for merges > -for rev in repo.revs('%ld and merge()', revs): > -ui.warn(_('skipping ungraftable merge revision %d\n') % rev) > -skipped.add(rev) > +if basectx is None: > +# check for merges > +for rev in repo.revs('%ld and merge()', revs): > +ui.warn(_('skipping ungraftable merge revision %d\n') % rev) > +skipped.add(rev) > revs = [r for r in revs if r not in skipped] > if not revs: > return -1 > +if basectx is not None and len(revs) != 1: > +raise error.Abort(_('only one revision allowed with --base ')) > > # Don't check in the --continue case, in effect retaining --force across > # --continues. That's because without --force, any revisions we decided to > @@ -2398,7 +2411,7 @@ def _dograft(ui, repo, *revs, **opts): > # way to the graftstate. With --force, any revisions we would have > otherwise > # skipped would not have been filtered out, and if they hadn't been > applied > # already, they'd have been in the graftstate. > -if not (cont or opts.get('force')): > +if not (cont or opts.get('force')) and basectx is None: > # check for ancestors of dest branch > crev = repo['.'].rev() > ancestors = repo.changelog.ancestors([crev], inclusive=True) > @@ -2494,8 +2507,9 @@ def _dograft(ui, repo, *revs, **opts): > if not cont: > # perform the graft merge with p1(rev) as 'ancestor' > overrides = {('ui', 'forcemerge'): opts.get('tool', '')} > +base = ctx.p1() if basectx is None else basectx > with ui.configoverride(overrides, 'graft'): > -stats = mergemod.graft(repo, ctx, ctx.p1(), ['local', > 'graft']) > +stats = mergemod.graft(repo, ctx, base, ['local', 'graft']) > # report any conflicts > if stats.unresolvedcount > 0: > # write out state for --continue > diff --git a/tests/test-completion.t b/tests/test-completion.t > --- a/tests/test-completion.t > +++ b/tests/test-completion.t > @@ -318,7 +318,7 @@ Show all commands + options > debugwireargs: three,
D5060: releasenotes: fix dumb whitespace bug I missed
pulkit added a comment. In https://phab.mercurial-scm.org/D5060#75838, @yuja wrote: > Oops, I've fixed this in flight. And gave me 10 content divergent changes. :( REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5060 To: durin42, #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
D5063: churn: use integer division consistently
This revision was automatically updated to reflect the committed changes. Closed by commit rHG81e4f039a0cd: churn: use integer division consistently (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5063?vs=12029=12045 REVISION DETAIL https://phab.mercurial-scm.org/D5063 AFFECTED FILES contrib/python3-whitelist hgext/churn.py tests/test-churn.t CHANGE DETAILS diff --git a/tests/test-churn.t b/tests/test-churn.t --- a/tests/test-churn.t +++ b/tests/test-churn.t @@ -52,7 +52,7 @@ $ hg churn -r :2 user2 2 *** - user1 1 + user1 1 *** $ cd .. churn with aliases @@ -83,36 +83,36 @@ churn by hour $ hg churn -f '%H' -s - 06 1 * + 06 1 09 2 * 12 4 ** - 13 1 * + 13 1 churn with separated added/removed lines $ hg rm d/g/f2.txt $ hg ci -Am "removed d/g/f2.txt" -u user1 -d 14:00 d/g/f2.txt $ hg churn --diffstat - user1 +3/-1 +-- - user3 +3/-0 + + user1 +3/-1 - + user3 +3/-0 user2 +2/-0 +++ churn --diffstat with color $ hg --config extensions.color= churn --config color.mode=ansi \ > --diffstat --color=always - user1 +3/-1 \x1b[0;32m+\x1b[0m\x1b[0;31m--\x1b[0m (esc) - user3 +3/-0 \x1b[0;32m+\x1b[0m (esc) + user1 +3/-1 \x1b[0;32m\x1b[0m\x1b[0;31m-\x1b[0m (esc) + user3 +3/-0 \x1b[0;32m\x1b[0m (esc) user2 +2/-0 \x1b[0;32m+++\x1b[0m (esc) changeset number churn $ hg churn -c user1 4 *** user3 3 *** - user2 2 + user2 2 *** $ echo 'with space = no-space' >> ../aliases $ echo a >> a @@ -154,39 +154,39 @@ [us...@x.com] $ hg churn -c user14 * - user33 *** - user22 * - us...@x.com 2 * + user33 ** + user22 + us...@x.com 2 with space 1 ** Test multibyte sequences in names $ echo bar >> bar $ hg --encoding utf-8 ci -m'changed bar' -u 'El NiƱo ' $ hg --encoding utf-8 churn -ct '{author|person}' user1 4 ** - user3 3 + user3 3 *** user2 2 * user4 2 * - El Ni\xc3\xb1o 1 *** (esc) - with space 1 *** + El Ni\xc3\xb1o 1 ** (esc) + with space 1 ** Test --template argument, with backwards compatibility $ hg churn -t '{author|user}' user1 4 *** user3 3 *** - user2 2 - nino 1 - with 1 + user2 2 *** + nino 1 *** + with 1 *** 0 user4 0 $ hg churn -T '{author|user}' user1 4 *** user3 3 *** - user2 2 - nino 1 - with 1 + user2 2 *** + nino 1 *** + with 1 *** 0 user4 0 $ hg churn -t 'alltogether' diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -8,7 +8,7 @@ '''command to display statistics about repository history''' -from __future__ import absolute_import +from __future__ import absolute_import,
D5062: churn: fix stack traces on Python 3
This revision was automatically updated to reflect the committed changes. Closed by commit rHG6f3e733848ae: churn: fix stack traces on Python 3 (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5062?vs=12028=12044 REVISION DETAIL https://phab.mercurial-scm.org/D5062 AFFECTED FILES hgext/churn.py CHANGE DETAILS diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -52,7 +52,8 @@ def getkey(ctx): t, tz = ctx.date() date = datetime.datetime(*time.gmtime(float(t) - tz)[:6]) -return date.strftime(encoding.strfromlocal(opts['dateformat'])) +return encoding.strtolocal( +date.strftime(encoding.strfromlocal(opts['dateformat']))) else: tmpl = opts.get('oldtemplate') or opts.get('template') tmpl = logcmdutil.maketemplater(ui, repo, tmpl) To: durin42, #hg-reviewers, pulkit Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5069: help: adding a proper declaration for shortlist/basic commands
rdamazio updated this revision to Diff 12043. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5069?vs=12035=12043 REVISION DETAIL https://phab.mercurial-scm.org/D5069 AFFECTED FILES contrib/perf.py hgext/absorb.py hgext/blackbox.py hgext/fastannotate/commands.py hgext/githelp.py hgext/mq.py hgext/record.py hgext/sparse.py hgext/split.py hgext/uncommit.py mercurial/cmdutil.py mercurial/commands.py mercurial/help.py mercurial/hgweb/webcommands.py mercurial/registrar.py tests/test-completion.t CHANGE DETAILS diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -231,31 +231,18 @@ Show all commands + options $ hg debugcommands add: include, exclude, subrepos, dry-run + addremove: similarity, subrepos, include, exclude, dry-run annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template - clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure - commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos - diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos - export: bookmark, output, switch-parent, rev, text, git, binary, nodates, template - forget: interactive, include, exclude, dry-run - init: ssh, remotecmd, insecure - log: follow, follow-first, date, copies, keyword, rev, line-range, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude - merge: force, rev, preview, abort, tool - pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure - push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure - remove: after, force, subrepos, include, exclude, dry-run - serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, print-url, subrepos - status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template - summary: remote - update: clean, check, merge, date, rev, tool - addremove: similarity, subrepos, include, exclude, dry-run archive: no-decode, prefix, rev, type, subrepos, include, exclude backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user bisect: reset, good, bad, skip, extend, command, noupdate bookmarks: force, rev, delete, rename, inactive, list, template branch: force, clean, rev branches: active, closed, template bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure cat: output, rev, decode, include, exclude, template + clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure + commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos config: untrusted, edit, local, global, template copy: after, force, include, exclude, dry-run debugancestor: @@ -317,30 +304,43 @@ debugwhyunstable: debugwireargs: three, four, five, ssh, remotecmd, insecure debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure + diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos + export: bookmark, output, switch-parent, rev, text, git, binary, nodates, template files: rev, print0, include, exclude, template, subrepos + forget: interactive, include, exclude, dry-run graft: rev, continue, stop, abort, edit, log, no-commit, force, currentdate, currentuser, date, user, tool, dry-run grep: print0, all, diff, text, follow, ignore-case, files-with-matches, line-number, rev, all-files, user, date, template, include, exclude heads: rev, topo, active, closed, style, template help: extension, command, keyword, system identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos + init: ssh, remotecmd, insecure locate: rev, print0, fullpath, include, exclude + log: follow, follow-first, date,
D5069: help: adding a proper declaration for shortlist/basic commands
rdamazio added a comment. Done now. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5069 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
D5066: help: splitting the topics by category
rdamazio updated this revision to Diff 12040. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5066?vs=12032=12040 REVISION DETAIL https://phab.mercurial-scm.org/D5066 AFFECTED FILES mercurial/help.py mercurial/hgweb/webcommands.py CHANGE DETAILS diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -1401,7 +1401,8 @@ topicname = web.req.qsparams.get('node') if not topicname: def topics(context): -for entries, summary, _doc in helpmod.helptable: +for h in helpmod.helptable: +entries, summary, _doc = h[0:3] yield {'topic': entries[0], 'summary': summary} early, other = [], [] diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -58,6 +58,17 @@ CATEGORY_NONE, ] +# Topic categories. +TOPIC_CATEGORY_NONE = _('Uncategorized topics') + +# The order in which topic categories will be displayed. +# Extensions with custom categories should insert them into this list +# after/before the appropriate item, rather than replacing the list or +# assuming absolute positions. +TOPIC_CATEGORY_ORDER = [ +TOPIC_CATEGORY_NONE, +] + def listexts(header, exts, indent=1, showdeprecated=False): '''return a text listing of the given extensions''' rst = [] @@ -150,7 +161,8 @@ 'extensions': [], 'extensioncommands': [], } -for names, header, doc in helptable: +for topic in helptable: +names, header, doc = topic[0:3] # Old extensions may use a str as doc. if (sum(map(lowercontains, names)) or lowercontains(header) @@ -517,12 +529,34 @@ rst.append('\n') rst.extend(exts) -rst.append(_("\nadditional help topics:\n\n")) -topics = [] -for names, header, doc in helptable: -topics.append((names[0], header)) -for t, desc in topics: -rst.append(" :%s: %s\n" % (t, desc)) +rst.append(_("\nadditional help topics:\n")) +# Group commands by category. +topiccats = {} +for topic in helptable: +names, header, doc = topic[0:3] +if len(topic) > 3 and topic[3]: +category = topic[3] +else: +category = TOPIC_CATEGORY_NONE + +topiccats.setdefault(category, []).append((names[0], header)) + +# Check that all categories have an order. +missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER) +if missing_order: +ui.develwarn( +'Help categories missing from TOPIC_CATEGORY_ORDER: %s' % +missing_order) + +# Output topics per category. +for cat in TOPIC_CATEGORY_ORDER: +topics = topiccats.get(cat, []) +if topics: +if len(topiccats) > 1: +rst.append("\n%s:\n" % cat) +rst.append("\n") +for t, desc in topics: +rst.append(" :%s: %s\n" % (t, desc)) if ui.quiet: pass @@ -557,7 +591,8 @@ break if not header: -for names, header, doc in helptable: +for topic in helptable: +names, header, doc = topic[0:3] if name in names: break else: 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
D5065: help: adding support for command categories
rdamazio updated this revision to Diff 12039. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5065?vs=12031=12039 REVISION DETAIL https://phab.mercurial-scm.org/D5065 AFFECTED FILES doc/gendoc.py mercurial/configitems.py mercurial/help.py mercurial/registrar.py CHANGE DETAILS diff --git a/mercurial/registrar.py b/mercurial/registrar.py --- a/mercurial/registrar.py +++ b/mercurial/registrar.py @@ -146,6 +146,10 @@ to prevent the command from running if the requested intent could not be fulfilled. +If `helpcategory` is set (usually to one of the constants in the help +module), the command will be displayed under that category in the help's +list of commands. + The following intents are defined: readonly @@ -166,12 +170,12 @@ def _doregister(self, func, name, options=(), synopsis=None, norepo=False, optionalrepo=False, inferrepo=False, -intents=None): - +intents=None, helpcategory=None): func.norepo = norepo func.optionalrepo = optionalrepo func.inferrepo = inferrepo func.intents = intents or set() +func.helpcategory = helpcategory if synopsis: self._table[name] = func, list(options), synopsis else: diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -47,6 +47,17 @@ _("(EXPERIMENTAL)"), } +# Command categories. +CATEGORY_NONE = _('Uncategorized commands') + +# The order in which command categories will be displayed. +# Extensions with custom categories should insert them into this list +# after/before the appropriate item, rather than replacing the list or +# assuming absolute positions. +CATEGORY_ORDER = [ +CATEGORY_NONE, +] + def listexts(header, exts, indent=1, showdeprecated=False): '''return a text listing of the given extensions''' rst = [] @@ -121,6 +132,8 @@ return True if not ui.verbose and doc and any(w in doc for w in _exclkeywords): return True +if ui.configbool('help', 'hide.%s' % cmd): +return True return False def topicmatch(ui, commands, kw): @@ -421,53 +434,80 @@ def helplist(select=None, **opts): -# list of commands -if name == "shortlist": -header = _('basic commands:\n\n') -elif name == "debug": -header = _('debug commands (internal and unsupported):\n\n') -else: -header = _('list of commands:\n\n') - +# Category -> list of commands +cats = {} +# Command -> short description h = {} -cmds = {} +# Command -> string showing synonyms +syns = {} for c, e in commands.table.iteritems(): fs = cmdutil.parsealiases(c) f = fs[0] +syns[f] = ', '.join(fs) +func = e[0] p = '' if c.startswith("^"): p = '^' if select and not select(p + f): continue if (not select and name != 'shortlist' and -e[0].__module__ != commands.__name__): +func.__module__ != commands.__name__): continue if name == "shortlist" and not p: continue -doc = pycompat.getdoc(e[0]) +doc = pycompat.getdoc(func) if filtercmd(ui, f, name, doc): continue doc = gettext(doc) if not doc: doc = _("(no help text available)") h[f] = doc.splitlines()[0].rstrip() -cmds[f] = '|'.join(fs) + +cat = getattr(func, 'helpcategory', None) or CATEGORY_NONE +cats.setdefault(cat, []).append(f) rst = [] if not h: if not ui.quiet: rst.append(_('no commands defined\n')) return rst +# Output top header. if not ui.quiet: -rst.append(header) -fns = sorted(h) -for f in fns: -if ui.verbose: -commacmds = cmds[f].replace("|",", ") -rst.append(" :%s: %s\n" % (commacmds, h[f])) +if name == "shortlist": +rst.append(_('basic commands:\n\n')) +elif name == "debug": +rst.append(_('debug commands (internal and unsupported):\n\n')) else: -rst.append(' :%s: %s\n' % (f, h[f])) +rst.append(_('list of commands:\n')) + +def appendcmds(cmds): +cmds = sorted(cmds) +for c in cmds: +if ui.verbose: +rst.append(" :%s: %s\n" % (syns[c], h[c])) +else: +rst.append(' :%s: %s\n' % (c, h[c])) + +if name in ('shortlist', 'debug'): +# List without categories. +appendcmds(h) +
D5071: run-tests: run tests with as many processes as cores by default
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This seems like a useful default behavior so tests run faster by default* - Except in special circumstances where the OS/filesystem doesn't scale well to many CPU cores (like APFS *cough* *cough*). REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5071 AFFECTED FILES tests/run-tests.py tests/test-run-tests.t CHANGE DETAILS diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t --- a/tests/test-run-tests.t +++ b/tests/test-run-tests.t @@ -15,7 +15,7 @@ = $ rt() > { - > "$PYTHON" $TESTDIR/run-tests.py --with-hg=`which hg` "$@" + > "$PYTHON" $TESTDIR/run-tests.py --with-hg=`which hg` -j1 "$@" > } error paths @@ -1329,7 +1329,7 @@ Add support for external test formatter === - $ CUSTOM_TEST_RESULT=basic_test_result "$PYTHON" $TESTDIR/run-tests.py --with-hg=`which hg` "$@" test-success.t test-failure.t + $ CUSTOM_TEST_RESULT=basic_test_result "$PYTHON" $TESTDIR/run-tests.py --with-hg=`which hg` -j1 "$@" test-success.t test-failure.t running 2 tests using 1 parallel processes # Ran 2 tests, 0 skipped, 0 failed. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -51,6 +51,7 @@ import distutils.version as version import errno import json +import multiprocessing import os import random import re @@ -287,7 +288,7 @@ IMPL_PATH = b'JYTHONPATH' defaults = { -'jobs': ('HGTEST_JOBS', 1), +'jobs': ('HGTEST_JOBS', multiprocessing.cpu_count()), 'timeout': ('HGTEST_TIMEOUT', 180), 'slowtimeout': ('HGTEST_SLOWTIMEOUT', 500), 'port': ('HGTEST_PORT', 20059), To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel