The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit 22b7ad2b0a6c228f234bcf7f5a0b164fca17e122
Author: Georg Baum <[email protected]>
Date:   Thu Feb 7 22:07:22 2013 +0100

    Implement revision info for git

diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp
index a6ce1c3..599e331 100644
--- a/src/VCBackend.cpp
+++ b/src/VCBackend.cpp
@@ -2112,12 +2112,99 @@ bool GIT::undoLastEnabled()
 }
 
 
-string GIT::revisionInfo(LyXVC::RevisionInfo const /*info*/)
+string GIT::revisionInfo(LyXVC::RevisionInfo const info)
 {
+       if (info == LyXVC::Tree) {
+               if (rev_tree_cache_.empty())
+                       if (!getTreeRevisionInfo())
+                               rev_tree_cache_ = "?";
+               if (rev_tree_cache_ == "?")
+                       return string();
+
+               return rev_tree_cache_;
+       }
+
+       // fill the rest of the attributes for a single file
+       if (rev_file_cache_.empty())
+               if (!getFileRevisionInfo())
+                       rev_file_cache_ = "?";
+
+       switch (info) {
+               case LyXVC::File:
+                       if (rev_file_cache_ == "?")
+                               return string();
+                       return rev_file_cache_;
+               case LyXVC::Author:
+                       return rev_author_cache_;
+               case LyXVC::Date:
+                       return rev_date_cache_;
+               case LyXVC::Time:
+                       return rev_time_cache_;
+               default: ;
+
+       }
+
        return string();
 }
 
 
+bool GIT::getFileRevisionInfo()
+{
+       FileName tmpf = FileName::tempName("lyxvcout");
+       if (tmpf.empty()) {
+               LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
+               return false;
+       }
+
+       doVCCommand("git log -n 1 --pretty=format:%H%n%an%n%ai " + 
quoteName(onlyFileName(owner_->absFileName()))
+                   + " > " + quoteName(tmpf.toFilesystemEncoding()),
+                   FileName(owner_->filePath()));
+
+       if (tmpf.empty())
+               return false;
+
+       ifstream ifs(tmpf.toFilesystemEncoding().c_str());
+
+       if (ifs)
+               getline(ifs, rev_file_cache_);
+       if (ifs)
+               getline(ifs, rev_author_cache_);
+       if (ifs) {
+               string line;
+               getline(ifs, line);
+               rev_time_cache_ = split(line, rev_date_cache_, ' ');
+       }
+
+       ifs.close();
+       tmpf.removeFile();
+       return !rev_file_cache_.empty();
+}
+
+
+bool GIT::getTreeRevisionInfo()
+{
+       FileName tmpf = FileName::tempName("lyxvcout");
+       if (tmpf.empty()) {
+               LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
+               return false;
+       }
+
+       doVCCommand("git log -n 1 --pretty=format:%H . > " + 
quoteName(tmpf.toFilesystemEncoding()),
+                   FileName(owner_->filePath()));
+
+       if (tmpf.empty())
+               return false;
+
+       // only first line in case something bad happens.
+       ifstream ifs(tmpf.toFilesystemEncoding().c_str());
+       getline(ifs, rev_tree_cache_);
+       ifs.close();
+       tmpf.removeFile();
+
+       return !rev_tree_cache_.empty();
+}
+
+
 void GIT::getLog(FileName const & tmpf)
 {
        doVCCommand("git log " + quoteName(onlyFileName(owner_->absFileName()))
diff --git a/src/VCBackend.h b/src/VCBackend.h
index 6d3903c..ab7f52f 100644
--- a/src/VCBackend.h
+++ b/src/VCBackend.h
@@ -542,6 +542,27 @@ protected:
        /// Check in files \p f with log \p msg
        LyXVC::CommandResult checkIn(std::vector<support::FileName> const & f,
                                     std::string const & msg, std::string & 
log);
+
+private:
+       /**
+        * Real code for obtaining file revision info. Fills all file-related 
caches
+        * and returns true if successfull.
+        * "?" is stored in rev_file_cache_ as a signal if request for 
obtaining info
+        * was already unsuccessful.
+        */
+       bool getFileRevisionInfo();
+       /// cache for file revision number, "?" if already unsuccessful, 
isNumber==true
+       std::string rev_file_cache_;
+       /// cache for author of last commit
+       std::string rev_author_cache_;
+       /// cache for date of last commit
+       std::string rev_date_cache_;
+       /// cache for time of last commit
+       std::string rev_time_cache_;
+       /// fills rev_tree_cache_, returns true if successfull.
+       bool getTreeRevisionInfo();
+       /// cache for tree revision number, "?" if already unsuccessful
+       std::string rev_tree_cache_;
 };
 
 } // namespace lyx

commit 5a62a1ccb8ca0b41bd48ea63274a5b9e22f7653e
Author: Georg Baum <[email protected]>
Date:   Thu Feb 7 21:24:32 2013 +0100

    Describe GIT support

diff --git a/lib/doc/Additional.lyx b/lib/doc/Additional.lyx
index 3bfa4e6..ec8e87b 100644
--- a/lib/doc/Additional.lyx
+++ b/lib/doc/Additional.lyx
@@ -18915,7 +18915,7 @@ Introduction
 \end_layout
 
 \begin_layout Standard
-LyX supports some of the most basic RCS/CVS/SVN commands.
+LyX supports some of the most basic RCS/CVS/SVN/GIT commands.
  If you need something a bit more sophisticated you will have to do that
  manually in a terminal.
 \end_layout
@@ -18964,7 +18964,7 @@ man rcsintro
 
 \begin_layout Standard
 Before you begin to use the version control features in LyX, you should
- be familiar with RCS/CVS/SVN usage.
+ be familiar with RCS/CVS/SVN/GIT usage.
  The implementation in LyX assumes a recent version of the GNU RCS or CVS/SVN
  package — no guarantees are made for older versions.
  Most of the log messages are not currently displayed after operations —
@@ -21563,6 +21563,287 @@ svn propset svn:eol-style native FILE_NAME
 \end_layout
 
 \begin_layout Subsection
+GIT commands in LyX
+\end_layout
+
+\begin_layout Standard
+A minimal subset of GIT commands is now supported by LyX.
+ You can find the commands in the 
+\family sans
+File\SpecialChar \menuseparator
+Version
+\begin_inset space ~
+\end_inset
+
+Control
+\family default
+ submenu.
+ Please note that if you use password protected access to repository via
+ ssh, you will be asked in terminal window.
+ LyX was tested against GIT 1.7.
+\end_layout
+
+\begin_layout Standard
+One big difference of GIT and the other supported version control systems
+ is the distributed nature of GIT: With traditional version control systems
+ there is one central server which hosts the repository.
+ Users commit their changes to the server, and get updates made by other
+ users from it.
+ With GIT, users commit to a local repository.
+ The local repository can be synchronized with one or more remote repositories
+ using the 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+pull
+\end_layout
+
+\end_inset
+
+ and 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+push
+\end_layout
+
+\end_inset
+
+ GIT commands.
+ LyX does not interact in any way with remote GIT repositories.
+ It works exclusively with the local repository in a very similar way as
+ with a central CVS or SVN repository.
+ If you use remote GIT repositories you need to do the 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+pull
+\end_layout
+
+\end_inset
+
+ and 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+push
+\end_layout
+
+\end_inset
+
+ operations with your favourite GIT client.
+\end_layout
+
+\begin_layout Subsubsection
+
+\family sans
+Register
+\end_layout
+
+\begin_layout Standard
+If your document is not under revision control, this is the only item shown
+ in the menu.
+ And if it is under revision control, the 
+\family sans
+\bar under
+R
+\bar default
+egister
+\family default
+ item is not visible.
+\end_layout
+
+\begin_layout Standard
+This command registers in GIT your document ONLY in case you have already
+ the documents directory under GIT control (in particular 
+\family typewriter
+.git/index
+\family default
+ file exists).
+ This means you have to checkout the archive by yourself.
+\end_layout
+
+\begin_layout Standard
+Then you are asked interactively to supply an initial description of the
+ document.
+ Don't forget that registered file is not yet commited.
+\end_layout
+
+\begin_layout Standard
+GIT command that is run: 
+\family typewriter
+git add 
+\begin_inset Quotes eld
+\end_inset
+
+<file-name>
+\begin_inset Quotes erd
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Read 
+\family typewriter
+man git
+\family default
+ to understand the switches.
+\end_layout
+
+\begin_layout Subsubsection
+
+\family sans
+Check In Changes
+\end_layout
+
+\begin_layout Standard
+When you are finished editing a file, you commit your changes.
+ When you do this, you are asked for a description of the changes.
+ After that changes are commited.
+\end_layout
+
+\begin_layout Standard
+GIT command: 
+\family typewriter
+git commit -q -m"<description>" <file-name>
+\end_layout
+
+\begin_layout Subsubsection
+
+\family sans
+Revert To Repository Version
+\end_layout
+
+\begin_layout Standard
+This will discard all changes made to the document since the last check
+ in.
+ You get a warning before changes are discarded.
+\end_layout
+
+\begin_layout Standard
+GIT command: 
+\family typewriter
+git checkout -q 
+\begin_inset Quotes eld
+\end_inset
+
+<file-name>
+\begin_inset Quotes erd
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsubsection
+
+\family sans
+Rename
+\end_layout
+
+\begin_layout Standard
+This will rename the current document including the version history.
+ It requires a clean document without any changes since the last checkin.
+ You are asked for a file name and a description of the rename operation.
+ After that the document is renamed, both locally and in the repository.
+ If the parent directories of the new and old file names differ, all relative
+ paths of included files are adjusted (like in 
+\family sans
+File\SpecialChar \menuseparator
+Save As
+\family default
+\SpecialChar \ldots{}
+).
+ Finally, the document is reloaded using the new name.
+\end_layout
+
+\begin_layout Labeling
+\labelwidthstring 00.00.0000
+GIT
+\begin_inset space ~
+\end_inset
+
+commands: 
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+git mv 
+\family typewriter
+
+\begin_inset Quotes eld
+\end_inset
+
+<file-name>
+\begin_inset Quotes erd
+\end_inset
+
+ 
+\begin_inset Quotes eld
+\end_inset
+
+<new-file-name>
+\begin_inset Quotes erd
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+git commit
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsubsection
+
+\family sans
+Show History
+\end_layout
+
+\begin_layout Standard
+This shows the complete history of the GIT document.
+ The output of 
+\family typewriter
+git log 
+\begin_inset Quotes eld
+\end_inset
+
+<file-name>
+\begin_inset Quotes erd
+\end_inset
+
+
+\family default
+ is shown in a browser.
+\end_layout
+
+\begin_layout Subsection
 Further tuning
 \end_layout
 

-----------------------------------------------------------------------

Summary of changes:
 lib/doc/Additional.lyx |  285 +++++++++++++++++++++++++++++++++++++++++++++++-
 src/VCBackend.cpp      |   89 +++++++++++++++-
 src/VCBackend.h        |   21 ++++
 3 files changed, 392 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to