Commit 0c5c16a8 authored by Christian Loose's avatar Christian Loose
Browse files

Added new parseCvsAnnotate() method to AnnotateDialog

that uses the new cvs DCOP service

svn path=/trunk/kdesdk/cervisia/; revision=194928
parent c0a53dd7
......@@ -2,6 +2,8 @@
* Replace deprecated QMultiLineEdit with KTextEdit in
ChangeLog dialog
* Added new parseCvsAnnotate() method to AnnotateDialog
that uses the new cvs DCOP service
2002-12-18 Christian Loose <christian.loose@hamburg.de>
......
......@@ -14,6 +14,7 @@
#include "annotatedlg.h"
#include <dcopref.h>
#include <kconfig.h>
#include <klocale.h>
#include <kprocess.h>
......@@ -21,6 +22,7 @@
#include "annotateview.h"
#include "cvsprogressdlg.h"
#include "misc.h"
#include "progressdlg.h"
AnnotateDialog::Options *AnnotateDialog::options = 0;
......@@ -194,6 +196,111 @@ bool AnnotateDialog::parseCvsAnnotate(const QString &sandbox, const QString &rep
}
bool AnnotateDialog::parseCvsAnnotate(DCOPRef& cvsService, const QString& fileName,
const QString& revision)
{
QMap<QString, QString> logmap; // maps comment to a revision
enum { Begin, Tags, Admin, Revision,
Author, Branches, Comment, Finished } state;
setCaption(i18n("CVS Annotate: %1").arg(fileName));
DCOPReply job = cvsService.call("annotate(QString, QString)", fileName,
revision);
if( !job.isValid() )
return false;
ProgressDialog dlg(this, "Annotate", job, "annotate", i18n("CVS Annotate"));
if( !dlg.execute() )
return false;
// process cvs log output
state = Begin;
QString line, comment, rev;
while( dlg.getLine(line) )
{
switch( state )
{
case Begin:
if( line == "symbolic names:" )
state = Tags;
break;
case Tags:
if( line[0] != '\t' )
state = Admin;
break;
case Admin:
if( line == "----------------------------" )
state = Revision;
break;
case Revision:
rev = line.section(' ', 1, 1);
state = Author;
break;
case Author:
state = Branches;
break;
case Branches:
if( !line.startsWith("branches:") )
{
state = Comment;
comment = line;
}
break;
case Comment:
if( line == "----------------------------" )
state = Revision;
else if( line == "=============================================================================" )
state = Finished;
if( state == Comment )
comment += QString("\n") + line;
else
logmap[rev] = comment;
break;
case Finished:
;
}
if (state == Finished)
break;
}
// skip 2 lines
for( int i = 0; i < 2; ++i )
dlg.getLine(line);
// process cvs annotate output
QString date, author, content;
bool odd = false;
QString oldRevision = "";
while( dlg. getLine(line) )
{
rev = line.left(13).stripWhiteSpace();
comment = logmap[rev];
author = line.mid(14, 8).stripWhiteSpace();
date = line.mid(23, 9);
content = line.mid(35, line.length()-35);
if( comment.isNull() )
comment = "";
if( rev == oldRevision )
{
author = QString::null;
rev = QString::null;
}
else
{
oldRevision = rev;
odd = !odd;
}
annotate->addLine(rev, author, date, content, comment, odd);
}
return true;
}
// Local Variables:
// c-basic-offset: 4
......
......@@ -21,6 +21,7 @@
class KConfig;
class AnnotateView;
class DCOPRef;
class AnnotateDialog : public KDialogBase
......@@ -34,6 +35,9 @@ public:
bool parseCvsAnnotate(const QString &sandbox, const QString &repository,
const QString &filename, const QString &rev);
bool parseCvsAnnotate(DCOPRef& cvsService, const QString& fileName,
const QString& revision = "");
static void loadOptions(KConfig *config);
static void saveOptions(KConfig *config);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment