Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-03-09 Thread Pavel Sanda
On Mon, Mar 08, 2021 at 10:48:07PM -0500, Richard Kimberly Heck wrote:
> > Riki, unless you object I suggest to revert the whole 7e5c42593e45 because 
> > it seems
> > to bring more problems then it solves... Would that be Ok with you?
> 
> OK, go ahead. We can try something else later.

Committed. P
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-03-08 Thread Richard Kimberly Heck
On 3/8/21 5:35 PM, Pavel Sanda wrote:
> On Wed, Mar 03, 2021 at 04:53:23PM +0100, Pavel Sanda wrote:
>> On Sat, Jan 09, 2021 at 12:12:45AM -0500, Scott Kostyshak wrote:
> I can see why the implementation in the previous version of using git-ls
> was complex since we had to redirect output to a file and check it, but
> what about using "git ls-files --error-unmatch " ? The
> "--error-unmatch" seems to make it so we don't have to check a file.
> The only annoyance I see is that there is no "--quiet" option so we
> would need to redirect the output. I can look into adding a "quiet"
> argument to doVCCommandCall() that would quiet both STDOUT and STDERR if
> the attached patch is on the right track.
 It looks right to me.

 Enrico may have good ideas about how to do the redirection.
>>> Sounds good. If anyone knows a good approach, please feel free to merge it 
>>> into the patch and commit. Or describe the approach and I'll implement it.
>> I hope to check the git part once I have some spare time.
> Found some time to check and agree that current code for git findFile in the 
> master is wrong.
>
> I'm not entirely against --error-unmatch solution but it would need 
> confirmation
> that the whole construct works on other platforms (I really mean Windows) -- 
> we do
> not use this elsewhere in VCS routines.
>
> Riki, unless you object I suggest to revert the whole 7e5c42593e45 because it 
> seems
> to bring more problems then it solves... Would that be Ok with you?

OK, go ahead. We can try something else later.

Riki


-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-03-08 Thread Pavel Sanda
On Wed, Mar 03, 2021 at 04:53:23PM +0100, Pavel Sanda wrote:
> On Sat, Jan 09, 2021 at 12:12:45AM -0500, Scott Kostyshak wrote:
> > > > I can see why the implementation in the previous version of using git-ls
> > > > was complex since we had to redirect output to a file and check it, but
> > > > what about using "git ls-files --error-unmatch " ? The
> > > > "--error-unmatch" seems to make it so we don't have to check a file.
> > > > The only annoyance I see is that there is no "--quiet" option so we
> > > > would need to redirect the output. I can look into adding a "quiet"
> > > > argument to doVCCommandCall() that would quiet both STDOUT and STDERR if
> > > > the attached patch is on the right track.
> > > 
> > > It looks right to me.
> > > 
> > > Enrico may have good ideas about how to do the redirection.
> > 
> > Sounds good. If anyone knows a good approach, please feel free to merge it 
> > into the patch and commit. Or describe the approach and I'll implement it.
> 
> I hope to check the git part once I have some spare time.

Found some time to check and agree that current code for git findFile in the 
master is wrong.

I'm not entirely against --error-unmatch solution but it would need confirmation
that the whole construct works on other platforms (I really mean Windows) -- we 
do
not use this elsewhere in VCS routines.

Riki, unless you object I suggest to revert the whole 7e5c42593e45 because it 
seems
to bring more problems then it solves... Would that be Ok with you?

Pavel
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-03-04 Thread Richard Kimberly Heck
On 3/3/21 10:48 AM, Pavel Sanda wrote:
> On Fri, Dec 25, 2020 at 06:35:08PM +0100, Pavel Sanda wrote:
>> are you positive that cvs log does not actually try to connect to server 
>> (would
>> make us fail if you are offline)? It's really long time ago I used cvs, but
>> IIRC each tracked directory has the needed metadata locally at the place
>> so do we actualy need these changes to fulfil the users-list request?
>>
>> Sorry for nitpicking, but given that this piece of code is executed at each
>> document load we better be super careful here...
> Riki, I would like to have your feedback about the cvs part once you have
> some moment...

I'll have a look into it shortly.

Riki


-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-03-03 Thread Pavel Sanda
On Sat, Jan 09, 2021 at 12:12:45AM -0500, Scott Kostyshak wrote:
> > > I can see why the implementation in the previous version of using git-ls
> > > was complex since we had to redirect output to a file and check it, but
> > > what about using "git ls-files --error-unmatch " ? The
> > > "--error-unmatch" seems to make it so we don't have to check a file.
> > > The only annoyance I see is that there is no "--quiet" option so we
> > > would need to redirect the output. I can look into adding a "quiet"
> > > argument to doVCCommandCall() that would quiet both STDOUT and STDERR if
> > > the attached patch is on the right track.
> > 
> > It looks right to me.
> > 
> > Enrico may have good ideas about how to do the redirection.
> 
> Sounds good. If anyone knows a good approach, please feel free to merge it 
> into the patch and commit. Or describe the approach and I'll implement it.

I hope to check the git part once I have some spare time.

Pavel
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-03-03 Thread Pavel Sanda
On Fri, Dec 25, 2020 at 06:35:08PM +0100, Pavel Sanda wrote:
> are you positive that cvs log does not actually try to connect to server 
> (would
> make us fail if you are offline)? It's really long time ago I used cvs, but
> IIRC each tracked directory has the needed metadata locally at the place
> so do we actualy need these changes to fulfil the users-list request?
> 
> Sorry for nitpicking, but given that this piece of code is executed at each
> document load we better be super careful here...

Riki, I would like to have your feedback about the cvs part once you have
some moment...

Pavel
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-01-11 Thread José Abílio Matos
On Saturday, January 9, 2021 10:38:21 PM WET Scott Kostyshak wrote:
> That does sounds like a good idea, so as to avoid overhead of separate
> processes. I have no idea if it's doable, but I like your strategy:
> whenever José proposes something time-consuming, I will reframe it into
> having to do with Python and shoot it back to him 
> 
> Scott

I will take that challenge when we drop support for python2.
What you ask is simple, but to do it in a way that is compatible with python 2 
and 3 is now out of my mindset. :-)
-- 
José Abílio-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-01-09 Thread Scott Kostyshak
On Sat, Jan 09, 2021 at 10:38:22PM +0100, Jean-Marc Lasgouttes wrote:
> Le 09/01/2021 à 18:14, Scott Kostyshak a écrit :
> > No bonus points given because it's a good point. It would be more clean and 
> > might actually make a noticeable difference in terms of speed. I haven't 
> > particularly noticed slowness because of the VC code (although the previous 
> > code that redirected output to a file might have caused slowness because of 
> > IO?) but I wouldn't be a surprised. It might also open up more extensions 
> > to the VC code in the future. That said, I don't have the time to look into 
> > it now.
> 
> I would be more interested in having a nice interaction with a running
> python instance to speed up all our python scripting needs. Would that be
> doable?

That does sounds like a good idea, so as to avoid overhead of separate
processes. I have no idea if it's doable, but I like your strategy:
whenever José proposes something time-consuming, I will reframe it into
having to do with Python and shoot it back to him :)

Scott


signature.asc
Description: PGP signature
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-01-09 Thread Jean-Marc Lasgouttes

Le 09/01/2021 à 18:14, Scott Kostyshak a écrit :

No bonus points given because it's a good point. It would be more clean and 
might actually make a noticeable difference in terms of speed. I haven't 
particularly noticed slowness because of the VC code (although the previous 
code that redirected output to a file might have caused slowness because of 
IO?) but I wouldn't be a surprised. It might also open up more extensions to 
the VC code in the future. That said, I don't have the time to look into it now.


I would be more interested in having a nice interaction with a running 
python instance to speed up all our python scripting needs. Would that 
be doable?


JMarc
--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-01-09 Thread Scott Kostyshak
On Sat, Jan 09, 2021 at 09:12:19AM +, José Abílio Matos wrote:
> On Saturday, January 9, 2021 5:12:45 AM WET Scott Kostyshak wrote:
> > Sounds good. If anyone knows a good approach, please feel free to merge it
> > into the patch and commit. Or describe the approach and I'll implement it.
> > 
> > Scott
> 
> Not necessarily what you want to hear, and clearly overkill in this context, 
> but using libgit2 or one of its c++ wrappers is one idea. :-)
> 
> I think that I earn bonus points for the useless tip of the day. :-D

No bonus points given because it's a good point. It would be more clean and 
might actually make a noticeable difference in terms of speed. I haven't 
particularly noticed slowness because of the VC code (although the previous 
code that redirected output to a file might have caused slowness because of 
IO?) but I wouldn't be a surprised. It might also open up more extensions to 
the VC code in the future. That said, I don't have the time to look into it now.

Scott


signature.asc
Description: PGP signature
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-01-09 Thread José Abílio Matos
On Saturday, January 9, 2021 5:12:45 AM WET Scott Kostyshak wrote:
> Sounds good. If anyone knows a good approach, please feel free to merge it
> into the patch and commit. Or describe the approach and I'll implement it.
> 
> Scott

Not necessarily what you want to hear, and clearly overkill in this context, 
but using libgit2 or one of its c++ wrappers is one idea. :-)

I think that I earn bonus points for the useless tip of the day. :-D

-- 
José Abílio-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-01-08 Thread Scott Kostyshak
On Fri, Jan 08, 2021 at 10:59:43PM -0500, Richard Kimberly Heck wrote:
> On 1/8/21 10:45 PM, Scott Kostyshak wrote:
> > On Mon, Dec 28, 2020 at 03:45:11PM +0200, Yuriy Skalko wrote:
> > I am sorry not to have a time to follow this thoroughly, but is this
> > cvs log / git log used only inh "register" case as initially discussed
> > or you want to use it on every file load?
> > Calling log could but pretty expensive operation for large archives.
>  The -n0 flag that Yuriy proposed should take care of that, too. So
>  another reason to go that way.
> >>>
> >>> I understood that. The minor concern was that it can still take seconds 
> >>> to get
> >>> the first commit touching particular file in larger git repos if its 
> >>> buried
> >>> down in the history.  But maybe it's not that different from git-ls.
> >>>
> >>> My main concern though were changes to CVS - I haven't seen -n0 
> >>> equivalent and
> >>> are you positive that cvs log does not actually try to connect to server 
> >>> (would
> >>> make us fail if you are offline)? It's really long time ago I used cvs, 
> >>> but
> >>> IIRC each tracked directory has the needed metadata locally at the place
> >>> so do we actualy need these changes to fulfil the users-list request?
> >>>
> >>> Sorry for nitpicking, but given that this piece of code is executed at 
> >>> each
> >>> document load we better be super careful here...
> >>>
> >>> Pavel
> >> Committed "-n 0" for Git. CVS has "-Q" option 
> >> (https://www.gnu.org/software/trans-coord/manual/cvs/html_node/Global-options.html#Global-options)
> >> that may help too, but I have no CVS installed, so cannot test this.
> > I'm not sure that "git log " do
> > what we want here. For me (git version 2.20.1) they do not exit with
> > error if the file is not tracked.
> 
> Hmm. I was certain I had checked this, but it is not exiting with an
> error now for me either.
> 
> 
> > I can see why the implementation in the previous version of using git-ls
> > was complex since we had to redirect output to a file and check it, but
> > what about using "git ls-files --error-unmatch " ? The
> > "--error-unmatch" seems to make it so we don't have to check a file.
> > The only annoyance I see is that there is no "--quiet" option so we
> > would need to redirect the output. I can look into adding a "quiet"
> > argument to doVCCommandCall() that would quiet both STDOUT and STDERR if
> > the attached patch is on the right track.
> 
> It looks right to me.
> 
> Enrico may have good ideas about how to do the redirection.

Sounds good. If anyone knows a good approach, please feel free to merge it into 
the patch and commit. Or describe the approach and I'll implement it.

Scott


signature.asc
Description: PGP signature
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-01-08 Thread Richard Kimberly Heck
On 1/8/21 10:45 PM, Scott Kostyshak wrote:
> On Mon, Dec 28, 2020 at 03:45:11PM +0200, Yuriy Skalko wrote:
> I am sorry not to have a time to follow this thoroughly, but is this
> cvs log / git log used only inh "register" case as initially discussed
> or you want to use it on every file load?
> Calling log could but pretty expensive operation for large archives.
 The -n0 flag that Yuriy proposed should take care of that, too. So
 another reason to go that way.
>>>
>>> I understood that. The minor concern was that it can still take seconds to 
>>> get
>>> the first commit touching particular file in larger git repos if its buried
>>> down in the history.  But maybe it's not that different from git-ls.
>>>
>>> My main concern though were changes to CVS - I haven't seen -n0 equivalent 
>>> and
>>> are you positive that cvs log does not actually try to connect to server 
>>> (would
>>> make us fail if you are offline)? It's really long time ago I used cvs, but
>>> IIRC each tracked directory has the needed metadata locally at the place
>>> so do we actualy need these changes to fulfil the users-list request?
>>>
>>> Sorry for nitpicking, but given that this piece of code is executed at each
>>> document load we better be super careful here...
>>>
>>> Pavel
>> Committed "-n 0" for Git. CVS has "-Q" option 
>> (https://www.gnu.org/software/trans-coord/manual/cvs/html_node/Global-options.html#Global-options)
>> that may help too, but I have no CVS installed, so cannot test this.
> I'm not sure that "git log " do
> what we want here. For me (git version 2.20.1) they do not exit with
> error if the file is not tracked.

Hmm. I was certain I had checked this, but it is not exiting with an
error now for me either.


> I can see why the implementation in the previous version of using git-ls
> was complex since we had to redirect output to a file and check it, but
> what about using "git ls-files --error-unmatch " ? The
> "--error-unmatch" seems to make it so we don't have to check a file.
> The only annoyance I see is that there is no "--quiet" option so we
> would need to redirect the output. I can look into adding a "quiet"
> argument to doVCCommandCall() that would quiet both STDOUT and STDERR if
> the attached patch is on the right track.

It looks right to me.

Enrico may have good ideas about how to do the redirection.

Riki


-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2021-01-08 Thread Scott Kostyshak
On Mon, Dec 28, 2020 at 03:45:11PM +0200, Yuriy Skalko wrote:
> > > > I am sorry not to have a time to follow this thoroughly, but is this
> > > > cvs log / git log used only inh "register" case as initially discussed
> > > > or you want to use it on every file load?
> > > > Calling log could but pretty expensive operation for large archives.
> > > 
> > > The -n0 flag that Yuriy proposed should take care of that, too. So
> > > another reason to go that way.
> > 
> > 
> > I understood that. The minor concern was that it can still take seconds to 
> > get
> > the first commit touching particular file in larger git repos if its buried
> > down in the history.  But maybe it's not that different from git-ls.
> > 
> > My main concern though were changes to CVS - I haven't seen -n0 equivalent 
> > and
> > are you positive that cvs log does not actually try to connect to server 
> > (would
> > make us fail if you are offline)? It's really long time ago I used cvs, but
> > IIRC each tracked directory has the needed metadata locally at the place
> > so do we actualy need these changes to fulfil the users-list request?
> > 
> > Sorry for nitpicking, but given that this piece of code is executed at each
> > document load we better be super careful here...
> > 
> > Pavel
> 
> Committed "-n 0" for Git. CVS has "-Q" option 
> (https://www.gnu.org/software/trans-coord/manual/cvs/html_node/Global-options.html#Global-options)
> that may help too, but I have no CVS installed, so cannot test this.

I'm not sure that "git log " do
what we want here. For me (git version 2.20.1) they do not exit with
error if the file is not tracked.

I can see why the implementation in the previous version of using git-ls
was complex since we had to redirect output to a file and check it, but
what about using "git ls-files --error-unmatch " ? The
"--error-unmatch" seems to make it so we don't have to check a file.
The only annoyance I see is that there is no "--quiet" option so we
would need to redirect the output. I can look into adding a "quiet"
argument to doVCCommandCall() that would quiet both STDOUT and STDERR if
the attached patch is on the right track.

Scott
From cc80dd9a6f18ac7de0ddc13f7950132fe2e4f3e5 Mon Sep 17 00:00:00 2001
From: Scott Kostyshak 
Date: Fri, 8 Jan 2021 22:37:31 -0500
Subject: [PATCH] Works but does not redirect standard error

---
 src/VCBackend.cpp | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp
index b20a586090..078c59adaa 100644
--- a/src/VCBackend.cpp
+++ b/src/VCBackend.cpp
@@ -39,6 +39,8 @@ using namespace lyx::support;
 
 namespace lyx {
 
+namespace os = support::os;
+
 
 int VCS::doVCCommandCall(string const & cmd, FileName const & path)
 {
@@ -1830,7 +1832,9 @@ bool GIT::findFile(FileName const & file)
 	string const fname = onlyFileName(file.absFileName());
 	LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under git control for `"
 			<< fname << '\'');
-	int const ret = doVCCommandCall("git log -n 0 " + quoteName(fname),
+	int const ret = doVCCommandCall("git ls-files --error-unmatch " +
+			quoteName(fname) + " > " +
+			quoteName(os::nulldev()),
 			file.onlyPath());
 	bool const found = (ret == 0);
 	LYXERR(Debug::LYXVC, "GIT control: " << (found ? "enabled" : "disabled"));
-- 
2.20.1



signature.asc
Description: PGP signature
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2020-12-28 Thread Yuriy Skalko

> I am sorry not to have a time to follow this thoroughly, but is this
> cvs log / git log used only inh "register" case as initially discussed
> or you want to use it on every file load?
> Calling log could but pretty expensive operation for large archives.

The -n0 flag that Yuriy proposed should take care of that, too. So
another reason to go that way.



I understood that. The minor concern was that it can still take seconds to get
the first commit touching particular file in larger git repos if its buried
down in the history.  But maybe it's not that different from git-ls.

My main concern though were changes to CVS - I haven't seen -n0 equivalent and
are you positive that cvs log does not actually try to connect to server (would
make us fail if you are offline)? It's really long time ago I used cvs, but
IIRC each tracked directory has the needed metadata locally at the place
so do we actualy need these changes to fulfil the users-list request?

Sorry for nitpicking, but given that this piece of code is executed at each
document load we better be super careful here...

Pavel


Committed "-n 0" for Git. CVS has "-Q" option 
(https://www.gnu.org/software/trans-coord/manual/cvs/html_node/Global-options.html#Global-options) 
that may help too, but I have no CVS installed, so cannot test this.



Yuriy

--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2020-12-25 Thread Pavel Sanda
On Thu, Dec 24, 2020 at 10:34:40AM -0500, Richard Kimberly Heck wrote:
> > I am sorry not to have a time to follow this thoroughly, but is this
> > cvs log / git log used only inh "register" case as initially discussed
> > or you want to use it on every file load?
> > Calling log could but pretty expensive operation for large archives.
> 
> The -n0 flag that Yuriy proposed should take care of that, too. So
> another reason to go that way.

I understood that. The minor concern was that it can still take seconds to get
the first commit touching particular file in larger git repos if its buried
down in the history.  But maybe it's not that different from git-ls.

My main concern though were changes to CVS - I haven't seen -n0 equivalent and
are you positive that cvs log does not actually try to connect to server (would
make us fail if you are offline)? It's really long time ago I used cvs, but
IIRC each tracked directory has the needed metadata locally at the place
so do we actualy need these changes to fulfil the users-list request?

Sorry for nitpicking, but given that this piece of code is executed at each
document load we better be super careful here...

Pavel
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2020-12-24 Thread Richard Kimberly Heck
On 12/24/20 3:20 AM, Pavel Sanda wrote:
> On Fri, Dec 18, 2020 at 10:13:25PM +0100, Richard Kimberly Heck wrote:
>> commit 7e5c42593e45424676b466db257e5c377329c2e4
>> Author: Richard Kimberly Heck 
>> Date:   Fri Dec 18 16:43:52 2020 -0500
>>
>> Simplify checking whether files are controlled by SVN and GIT.
>> ---
>>  src/VCBackend.cpp |   40 
>>  1 files changed, 12 insertions(+), 28 deletions(-)
>>
>> diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp
>> index f8c2497..01d546d 100644
>> --- a/src/VCBackend.cpp
>> +++ b/src/VCBackend.cpp
>> @@ -537,25 +537,19 @@ CVS::CVS(FileName const & m, Buffer * b) : VCS(b)
>>  
>>  FileName const CVS::findFile(FileName const & file)
>>  {
>> -// First we look for the CVS/Entries in the same dir
>> -// where we have file.
>> +LYXERR(Debug::LYXVC, "LyXVC: Checking if "
>> +   << onlyFileName(file.absFileName()) << "is under cvs");
>> +// First we look for the CVS/Entries in the same dir where we have file.
>>  // Note that it is not necessary to search parent directories, since
>>  // there will be a CVS/Entries file in every subdirectory.
>>  FileName const entries(onlyPath(file.absFileName()) + "/CVS/Entries");
>> -string const tmpf = '/' + onlyFileName(file.absFileName()) + '/';
>> -LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under cvs in `" << 
>> entries
>> - << "' for `" << tmpf << '\'');
>>  if (entries.isReadableFile()) {
>> -// Ok we are at least in a CVS dir. Parse the CVS/Entries
>> -// and see if we can find this file. We do a fast and
>> -// dirty parse here.
>> -ifstream ifs(entries.toFilesystemEncoding().c_str());
>> -string line;
>> -while (getline(ifs, line)) {
>> -LYXERR(Debug::LYXVC, "\tEntries: " << line);
>> -if (contains(line, tmpf))
>> -return entries;
>> -}
>> +// We are in a CVS-managed directory
>> +// See if the file is known to CVS
>> +string const cmd = "cvs log " + 
>> quoteName(file.toFilesystemEncoding());
>> +int const ret = doVCCommandCall(cmd, file.onlyPath());
>> +if (ret == 0)
>> +return entries;
>>  }
>>  return FileName();
>>  }
>> @@ -1837,23 +1831,13 @@ bool GIT::findFile(FileName const & file)
>>  return false;
>>  }
>>  
>> -// Now we check the status of the file.
>> -TempFile tempfile("lyxvcout");
>> -FileName tmpf = tempfile.name();
>> -if (tmpf.empty()) {
>> -LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
>> -return false;
>> -}
>> -
>> +// Now we check if the file is known to git.
>>  string const fname = onlyFileName(file.absFileName());
>>  LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under git control for 
>> `"
>>  << fname << '\'');
>> -doVCCommandCall("git ls-files " +
>> -quoteName(fname) + " > " +
>> -quoteName(tmpf.toFilesystemEncoding()),
>> +int const ret = doVCCommandCall("git log " + quoteName(fname),
>>  file.onlyPath());
>> -tmpf.refresh();
>> -bool found = !tmpf.isFileEmpty();
>> +bool const found = (ret == 0);
>>  LYXERR(Debug::LYXVC, "GIT control: " << (found ? "enabled" : 
>> "disabled"));
>>  return found;
>>  }
> I am sorry not to have a time to follow this thoroughly, but is this
> cvs log / git log used only inh "register" case as initially discussed
> or you want to use it on every file load?
> Calling log could but pretty expensive operation for large archives.

The -n0 flag that Yuriy proposed should take care of that, too. So
another reason to go that way.

Riki


-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2020-12-24 Thread Pavel Sanda
On Fri, Dec 18, 2020 at 10:13:25PM +0100, Richard Kimberly Heck wrote:
> commit 7e5c42593e45424676b466db257e5c377329c2e4
> Author: Richard Kimberly Heck 
> Date:   Fri Dec 18 16:43:52 2020 -0500
> 
> Simplify checking whether files are controlled by SVN and GIT.
> ---
>  src/VCBackend.cpp |   40 
>  1 files changed, 12 insertions(+), 28 deletions(-)
> 
> diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp
> index f8c2497..01d546d 100644
> --- a/src/VCBackend.cpp
> +++ b/src/VCBackend.cpp
> @@ -537,25 +537,19 @@ CVS::CVS(FileName const & m, Buffer * b) : VCS(b)
>  
>  FileName const CVS::findFile(FileName const & file)
>  {
> - // First we look for the CVS/Entries in the same dir
> - // where we have file.
> + LYXERR(Debug::LYXVC, "LyXVC: Checking if "
> +<< onlyFileName(file.absFileName()) << "is under cvs");
> + // First we look for the CVS/Entries in the same dir where we have file.
>   // Note that it is not necessary to search parent directories, since
>   // there will be a CVS/Entries file in every subdirectory.
>   FileName const entries(onlyPath(file.absFileName()) + "/CVS/Entries");
> - string const tmpf = '/' + onlyFileName(file.absFileName()) + '/';
> - LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under cvs in `" << 
> entries
> -  << "' for `" << tmpf << '\'');
>   if (entries.isReadableFile()) {
> - // Ok we are at least in a CVS dir. Parse the CVS/Entries
> - // and see if we can find this file. We do a fast and
> - // dirty parse here.
> - ifstream ifs(entries.toFilesystemEncoding().c_str());
> - string line;
> - while (getline(ifs, line)) {
> - LYXERR(Debug::LYXVC, "\tEntries: " << line);
> - if (contains(line, tmpf))
> - return entries;
> - }
> + // We are in a CVS-managed directory
> + // See if the file is known to CVS
> + string const cmd = "cvs log " + 
> quoteName(file.toFilesystemEncoding());
> + int const ret = doVCCommandCall(cmd, file.onlyPath());
> + if (ret == 0)
> + return entries;
>   }
>   return FileName();
>  }
> @@ -1837,23 +1831,13 @@ bool GIT::findFile(FileName const & file)
>   return false;
>   }
>  
> - // Now we check the status of the file.
> - TempFile tempfile("lyxvcout");
> - FileName tmpf = tempfile.name();
> - if (tmpf.empty()) {
> - LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
> - return false;
> - }
> -
> + // Now we check if the file is known to git.
>   string const fname = onlyFileName(file.absFileName());
>   LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under git control for 
> `"
>   << fname << '\'');
> - doVCCommandCall("git ls-files " +
> - quoteName(fname) + " > " +
> - quoteName(tmpf.toFilesystemEncoding()),
> + int const ret = doVCCommandCall("git log " + quoteName(fname),
>   file.onlyPath());
> - tmpf.refresh();
> - bool found = !tmpf.isFileEmpty();
> + bool const found = (ret == 0);
>   LYXERR(Debug::LYXVC, "GIT control: " << (found ? "enabled" : 
> "disabled"));
>   return found;
>  }

I am sorry not to have a time to follow this thoroughly, but is this
cvs log / git log used only inh "register" case as initially discussed
or you want to use it on every file load?
Calling log could but pretty expensive operation for large archives.

Pavel
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2020-12-23 Thread Scott Kostyshak
On Wed, Dec 23, 2020 at 12:46:01PM -0500, Richard Kimberly Heck wrote:
> On 12/23/20 2:47 AM, Yuriy Skalko wrote:
> > > I think starting with this commit I now get a lot of Git output. For
> > > example:
> > > 
> > > ...
> > > 
> > > Another question is: is it possible to avoid these commands for
> > > command-line export? I'm guessing it would be too complicated.
> > > 
> > > Scott
> > 
> > Passing "-n 0" option to git should help, try the attached patch.
> 
> Yes, sorry. I meant to do something like that after testing. We may need a
> '-q' or something in other cases, too.

Looks good to me, Yuriy. I did not test it, but I suggest to commit it
(or Riki's suggestion if there is a quiet option) if you tested.

Thanks!
Scott


signature.asc
Description: PGP signature
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2020-12-23 Thread Richard Kimberly Heck

On 12/23/20 2:47 AM, Yuriy Skalko wrote:
I think starting with this commit I now get a lot of Git output. For 
example:


...

Another question is: is it possible to avoid these commands for 
command-line export? I'm guessing it would be too complicated.


Scott


Passing "-n 0" option to git should help, try the attached patch.


Yes, sorry. I meant to do something like that after testing. We may need 
a '-q' or something in other cases, too.


Riki


--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2020-12-22 Thread Yuriy Skalko

I think starting with this commit I now get a lot of Git output. For example:

...

Another question is: is it possible to avoid these commands for command-line 
export? I'm guessing it would be too complicated.


Scott


Passing "-n 0" option to git should help, try the attached patch.

Yuriy
diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp
index 48cb618e74..b20a586090 100644
--- a/src/VCBackend.cpp
+++ b/src/VCBackend.cpp
@@ -1830,7 +1830,7 @@ bool GIT::findFile(FileName const & file)
string const fname = onlyFileName(file.absFileName());
LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under git control for 
`"
<< fname << '\'');
-   int const ret = doVCCommandCall("git log " + quoteName(fname),
+   int const ret = doVCCommandCall("git log -n 0 " + quoteName(fname),
file.onlyPath());
bool const found = (ret == 0);
LYXERR(Debug::LYXVC, "GIT control: " << (found ? "enabled" : 
"disabled"));
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Simplify checking whether files are controlled by SVN and GIT.

2020-12-22 Thread Scott Kostyshak
On Fri, Dec 18, 2020 at 10:13:25PM +0100, Richard Kimberly Heck wrote:
> commit 7e5c42593e45424676b466db257e5c377329c2e4
> Author: Richard Kimberly Heck 
> Date:   Fri Dec 18 16:43:52 2020 -0500
> 
> Simplify checking whether files are controlled by SVN and GIT.
> ---

I think starting with this commit I now get a lot of Git output. For example:

  $ lyx -e pdf2 lib/examples/Welcome.lyx 
  commit 4a2f4fb1d63ae6d7cd96012c375753aa146a815b
  Author: Günter Milde 
  Date:   Wed Mar 27 16:24:14 2019 +0100
  
  Use LaTeX input encoding "utf8", part 1/many.
  
  See #5.
  Start with simple cases.
  
  commit 2860266e308e919efcf0df5d2a76e268ef3569ba
  Author: Juergen Spitzmueller 
  Date:   Mon Mar 25 16:32:27 2019 +0100
  
  remove buildlyxdir again
  
  per request
  
  commit aed6755f59b3321d929e9d7a4c8f5af0a4a7a02d
  Author: Juergen Spitzmueller 
  Date:   Sun Mar 24 17:33:10 2019 +0100
  
  Update \origin specifications
  
  commit d3ec77c633852516677ad97d40e3de66effcb735
  Author: Juergen Spitzmueller 
  Date:   Tue Mar 19 07:07:22 2019 +0100
  
  Reorganize templates and example folders
  
  Re-structure and rename files in a transparent way. Most template/example
  names now correspond to the (verbose GUI) name of their layouts.
  
  Note that this, most prominently, also changes [LANG/]splash.lyx to
  something less insiderish, namely "Welcome.lyx".
  This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded 
format=pdflatex)
   restricted \write18 enabled.
  entering extended mode
  (./Welcome.tex
  LaTeX2e <2017-04-15>
  Babel <3.13> and hyphenation patterns for 84 language(s) loaded.
  
  This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded 
format=pdflatex)
   restricted \write18 enabled.
  entering extended mode
  (./Welcome.tex
  LaTeX2e <2017-04-15>
  Babel <3.13> and hyphenation patterns for 84 language(s) loaded.
  $


Another question is: is it possible to avoid these commands for command-line 
export? I'm guessing it would be too complicated.

Scott


signature.asc
Description: PGP signature
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel