[PATCH 1 of 3 stable] guess: keep internal thread id of RenameSearchThread while running (refs #1990)

4 views
Skip to first unread message

Yuya Nishihara

unread,
Jul 27, 2013, 8:35:17 AM7/27/13
to thg...@googlegroups.com
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1374927309 -32400
# Sat Jul 27 21:15:09 2013 +0900
# Branch stable
# Node ID af049ff8d796d0428ee10bdd6840d742f713e298
# Parent 94d3c8b89a8f47a7a3f99c902339d7491d2ffe0f
guess: keep internal thread id of RenameSearchThread while running (refs #1990)

diff --git a/tortoisehg/hgqt/guess.py b/tortoisehg/hgqt/guess.py
--- a/tortoisehg/hgqt/guess.py
+++ b/tortoisehg/hgqt/guess.py
@@ -399,6 +399,7 @@ class RenameSearchThread(QThread):
self.minpct = minpct
self.copies = copies
self.stopped = False
+ self.threadid = None

def run(self):
def emit(topic, pos, item='', unit='', total=None):
@@ -407,10 +408,14 @@ class RenameSearchThread(QThread):
unit = hglib.tounicode(unit or '')
self.progress.emit(topic, pos, item, unit, total)
self.repo.ui.progress = emit
+ self.threadid = int(self.currentThreadId())
try:
- self.search(self.repo)
- except Exception, e:
- self.showMessage.emit(hglib.tounicode(str(e)))
+ try:
+ self.search(self.repo)
+ except Exception, e:
+ self.showMessage.emit(hglib.tounicode(str(e)))
+ finally:
+ self.threadid = None

def cancel(self):
self.stopped = True

Yuya Nishihara

unread,
Jul 27, 2013, 8:35:18 AM7/27/13
to thg...@googlegroups.com
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1374927657 -32400
# Sat Jul 27 21:20:57 2013 +0900
# Branch stable
# Node ID e4ae1c8aae6c387f53e3a5dfb9a336931002d8cf
# Parent af049ff8d796d0428ee10bdd6840d742f713e298
guess: try to abort RenameSearchThread by exception on cancel (fixes #1990)

similar._findexactmatches and _findsimilarmatches may take a long time if
repository has many files.

diff --git a/tortoisehg/hgqt/guess.py b/tortoisehg/hgqt/guess.py
--- a/tortoisehg/hgqt/guess.py
+++ b/tortoisehg/hgqt/guess.py
@@ -9,7 +9,7 @@ import os

from mercurial import hg, ui, mdiff, similar, patch

-from tortoisehg.util import hglib, shlib
+from tortoisehg.util import hglib, shlib, thread2

from tortoisehg.hgqt.i18n import _
from tortoisehg.hgqt import qtlib, htmlui, cmdui
@@ -412,13 +412,22 @@ class RenameSearchThread(QThread):
try:
try:
self.search(self.repo)
+ except KeyboardInterrupt:
+ pass
except Exception, e:
self.showMessage.emit(hglib.tounicode(str(e)))
finally:
self.threadid = None

def cancel(self):
+ tid = self.threadid
+ if tid is None:
+ return
self.stopped = True
+ try:
+ thread2._async_raise(tid, KeyboardInterrupt)
+ except ValueError:
+ pass

def search(self, repo):
wctx = repo[None]

Yuya Nishihara

unread,
Jul 27, 2013, 8:35:19 AM7/27/13
to thg...@googlegroups.com
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1374927775 -32400
# Sat Jul 27 21:22:55 2013 +0900
# Branch stable
# Node ID 5e50d5490cd4f54e55e485f8b346bcca941c1559
# Parent e4ae1c8aae6c387f53e3a5dfb9a336931002d8cf
guess: remove cancel flag of RenameSearchThread

It should be superseded by KeyboardInterrupt.

diff --git a/tortoisehg/hgqt/guess.py b/tortoisehg/hgqt/guess.py
--- a/tortoisehg/hgqt/guess.py
+++ b/tortoisehg/hgqt/guess.py
@@ -398,7 +398,6 @@ class RenameSearchThread(QThread):
self.ufiles = ufiles
self.minpct = minpct
self.copies = copies
- self.stopped = False
self.threadid = None

def run(self):
@@ -423,7 +422,6 @@ class RenameSearchThread(QThread):
tid = self.threadid
if tid is None:
return
- self.stopped = True
try:
thread2._async_raise(tid, KeyboardInterrupt)
except ValueError:
@@ -446,8 +444,6 @@ class RenameSearchThread(QThread):
exacts = []
gen = similar._findexactmatches(repo, added, removed)
for o, n in gen:
- if self.stopped:
- return
old, new = o.path(), n.path()
exacts.append(old)
self.match.emit([old, new, 1.0])
@@ -456,7 +452,5 @@ class RenameSearchThread(QThread):
removed = [r for r in removed if r.path() not in exacts]
gen = similar._findsimilarmatches(repo, added, removed, self.minpct)
for o, n, s in gen:
- if self.stopped:
- return
old, new, sim = o.path(), n.path(), s
self.match.emit([old, new, sim])

Steve Borho

unread,
Jul 27, 2013, 3:00:42 PM7/27/13
to thg...@googlegroups.com
On Sat, Jul 27, 2013 at 7:35 AM, Yuya Nishihara <yu...@tcha.org> wrote:
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1374927775 -32400
#      Sat Jul 27 21:22:55 2013 +0900
# Branch stable
# Node ID 5e50d5490cd4f54e55e485f8b346bcca941c1559
# Parent  e4ae1c8aae6c387f53e3a5dfb9a336931002d8cf
guess: remove cancel flag of RenameSearchThread

It should be superseded by KeyboardInterrupt.

These look good too
 

--
You received this message because you are subscribed to the Google Groups "TortoiseHg Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thg-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.





--
Steve Borho

Yuya Nishihara

unread,
Jul 28, 2013, 1:04:04 AM7/28/13
to thg...@googlegroups.com
On Sat, 27 Jul 2013 14:00:42 -0500, Steve Borho wrote:
> On Sat, Jul 27, 2013 at 7:35 AM, Yuya Nishihara <yu...@tcha.org> wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yu...@tcha.org>
> > # Date 1374927775 -32400
> > # Sat Jul 27 21:22:55 2013 +0900
> > # Branch stable
> > # Node ID 5e50d5490cd4f54e55e485f8b346bcca941c1559
> > # Parent e4ae1c8aae6c387f53e3a5dfb9a336931002d8cf
> > guess: remove cancel flag of RenameSearchThread
> >
> > It should be superseded by KeyboardInterrupt.
>
> These look good too

Thanks, pushed.

Regards,
Reply all
Reply to author
Forward
0 new messages