]> git.lyx.org Git - features.git/commitdiff
Remove unused return values and useless member assignment.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Fri, 18 Dec 2020 21:23:31 +0000 (16:23 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Fri, 18 Dec 2020 21:27:57 +0000 (16:27 -0500)
The master_ variable holds a FileName that points to the meta-data
for this file, e.g., CVS/Entries. There is no such thing in SVN or GIT.
So we remove that variable from those classes.

src/LyXVC.cpp
src/VCBackend.cpp
src/VCBackend.h

index 8d0255fb6e3ec4c45813eadeb08e123d6510b707..1e6cb121536f562cbb288dd6f3c2272d059acedd 100644 (file)
@@ -58,9 +58,9 @@ bool LyXVC::fileInVC(FileName const & fn)
                return true;
        if (!CVS::findFile(fn).empty())
                return true;
-       if (!SVN::findFile(fn).empty())
+       if (SVN::findFile(fn))
                return true;
-       if (!GIT::findFile(fn).empty())
+       if (GIT::findFile(fn))
                return true;
        return false;
 }
@@ -80,13 +80,13 @@ bool LyXVC::file_found_hook(FileName const & fn)
                return true;
        }
        // Check if file is under SVN
-       if (!(found_file = SVN::findFile(fn)).empty()) {
-               vcs_.reset(new SVN(found_file, owner_));
+       if (SVN::findFile(fn)) {
+               vcs_.reset(new SVN(owner_));
                return true;
        }
        // Check if file is under GIT
-       if (!(found_file = GIT::findFile(fn)).empty()) {
-               vcs_.reset(new GIT(found_file, owner_));
+       if (GIT::findFile(fn)) {
+               vcs_.reset(new GIT(owner_));
                return true;
        }
 
@@ -104,8 +104,8 @@ bool LyXVC::file_not_found_hook(FileName const & fn)
        // checked out.
        bool foundRCS = !RCS::findFile(fn).empty();
        bool foundCVS = foundRCS ? false : !CVS::findFile(fn).empty();
-       bool foundSVN = (foundRCS || foundCVS) ? false : !SVN::findFile(fn).empty();
-       bool foundGIT = (foundRCS || foundCVS || foundSVN) ? false : !GIT::findFile(fn).empty();
+       bool foundSVN = (foundRCS || foundCVS) ? false : SVN::findFile(fn);
+       bool foundGIT = (foundRCS || foundCVS || foundSVN) ? false : GIT::findFile(fn);
        if (foundRCS || foundCVS || foundSVN || foundGIT) {
                docstring const file = makeDisplayPath(fn.absFileName(), 20);
                docstring const text =
@@ -159,14 +159,14 @@ bool LyXVC::registrer()
                if (!found.empty()) {
                        LYXERR(Debug::LYXVC, "LyXVC: registering "
                                << to_utf8(filename.displayName()) << " with GIT");
-                       vcs_.reset(new GIT(found, owner_));
+                       vcs_.reset(new GIT(owner_));
 
                } else {
                        found = VCS::checkParentDirs(filename, ".svn/entries");
                        if (!found.empty()) {
                                LYXERR(Debug::LYXVC, "LyXVC: registering "
                                        << to_utf8(filename.displayName()) << " with SVN");
-                               vcs_.reset(new SVN(found, owner_));
+                               vcs_.reset(new SVN(owner_));
 
                        } else {
                                // We only need to check the current directory, since CVS meta-data
index d242a21e499d557eb696be7c83c5477a619750ef..f8c24975d85c5975c7bdc236753e896a4cfb4da9 100644 (file)
@@ -1157,22 +1157,21 @@ bool CVS::prepareFileRevisionEnabled()
 //
 /////////////////////////////////////////////////////////////////////
 
-SVN::SVN(FileName const & m, Buffer * b) : VCS(b)
+SVN::SVN(Buffer * b) : VCS(b)
 {
        // Here we know that the buffer file is either already in SVN or
        // about to be registered
-       master_ = m;
        locked_mode_ = false;
        scanMaster();
 }
 
 
-FileName const SVN::findFile(FileName const & file)
+bool SVN::findFile(FileName const & file)
 {
        // First we check the existence of repository meta data.
        if (VCS::checkParentDirs(file, ".svn").empty()) {
                LYXERR(Debug::LYXVC, "Cannot find SVN meta data for " << file);
-               return FileName();
+               return false;
        }
 
        // Now we check the status of the file.
@@ -1181,7 +1180,7 @@ FileName const SVN::findFile(FileName const & file)
        bool found = 0 == doVCCommandCall("svn info " + quoteName(fname),
                                                file.onlyPath());
        LYXERR(Debug::LYXVC, "SVN control: " << (found ? "enabled" : "disabled"));
-       return found ? file : FileName();
+       return found;
 }
 
 
@@ -1822,21 +1821,20 @@ bool SVN::toggleReadOnlyEnabled()
 //
 /////////////////////////////////////////////////////////////////////
 
-GIT::GIT(FileName const & m, Buffer * b) : VCS(b)
+GIT::GIT(Buffer * b) : VCS(b)
 {
        // Here we know that the buffer file is either already in GIT or
        // about to be registered
-       master_ = m;
        scanMaster();
 }
 
 
-FileName const GIT::findFile(FileName const & file)
+bool GIT::findFile(FileName const & file)
 {
        // First we check the existence of repository meta data.
        if (VCS::checkParentDirs(file, ".git").empty()) {
                LYXERR(Debug::LYXVC, "Cannot find GIT meta data for " << file);
-               return FileName();
+               return false;
        }
 
        // Now we check the status of the file.
@@ -1844,7 +1842,7 @@ FileName const GIT::findFile(FileName const & file)
        FileName tmpf = tempfile.name();
        if (tmpf.empty()) {
                LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
-               return FileName();
+               return false;
        }
 
        string const fname = onlyFileName(file.absFileName());
@@ -1857,7 +1855,7 @@ FileName const GIT::findFile(FileName const & file)
        tmpf.refresh();
        bool found = !tmpf.isFileEmpty();
        LYXERR(Debug::LYXVC, "GIT control: " << (found ? "enabled" : "disabled"));
-       return found ? file : FileName();
+       return found;
 }
 
 
index b3f4e14ff144797ca888f7b62a9b066645624e5e..ed4201a0838f2345e0eafaebbc3b06131a38c18c 100644 (file)
@@ -131,12 +131,6 @@ protected:
         */
        static int doVCCommandCall(std::string const & cmd, support::FileName const & path);
 
-       /**
-        * The master VC file. For RCS this is *,v or RCS/ *,v. master should
-        * have full path.
-        */
-       support::FileName master_;
-
        /// The status of the VC controlled file.
        VCStatus vcstatus_;
 
@@ -216,6 +210,12 @@ protected:
        void scanMaster() override;
 private:
        bool getRevisionInfo();
+       /**
+        * The master VC file. For RCS this is *,v or RCS/ *,v.
+        * master should have full path.
+        */
+       support::FileName master_;
+
        /**
         * The version of the VC file. I am not sure if this can be a
         * string or if it must be a float/int.
@@ -322,6 +322,11 @@ protected:
        };
 
 private:
+       /**
+        * The master VC file. For CVS this is CVS/Entries
+        * master should have full path.
+        */
+       support::FileName master_;
        // revision number from scanMaster
        std::string version_;
 
@@ -379,11 +384,10 @@ class SVN : public VCS {
 public:
        ///
        explicit
-       SVN(support::FileName const & m, Buffer * b);
+       SVN(Buffer * b);
 
        /// Determine whether the file is under SVN control
-       /// \return the file itself if so, else empty
-       static support::FileName const findFile(support::FileName const & file);
+       static bool findFile(support::FileName const & file);
 
        /// get file from repo, the caller must ensure that it does not exist locally
        static bool retrieve(support::FileName const & file);
@@ -490,11 +494,11 @@ class GIT : public VCS {
 public:
        ///
        explicit
-       GIT(support::FileName const & m, Buffer * b);
+       GIT(Buffer * b);
 
        /// Determine whether the file is under GIT control
        /// \return the file itself if so, else empty
-       static support::FileName const findFile(support::FileName const & file);
+       static bool findFile(support::FileName const & file);
 
        /// get file from repo, the caller must ensure that it does not exist locally
        static bool retrieve(support::FileName const & file);