]> git.lyx.org Git - lyx.git/blob - src/vc-backend.h
Add In nsetOld * argument to updateInset to rebreak the correct par.
[lyx.git] / src / vc-backend.h
1 // -*- C++ -*-
2 /**
3  * \file vc-backend.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef VC_BACKEND_H
13 #define VC_BACKEND_H
14
15 #include "LString.h"
16
17 class Buffer;
18
19 /// A simple version control system interface
20 class VCS {
21 public:
22         /// the status of the managed file
23         enum VCStatus {
24                 UNLOCKED,
25                 LOCKED
26         };
27
28         virtual ~VCS() {}
29
30         /// register a file for version control
31         virtual void registrer(string const & msg) = 0;
32         /// check in the current revision
33         virtual void checkIn(string const & msg) = 0;
34         /// check out for editing
35         virtual void checkOut() = 0;
36         /// revert current edits
37         virtual void revert() = 0;
38         /// FIXME
39         virtual void undoLast() = 0;
40         /**
41          * getLog - read the revision log into the given file
42          * @param fname file name to read into
43          */
44         virtual void getLog(string const &) = 0;
45         /// return the current version description
46         virtual string const versionString() const = 0;
47         /// return the current version
48         string const & version() const {
49                 return version_;
50         }
51         /// return the user who has locked the file
52         string const & locker() const { return locker_; }
53         /// set the owning buffer
54         void owner(Buffer * b) { owner_ = b; }
55         /// return the owning buffer
56         Buffer * owner() const { return owner_; }
57         /// return the lock status of this file
58         VCStatus status() const { return vcstatus; }
59 protected:
60         /// parse information from the version file
61         virtual void scanMaster() = 0;
62
63         /**
64          * doVCCommand - call out to the version control utility
65          * @param cmd the command to execute
66          * @param path the path from which to execute
67          * @return exit status
68          */
69         static int doVCCommand(string const & cmd, string const & path);
70
71         /**
72          * The master VC file. For RCS this is *,v or RCS/ *,v. master should
73          * have full path.
74          */
75         string master_;
76
77         /// The status of the VC controlled file.
78         VCStatus vcstatus;
79
80         /**
81          * The version of the VC file. I am not sure if this can be a
82          * string or if it must be a float/int.
83          */
84         string version_;
85
86         /// The user currently keeping the lock on the VC file.
87         string locker_;
88         /// The buffer using this VC
89         Buffer * owner_;
90 };
91
92
93 ///
94 class RCS : public VCS {
95 public:
96
97         explicit
98         RCS(string const & m);
99
100         /// return the revision file for the given file, if found
101         static string const find_file(string const & file);
102
103         static void retrieve(string const & file);
104
105         virtual void registrer(string const & msg);
106
107         virtual void checkIn(string const & msg);
108
109         virtual void checkOut();
110
111         virtual void revert();
112
113         virtual void undoLast();
114
115         virtual void getLog(string const &);
116
117         virtual string const versionString() const {
118                 return "RCS: " + version_;
119         }
120
121 protected:
122         virtual void scanMaster();
123 };
124
125
126 ///
127 class CVS : public VCS {
128 public:
129         ///
130         explicit
131         CVS(string const & m, string const & f);
132
133         /// return the revision file for the given file, if found
134         static string const find_file(string const & file);
135
136         virtual void registrer(string const & msg);
137
138         virtual void checkIn(string const & msg);
139
140         virtual void checkOut();
141
142         virtual void revert();
143
144         virtual void undoLast();
145
146         virtual void getLog(string const &);
147
148         virtual string const versionString() const {
149                 return "CVS: " + version_;
150         }
151
152 protected:
153         virtual void scanMaster();
154
155 private:
156         string file_;
157 };
158 #endif // VCBACKEND_H