Hi Simon,

Thanks for your contribution. We are missing a maintainer on hgview
nowadays. (Philippe has done the most recent releases).

I pushed the most recent version of the code
https://hg.logilab.org/master/hgview/ to
https://hg.logilab.org/master/hgview/ (should probably find a way to
mirror automatically).

I'll take a look at your patch and try to integrate it and release a new
version tomorrow.

Arthur

On 30/07/2019 16:08, Simon Giesecke wrote:
> Here is the updated patchset:
>
> # HG changeset patch
> # User Simon Giesecke <sgiese...@mozilla.com>
> # Date 1562663911 -7200
> #      Tue Jul 09 11:18:31 2019 +0200
> # Node ID 273b4ae25ccb8e26ca8b27b61861a621abcfb71f
> # Parent  7f3142453cd546d701a7455cab9568cce08d9974
> Bugfix: do not return matcher function, but use it for calling diff
>
> diff -r 7f3142453cd5 -r 273b4ae25ccb hgviewlib/hggraph.py
> --- a/hgviewlib/hggraph.py Wed Jun 26 13:55:23 2019 +0200
> +++ b/hgviewlib/hggraph.py Tue Jul 09 11:18:31 2019 +0200
> @@ -64,9 +64,9 @@
>      # backward compat with mercurial < 5.0
>      if tuple(map(int, hgversion.split('.', 2)[:2])) < (5, 0):
>          if files is None:
> -            return match.always(repo.root, repo.getcwd())
> +            matchfn = match.always(repo.root, repo.getcwd())
>          else:
> -            return match.exact(repo.root, repo.getcwd(), files)
> +            matchfn = match.exact(repo.root, repo.getcwd(), files)
>      else:
>          if files is None:
>              matchfn = match.always()
> # HG changeset patch
> # User Simon Giesecke <sgiese...@mozilla.com>
> # Date 1564495318 -7200
> #      Tue Jul 30 16:01:58 2019 +0200
> # Node ID 9b01ad1b0ee86c2eba0a5b9f903228ce7c5400f5
> # Parent  273b4ae25ccb8e26ca8b27b61861a621abcfb71f
> Bugfix: support conversion of QString to unicode
>
> Removed unused import for methodcaller
> Inlined redundant lambda
>
> diff -r 273b4ae25ccb -r 9b01ad1b0ee8 hgviewlib/qt4/hgrepoviewer.py
> --- a/hgviewlib/qt4/hgrepoviewer.py Tue Jul 09 11:18:31 2019 +0200
> +++ b/hgviewlib/qt4/hgrepoviewer.py Tue Jul 30 16:01:58 2019 +0200
> @@ -14,7 +14,6 @@
>  import re
>  import errno
>  from functools import partial
> -from operator import methodcaller
>
>  from PyQt4 import QtCore, QtGui, Qsci
>
> @@ -87,11 +86,10 @@
>              self.setupModels(fromhead)
>              self._setupQuickOpen()
>
> -        to_utf8 = methodcaller('encode', 'utf-8')
>          if self.cfg.getFileDescriptionView() == 'asfile':
> -            fileselcallback = compose(self.displaySelectedFile, to_utf8)
> +            fileselcallback = compose(self.displaySelectedFile, tounicode)
>          else:
> -            fileselcallback =
> compose(self.textview_status.displayFile, to_utf8)
> +            fileselcallback =
> compose(self.textview_status.displayFile, tounicode)
>          self.tableView_filelist.file_selected[str].connect(fileselcallback)
>          self.tableView_filelist.file_selected[str,
> int].connect(fileselcallback)
>
> diff -r 273b4ae25ccb -r 9b01ad1b0ee8 hgviewlib/util.py
> --- a/hgviewlib/util.py Tue Jul 09 11:18:31 2019 +0200
> +++ b/hgviewlib/util.py Tue Jul 30 16:01:58 2019 +0200
> @@ -30,6 +30,8 @@
>      """
>      if isinstance(text, unicode):
>          return text
> +    elif hasattr(text, 'toUtf8'): # a QString
> +        return text.toUtf8().data()
>      else:
>          text = str(text)
>      for encoding in ('utf-8', 'iso-8859-15', 'cp1252'):
> # HG changeset patch
> # User Simon Giesecke <sgiese...@mozilla.com>
> # Date 1564495420 -7200
> #      Tue Jul 30 16:03:40 2019 +0200
> # Node ID 093ed6e5aa51b1a454a13c5b171221a6e8169d77
> # Parent  9b01ad1b0ee86c2eba0a5b9f903228ce7c5400f5
> Bugfix: status may be a QVariant
>
> diff -r 9b01ad1b0ee8 -r 093ed6e5aa51 hgviewlib/qt4/hgrepoviewer.py
> --- a/hgviewlib/qt4/hgrepoviewer.py Tue Jul 30 16:01:58 2019 +0200
> +++ b/hgviewlib/qt4/hgrepoviewer.py Tue Jul 30 16:03:40 2019 +0200
> @@ -294,6 +294,8 @@
>              status = settings.value(entryname)
>              if status is None:
>                  status = 1
> +            elif isinstance(status, QtCore.QVariant):
> +                status = int(status.toBool())
>              else:
>                  try:
>                      status = int(status)
>
>
> On Mon, Jul 29, 2019 at 2:40 PM Simon Giesecke <sgiese...@mozilla.com> wrote:
>>
>> Hi,
>>
>> On Sat, Jul 27, 2019 at 1:12 AM Mads Kiilerich <m...@kiilerich.com> wrote:
>>> On 7/26/19 4:08 PM, Simon Giesecke wrote:
>>>> Hi,
>>>>
>>>> I needed the following patches to get hgview (with the Qt frontend)
>>>> basically running on my Fedora 30 instance. Please consider merging them.
>>>
>>> I confirm they make the QT frontend work - tested with Mercurial 4.9.
>>>
>>> (The curses frontend is however still broken. And migration to Python 3
>>> will very soon be necessary for Fedora packaging.)
>>
>> Yes that's true, I can check migrating to Python 3, but probably some 
>> dependencies will need to be migrated first.
>>
>>>> # HG changeset patch
>>>> # User Simon Giesecke <sgiese...@mozilla.com>
>>>> # Date 1562663911 -7200
>>>> #      Tue Jul 09 11:18:31 2019 +0200
>>>> # Node ID 273b4ae25ccb8e26ca8b27b61861a621abcfb71f
>>>> # Parent  7f3142453cd546d701a7455cab9568cce08d9974
>>>> Bugfix: do not return matcher function, but use it for calling diff
>>>
>>> Fixing a trivial recent regression for Mercurial < 5.0 from
>>> http://hg.logilab.org/review/hgview/rev/15113c412f4c .
>>>
>>>
>>>> # HG changeset patch
>>>> # User Simon Giesecke <sgiese...@mozilla.com>
>>>> # Date 1562664056 -7200
>>>> #      Tue Jul 09 11:20:56 2019 +0200
>>>> # Node ID e73ef9c7f73339207df78209f8b9ed384c166aad
>>>> # Parent  273b4ae25ccb8e26ca8b27b61861a621abcfb71f
>>>> Bugfix: status may be a QVariant
>>>
>>> Is it known what introduced this change? Is the old behaviour still
>>> relevant?
>>
>> Unfortunately, I have no idea. I am not familiar with PyQt4 or sip, I was 
>> just trying to do some minimal changes to make it work.
>>
>> Probably this is not the best approach, following 
>> https://www.riverbankcomputing.com/static/Docs/PyQt4/python_v3.html#qvariant 
>> (this is about Python3, but I did not find any equivalent documentation 
>> regarding Python2) and 
>> https://www.riverbankcomputing.com/static/Docs/PyQt4/pyqt_qvariant.html, 
>> which sounds as if converting to int should actually work. So maybe this is 
>> more a bug in PyQt4, and my change just works around that?
>>
>> Unfortunately, I have no idea when hgview last worked, since I am a new user.
>>
>>>> diff --git a/hgviewlib/qt4/hgrepoviewer.py b/hgviewlib/qt4/hgrepoviewer.py
>>>> --- a/hgviewlib/qt4/hgrepoviewer.py
>>>> +++ b/hgviewlib/qt4/hgrepoviewer.py
>>>> @@ -299,6 +299,9 @@ class HgRepoViewer(ActionsMixin, HgDialo
>>>>              else:
>>>>                  try:
>>>>                      status = int(status)
>>>> +                except TypeError:
>>>> +                    # assume status is a QVariant
>>>> +                    status = int(status.toBool())
>>>>                  except ValueError:
>>>>                      # for backward compatibility
>>>>                      status = {'false': False , 'true':
>>>> True}.get(status.lower(), status)
>>>
>>> Instead of catching the generic TypeError, how about something like:
>>>
>>>               status = settings.value(entryname)
>>>               if status is None:
>>>                   status = 1
>>> +            elif isinstance(status, QtCore.QVariant):
>>> +                status = int(status.toBool())
>>>               else:
>>>                   try:
>>>                       status = int(status)
>>>
>> Yes, that's probably better, I will change the patch to do just that. Thanks 
>> for the suggestion!
>>
>> Best wishes
>> Simon
> _______________________________________________
> Python-Projects mailing list
> Python-Projects@lists.logilab.org
> https://lists.logilab.org/mailman/listinfo/python-projects

_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
https://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to