]> git.lyx.org Git - features.git/commitdiff
scanLog for checkout svn in VCS.
authorPavel Sanda <sanda@lyx.org>
Tue, 22 Jul 2008 10:16:54 +0000 (10:16 +0000)
committerPavel Sanda <sanda@lyx.org>
Tue, 22 Jul 2008 10:16:54 +0000 (10:16 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25795 a592a061-630c-0410-9148-cb99ea01b6c8

src/VCBackend.cpp
src/VCBackend.h

index bacad51916b2499fe90c7cf01de65981f369ffa8..ff722f0d1976e86c6dfc0ba7e571105368ba0eb3 100644 (file)
@@ -461,11 +461,45 @@ bool SVN::checkInEnabled()
        return true;
 }
 
+// FIXME Correctly return code should be checked instead of this.
+// This would need another solution than just plain startscript.
+string SVN::scanLogFile(FileName const & f)
+{
+       ifstream ifs(f.toFilesystemEncoding().c_str());
+       string line;
+
+       while (ifs){
+               getline(ifs,line);
+               lyxerr<<line<<"\n";
+               if (prefixIs(line, "C "))
+                       return line;
+               if (contains(line, "Commit failed"))
+                       return line;
+       }
+       return string();
+}
+
 
 void SVN::checkOut()
 {
-       doVCCommand("svn update " + quoteName(onlyFilename(owner_->absFileName())),
+       FileName tmpf = FileName::tempName("lyxvcout");
+       if (tmpf.empty()){
+               LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
+               return;
+       }
+
+       doVCCommand("svn update " + quoteName(onlyFilename(owner_->absFileName()))
+                   + " > " + tmpf.toFilesystemEncoding(),
                    FileName(owner_->filePath()));
+
+       string res = scanLogFile(tmpf);
+       if (!res.empty())
+               frontend::Alert::error(_("Revision control error."),
+                       bformat(_("Error when updating from repository.\n"
+                               "You have to manually resolve the conflicts NOW!\n'%1$s'.\n\n"
+                               "After pressing OK, LyX will try to reopen resolved document."),
+                       from_ascii(res)));
+       tmpf.erase();
 }
 
 
index d44bb045f99fbfd2e6ce1c31536578c19efef462..1b663e8b9bec9eebbb1c771afb7a14479bedb00f 100644 (file)
@@ -221,6 +221,8 @@ public:
 
 protected:
        virtual void scanMaster();
+       /// Check for error messages in svn output.
+       std::string scanLogFile(support::FileName const & f);
 
 private:
        support::FileName file_;