Re: Don't show context menu for paths

Daniel Sahlberg via TortoiseSVN-dev <[email protected]> Wed, 18 Sep 2024 00:45:10 -0700 (PDT)
Newsgroups gmane.comp.version-control.subversion.tortoisesvn.devel
Message-ID <[email protected]>
------=_Part_191860_457113716.1726645510318
Content-Type: multipart/alternative; 
	boundary="----=_Part_191861_1966102200.1726645510318"

------=_Part_191861_1966102200.1726645510318
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

s=C3=B6ndag 15 september 2024 kl. 19:24:22 UTC+2 skrev Stefan:

On Sunday, September 15, 2024 at 4:13:52=E2=80=AFPM UTC+2 daniel.l...@gmail=
.com=20
wrote:

This is handled in ShellCache::IsContextPathAllowed(LPCWSTR path). If=20
right-clicking the folder itself, path will be c:\temp\wc

I'm considering to check the list of ignored paths for a trailing \* as=20
follows (adding the ternary operator to check for \\).

        if (!I->empty() && I->at(I->size() - 1) =3D=3D '*')
        {
            std::wstring str =3D I->substr(0, I->size() - *(I->at(I->size()=
 -=20
2) =3D=3D '\\' ? 2 : *1*)*);


but first check that the string has at least two chars, otherwise a -2=20
would make it crash.
=20

Then c:\temp\wc\* would work, but it might crash on a single * (didn't=20
check yet).

Or to check separately for trailing \:

        else if (!I->empty() && I->at(I->size() - 1) =3D=3D '\')
        {
            std::wstring str =3D I->substr(0, I->size() - 1);
            if (_wcsnicmp(str.c_str(), path, str.size()) =3D=3D 0)
                return FALSE;
        }


that would work too. I don't really have a preference here.
=20

Basically treating \ as a wildcard character - then you could add=20
c:\temp\wc\ as "ignore the wc folder and everything below".

What do you think? Any risk of regressions?


No, no risk of regressions.
=20


While I was at it, I'd suggest to remove the check for !I->empty() in the=
=20
if statement. There is already a separate statement:

        if (I->empty())
            continue;

just above. So we KNOW that I->empty() is false. Do I miss something here?=
=20
(For comparison, TortoiseGit don't have that !I->empty() check).


yes, you can remove that.

Stefan


Thanks.

I've committed some code as r29713. I've tested with the following layout:

c:\temp\wc
c:\temp\wc2

"Don't show" set as c:\temp\wc

The context menu is shown when right-clicking anywhere in c:\temp, except=
=20
when right-clicking on c:\temp\wc. The context menu is shown within=20
c:\temp\wc2\. The context menu is not shown within c:\temp\wc\. I think=20
that is reasonable.

Kind regards,
Daniel

=20

--=20
You received this message because you are subscribed to the Google Groups "=
TortoiseSVN-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/=
tortoisesvn-dev/a16a22d1-7cad-49eb-8a24-5ca0c1a37a43n%40googlegroups.com.

------=_Part_191861_1966102200.1726645510318
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div><div dir=3D"auto">s=C3=B6ndag 15 september 2024 kl. 19:24:22 UTC+2 skr=
ev Stefan:<br /></div><blockquote style=3D"margin: 0px 0px 0px 0.8ex; borde=
r-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div dir=3D"=
auto">On Sunday, September 15, 2024 at 4:13:52=E2=80=AFPM UTC+2 <a href=3D"=
" rel=3D"nofollow">[email protected]</a> wrote:<br /></div><blockquote =
style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 20=
4); padding-left: 1ex;"><div>This is handled in ShellCache::IsContextPathAl=
lowed(LPCWSTR path). If right-clicking the folder itself, path will be c:\t=
emp\wc<br /></div><div><br /></div><div>I'm considering to check the list o=
f ignored paths for a trailing \* as follows (adding the ternary operator t=
o check for \\).</div><div><br /></div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!I-&=
gt;empty() &amp;&amp; I-&gt;at(I-&gt;size() - 1) =3D=3D '*')<br />=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 {<br /><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
std::wstring str =3D I-&gt;substr(0, I-&gt;size() - <b>(I-&gt;at(I-&gt;size=
() - 2) =3D=3D '\\' ? 2 : </b>1<b>)</b>);<br /></div></blockquote><div><br =
/></div></div><div><div>but first check that the string has at least two ch=
ars, otherwise a -2 would make it crash.</div></div><div><div>=C2=A0</div><=
blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(2=
04, 204, 204); padding-left: 1ex;"><div></div><div>Then c:\temp\wc\* would =
work, but it might crash on a single * (didn't check yet).<br /></div><div>=
<br /></div><div>Or to check separately for trailing \:</div><div><br /></d=
iv><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 else if (!I-&gt;empty() &amp;&amp; I-&g=
t;at(I-&gt;size() - 1) =3D=3D '\')<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 {<br />=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 std::wstring str =3D I-&gt;substr=
(0, I-&gt;size() - 1);<br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (_=
wcsnicmp(str.c_str(), path, str.size()) =3D=3D 0)<br />=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return FALSE;<br />=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 }<br /></div><div><br /></div></blockquote><div><br /></div></div><=
div><div>that would work too. I don't really have a preference here.</div><=
/div><div><div>=C2=A0</div><blockquote style=3D"margin: 0px 0px 0px 0.8ex; =
border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div></div><=
div>Basically treating \ as a wildcard character - then you could add c:\te=
mp\wc\ as "ignore the wc folder and everything below".</div><div><br /></di=
v><div>What do you think? Any risk of regressions?</div></blockquote><div><=
br /></div></div><div><div>No, no risk of regressions.</div></div><div><div=
>=C2=A0</div><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1=
px solid rgb(204, 204, 204); padding-left: 1ex;"><div><br /></div><div>Whil=
e I was at it, I'd suggest to remove the check for !I-&gt;empty() in the if=
 statement. There is already a separate statement:</div><div><br /></div><d=
iv>=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (I-&gt;empty())<br />=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 continue;<br /></div><div><br /></div><div>just above=
. So we KNOW that I-&gt;empty() is false. Do I miss something here? (For co=
mparison, TortoiseGit don't have that !I-&gt;empty() check).</div><div><br =
/></div></blockquote><div><br /></div></div><div><div>yes, you can remove t=
hat.</div><div><br /></div><div>Stefan</div></div></blockquote><div><br /><=
/div><div>Thanks.</div><div><br /></div><div>I've committed some code as r2=
9713. I've tested with the following layout:</div><div><br /></div><div>c:\=
temp\wc</div><div>c:\temp\wc2</div><div><br /></div><div>"Don't show" set a=
s c:\temp\wc</div><div><br /></div><div>The context menu is shown when righ=
t-clicking anywhere in c:\temp, except when right-clicking on c:\temp\wc. T=
he context menu is shown within c:\temp\wc2\. The context menu is not shown=
 within c:\temp\wc\. I think that is reasonable.</div><div><br /></div><div=
>Kind regards,</div><div>Daniel</div><div><br /></div><div>=C2=A0</div></di=
v>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;TortoiseSVN-dev&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">tor=
[email protected]</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/tortoisesvn-dev/a16a22d1-7cad-49eb-8a24-5ca0c1a37a43n%40googlegr=
oups.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/=
d/msgid/tortoisesvn-dev/a16a22d1-7cad-49eb-8a24-5ca0c1a37a43n%40googlegroup=
s.com</a>.<br />

------=_Part_191861_1966102200.1726645510318--

------=_Part_191860_457113716.1726645510318--