]> git.lyx.org Git - lyx.git/blobdiff - src/lyxvc.C
minimal effort implementation of:
[lyx.git] / src / lyxvc.C
index b4dae54556863c0f6b2f3f09777dbe6c71a4855c..d05c292f7a20aab3b0859d0836ae6031c198e2f4 100644 (file)
@@ -27,8 +27,8 @@
 #include "support/lyxlib.h"
 
 using lyx::support::bformat;
-using lyx::support::IsFileReadable;
-using lyx::support::MakeDisplayPath;
+using lyx::support::isFileReadable;
+using lyx::support::makeDisplayPath;
 using lyx::support::tempName;
 
 using std::endl;
@@ -38,15 +38,13 @@ using std::pair;
 
 LyXVC::LyXVC()
 {
-       vcs = 0;
        owner_ = 0;
 }
 
 
+// for the sake of boost::scoped_ptr
 LyXVC::~LyXVC()
-{
-       delete vcs;
-}
+{}
 
 
 bool LyXVC::file_found_hook(string const & fn)
@@ -54,13 +52,13 @@ bool LyXVC::file_found_hook(string const & fn)
        string found_file;
        // Check if file is under RCS
        if (!(found_file = RCS::find_file(fn)).empty()) {
-               vcs = new RCS(found_file);
+               vcs.reset(new RCS(found_file));
                vcs->owner(owner_);
                return true;
        }
        // Check if file is under CVS
        if (!(found_file = CVS::find_file(fn)).empty()) {
-               vcs = new CVS(found_file, fn);
+               vcs.reset(new CVS(found_file, fn));
                vcs->owner(owner_);
                return true;
        }
@@ -91,7 +89,7 @@ void LyXVC::registrer()
        string const filename = owner_->fileName();
 
        // there must be a file to save
-       if (!IsFileReadable(filename)) {
+       if (!isFileReadable(filename)) {
                Alert::error(_("Document not saved"),
                             _("You must save the document "
                               "before it can be registered."));
@@ -102,19 +100,19 @@ void LyXVC::registrer()
        if (!vcs) {
                string const cvs_entries = "CVS/Entries";
 
-               if (IsFileReadable(cvs_entries)) {
+               if (isFileReadable(cvs_entries)) {
                        lyxerr[Debug::LYXVC]
                                << "LyXVC: registering "
-                               << MakeDisplayPath(filename)
+                               << makeDisplayPath(filename)
                                << " with CVS" << endl;
-                       vcs = new CVS(cvs_entries, filename);
+                       vcs.reset(new CVS(cvs_entries, filename));
 
                } else {
                        lyxerr[Debug::LYXVC]
                                << "LyXVC: registering "
-                               << MakeDisplayPath(filename)
+                               << makeDisplayPath(filename)
                                << " with RCS" << endl;
-                       vcs = new RCS(filename);
+                       vcs.reset(new RCS(filename));
                }
 
                vcs->owner(owner_);
@@ -162,7 +160,7 @@ void LyXVC::revert()
 {
        lyxerr[Debug::LYXVC] << "LyXVC: revert" << endl;
 
-       string const file = MakeDisplayPath(owner_->fileName(), 20);
+       string const file = makeDisplayPath(owner_->fileName(), 20);
        string text = bformat(_("Reverting to the stored version of the "
                "document %1$s will lose all current changes.\n\n"
                "Do you want to revert to the saved version?"), file);
@@ -225,6 +223,11 @@ string const LyXVC::getLogFile() const
                return string();
 
        string tmpf = tempName(string(), "lyxvclog");
+       if (tmpf.empty()) {
+               lyxerr[Debug::LYXVC] << "Could not generate logfile "
+                                    << tmpf << endl;
+               return string();
+       }
        lyxerr[Debug::LYXVC] << "Generating logfile " << tmpf << endl;
        vcs->getLog(tmpf);
        return tmpf;