changeset 44586:f8427841c8fc

merge with stable
author Yuya Nishihara <yuya@tcha.org>
date Fri, 20 Mar 2020 17:18:14 +0900
parents 2ec6160449aa (current diff) bc9a9016467d (diff)
children 90adda73676a
files contrib/heptapod-ci.yml mercurial/archival.py mercurial/cext/revlog.c rust/hg-core/src/lib.rs tests/run-tests.py
diffstat 6 files changed, 48 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/byteify-strings.py	Thu Mar 19 14:54:10 2020 -0400
+++ b/contrib/byteify-strings.py	Fri Mar 20 17:18:14 2020 +0900
@@ -328,6 +328,7 @@
         'allow-attr-methods': args.allow_attr_methods,
     }
     for fname in args.files:
+        fname = os.path.realpath(fname)
         if args.inplace:
             with editinplace(fname) as fout:
                 with open(fname, 'rb') as fin:
--- a/contrib/heptapod-ci.yml	Thu Mar 19 14:54:10 2020 -0400
+++ b/contrib/heptapod-ci.yml	Fri Mar 20 17:18:14 2020 +0900
@@ -6,7 +6,7 @@
     - hg clone . /tmp/mercurial-ci/ --noupdate
     - hg -R /tmp/mercurial-ci/ update `hg log --rev '.' --template '{node}'`
     - cd /tmp/mercurial-ci/
-    - (cd tests; ls -1 test-check-*.*) > /tmp/check-tests.txt
+    - ls -1 tests/test-check-*.* > /tmp/check-tests.txt
 
 variables:
     PYTHON: python
@@ -14,10 +14,9 @@
 
 .runtests_template: &runtests
     script:
-        - cd tests/
         - echo "python used, $PYTHON"
         - echo "$RUNTEST_ARGS"
-        - HGMODULEPOLICY="$TEST_HGMODULEPOLICY" "$PYTHON" run-tests.py --color=always $RUNTEST_ARGS
+        - HGMODULEPOLICY="$TEST_HGMODULEPOLICY" "$PYTHON" tests/run-tests.py --color=always $RUNTEST_ARGS
 
 checks-py2:
     <<: *runtests
--- a/mercurial/archival.py	Thu Mar 19 14:54:10 2020 -0400
+++ b/mercurial/archival.py	Fri Mar 20 17:18:14 2020 +0900
@@ -135,34 +135,38 @@
     '''write archive to tar file or stream.  can write uncompressed,
     or compress with gzip or bzip2.'''
 
-    class GzipFileWithTime(gzip.GzipFile):
-        def __init__(self, *args, **kw):
-            timestamp = None
-            if 'timestamp' in kw:
-                timestamp = kw.pop('timestamp')
-            if timestamp is None:
-                self.timestamp = time.time()
-            else:
-                self.timestamp = timestamp
-            gzip.GzipFile.__init__(self, *args, **kw)
+    if pycompat.ispy3:
+        GzipFileWithTime = gzip.GzipFile  # camelcase-required
+    else:
+
+        class GzipFileWithTime(gzip.GzipFile):
+            def __init__(self, *args, **kw):
+                timestamp = None
+                if 'mtime' in kw:
+                    timestamp = kw.pop('mtime')
+                if timestamp is None:
+                    self.timestamp = time.time()
+                else:
+                    self.timestamp = timestamp
+                gzip.GzipFile.__init__(self, *args, **kw)
 
-        def _write_gzip_header(self):
-            self.fileobj.write(b'\037\213')  # magic header
-            self.fileobj.write(b'\010')  # compression method
-            fname = self.name
-            if fname and fname.endswith(b'.gz'):
-                fname = fname[:-3]
-            flags = 0
-            if fname:
-                flags = gzip.FNAME  # pytype: disable=module-attr
-            self.fileobj.write(pycompat.bytechr(flags))
-            gzip.write32u(  # pytype: disable=module-attr
-                self.fileobj, int(self.timestamp)
-            )
-            self.fileobj.write(b'\002')
-            self.fileobj.write(b'\377')
-            if fname:
-                self.fileobj.write(fname + b'\000')
+            def _write_gzip_header(self):
+                self.fileobj.write(b'\037\213')  # magic header
+                self.fileobj.write(b'\010')  # compression method
+                fname = self.name
+                if fname and fname.endswith(b'.gz'):
+                    fname = fname[:-3]
+                flags = 0
+                if fname:
+                    flags = gzip.FNAME  # pytype: disable=module-attr
+                self.fileobj.write(pycompat.bytechr(flags))
+                gzip.write32u(  # pytype: disable=module-attr
+                    self.fileobj, int(self.timestamp)
+                )
+                self.fileobj.write(b'\002')
+                self.fileobj.write(b'\377')
+                if fname:
+                    self.fileobj.write(fname + b'\000')
 
     def __init__(self, dest, mtime, kind=b''):
         self.mtime = mtime
@@ -178,7 +182,7 @@
                     pycompat.sysstr(mode + b'b'),
                     zlib.Z_BEST_COMPRESSION,
                     fileobj,
-                    timestamp=mtime,
+                    mtime=mtime,
                 )
                 self.fileobj = gzfileobj
                 return tarfile.TarFile.taropen(  # pytype: disable=attribute-error
--- a/mercurial/cext/revlog.c	Thu Mar 19 14:54:10 2020 -0400
+++ b/mercurial/cext/revlog.c	Fri Mar 20 17:18:14 2020 +0900
@@ -159,7 +159,10 @@
 			                             sizeof(*self->offsets));
 			if (self->offsets == NULL)
 				return (const char *)PyErr_NoMemory();
-			inline_scan(self, self->offsets);
+			Py_ssize_t ret = inline_scan(self, self->offsets);
+			if (ret == -1) {
+				return NULL;
+			};
 		}
 		return self->offsets[pos];
 	}
--- a/rust/hg-core/src/lib.rs	Thu Mar 19 14:54:10 2020 -0400
+++ b/rust/hg-core/src/lib.rs	Fri Mar 20 17:18:14 2020 +0900
@@ -27,6 +27,14 @@
 pub mod re2;
 pub mod utils;
 
+// Remove this to see (potential) non-artificial compile failures. MacOS
+// *should* compile, but fail to compile tests for example as of 2020-03-06
+#[cfg(not(target_os = "linux"))]
+compile_error!(
+    "`hg-core` has only been tested on Linux and will most \
+     likely not behave correctly on other platforms."
+);
+
 use crate::utils::hg_path::{HgPathBuf, HgPathError};
 pub use filepatterns::{
     parse_pattern_syntax, read_pattern_file, IgnorePattern,
--- a/tests/run-tests.py	Thu Mar 19 14:54:10 2020 -0400
+++ b/tests/run-tests.py	Fri Mar 20 17:18:14 2020 +0900
@@ -1632,7 +1632,7 @@
             return self._have.get(allreqs)
 
         # TODO do something smarter when all other uses of hghave are gone.
-        runtestdir = os.path.abspath(os.path.dirname(_sys2bytes(__file__)))
+        runtestdir = osenvironb[b'RUNTESTDIR']
         tdir = runtestdir.replace(b'\\', b'/')
         proc = Popen4(
             b'%s -c "%s/hghave %s"' % (self._shell, tdir, allreqs),