[PATCH 1 of 2] visdiff: remove `dodiffwrapper()`

2 views
Skip to first unread message

Aay Jay Chan

unread,
Jul 24, 2021, 11:15:40 AM7/24/21
to thg...@googlegroups.com
# HG changeset patch
# User Aay Jay Chan <aayja...@itopia.com.hk>
# Date 1627136549 -28800
# Sat Jul 24 22:22:29 2021 +0800
# Node ID 85b166783acf94584b0e6c4db1a34cc323e27203
# Parent 5849ec046555ce24a28268c086ab171ff41ad268
visdiff: remove `dodiffwrapper()`

Since b85e65f3a070 (visdiff: use qtlib.gettempdir(), 2010-05-08), temporary
files are cleaned up on application exit. `dodiffwrapper()` doesn't do any
actual work, only logs a misleading message.

diff --git a/tortoisehg/hgqt/visdiff.py b/tortoisehg/hgqt/visdiff.py
--- a/tortoisehg/hgqt/visdiff.py
+++ b/tortoisehg/hgqt/visdiff.py
@@ -451,19 +451,12 @@
except EnvironmentError:
pass # Ignore I/O errors or missing files

- def dodiffwrapper():
- try:
- dodiff()
- finally:
- # cleanup happens atexit
- ui.note(b'cleaning up temp directory\n')
-
if mainapp:
- dodiffwrapper()
+ dodiff()
else:
# We are not the main application, so this must be done in a
# background thread
- thread = threading.Thread(target=dodiffwrapper, name='visualdiff')
+ thread = threading.Thread(target=dodiff, name='visualdiff')
thread.setDaemon(True)
thread.start()


Aay Jay Chan

unread,
Jul 24, 2021, 11:15:41 AM7/24/21
to thg...@googlegroups.com
# HG changeset patch
# User Aay Jay Chan <aayja...@itopia.com.hk>
# Date 1627138206 -28800
# Sat Jul 24 22:50:06 2021 +0800
# Node ID 4bc900808cb5f1cae74a5db311feaa618d14057b
# Parent 85b166783acf94584b0e6c4db1a34cc323e27203
visdiff: don't use a separate thread to start diff tool

When using a separate thread without error handling, exceptions that occur when
starting diff tool are not visible to the UI. The non-blocking behaviour is
preserved by not waiting the diff tool process to exit.

diff --git a/tortoisehg/hgqt/visdiff.py b/tortoisehg/hgqt/visdiff.py
--- a/tortoisehg/hgqt/visdiff.py
+++ b/tortoisehg/hgqt/visdiff.py
@@ -438,7 +438,7 @@
phash1=str(ctx1a), phash2=str(ctx1b),
repo=hglib.fromunicode(repoagent.displayName()),
clabel=label2, child=dir2, chash=str(ctx2)) # type: Dict[Text, Union[bytes, Text]]
- launchtool(diffcmd, args, replace, True)
+ launchtool(diffcmd, args, replace, mainapp)

# detect if changes were made to mirrored working files
for copy_fn, working_fn, mtime in fns_and_mtime:
@@ -451,14 +451,7 @@
except EnvironmentError:
pass # Ignore I/O errors or missing files

- if mainapp:
- dodiff()
- else:
- # We are not the main application, so this must be done in a
- # background thread
- thread = threading.Thread(target=dodiff, name='visualdiff')
- thread.setDaemon(True)
- thread.start()
+ dodiff()

class FileSelectionDialog(QDialog):
'Dialog for selecting visual diff candidates'

Yuya Nishihara

unread,
Jul 26, 2021, 8:01:42 AM7/26/21
to thg...@googlegroups.com, Aay Jay Chan
On Sat, 24 Jul 2021 23:15:35 +0800, Aay Jay Chan wrote:
> # HG changeset patch
> # User Aay Jay Chan <aayja...@itopia.com.hk>
> # Date 1627136549 -28800
> # Sat Jul 24 22:22:29 2021 +0800
> # Node ID 85b166783acf94584b0e6c4db1a34cc323e27203
> # Parent 5849ec046555ce24a28268c086ab171ff41ad268
> visdiff: remove `dodiffwrapper()`

Queued this, thanks.

Yuya Nishihara

unread,
Jul 26, 2021, 8:01:47 AM7/26/21
to thg...@googlegroups.com, Aay Jay Chan
On Sat, 24 Jul 2021 23:15:36 +0800, Aay Jay Chan wrote:
> # HG changeset patch
> # User Aay Jay Chan <aayja...@itopia.com.hk>
> # Date 1627138206 -28800
> # Sat Jul 24 22:50:06 2021 +0800
> # Node ID 4bc900808cb5f1cae74a5db311feaa618d14057b
> # Parent 85b166783acf94584b0e6c4db1a34cc323e27203
> visdiff: don't use a separate thread to start diff tool
>
> When using a separate thread without error handling, exceptions that occur when
> starting diff tool are not visible to the UI. The non-blocking behaviour is
> preserved by not waiting the diff tool process to exit.
>
> diff --git a/tortoisehg/hgqt/visdiff.py b/tortoisehg/hgqt/visdiff.py
> --- a/tortoisehg/hgqt/visdiff.py
> +++ b/tortoisehg/hgqt/visdiff.py
> @@ -438,7 +438,7 @@
> phash1=str(ctx1a), phash2=str(ctx1b),
> repo=hglib.fromunicode(repoagent.displayName()),
> clabel=label2, child=dir2, chash=str(ctx2)) # type: Dict[Text, Union[bytes, Text]]
> - launchtool(diffcmd, args, replace, True)
> + launchtool(diffcmd, args, replace, mainapp)
>
> # detect if changes were made to mirrored working files
> for copy_fn, working_fn, mtime in fns_and_mtime:

I wanted to queued this patch, but apparently this copy-back loop relies
on blocking launchtool(), sigh.
Reply all
Reply to author
Forward
0 new messages