[PYTHON] Try modifying TortoiseHg's file view a bit more

It is a continuation of http://qiita.com/items/940cab68f7e112af249f.

Thing you want to do

If you search on Google Chrome or PyCharm, the marker will tell you which side has the hit keyword.

Like this. This is Iron, not Chrome. Iron search

I want this feature in TortoiseHg as well. ** By the way, Tortoise Bzr already has it. ** </ Stemmer>

What i did

For the time being, it seems that the BlockList class, which I modified the other day, can be used almost as it is. Let's place it on the right side of the file view, like Chrome. So it looks like this. thg-fileview

The source is here. https://bitbucket.org/iwata0303/thg/commits/d8452bd98690ab2f939164358976ff68 SIGNAL / SLOT is carefully defined in the TortoiseHg code, so this kind of extension is easy :)

Extension

Now, like the other day, let's implement this function with a plugin. It's a hassle to build TortoiseHg yourself. Last time, I realized it by adding a method to the BlockList class at runtime, but this time it is a bit troublesome because the corrections are divided into several parts and the existing methods also have corrections. .. At this time, it seems faster to replace each class. It's easier to deal with version upgrades.

The procedure is like this.

  1. Create a folder called thg-ext (whatever the name is) in a suitable location.
  2. Throw the modified files (blockmatcher.py, qscilib.py, fileview.py) into that folder.
  3. Create a file called __init__.py in the same folder with the following contents.

__init__.py


# -*- coding: utf-8 -*-
import sys
import os

def extsetup():
    #Make it work only when launched from TortoiseHg
    if not os.path.basename(sys.argv[0]).startswith('thg'):
        return
    
    # qscilib.Replace scintilla
    from tortoisehg.hgqt import qscilib
    from .qscilib import Scintilla
    qscilib.Scintilla = Scintilla
    # blockmatcher.Replace BlockList
    from tortoisehg.hgqt import blockmatcher
    from .blockmatcher import BlockList
    blockmatcher.BlockList = BlockList
    # fileview.Replace HgFileView
    from tortoisehg.hgqt import fileview
    from .fileview import HgFileView
    fileview.HgFileView = HgFileView

By the way, the replacement order of Scintilla HgFileView is important. HgFileView inherits Scintilla, so if you load HgFileView first, you will use Scintilla before replacement.

  1. In mercurial.ini or hgrc, register the path of the thg-ext folder as an extension.

mercurial.ini


[extensions]
thgext = C:\Work\thg-ext

So, congratulations, the search marker function worked :) Freedom is good for dynamic languages. It is a source of trouble from the side that prepares the plug-in mechanism, but w

Recommended Posts

Try modifying TortoiseHg's file view a bit more
Try modifying the TortoiseHg file view a bit
Try creating a compressed file using Python and zlib