]> git.lyx.org Git - features.git/commitdiff
SVN file revision number
authorPavel Sanda <sanda@lyx.org>
Fri, 12 Feb 2010 01:43:55 +0000 (01:43 +0000)
committerPavel Sanda <sanda@lyx.org>
Fri, 12 Feb 2010 01:43:55 +0000 (01:43 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33424 a592a061-630c-0410-9148-cb99ea01b6c8

src/VCBackend.cpp
src/VCBackend.h

index 56d4c3f9f6872116c83ec0326d4f6aaa8b388584..bf439b85a3d76575d3ab75e35adab328a4999c33 100644 (file)
@@ -844,6 +844,40 @@ bool SVN::undoLastEnabled()
 }
 
 
+string SVN::getFileRevisionInfo(){
+       FileName tmpf = FileName::tempName("lyxvcout");
+
+       doVCCommand("svn info --xml " + quoteName(onlyFilename(owner_->absFileName()))
+                   + " > " + quoteName(tmpf.toFilesystemEncoding()),
+                   FileName(owner_->filePath()));
+
+       if (tmpf.empty())
+               return string();
+
+       ifstream ifs(tmpf.toFilesystemEncoding().c_str());
+       string line;
+       // commit log part
+       bool c = false;
+       string rev;
+
+       while (ifs) {
+               getline(ifs, line);
+               LYXERR(Debug::LYXVC, line);
+               if (prefixIs(line, "<commit"))
+                       c = true;
+               if (c && prefixIs(line, "   revision=\"") && suffixIs(line, "\">")) {
+                       string l1 = subst(line, "revision=\"", "");
+                       string l2 = subst(l1, "\">", "");
+                       if (isStrInt(l2))
+                               rev = l2;
+               }
+       }
+       ifs.close();
+       tmpf.erase();
+       return rev;
+}
+
+
 void SVN::getLog(FileName const & tmpf)
 {
        doVCCommand("svn log " + quoteName(onlyFilename(owner_->absFileName()))
index dbcd84ca8151016dd84db7f979f94a7ca5f8952e..5f5f0f77d9713dd508c1ecee5d46f196387b1071 100644 (file)
@@ -254,6 +254,8 @@ public:
 
        virtual bool toggleReadOnlyEnabled();
 
+       std::string getFileRevisionInfo();
+
 protected:
        virtual void scanMaster();
        /// Check for messages in svn output. Returns error.