Skip to content
Snippets Groups Projects
  1. Jul 01, 2020
  2. Jun 30, 2020
    • Manuel Jacob's avatar
      convert: handle percent-encoded bytes in file URLs like Subversion · 0ea9c86fac89
      Manuel Jacob authored
      75b59d221aa3 added most of the code that gets removed by this patch. It helped
      making progress on Python 3, but the reasoning was wrong in many ways. I tried
      to retract it while it was queued, but it was too late.
      
      Back then, I was asssuming that what happened on Python 2 (preserving bytes) is
      correct and my Python 3 change is a hack. However it turned out that Subversion
      interprets percent-encoded bytes as UTF-8. Accepting the same format as
      Subversion is a good idea.
      
      Consistency with urlreq.pathname2url() (as described in the removed comment)
      doesn’t matter because that function is only used for passing paths to urllib.
      
      This is not a backwards-incompatible change because before 5c0d5b48e58c,
      non-ASCII filenames didn’t work at all on Python 2.
      
      When the locale encoding is ISO-8859-15, `svn` accepts `file:///tmp/a%E2%82%AC`
      for `/tmp/a€`. Before this patch, this was the case for this extension on
      Python 3, but not on Python 2. This patch makes it work like with `svn` on both
      Python 2 and Python 3.
      5.4.2
      0ea9c86fac89
    • Manuel Jacob's avatar
      convert: add docstring on convert.subversion.geturl() · ddf66c218104
      Manuel Jacob authored
      The function is unusual for a bytes-handling function in Mercurial because it
      can’t handle arbitrary bytes. Therefore we should document this fact.
      
      Pointed out by Yuya Nishihara while reviewing e3b19004087a.
      ddf66c218104
  3. Jun 29, 2020
  4. Jun 30, 2020
    • Manuel Jacob's avatar
      convert: convert URLs to UTF-8 for Subversion · e54c3cafda15
      Manuel Jacob authored
      Preamble: for comprehension, note that the `path` of geturl() would better be
      called `path_or_url` (the argument of the call of getsvn() is called `url`).
      
      For HTTP(S) URLs, the changes don’t make a difference, as they are restricted to
      ASCII.
      
      For file URLs, the reasoning is the same as for paths: we have to roundtrip with
      what Subversion is doing.
      
      When the locale encoding is ISO-8859-15, trying to convert a SVN repo
      `file:///tmp/a€` failed before like this:
      
      file:///tmp/a%A4 does not look like a Subversion repository to libsvn version 1.14.0
      
      Decoding the path using the locale encoding can fail. In this case, we have to
      bail out, as Subversion won’t be able to do anything useful with the path.
      e54c3cafda15
  5. Jun 29, 2020
    • Manuel Jacob's avatar
      convert: correctly convert paths to UTF-8 for Subversion · e3b19004087a
      Manuel Jacob authored
      The previous code using encoding.tolocal() only worked by chance in these
      situations:
      
      * The string is ASCII: The fast path was triggered and the string was returned
        unmodified.
      * The local encoding is UTF-8: The source and target encoding is the same.
      * The string is not valid UTF-8 and the native encoding is ISO-8859-1: If the
        string doesn’t decode using UTF-8, ISO-8859-1 is tried as a fallback. During
        `hg convert`, the local encoding is always UTF-8. The irony is that in this
        case, encoding.tolocal() behaves like what someone would expect the reverse
        function, encoding.fromlocal(), to do.
      
      When the locale encoding is ISO-8859-15, trying to convert a SVN repo `/tmp/a€`
      failed before like this:
      
      file:///tmp/a%C2%A4 does not look like a Subversion repository to libsvn version 1.14.0
      
      The correct URL is `file:///tmp/a%E2%82%AC`.
      
      Unlike previously (with the ISO-8859-1 fallback), decoding the path using the
      locale encoding can fail. In this case, we have to bail out, as Subversion
      won’t be able to do anything useful with the path.
      e3b19004087a
  6. Jun 30, 2020
    • Manuel Jacob's avatar
      py3: pass URL as str · cb097496138a
      Manuel Jacob authored
      Before the patch, HTTP(S) URLs were never recognized as a Subversion repository
      on Python 3.
      cb097496138a
    • Manuel Jacob's avatar
      convert: bail out in Subversion source if encountering non-ASCII HTTP(S) URL · 697212a830fb
      Manuel Jacob authored
      Before this patch, in the tested case, urllib raised `httplib.InvalidURL: URL
      can't contain control characters. '/\xff/!svn/ver/0/.svn' (found at least
      '\xff')`, which resulted in that the URL was never recognized as a Subversion
      repository.
      
      This patch adds a check that bails out if the URL contains non-ASCII characters.
      The warning is not overly user-friendly, but giving the user something to type
      into a search engine is definitively better than not explaining why the
      repository was not recognized.
      
      We could support non-ASCII chracters by quoting them before passing them to
      urllib. However, we would want to be compatible with what the `svn` command
      does, which converts the URL from the locale encoding to UTF-8, percent-encodes
      it and sends it to the server. If the locale encoding is not UTF-8, the
      behavior is IMHO not very intuitive, as the `svn` command may send different
      (percent-encoded) octets than what was passed on the console. Instead of
      copying this behavior, we better leave it forbidden.
      697212a830fb
  7. Jun 29, 2020
    • Manuel Jacob's avatar
      run-tests: fix escapes with conditions · bd0f122f3f51
      Manuel Jacob authored
      Before this fix, escapes with conditions in tests failed like this on Python 3:
      
         $ $PYTHON -c 'from mercurial.utils.procutil import stdout; stdout.write(b"\xff")'
      -  \xff (no-eol) (esc) (true !)
      +  \xff (no-eol) (esc)
      
      The unicode_escape encoding decodes br'\xff' to u'\xff'. To convert the first
      256 code points to bytes with the same ordinal, the latin-1 encoding must be
      used.
      
      Escapes without conditions already worked before on Python 3, but not through
      `el == l` a few lines below the changed line in run-tests.py. I didn’t
      investigate further.
      bd0f122f3f51
  8. Jun 28, 2020
    • Manuel Jacob's avatar
      convert: set LC_CTYPE around calls to Subversion bindings · 5c0d5b48e58c
      Manuel Jacob authored
      The Subversion bindings require that LC_CTYPE is set. However, we don’t want to
      set it all the time, as it changes the behavior of str methods on Python 2. The
      taken approach is hopefully fine-grained enough to not trigger any
      locale-specfic behavior of the str methods and coarse-grained enough to not
      clutter the code.
      
      Emulating the with-statement behavior in before() and after() should be safe, as
      after() is always called when before() is called. hgext.convert.hg takes a
      similar approach.
      5c0d5b48e58c
    • Manuel Jacob's avatar
      curses: do not initialize LC_ALL to user settings (issue6358) · 1bab6b61b62b
      Manuel Jacob authored
      701341f57ceb moved the setlocale() call to right before curses was used. This
      didn’t fully solve the problem it was supposed to solve (locale-dependent
      functions, like date formatting/parsing and str methods on Python 2), but only
      postponed it.
      
      Initializing LC_CTYPE seems to be sufficient for curses to work correctly.
      Therefore LC_CTYPE is set while curses is used and reset afterwards. Some
      locale-dependent str methods might behave differently on Python 2 while curses
      is used, but that shouldn’d be a problem.
      1bab6b61b62b
  9. Jun 25, 2020
    • Manuel Jacob's avatar
      hgweb: encode WSGI environment like OS environment · 2632c1ed8f34
      Manuel Jacob authored
      Previously, the WSGI environment keys and values were encoded using latin-1.
      This resulted in a crash if a WSGI environment key or value could not be encoded
      using latin-1.
      
      On Unix, the OS environment is byte-based. Therefore we should do the reverse of
      what Python does for os.environ.
      
      On Windows, there’s no native byte-based OS environment. Therefore we should do
      the same as what mercurial.encoding does with the OS environment.
      2632c1ed8f34
    • Manuel Jacob's avatar
      hgweb: deduplicate code · 839328c5a728
      Manuel Jacob authored
      A following patch will change the way keys and values are encoded. To reduce the
      diff, I’ve split off the uninteresting part.
      839328c5a728
  10. Jun 23, 2020
  11. Jun 25, 2020
  12. Jun 24, 2020
  13. Jun 23, 2020
  14. Jun 17, 2020
  15. Jun 16, 2020
    • Manuel Jacob's avatar
      py3: fix comparison between int and None · 9e5f598fd29b
      Manuel Jacob authored
      If stop is None, the condition was always false on Python 2, as None compares
      smaller than ints. Therefore we make the condition false if stop is None.
      9e5f598fd29b
    • Manuel Jacob's avatar
      py3: pass regex as bytes · 423e20c78e6d
      Manuel Jacob authored
      423e20c78e6d
    • Manuel Jacob's avatar
      py3: avoid using %r format on bytes · 7a4630536e53
      Manuel Jacob authored
      Before the patch, the 'b' prefix appeared in the formatted string. Wrapping the
      bytes as pycompat.bytestr solves this problem.
      
      Eventually, I think that we should move away from using %r (like 975e517451a6
      and 4d6019c0e0ef did), but that would change output of non-ASCII bytes on
      Python 2, so we can’t do it on the stable branch. Also, many places continue to
      use %r, so it would be a good idea to do the change all at once.
      7a4630536e53
    • Manuel Jacob's avatar
      py3: use `%d` for int in % formatting · d545b895234a
      Manuel Jacob authored
      On Python 3, `%s` is an alias to `%b`, which requires that the object implements
      `__bytes__()`, which is not the case for `int`.
      d545b895234a
    • Manuel Jacob's avatar
      py3: pass native string to urlreq.url2pathname() · 75b59d221aa3
      Manuel Jacob authored
      Of course, I’m not happy with the warning, but it’s better than crashing.
      Solving the problem properly is hard, and non-UTF-8 percent-encoded bytes in
      file URLs seem rare enough to block solving that all file URLs (even if not
      SVN-specific) will cause a crash.
      75b59d221aa3
    • Manuel Jacob's avatar
      py3: suppress DeprecationWarning about deprecated base64 module aliases · de7bdb0e2a95
      Manuel Jacob authored
      base64.encodestring() / base64.decodestring() were renamed to
      base64.encodebytes() / base64.decodebytes() in Python 3. The old names still
      worked, but raised a DeprecationWarning.
      de7bdb0e2a95
  16. Jun 15, 2020
  17. Jun 06, 2020
    • Anton Shestakov's avatar
      tests: adjust to the new format in pyflakes output · 170f8a43b5b8
      Anton Shestakov authored
      According to the pyflakes' NEWS.rst, the default output format changed
      recently:
      
        2.2.0 (2020-04-08)
        - Include column information in error messages
      
      So the lines now read:
      
        contrib/perf.py:149:15 undefined name 'xrange'
        mercurial/hgweb/server.py:427:13 undefined name 'reload'
        mercurial/util.py:2862:24 undefined name 'file'
      
      This is a graft of a similar fix that ended up on default.
      
      Differential Revision: https://phab.mercurial-scm.org/D8630
      170f8a43b5b8
    • Anton Shestakov's avatar
      tests: consistently use pyflakes as a Python module · f9099e210c57
      Anton Shestakov authored
      We check availability of pyflakes as a module, and also running it for real as
      a module. Only fair to test filterpyflakes.py working correctly when using
      pyflakes as a module too.
      
      This is a graft of a similar fix that ended up on default.
      
      Differential Revision: https://phab.mercurial-scm.org/D8629
      f9099e210c57
    • Anton Shestakov's avatar
      tests: skip pyflakes for mercurial/thirdparty/ · 1ca0d5cae9bc
      Anton Shestakov authored
      The current version of pyflakes (2.2.0) correctly detects one issue:
      
        mercurial/thirdparty/selectors2.py:335:40 '...'.format(...) has unused arguments at position(s): 1
      
      But we're not interested in fixing lint errors in third-party code, so we need
      to exclude at least selectors2.py. And in the discussion for this patch it was
      decided to just skip the entire thirdparty directory.
      
      This is a graft of a similar fix that ended up on default.
      
      Differential Revision: https://phab.mercurial-scm.org/D8628
      1ca0d5cae9bc
  18. Jun 13, 2020
  19. Jun 12, 2020
    • Adam Hull's avatar
      ignore: note debugignore on ignore man page · b77d5b568496
      Adam Hull authored
      It took me a long time to find debugignore. I found the ignore man page
      quickly. This change adds a debugging section to the ignore man page
      letting people know there is a debug command.
      b77d5b568496
  20. Jun 13, 2020
  21. Jun 09, 2020
  22. Apr 30, 2020
  23. Jun 05, 2020
Loading