[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdevplatform/plugins
From: Fabian Wiesel <fabian.wiesel () googlemail ! com>
Date: 2009-03-23 7:21:35
Message-ID: 1237792895.433536.1793.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 943002 by wiesel:
DVCS: Escape filenames beginning with a hyphen
M +20 -12 git/gitplugin.cpp
M +1 -1 mercurial/CMakeLists.txt
M +32 -78 mercurial/mercurialplugin.cpp
--- trunk/KDE/kdevplatform/plugins/git/gitplugin.cpp #943001:943002
@@ -84,19 +84,18 @@
bool GitPlugin::isVersionControlled(const KUrl &path)
{
- QString workDir = path.path();
- QString filename;
- QFileInfo fsObject(workDir);
- if (fsObject.isFile())
- {
- workDir = fsObject.path();
- filename = fsObject.fileName();
+ QFileInfo fsObject(path.path());
+ if (!fsObject.isFile()) {
+ return isValidDirectory(path);
}
- else
- return isValidDirectory(path);
- QStringList otherFiles = getLsFiles(workDir);
- return otherFiles.contains(filename);
+ QString workDir = fsObject.path();
+ QString filename = fsObject.fileName();
+
+ QStringList listfiles("--");
+ listfiles.append(filename);
+ QStringList otherFiles = getLsFiles(workDir, listfiles);
+ return !otherFiles.empty();
}
VcsJob* GitPlugin::init(const KUrl &directory)
@@ -117,6 +116,7 @@
if (prepareJob(job, localRepositoryRoot.toLocalFile(), GitPlugin::Init) ) {
*job << "git";
*job << "clone";
+ *job << "--";
*job << localOrRepoLocationSrc.localUrl().pathOrUrl();
return job;
}
@@ -134,6 +134,7 @@
if (prepareJob(job, localLocations.front().path()) ) {
*job << "git";
*job << "add";
+ *job << "--";
addFileList(job, localLocations);
return job;
@@ -167,7 +168,7 @@
{
Q_UNUSED(recursion)
- if (localLocations.empty())
+ if (localLocations.empty() || message.isEmpty())
return NULL;
DVcsJob* job = new DVcsJob(this);
@@ -177,6 +178,8 @@
*job << "-m";
//Note: the message is quoted somewhere else, so if we quote here then we \
have quotes in the commit log
*job << message;
+ *job << "--";
+ addFileList(job, localLocations);
return job;
}
if (job) delete job;
@@ -192,6 +195,7 @@
if (prepareJob(job, files.front().path()) ) {
*job << "git";
*job << "rm";
+ *job << "--";
addFileList(job, files);
return job;
}
@@ -210,6 +214,7 @@
if (prepareJob(job, localLocation.path()) ) {
*job << "git";
*job << "log";
+ *job << "--";
addFileList(job, localLocation);
return job;
}
@@ -246,6 +251,7 @@
if (prepareJob(job, repository) ) {
*job << "git";
*job << "checkout";
+ *job << "--";
*job << branch;
return job;
}
@@ -263,6 +269,7 @@
//Empty branch has 'something' so it breaks the command
if (!args.isEmpty())
*job << args;
+ *job << "--";
if (!branch.isEmpty())
*job << branch;
if (!basebranch.isEmpty())
@@ -285,6 +292,7 @@
//Empty branch has 'something' so it breaks the command
if (!args.isEmpty())
*job << args;
+ *job << "--";
addFileList(job, files);
return job;
}
--- trunk/KDE/kdevplatform/plugins/mercurial/CMakeLists.txt #943001:943002
@@ -1,4 +1,4 @@
-add_definitions(-DKDE_DEFAULT_DEBUG_AREA=9525)
+add_definitions(-DKDE_DEFAULT_DEBUG_AREA=9526)
add_subdirectory(tests)
########### next target ###############
--- trunk/KDE/kdevplatform/plugins/mercurial/mercurialplugin.cpp #943001:943002
@@ -75,6 +75,7 @@
bool MercurialPlugin::isValidDirectory(const KUrl & directory)
{
+ // Mercurial uses the same test, so we don't lose any functionality
static const QString hgDir(".hg");
const QString initialPath(directory.toLocalFile());
const QFileInfo finfo(initialPath);
@@ -88,7 +89,7 @@
while (!dir.cd(hgDir) && dir.cdUp()) {} // cdUp, until there is a sub-directory \
called .hg
- return hgDir == dir.dirName(); // Mercurial uses the same test, so we don't \
lose any functionality + return hgDir == dir.dirName();
}
bool MercurialPlugin::isVersionControlled(const KUrl & url)
@@ -99,12 +100,14 @@
return isValidDirectory(url);
}
- // Clean, Added, Modified, Only current and subdirectories
- static const QStringList versionControlledFlags(QString("-c -a -m .").split(' \
')); + // Clean, Added, Modified. Escape possible files starting with "-"
+ static const QStringList versionControlledFlags(QString("-c -a -m --").split(' \
')); const QString absolutePath = fsObject.absolutePath();
- const QStringList filesInDir = getLsFiles(absolutePath, versionControlledFlags);
+ QStringList listFile(versionControlledFlags);
+ listFile.push_back(fsObject.fileName());
+ const QStringList filesInDir = getLsFiles(absolutePath, listFile);
- return filesInDir.contains(fsObject.absoluteFilePath());
+ return !filesInDir.empty();
}
VcsJob* MercurialPlugin::init(const KUrl &directory)
@@ -128,7 +131,7 @@
return NULL;
}
- *job << "hg" << "clone" << localOrRepoLocationSrc.localUrl().pathOrUrl();
+ *job << "hg" << "clone" << "--" << \
localOrRepoLocationSrc.localUrl().pathOrUrl();
return job.release();
}
@@ -141,7 +144,7 @@
return NULL;
}
- *job << "hg" << "fetch";
+ *job << "hg" << "fetch" << "--";
QString pathOrUrl = otherRepository.localUrl().pathOrUrl();
@@ -159,7 +162,7 @@
return NULL;
}
- *job << "hg" << "push";
+ *job << "hg" << "push" << "--";
QString pathOrUrl = otherRepository.localUrl().pathOrUrl();
@@ -180,7 +183,7 @@
return NULL;
}
- *job << "hg" << "add";
+ *job << "hg" << "add" << "--";
if (!addDirsConditionally(job.get(), localLocations, recursion)) {
return NULL;
@@ -197,7 +200,7 @@
return NULL;
}
- *job << "hg" << "cp" << localLocationSrc.path() << localLocationDst.path();
+ *job << "hg" << "cp" << "--" << localLocationSrc.path() << \
localLocationDst.path();
return job.release();
}
@@ -211,7 +214,7 @@
return NULL;
}
- *job << "hg" << "mv" << localLocationSrc.path() << localLocationDst.path();
+ *job << "hg" << "mv" << "--" << localLocationSrc.path() << \
localLocationDst.path();
return job.release();
}
@@ -231,7 +234,7 @@
}
//Note: the message is quoted somewhere else, so if we quote here then we have \
quotes in the commit log
- *job << "hg" << "commit" << "-m" << message;
+ *job << "hg" << "commit" << "-m" << message << "--";
if (!addDirsConditionally(job.get(), localLocations, recursion)) {
return NULL;
@@ -281,6 +284,7 @@
// *job << "-r" << srcRev;
// if ("" != dstRev)
// *job << "-r" << dstRev;
+ *job << "--";
*job << srcPath;
connect(job.get(), SIGNAL(readyForParsing(DVcsJob*)), \
SLOT(parseDiff(DVcsJob*))); @@ -299,7 +303,7 @@
return NULL;
}
- *job << "hg" << "rm";
+ *job << "hg" << "rm" << "--";
addFileList(job.get(), files);
return job.release();
@@ -313,7 +317,7 @@
return NULL;
}
- *job << "hg" << "status";
+ *job << "hg" << "status" << "-A" << "--";
if (!addDirsConditionally(job.get(), localLocations, recursion)) {
return NULL;
}
@@ -325,18 +329,21 @@
bool MercurialPlugin::parseStatus(DVcsJob *job) const
{
- if (job->status() != VcsJob::JobSucceeded)
+ if (job->status() != VcsJob::JobSucceeded) {
+ kDebug() << job->output();
return false;
+ }
const QString dir = \
job->getDirectory().absolutePath().append(QDir::separator());
const QStringList output = job->output().split('\n', QString::SkipEmptyParts);
QList<QVariant> filestatus;
-
foreach(const QString &line, output) {
QChar stCh = line.at(0);
KUrl file(line.mid(2).prepend(dir));
+ kDebug() << dir;
+
VcsStatusInfo status;
status.setUrl(file);
status.setState(charToState(stCh.toAscii()));
@@ -360,7 +367,7 @@
return NULL;
}
- *job << "hg" << "revert";
+ *job << "hg" << "revert" << "--";
if (!addDirsConditionally(job.get(), localLocations, recursion)) {
return NULL;
}
@@ -380,7 +387,7 @@
return NULL;
}
- *job << "hg" << "log" << "--template" << \
"{file_copies}\\0{file_dels}\\0{file_adds}\\0{file_mods}\\0{desc}\\0{date|isodate}\\0{author}\\0{parents}\\0{node}\\0{rev}\\0";
+ *job << "hg" << "log" << "--template" << \
"{file_copies}\\0{file_dels}\\0{file_adds}\\0{file_mods}\\0{desc}\\0{date|isodate}\\0{author}\\0{parents}\\0{node}\\0{rev}\\0" \
<< "--";
addFileList(job.get(), localLocation);
connect(job.get(), SIGNAL(readyForParsing(DVcsJob*)), \
SLOT(parseLogOutputBasicVersionControl(DVcsJob*))); @@ -413,6 +420,8 @@
if (srev != QString::null && !srev.isEmpty())
*job << "-r" << srev;
+ *job << "--";
+
*job << localLocation.path();
connect(job.get(), SIGNAL(readyForParsing(DVcsJob*)), \
SLOT(parseAnnotations(DVcsJob*)));
@@ -428,7 +437,7 @@
return NULL;
}
- *job << "hg" << "update" << branch;
+ *job << "hg" << "update" << "--" << branch;
return job.release();
}
@@ -453,7 +462,7 @@
return NULL;
}
- *job << "hg" << "branch" << branch;
+ *job << "hg" << "branch" << "--" << branch;
return job.release();
}
@@ -471,9 +480,10 @@
if (!args.isEmpty())
*job << args;
- if (!files.isEmpty())
+ if (!files.isEmpty()) {
+ *job << "--";
addFileList(job.get(), files);
- else
+ } else
*job << "-a";
return job.release();
@@ -510,65 +520,9 @@
return job->output().split('\n', QString::SkipEmptyParts);
}
-#if 0
-QList<QVariant> MercurialPlugin::getOtherFiles(const QString & directory)
-{
- QStringList args("-u"); // Unknown file
- args.push_back("."); // Current and subdirectories
- const QStringList otherFiles = getLsFiles(directory, args);
- QList<QVariant> others;
- foreach(const QString &file, otherFiles) {
- VcsStatusInfo status;
- status.setUrl(file);
- status.setState(VcsStatusInfo::ItemUnknown);
- others.append(qVariantFromValue<VcsStatusInfo>(status));
- }
- return others;
-}
-
-QList<QVariant> MercurialPlugin::getModifiedFiles(const QString &directory)
-{
- std::auto_ptr<DVcsJob> job(new DVcsJob(this));
-
- if (!prepareJob(job.get(), directory)) {
- return QList<QVariant>();
- }
- *job << "hg" << "status" << "-m" << "-a" << "-r" << "-d" << ".";
-
- if (!job->exec() || job->status() != VcsJob::JobSucceeded)
- return QList<QVariant>();
-
- const QString dir = \
job->getDirectory().absolutePath().append(QDir::separator());
- const QStringList output = job.release()->output().split('\n', \
QString::SkipEmptyParts);
- QList<QVariant> modifiedFiles;
-
- foreach(const QString &line, output) {
- QChar stCh = line.at(0);
-
- KUrl file(line.mid(2).prepend(dir));
-
- VcsStatusInfo status;
- status.setUrl(file);
- status.setState(charToState(stCh.toAscii()));
-
- modifiedFiles.append(qVariantFromValue<VcsStatusInfo>(status));
- }
-
- return modifiedFiles;
-}
-
-QList<QVariant> MercurialPlugin::getCachedFiles(const QString &directory)
-{
- Q_UNUSED(directory)
- QList<QVariant> cachedFiles;
- return cachedFiles;
-}
-#endif
-
QList<DVcsEvent> MercurialPlugin::getAllCommits(const QString &repo)
{
- qDebug("MercurialPlugin::getAllCommits(): %s", repo.toLocal8Bit().constData());
std::auto_ptr<DVcsJob> job(new DVcsJob(this));
job->setAutoDelete(false);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic