Commit f1b7c7ba authored by René J.V. Bertin's avatar René J.V. Bertin

Restore upload functionality to git.reviewboard.kde.org

BUG:341875
REVIEW:121586
parent 9ff57fd3
......@@ -175,7 +175,7 @@ QDir urlDir(const KUrl::List& urls) { return urlDir(urls.first()); } //TODO: cou
}
GitPlugin::GitPlugin( QObject *parent, const QVariantList & )
: DistributedVersionControlPlugin(parent, KDevGitFactory::componentData()), m_oldVersion(false)
: DistributedVersionControlPlugin(parent, KDevGitFactory::componentData()), m_oldVersion(false), m_usePrefix(true)
{
if (KStandardDirs::findExe("git").isEmpty()) {
m_hasError = true;
......@@ -354,7 +354,12 @@ VcsJob* GitPlugin::diff(const KUrl& fileOrDirectory, const KDevelop::VcsRevision
DVcsJob* job = new GitJob(dotGitDirectory(fileOrDirectory), this, KDevelop::OutputJob::Silent);
job->setType(VcsJob::Diff);
*job << "git" << "diff" << "--no-prefix" << "--no-color" << "--no-ext-diff";
*job << "git" << "diff" << "--no-color" << "--no-ext-diff";
if (!usePrefix()) {
// KDE's ReviewBoard now requires p1 patchfiles, so `git diff --no-prefix` to generate p0 patches
// has become optional.
*job << "--no-prefix";
}
if(srcRevision.revisionType()==VcsRevision::Special
&& dstRevision.revisionType()==VcsRevision::Special
&& srcRevision.specialType()==VcsRevision::Base
......@@ -1065,6 +1070,7 @@ void GitPlugin::parseGitDiffOutput(DVcsJob* job)
VcsDiff diff;
diff.setDiff(job->output());
diff.setBaseDiff(repositoryRoot(KUrl(job->directory().absolutePath())));
diff.setDepth(usePrefix()? 1 : 0);
job->setResults(qVariantFromValue(diff));
}
......
......@@ -144,6 +144,19 @@ public:
virtual void registerRepositoryForCurrentBranchChanges(const KUrl& repository);
KDevelop::CheckInRepositoryJob* isInRepository(KTextEditor::Document* document);
// this indicates whether the diff() function will generate a diff (patch) which
// includes the working copy directory name or not (in which case git diff is called
// with --no-prefix).
bool usePrefix() const
{
return m_usePrefix;
}
void setUsePrefix(bool p)
{
m_usePrefix = p;
}
protected:
KUrl repositoryRoot(const KUrl& path);
......@@ -202,6 +215,7 @@ private:
QString m_errorDescription;
KDirWatch* m_watcher;
KUrl::List m_branchesChange;
bool m_usePrefix;
};
QVariant runSynchronously(KDevelop::VcsJob* job);
......
......@@ -552,6 +552,7 @@ void PatchReviewPlugin::exporterSelected( QAction* action ) {
if( exporter ) {
qDebug() << "exporting patch" << exporter << action->text();
// for git projects, m_patch will be a VCSDiffPatchSource instance
exporter->extension<IPatchExporter>()->exportPatch( patch() );
}
}
......
......@@ -132,7 +132,7 @@ void HttpCall::start()
connect(m_reply, SIGNAL(finished()), SLOT(finished()));
qDebug() << "starting..." << m_requrl << m_post;
qDebug() << "starting... requrl=" << m_requrl << "post=" << m_post;
}
QVariant HttpCall::result() const
......
......@@ -123,6 +123,7 @@ void ReviewBoardPlugin::reviewCreated(KJob* j)
{
if (j->error()==0) {
ReviewBoard::NewRequest const * job = qobject_cast<ReviewBoard::NewRequest*>(j);
// for git projects, m_source will be a VCSDiffPatchSource instance
ReviewBoard::SubmitPatchRequest* submitPatchJob=new ReviewBoard::SubmitPatchRequest(job->server(), m_source->file(), m_baseDir, job->requestId());
connect(submitPatchJob, SIGNAL(finished(KJob*)), SLOT(reviewDone(KJob*)));
submitPatchJob->start();
......
......@@ -36,8 +36,9 @@ public:
QHash<VcsLocation,QString> rightTexts;
KUrl baseDiff;
QString diff;
VcsDiff::Type type;
VcsDiff::Content content;
VcsDiff::Type type = VcsDiff::DiffDontCare;
VcsDiff::Content content = VcsDiff::Text;
uint depth = 0;
};
VcsDiff::VcsDiff()
......@@ -53,14 +54,7 @@ VcsDiff::~VcsDiff()
VcsDiff::VcsDiff( const VcsDiff& rhs )
: d(new VcsDiffPrivate)
{
d->leftBinaries = rhs.d->leftBinaries;
d->rightBinaries = rhs.d->rightBinaries;
d->leftTexts = rhs.d->leftTexts;
d->rightTexts = rhs.d->rightTexts;
d->diff = rhs.d->diff;
d->type = rhs.d->type;
d->content = rhs.d->content;
d->baseDiff = rhs.d->baseDiff;
*d = *rhs.d;
}
bool VcsDiff::isEmpty() const
......@@ -163,16 +157,9 @@ void VcsDiff::setContentType( VcsDiff::Content c )
VcsDiff& VcsDiff::operator=( const VcsDiff& rhs)
{
if(this == &rhs)
return *this;
d->content = rhs.d->content;
d->type = rhs.d->type;
d->leftBinaries = rhs.d->leftBinaries;
d->rightBinaries = rhs.d->rightBinaries;
d->leftTexts = rhs.d->leftTexts;
d->rightTexts = rhs.d->rightTexts;
d->diff = rhs.d->diff;
d->baseDiff = rhs.d->baseDiff;
if (this != &rhs) {
*d = *rhs.d;
}
return *this;
}
......@@ -181,21 +168,19 @@ KUrl VcsDiff::baseDiff() const
return d->baseDiff;
}
uint VcsDiff::depth() const
{
return d->depth;
}
void VcsDiff::setBaseDiff(const KUrl& url) const
{
d->baseDiff=url;
}
void VcsDiff::clear()
void VcsDiff::setDepth(const uint depth) const
{
// d->content;
// d->type;
d->leftBinaries.clear();
d->rightBinaries.clear();
d->leftTexts.clear();
d->rightTexts.clear();
d->diff.clear();
d->baseDiff.clear();
d->depth = depth;
}
......
......@@ -103,9 +103,17 @@ public:
/** @returns the base directory of the diff. */
KUrl baseDiff() const;
/**
* Depth - number of directories to left-strip from paths in the patch - see "patch -p"
* Defaults to 0
*/
uint depth() const;
/** Sets the base directory of the diff to the @p url */
void setBaseDiff(const KUrl& url) const;
/** Sets the depth of the diff to @p depth */
void setDepth(const uint depth) const;
void setDiff( const QString& );
void addLeftBinary( const KDevelop::VcsLocation&, const QByteArray& );
......@@ -125,8 +133,6 @@ public:
/** @returns whether there are not changes on the diff */
bool isEmpty() const;
/** Clears the diff information and it becomes an empty patch. */
void clear();
private:
class VcsDiffPrivate* const d;
};
......
......@@ -164,6 +164,10 @@ QString VCSDiffPatchSource::name() const {
return m_name;
}
uint VCSDiffPatchSource::depth() const {
return m_depth;
}
void VCSDiffPatchSource::updateFromDiff(VcsDiff vcsdiff)
{
if(!m_file.isValid())
......@@ -189,7 +193,8 @@ void VCSDiffPatchSource::updateFromDiff(VcsDiff vcsdiff)
m_name = "VCS Diff";
m_base = vcsdiff.baseDiff();
m_base.addPath("/");
m_depth = vcsdiff.depth();
emit patchChanged();
}
......
......@@ -77,6 +77,8 @@ class KDEVPLATFORMVCS_EXPORT VCSDiffPatchSource : public KDevelop::IPatchSource
virtual QString name() const ;
virtual uint depth() const ;
virtual void update() ;
virtual bool isAlreadyApplied() const { return true; }
......@@ -90,6 +92,7 @@ class KDEVPLATFORMVCS_EXPORT VCSDiffPatchSource : public KDevelop::IPatchSource
QMap<KUrl, KDevelop::VcsStatusInfo::State> m_selectable;
private:
void updateFromDiff(KDevelop::VcsDiff diff);
uint m_depth = 0;
};
class KDEVPLATFORMVCS_EXPORT VCSCommitDiffPatchSource : public VCSDiffPatchSource {
......
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