Allow revision to be string.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33474 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Pavel Sanda 2010-02-15 07:10:59 +00:00
parent 1353806c96
commit 3309cdca59
5 changed files with 19 additions and 16 deletions

View File

@ -313,7 +313,7 @@ bool LyXVC::undoLastEnabled() const
return vcs && vcs->undoLastEnabled(); return vcs && vcs->undoLastEnabled();
} }
bool LyXVC::prepareFileRevision(int rev, std::string & f) bool LyXVC::prepareFileRevision(string const & rev, std::string & f)
{ {
return vcs && vcs->prepareFileRevision(rev, f); return vcs && vcs->prepareFileRevision(rev, f);
} }

View File

@ -110,8 +110,9 @@ public:
* Parameter rev can be either revision number or negative number * Parameter rev can be either revision number or negative number
* which is interpreted as how many revision back from the current * which is interpreted as how many revision back from the current
* one do we want. rev=0 is reserved for the last (committed) revision. * one do we want. rev=0 is reserved for the last (committed) revision.
* We need rev to be string, since in various VCS revision is not integer.
*/ */
bool prepareFileRevision(int rev, std::string & f); bool prepareFileRevision(std::string const & rev, std::string & f);
/// Does the current VC supports this operation? /// Does the current VC supports this operation?
bool prepareFileRevisionEnabled(); bool prepareFileRevisionEnabled();

View File

@ -290,7 +290,7 @@ string RCS::revisionInfo(LyXVC::RevisionInfo const info)
} }
bool RCS::prepareFileRevision(int, std::string &) bool RCS::prepareFileRevision(string const &, string &)
{ {
return false; return false;
} }
@ -505,7 +505,7 @@ string CVS::revisionInfo(LyXVC::RevisionInfo const info)
} }
bool CVS::prepareFileRevision(int, std::string &) bool CVS::prepareFileRevision(string const &, string &)
{ {
return false; return false;
} }
@ -1006,8 +1006,12 @@ void SVN::getLog(FileName const & tmpf)
} }
bool SVN::prepareFileRevision(int rev, string & f) bool SVN::prepareFileRevision(string const & revis, string & f)
{ {
if (!isStrInt(revis))
return false;
int rev = convert<int>(revis);
if (rev <= 0) if (rev <= 0)
if (!getFileRevisionInfo()) if (!getFileRevisionInfo())
return false; return false;

View File

@ -79,7 +79,7 @@ public:
/// Return revision info specified by the argument. /// Return revision info specified by the argument.
virtual std::string revisionInfo(LyXVC::RevisionInfo const info) = 0; virtual std::string revisionInfo(LyXVC::RevisionInfo const info) = 0;
virtual bool prepareFileRevision(int rev, std::string & f) = 0; virtual bool prepareFileRevision(std::string const & rev, std::string & f) = 0;
virtual bool prepareFileRevisionEnabled() = 0; virtual bool prepareFileRevisionEnabled() = 0;
@ -157,7 +157,7 @@ public:
virtual std::string revisionInfo(LyXVC::RevisionInfo const info); virtual std::string revisionInfo(LyXVC::RevisionInfo const info);
virtual bool prepareFileRevision(int rev, std::string & f); virtual bool prepareFileRevision(std::string const & rev, std::string & f);
virtual bool prepareFileRevisionEnabled(); virtual bool prepareFileRevisionEnabled();
@ -218,7 +218,7 @@ public:
virtual std::string revisionInfo(LyXVC::RevisionInfo const info); virtual std::string revisionInfo(LyXVC::RevisionInfo const info);
virtual bool prepareFileRevision(int rev, std::string & f); virtual bool prepareFileRevision(std::string const & rev, std::string & f);
virtual bool prepareFileRevisionEnabled(); virtual bool prepareFileRevisionEnabled();
@ -278,7 +278,7 @@ public:
virtual std::string revisionInfo(LyXVC::RevisionInfo const info); virtual std::string revisionInfo(LyXVC::RevisionInfo const info);
virtual bool prepareFileRevision(int rev, std::string & f); virtual bool prepareFileRevision(std::string const & rev, std::string & f);
virtual bool prepareFileRevisionEnabled(); virtual bool prepareFileRevisionEnabled();

View File

@ -2579,22 +2579,20 @@ void GuiView::dispatchVC(FuncRequest const & cmd)
} }
case LFUN_VC_COMPARE: { case LFUN_VC_COMPARE: {
if (!isStrInt(cmd.getArg(0)))
break; string rev1 = cmd.getArg(0);
int rev1 = convert<int>(cmd.getArg(0));
string f1, f2; string f1, f2;
// f1 // f1
if (!buffer->lyxvc().prepareFileRevision(rev1, f1)) if (!buffer->lyxvc().prepareFileRevision(rev1, f1))
break; break;
if (rev1 <= 0) { if (isStrInt(rev1) && convert<int>(rev1) <= 0) {
f2 = buffer->absFileName(); f2 = buffer->absFileName();
} else { } else {
string arg2 = cmd.getArg(1); string rev2 = cmd.getArg(1);
if (arg2.empty() || !isStrInt(arg2)) if (rev2.empty() || !isStrInt(rev2))
break; break;
int rev2 = convert<int>(arg2);
// f2 // f2
if (!buffer->lyxvc().prepareFileRevision(rev2, f2)) if (!buffer->lyxvc().prepareFileRevision(rev2, f2))
break; break;