Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
thg
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
785
Issues
785
List
Boards
Labels
Service Desk
Milestones
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mercurial
TortoiseHg
thg
Commits
fcca5bb846a2
Commit
d72f3627
authored
Sep 01, 2020
by
Manuel Jacob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py3: fix custom tools
--HG-- branch : stable
parent
0ddbafd86b8b
Pipeline
#9853
passed with stage
in 23 minutes and 3 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
23 deletions
+39
-23
tortoisehg/hgqt/customtools.py
tortoisehg/hgqt/customtools.py
+9
-6
tortoisehg/hgqt/repowidget.py
tortoisehg/hgqt/repowidget.py
+11
-1
tortoisehg/util/hglib.py
tortoisehg/util/hglib.py
+19
-16
No files found.
tortoisehg/hgqt/customtools.py
View file @
fcca5bb846a2
...
...
@@ -20,6 +20,8 @@ from __future__ import absolute_import
import
re
from
mercurial
import
pycompat
from
.qtcore
import
(
QSettings
,
Qt
,
...
...
@@ -259,8 +261,7 @@ class ToolsFrame(QFrame):
pass
tools
=
self
.
value
()
for
uname
in
tools
:
name
=
hglib
.
fromunicode
(
uname
)
for
name
in
tools
:
if
name
[
0
]
in
'|-'
:
continue
for
field
in
sorted
(
tools
[
name
]):
...
...
@@ -268,7 +269,8 @@ class ToolsFrame(QFrame):
value
=
tools
[
name
][
field
]
# value may be bool if originating from hglib.tortoisehgtools()
if
value
!=
''
:
ini
.
set
(
section
,
keyname
,
str
(
value
))
updateIniValue
(
section
,
keyname
,
hglib
.
fromunicode
(
pycompat
.
unicode
(
value
)))
# 2. Save the new guidefs
for
n
,
toollistwidget
in
enumerate
(
self
.
widgets
):
...
...
@@ -278,7 +280,8 @@ class ToolsFrame(QFrame):
emitChanged
=
True
toollist
=
toollistwidget
.
value
()
updateIniValue
(
'tortoisehg'
,
toollocation
,
' '
.
join
(
toollist
))
updateIniValue
(
'tortoisehg'
,
toollocation
,
hglib
.
fromunicode
(
' '
.
join
(
toollist
)))
return
emitChanged
...
...
@@ -567,7 +570,7 @@ class ToolListBox(QListWidget):
if
[
name
]
==
toollist
[
-
1
:]:
continue
else
:
name
=
hglib
.
fromunicode
(
uname
)
name
=
uname
guidef
.
append
(
name
)
return
guidef
...
...
@@ -577,7 +580,7 @@ class ToolListBox(QListWidget):
else
:
if
not
icon
:
icon
=
DEFAULTICONNAME
if
isinstance
(
icon
,
str
):
if
hglib
.
isbasestring
(
icon
):
icon
=
qtlib
.
geticon
(
icon
)
item
=
QListWidgetItem
(
icon
,
text
)
row
=
self
.
currentIndex
().
row
()
...
...
tortoisehg/hgqt/repowidget.py
View file @
fcca5bb846a2
...
...
@@ -2184,11 +2184,15 @@ class RepoWidget(QWidget):
# Perform variable expansion
# This is done in two steps:
# 1. Expand environment variables
if
not
pycompat
.
ispy3
:
command
=
hglib
.
fromunicode
(
command
)
command
=
os
.
path
.
expandvars
(
command
).
strip
()
if
not
command
:
InfoMsgBox
(
_
(
'Invalid command'
),
_
(
'The selected command is empty'
))
return
if
not
pycompat
.
ispy3
:
workingdir
=
hglib
.
fromunicode
(
workingdir
)
if
workingdir
:
workingdir
=
os
.
path
.
expandvars
(
workingdir
).
strip
()
...
...
@@ -2257,7 +2261,13 @@ class RepoWidget(QWidget):
_ui
.
ferr
=
pycompat
.
bytesio
()
# avoid circular import of hgqt.run by importing it inplace
from
.
import
run
res
=
run
.
dispatch
(
cmd
,
u
=
_ui
)
cmdb
=
[]
for
part
in
cmd
:
if
isinstance
(
part
,
pycompat
.
unicode
):
cmdb
.
append
(
hglib
.
fromunicode
(
part
))
else
:
cmdb
.
append
(
part
)
res
=
run
.
dispatch
(
cmdb
,
u
=
_ui
)
if
res
:
errormsg
=
_ui
.
ferr
.
getvalue
().
strip
()
if
errormsg
:
...
...
tortoisehg/util/hglib.py
View file @
fcca5bb846a2
...
...
@@ -587,11 +587,11 @@ def tortoisehgtools(uiorconfig, selectedlocation=None):
>>> tools, toollist = tortoisehgtools(uiobj)
>>> pprint(tools) #doctest: +NORMALIZE_WHITESPACE
{
b'update_to_tip': {b'command': b
'hg update tip',
b'icon': b
'hg-update',
b'tooltip': b
'Update to tip'}}
{
'update_to_tip': {'command':
'hg update tip',
'icon':
'hg-update',
'tooltip':
'Update to tip'}}
>>> toollist
[
b
'update_to_tip']
['update_to_tip']
If selectedlocation is set, only return those tools that have been
configured to be shown at the given "location".
...
...
@@ -619,16 +619,16 @@ def tortoisehgtools(uiorconfig, selectedlocation=None):
>>> tools, toollist = tortoisehgtools(
... uiobj, selectedlocation='workbench.custom-toolbar')
>>> sorted(tools.keys())
[
b'explore_wd', b
'update_to_tip']
[
'explore_wd',
'update_to_tip']
>>> toollist
[
b'update_to_tip', b'|', b
'explore_wd']
[
'update_to_tip', '|',
'explore_wd']
>>> tools, toollist = tortoisehgtools(
... uiobj, selectedlocation='workbench.revdetails.custom-menu')
>>> sorted(tools.keys())
[
b'update_to_null', b
'update_to_tip']
[
'update_to_null',
'update_to_tip']
>>> toollist
[
b'update_to_tip', b
'update_to_null']
[
'update_to_tip',
'update_to_null']
Valid "locations lists" are:
- workbench.custom-toolbar
...
...
@@ -645,20 +645,20 @@ def tortoisehgtools(uiorconfig, selectedlocation=None):
>>> cfg.parse(b'<hgrc>', hgrctext)
>>> tools, toollist = tortoisehgtools(cfg)
>>> pprint(tools) #doctest: +NORMALIZE_WHITESPACE
{
b'update_to_tip': {b'command': b
'hg update tip',
b'icon': b
'hg-update',
b'tooltip': b
'Update to tip'}}
{
'update_to_tip': {'command':
'hg update tip',
'icon':
'hg-update',
'tooltip':
'Update to tip'}}
>>> toollist
[
b
'update_to_tip']
['update_to_tip']
>>> cfg = config.config()
>>> cfg.parse(b'<hgrc>', hgrctext_full)
>>> tools, toollist = tortoisehgtools(
... cfg, selectedlocation='workbench.custom-toolbar')
>>> sorted(tools.keys())
[
b'explore_wd', b
'update_to_tip']
[
'explore_wd',
'update_to_tip']
>>> toollist
[
b'update_to_tip', b'|', b
'explore_wd']
[
'update_to_tip', '|',
'explore_wd']
No error for empty config:
...
...
@@ -678,12 +678,14 @@ def tortoisehgtools(uiorconfig, selectedlocation=None):
tools
=
{}
for
key
,
value
in
configitems
(
b
'tortoisehg-tools'
):
toolname
,
field
=
key
.
split
(
b
'.'
,
1
)
toolname
,
field
=
tounicode
(
key
).
split
(
'.'
,
1
)
if
toolname
not
in
tools
:
tools
[
toolname
]
=
{}
bvalue
=
stringutil
.
parsebool
(
value
)
if
bvalue
is
not
None
:
value
=
bvalue
else
:
value
=
tounicode
(
value
)
tools
[
toolname
][
field
]
=
value
if
selectedlocation
is
None
:
...
...
@@ -698,7 +700,8 @@ def tortoisehgtools(uiorconfig, selectedlocation=None):
toollist
=
[]
selectedtools
=
{}
for
name
in
guidef
:
if
name
!=
b
'|'
:
name
=
tounicode
(
name
)
if
name
!=
'|'
:
info
=
tools
.
get
(
name
,
None
)
if
info
is
None
:
continue
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment