diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp index 01743ecadb..449e24d1a8 100644 --- a/src/LyXVC.cpp +++ b/src/LyXVC.cpp @@ -50,20 +50,17 @@ bool LyXVC::file_found_hook(FileName const & fn) FileName found_file; // Check if file is under RCS if (!(found_file = RCS::findFile(fn)).empty()) { - vcs.reset(new RCS(found_file)); - vcs->owner(owner_); + vcs.reset(new RCS(found_file, owner_)); return true; } // Check if file is under CVS if (!(found_file = CVS::findFile(fn)).empty()) { - vcs.reset(new CVS(found_file, fn)); - vcs->owner(owner_); + vcs.reset(new CVS(found_file, owner_)); return true; } // Check if file is under SVN if (!(found_file = SVN::findFile(fn)).empty()) { - vcs.reset(new SVN(found_file, fn)); - vcs->owner(owner_); + vcs.reset(new SVN(found_file, owner_)); return true; } @@ -127,20 +124,18 @@ bool LyXVC::registrer() if (svn_entries.isReadableFile()) { LYXERR(Debug::LYXVC, "LyXVC: registering " << to_utf8(filename.displayName()) << " with SVN"); - vcs.reset(new SVN(cvs_entries, filename)); + vcs.reset(new SVN(cvs_entries, owner_)); } else if (cvs_entries.isReadableFile()) { LYXERR(Debug::LYXVC, "LyXVC: registering " << to_utf8(filename.displayName()) << " with CVS"); - vcs.reset(new CVS(cvs_entries, filename)); + vcs.reset(new CVS(cvs_entries, owner_)); } else { LYXERR(Debug::LYXVC, "LyXVC: registering " << to_utf8(filename.displayName()) << " with RCS"); - vcs.reset(new RCS(FileName())); + vcs.reset(new RCS(FileName(), owner_)); } - - vcs->owner(owner_); } LYXERR(Debug::LYXVC, "LyXVC: registrer"); diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index bd468d86a7..31a8eb32e5 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -122,7 +122,7 @@ bool VCS::checkparentdirs(FileName const & file, std::string const & pathname) // ///////////////////////////////////////////////////////////////////// -RCS::RCS(FileName const & m) +RCS::RCS(FileName const & m, Buffer * b) : VCS(b) { master_ = m; scanMaster(); @@ -472,10 +472,9 @@ bool RCS::prepareFileRevisionEnabled() // ///////////////////////////////////////////////////////////////////// -CVS::CVS(FileName const & m, FileName const & f) +CVS::CVS(FileName const & m, Buffer * b) : VCS(b) { master_ = m; - file_ = f; have_rev_info_ = false; scanMaster(); } @@ -510,7 +509,7 @@ void CVS::scanMaster() LYXERR(Debug::LYXVC, "LyXVC::CVS: scanMaster. \n Checking: " << master_); // Ok now we do the real scan... ifstream ifs(master_.toFilesystemEncoding().c_str()); - string name = onlyFileName(file_.absFileName()); + string name = onlyFileName(owner_->absFileName()); string tmpf = '/' + name + '/'; LYXERR(Debug::LYXVC, "\tlooking for `" << tmpf << '\''); string line; @@ -530,12 +529,13 @@ void CVS::scanMaster() //sm[4]; // options //sm[5]; // tag or tagdate - if (file_.isReadableFile()) { - time_t mod = file_.lastModified(); + FileName file(owner_->absFileName()); + if (file.isReadableFile()) { + time_t mod = file.lastModified(); string mod_date = rtrim(asctime(gmtime(&mod)), "\n"); LYXERR(Debug::LYXVC, "Date in Entries: `" << file_date << "'\nModification date of file: `" << mod_date << '\''); - if (file_.isReadOnly()) { + if (file.isReadOnly()) { // readonly checkout is unlocked vcstatus = UNLOCKED; } else { @@ -1044,11 +1044,9 @@ bool CVS::prepareFileRevisionEnabled() // ///////////////////////////////////////////////////////////////////// -SVN::SVN(FileName const & m, FileName const & f) +SVN::SVN(FileName const & m, Buffer * b) : VCS(b) { - owner_ = 0; master_ = m; - file_ = f; locked_mode_ = 0; scanMaster(); } @@ -1103,9 +1101,9 @@ bool SVN::checkLockMode() } LYXERR(Debug::LYXVC, "Detecting locking mode..."); - if (doVCCommandCall("svn proplist " + quoteName(file_.onlyFileName()) + if (doVCCommandCall("svn proplist " + quoteName(onlyFileName(owner_->absFileName())) + " > " + quoteName(tmpf.toFilesystemEncoding()), - file_.onlyPath())) + FileName(owner_->filePath()))) return false; ifstream ifs(tmpf.toFilesystemEncoding().c_str()); @@ -1128,8 +1126,9 @@ bool SVN::checkLockMode() bool SVN::isLocked() const { - file_.refresh(); - return !file_.isReadOnly(); + FileName file(owner_->absFileName()); + file.refresh(); + return !file.isReadOnly(); } diff --git a/src/VCBackend.h b/src/VCBackend.h index abffaec044..6f81208be1 100644 --- a/src/VCBackend.h +++ b/src/VCBackend.h @@ -34,6 +34,7 @@ public: NOLOCKING }; + VCS(Buffer * b) : owner_(b) {} virtual ~VCS() {} /// register a file for version control @@ -71,8 +72,6 @@ public: virtual void getLog(support::FileName const &) = 0; /// return the current version description virtual std::string const versionString() const = 0; - /// set the owning buffer - void owner(Buffer * b) { owner_ = b; } /// return the owning buffer Buffer * owner() const { return owner_; } /// return the lock status of this file @@ -119,7 +118,7 @@ protected: VCStatus vcstatus; /// The buffer using this VC - Buffer * owner_; + Buffer * const owner_; }; @@ -128,7 +127,7 @@ class RCS : public VCS { public: explicit - RCS(support::FileName const & m); + RCS(support::FileName const & m, Buffer * b); /// return the revision file for the given file, if found static support::FileName const findFile(support::FileName const & file); @@ -202,7 +201,7 @@ class CVS : public VCS { public: /// explicit - CVS(support::FileName const & m, support::FileName const & f); + CVS(support::FileName const & m, Buffer * b); /// return the revision file for the given file, if found static support::FileName const findFile(support::FileName const & file); @@ -272,7 +271,6 @@ protected: }; private: - support::FileName file_; // revision number from scanMaster std::string version_; @@ -330,7 +328,7 @@ class SVN : public VCS { public: /// explicit - SVN(support::FileName const & m, support::FileName const & f); + SVN(support::FileName const & m, Buffer * b); /// return the revision file for the given file, if found static support::FileName const findFile(support::FileName const & file); @@ -389,7 +387,6 @@ protected: void fileLock(bool lock, support::FileName const & tmpf, std::string & status); private: - support::FileName file_; /// is the loaded file under locking policy? bool locked_mode_; /**