Commit 35798d4a authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

VCS: Use a single filename for log

The list always contains a single entry (or none) anyway

Take 2. This time it actually compiles ;-)

Change-Id: I71a9822360a9b569ba79afa0f575e27918bb2e03
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 92afe048
......@@ -724,7 +724,9 @@ void CvsPlugin::diffProject()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return);
cvsDiff(state.currentProjectTopLevel(), state.relativeCurrentProject());
const QString relativeProject = state.relativeCurrentProject();
cvsDiff(state.currentProjectTopLevel(),
relativeProject.isEmpty() ? QStringList() : QStringList(relativeProject));
}
void CvsPlugin::diffCurrentFile()
......@@ -738,7 +740,7 @@ void CvsPlugin::startCommitCurrentFile()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
startCommit(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
startCommit(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void CvsPlugin::startCommitAll()
......@@ -751,7 +753,7 @@ void CvsPlugin::startCommitAll()
/* Start commit of files of a single repository by displaying
* template and files in a submit editor. On closing, the real
* commit will start. */
void CvsPlugin::startCommit(const QString &workingDir, const QStringList &files)
void CvsPlugin::startCommit(const QString &workingDir, const QString &file)
{
if (raiseSubmitEditor())
return;
......@@ -770,9 +772,9 @@ void CvsPlugin::startCommit(const QString &workingDir, const QStringList &files)
// Get list of added/modified/deleted files and purge out undesired ones
// (do not run status with relative arguments as it will omit the directories)
StateList statusOutput = parseStatusOutput(QString(), response.stdOut);
if (!files.isEmpty()) {
if (!file.isEmpty()) {
for (StateList::iterator it = statusOutput.begin(); it != statusOutput.end() ; ) {
if (files.contains(it->second))
if (file == it->second)
++it;
else
it = statusOutput.erase(it);
......@@ -821,7 +823,7 @@ void CvsPlugin::filelogCurrentFile()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
filelog(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()), true);
filelog(state.currentFileTopLevel(), state.relativeCurrentFile(), true);
}
void CvsPlugin::logProject()
......@@ -839,16 +841,16 @@ void CvsPlugin::logRepository()
}
void CvsPlugin::filelog(const QString &workingDir,
const QStringList &files,
const QString &file,
bool enableAnnotationContextMenu)
{
QTextCodec *codec = VcsBaseEditorWidget::getCodec(workingDir, files);
QTextCodec *codec = VcsBaseEditorWidget::getCodec(workingDir, QStringList(file));
// no need for temp file
const QString id = VcsBaseEditorWidget::getTitleId(workingDir, files);
const QString source = VcsBaseEditorWidget::getSource(workingDir, files);
const QString id = VcsBaseEditorWidget::getTitleId(workingDir, QStringList(file));
const QString source = VcsBaseEditorWidget::getSource(workingDir, file);
QStringList args;
args << QLatin1String("log");
args.append(files);
args.append(file);
const CvsResponse response =
runCvs(workingDir, args, m_settings.timeOutMS(),
SshPasswordPrompt, codec);
......@@ -857,7 +859,7 @@ void CvsPlugin::filelog(const QString &workingDir,
// Re-use an existing view if possible to support
// the common usage pattern of continuously changing and diffing a file
const QString tag = VcsBaseEditorWidget::editorTag(LogOutput, workingDir, files);
const QString tag = VcsBaseEditorWidget::editorTag(LogOutput, workingDir, QStringList(file));
if (Core::IEditor *editor = VcsBaseEditorWidget::locateEditorByTag(tag)) {
editor->document()->setContents(response.stdOut.toUtf8());
Core::EditorManager::activateEditor(editor);
......@@ -877,11 +879,12 @@ void CvsPlugin::updateProject()
update(state.currentProjectTopLevel(), state.relativeCurrentProject());
}
bool CvsPlugin::update(const QString &topLevel, const QStringList &files)
bool CvsPlugin::update(const QString &topLevel, const QString &file)
{
QStringList args(QLatin1String("update"));
args.push_back(QLatin1String("-dR"));
args.append(files);
if (!file.isEmpty())
args.append(file);
const CvsResponse response =
runCvs(topLevel, args, m_settings.longTimeOutMS(),
SshPasswordPrompt|ShowStdOutInLogWindow);
......@@ -1012,10 +1015,11 @@ void CvsPlugin::annotate(const QString &workingDir, const QString &file,
}
}
bool CvsPlugin::status(const QString &topLevel, const QStringList &files, const QString &title)
bool CvsPlugin::status(const QString &topLevel, const QString &file, const QString &title)
{
QStringList args(QLatin1String("status"));
args.append(files);
if (!file.isEmpty())
args.append(file);
const CvsResponse response =
runCvs(topLevel, args, m_settings.timeOutMS(), 0);
const bool ok = response.result == CvsResponse::Ok;
......@@ -1049,14 +1053,14 @@ void CvsPlugin::statusRepository()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
status(state.topLevel(), QStringList(), tr("Repository status"));
status(state.topLevel(), QString(), tr("Repository status"));
}
void CvsPlugin::updateRepository()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
update(state.topLevel(), QStringList());
update(state.topLevel(), QString());
}
......
......@@ -150,16 +150,16 @@ private:
bool describe(const QString &toplevel, const QString &source, const QString &changeNr, QString *errorMessage);
bool describe(const QString &repository, QList<CvsLogEntry> entries, QString *errorMessage);
void filelog(const QString &workingDir,
const QStringList &files = QStringList(),
const QString &file = QString(),
bool enableAnnotationContextMenu = false);
bool unedit(const QString &topLevel, const QStringList &files);
bool status(const QString &topLevel, const QStringList &files, const QString &title);
bool update(const QString &topLevel, const QStringList &files);
bool status(const QString &topLevel, const QString &file, const QString &title);
bool update(const QString &topLevel, const QString &file);
bool checkCVSDirectory(const QDir &directory) const;
// Quick check if files are modified
bool diffCheckModified(const QString &topLevel, const QStringList &files, bool *modified);
QString findTopLevelForDirectoryI(const QString &directory) const;
void startCommit(const QString &workingDir, const QStringList &files = QStringList());
void startCommit(const QString &workingDir, const QString &file = QString());
bool commit(const QString &messageFile, const QStringList &subVersionFileList);
void cleanCommitMessageFile();
inline CvsControl *cvsVersionControl() const;
......
......@@ -315,7 +315,7 @@ void BranchDialog::log()
if (branchName.isEmpty())
return;
// Do not pass working dir by reference since it might change
GitPlugin::instance()->gitClient()->log(QString(m_repository), QStringList(), false, QStringList(branchName));
GitPlugin::instance()->gitClient()->log(QString(m_repository), QString(), false, QStringList(branchName));
}
void BranchDialog::merge()
......
......@@ -637,7 +637,7 @@ public:
const QString &directory,
bool enableAnnotationContextMenu,
const QStringList &args,
const QStringList &fileNames) :
const QString &fileName) :
BaseGitDiffArgumentsWidget(client, directory, args),
m_client(client),
m_workingDirectory(directory),
......@@ -657,24 +657,24 @@ public:
QToolButton *graphButton = addToggleButton(graphArguments, tr("Graph"),
tr("Show textual graph log."));
mapSetting(graphButton, m_client->settings()->boolPointer(GitSettings::graphLogKey));
setFileNames(fileNames);
setFileName(fileName);
}
void setFileNames(const QStringList &fileNames)
void setFileName(const QString &fileNames)
{
m_fileNames = fileNames;
m_fileName = fileNames;
}
void executeCommand()
{
m_client->log(m_workingDirectory, m_fileNames, m_enableAnnotationContextMenu, baseArguments());
m_client->log(m_workingDirectory, m_fileName, m_enableAnnotationContextMenu, baseArguments());
}
private:
GitClient *m_client;
QString m_workingDirectory;
bool m_enableAnnotationContextMenu;
QStringList m_fileNames;
QString m_fileName;
};
class ConflictHandler : public QObject
......@@ -1113,20 +1113,19 @@ void GitClient::status(const QString &workingDirectory)
Qt::QueuedConnection);
}
void GitClient::log(const QString &workingDirectory, const QStringList &fileNames,
void GitClient::log(const QString &workingDirectory, const QString &fileName,
bool enableAnnotationContextMenu, const QStringList &args)
{
const QString msgArg = fileNames.empty() ? workingDirectory :
fileNames.join(QLatin1String(", "));
const QString msgArg = fileName.isEmpty() ? workingDirectory : fileName;
const QString title = tr("Git Log \"%1\"").arg(msgArg);
const Core::Id editorId = Git::Constants::GIT_LOG_EDITOR_ID;
const QString sourceFile = VcsBase::VcsBaseEditorWidget::getSource(workingDirectory, fileNames);
const QString sourceFile = VcsBase::VcsBaseEditorWidget::getSource(workingDirectory, fileName);
VcsBase::VcsBaseEditorWidget *editor = findExistingVCSEditor("logFileName", sourceFile);
if (!editor)
editor = createVcsEditor(editorId, title, sourceFile, CodecLogOutput, "logFileName", sourceFile,
new GitLogArgumentsWidget(this, workingDirectory,
enableAnnotationContextMenu,
args, fileNames));
args, fileName));
editor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
editor->setDiffBaseDirectory(workingDirectory);
......@@ -1140,13 +1139,13 @@ void GitClient::log(const QString &workingDirectory, const QStringList &fileName
GitLogArgumentsWidget *argWidget = qobject_cast<GitLogArgumentsWidget *>(editor->configurationWidget());
argWidget->setBaseArguments(args);
argWidget->setFileNames(fileNames);
argWidget->setFileName(fileName);
QStringList userArgs = argWidget->arguments();
arguments.append(userArgs);
if (!fileNames.isEmpty())
arguments << QLatin1String("--") << fileNames;
if (!fileName.isEmpty())
arguments << QLatin1String("--") << fileName;
executeGit(workingDirectory, arguments, editor);
}
......
......@@ -146,7 +146,7 @@ public:
void merge(const QString &workingDirectory, const QStringList &unmergedFileNames = QStringList());
void status(const QString &workingDirectory);
void log(const QString &workingDirectory, const QStringList &fileNames = QStringList(),
void log(const QString &workingDirectory, const QString &fileName = QString(),
bool enableAnnotationContextMenu = false, const QStringList &args = QStringList());
void blame(const QString &workingDirectory, const QStringList &args, const QString &fileName,
const QString &revision = QString(), int lineNumber = -1);
......
......@@ -744,7 +744,9 @@ void GitPlugin::diffCurrentProject()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return);
m_gitClient->diff(state.currentProjectTopLevel(), state.relativeCurrentProject());
const QString relativeProject = state.relativeCurrentProject();
m_gitClient->diff(state.currentProjectTopLevel(),
relativeProject.isEmpty() ? QStringList() : QStringList(relativeProject));
}
void GitPlugin::diffRepository()
......@@ -758,7 +760,7 @@ void GitPlugin::logFile()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
m_gitClient->log(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()), true);
m_gitClient->log(state.currentFileTopLevel(), state.relativeCurrentFile(), true);
}
void GitPlugin::blameFile()
......
......@@ -105,19 +105,16 @@ static inline QString debugCodec(const QTextCodec *c)
// Ensure adding "..." to relative paths which is p4's convention
// for the current directory
static inline QStringList perforceRelativeFileArguments(const QStringList &args)
static inline QString perforceRelativeFileArguments(const QString &args)
{
if (args.isEmpty())
return QStringList(QLatin1String("..."));
QTC_ASSERT(args.size() == 1, return QStringList());
QStringList p4Args = args;
p4Args.front() += QLatin1String("/...");
return p4Args;
return QLatin1String("...");
return args + QLatin1String("/...");
}
static inline QStringList perforceRelativeProjectDirectory(const VcsBase::VcsBasePluginState &s)
{
return perforceRelativeFileArguments(s.relativeCurrentProject());
return QStringList(perforceRelativeFileArguments(s.relativeCurrentProject()));
}
// Clean user setting off diff-binary for 'p4 resolve' and 'p4 diff'.
......@@ -735,7 +732,7 @@ void PerforcePlugin::filelogCurrentFile()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
filelog(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()), true);
filelog(state.currentFileTopLevel(), state.relativeCurrentFile(), true);
}
void PerforcePlugin::filelog()
......@@ -743,7 +740,7 @@ void PerforcePlugin::filelog()
const QString file = QFileDialog::getOpenFileName(0, tr("p4 filelog"));
if (!file.isEmpty()) {
const QFileInfo fi(file);
filelog(fi.absolutePath(), QStringList(fi.fileName()));
filelog(fi.absolutePath(), fi.fileName());
}
}
......@@ -758,24 +755,25 @@ void PerforcePlugin::logRepository()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
filelog(state.topLevel(), perforceRelativeFileArguments(QStringList()));
filelog(state.topLevel(), perforceRelativeFileArguments(QString()));
}
void PerforcePlugin::filelog(const QString &workingDir, const QStringList &fileNames,
void PerforcePlugin::filelog(const QString &workingDir, const QString &fileName,
bool enableAnnotationContextMenu)
{
const QString id = VcsBase::VcsBaseEditorWidget::getTitleId(workingDir, fileNames);
QTextCodec *codec = VcsBase::VcsBaseEditorWidget::getCodec(workingDir, fileNames);
const QString id = VcsBase::VcsBaseEditorWidget::getTitleId(workingDir, QStringList(fileName));
QTextCodec *codec = VcsBase::VcsBaseEditorWidget::getCodec(workingDir, QStringList(fileName));
QStringList args;
args << QLatin1String("filelog") << QLatin1String("-li");
if (m_settings.logCount() > 0)
args << QLatin1String("-m") << QString::number(m_settings.logCount());
args.append(fileNames);
if (!fileName.isEmpty())
args.append(fileName);
const PerforceResponse result = runP4Cmd(workingDir, args,
CommandToWindow|StdErrToWindow|ErrorToWindow,
QStringList(), QByteArray(), codec);
if (!result.error) {
const QString source = VcsBase::VcsBaseEditorWidget::getSource(workingDir, fileNames);
const QString source = VcsBase::VcsBaseEditorWidget::getSource(workingDir, fileName);
Core::IEditor *editor = showOutputInEditor(tr("p4 filelog %1").arg(id), result.stdOut,
VcsBase::LogOutput, source, codec);
if (enableAnnotationContextMenu)
......@@ -843,8 +841,8 @@ bool PerforcePlugin::managesDirectoryFstat(const QString &directory)
bool managed = false;
do {
// Quick check: Must be at or below top level and not "../../other_path"
const QStringList relativeDirArgs = m_settings.relativeToTopLevelArguments(directory);
if (!relativeDirArgs.empty() && relativeDirArgs.front().startsWith(QLatin1String("..")))
const QString relativeDirArgs = m_settings.relativeToTopLevelArguments(directory);
if (!relativeDirArgs.isEmpty() && relativeDirArgs.startsWith(QLatin1String("..")))
break;
// Is it actually managed by perforce?
QStringList args;
......
......@@ -185,7 +185,7 @@ private:
QString clientFilePath(const QString &serverFilePath);
void annotate(const QString &workingDir, const QString &fileName,
const QString &changeList = QString(), int lineNumber = -1);
void filelog(const QString &workingDir, const QStringList &fileNames = QStringList(),
void filelog(const QString &workingDir, const QString &fileName = QString(),
bool enableAnnotationContextMenu = false);
void cleanCommitMessageFile();
bool isCommitEditorOpen() const;
......
......@@ -241,10 +241,9 @@ QString PerforceSettings::relativeToTopLevel(const QString &dir) const
return m_topLevelDir->relativeFilePath(dir);
}
QStringList PerforceSettings::relativeToTopLevelArguments(const QString &dir) const
QString PerforceSettings::relativeToTopLevelArguments(const QString &dir) const
{
const QString relative = relativeToTopLevel(dir);
return relative.isEmpty() ? QStringList() : QStringList(relative);
return relativeToTopLevel(dir);
}
// Map the root part of a path:
......
......@@ -117,7 +117,7 @@ public:
QString relativeToTopLevel(const QString &dir) const;
// Return argument list relative to top level (empty meaning,
// it is the same directory).
QStringList relativeToTopLevelArguments(const QString &dir) const;
QString relativeToTopLevelArguments(const QString &dir) const;
// Map p4 path back to file system in case of a symlinked top-level
QString mapToFileSystem(const QString &perforceFilePath) const;
......
......@@ -724,7 +724,8 @@ void SubversionPlugin::diffProject()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return);
svnDiff(state.currentProjectTopLevel(), state.relativeCurrentProject(), state.currentProjectName());
svnDiff(state.currentProjectTopLevel(), QStringList(state.relativeCurrentProject()),
state.currentProjectName());
}
void SubversionPlugin::diffCurrentFile()
......@@ -820,7 +821,7 @@ void SubversionPlugin::filelogCurrentFile()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
filelog(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()), true);
filelog(state.currentFileTopLevel(), state.relativeCurrentFile(), true);
}
void SubversionPlugin::logProject()
......@@ -858,13 +859,13 @@ void SubversionPlugin::updateRepository()
svnUpdate(state.topLevel());
}
void SubversionPlugin::svnStatus(const QString &workingDir, const QStringList &relativePaths)
void SubversionPlugin::svnStatus(const QString &workingDir, const QString &relativePath)
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
QStringList args(QLatin1String("status"));
if (!relativePaths.isEmpty())
args.append(relativePaths);
if (!relativePath.isEmpty())
args.append(relativePath);
VcsBase::VcsBaseOutputWindow *outwin = VcsBase::VcsBaseOutputWindow::instance();
outwin->setRepository(workingDir);
runSvn(workingDir, args, m_settings.timeOutMs(),
......@@ -873,7 +874,7 @@ void SubversionPlugin::svnStatus(const QString &workingDir, const QStringList &r
}
void SubversionPlugin::filelog(const QString &workingDir,
const QStringList &files,
const QString &file,
bool enableAnnotationContextMenu)
{
// no need for temp file
......@@ -882,7 +883,7 @@ void SubversionPlugin::filelog(const QString &workingDir,
args << QLatin1String("-l")
<< QString::number(m_settings.intValue(SubversionSettings::logCountKey));
}
foreach (const QString &file, files)
if (!file.isEmpty())
args.append(QDir::toNativeSeparators(file));
// subversion stores log in UTF-8 and returns it back in user system locale.
......@@ -896,14 +897,15 @@ void SubversionPlugin::filelog(const QString &workingDir,
// Re-use an existing view if possible to support
// the common usage pattern of continuously changing and diffing a file
const QString id = VcsBase::VcsBaseEditorWidget::getTitleId(workingDir, files);
const QString tag = VcsBase::VcsBaseEditorWidget::editorTag(VcsBase::LogOutput, workingDir, files);
const QString id = VcsBase::VcsBaseEditorWidget::getTitleId(workingDir, QStringList(file));
const QString tag = VcsBase::VcsBaseEditorWidget::editorTag(VcsBase::LogOutput, workingDir,
QStringList(file));
if (Core::IEditor *editor = VcsBase::VcsBaseEditorWidget::locateEditorByTag(tag)) {
editor->document()->setContents(response.stdOut.toUtf8());
Core::EditorManager::activateEditor(editor);
} else {
const QString title = QString::fromLatin1("svn log %1").arg(id);
const QString source = VcsBase::VcsBaseEditorWidget::getSource(workingDir, files);
const QString source = VcsBase::VcsBaseEditorWidget::getSource(workingDir, file);
Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VcsBase::LogOutput, source, /*codec*/0);
VcsBase::VcsBaseEditorWidget::tagEditor(newEditor, tag);
if (enableAnnotationContextMenu)
......@@ -918,12 +920,12 @@ void SubversionPlugin::updateProject()
svnUpdate(state.currentProjectTopLevel(), state.relativeCurrentProject());
}
void SubversionPlugin::svnUpdate(const QString &workingDir, const QStringList &relativePaths)
void SubversionPlugin::svnUpdate(const QString &workingDir, const QString &relativePath)
{
QStringList args(QLatin1String("update"));
args.push_back(QLatin1String(nonInteractiveOptionC));
if (!relativePaths.isEmpty())
args.append(relativePaths);
if (!relativePath.isEmpty())
args.append(relativePath);
const SubversionResponse response =
runSvn(workingDir, args, 10 * m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
......
......@@ -169,10 +169,10 @@ private:
unsigned flags, QTextCodec *outputCodec = 0);
void filelog(const QString &workingDir,
const QStringList &file = QStringList(),
const QString &file = QString(),
bool enableAnnotationContextMenu = false);
void svnStatus(const QString &workingDir, const QStringList &relativePath = QStringList());
void svnUpdate(const QString &workingDir, const QStringList &relativePaths = QStringList());
void svnStatus(const QString &workingDir, const QString &relativePath = QString());
void svnUpdate(const QString &workingDir, const QString &relativePath = QString());
bool checkSVNSubDir(const QDir &directory, const QString &fileName = QString()) const;
void startCommit(const QString &workingDir, const QStringList &files = QStringList());
bool commit(const QString &messageFile, const QStringList &subVersionFileList);
......
......@@ -404,13 +404,12 @@ QString VcsBasePluginState::currentProjectTopLevel() const
return data->m_state.currentProjectTopLevel;
}
QStringList VcsBasePluginState::relativeCurrentProject() const
QString VcsBasePluginState::relativeCurrentProject() const
{
QStringList rc;
QTC_ASSERT(hasProject(), return rc);
QTC_ASSERT(hasProject(), return QString());
if (data->m_state.currentProjectTopLevel != data->m_state.currentProjectPath)
rc.append(QDir(data->m_state.currentProjectTopLevel).relativeFilePath(data->m_state.currentProjectPath));
return rc;
return QDir(data->m_state.currentProjectTopLevel).relativeFilePath(data->m_state.currentProjectPath);
return QString();
}
bool VcsBasePluginState::hasTopLevel() const
......
......@@ -94,9 +94,9 @@ public:
QString currentProjectName() const;
QString currentProjectTopLevel() const;
/* Convenience: Returns project path relative to top level if it
* differs from top level (else empty()) as an argument list to do
* differs from top level (else empty string) as an argument list to do
* eg a 'vcs diff <args>' */
QStringList relativeCurrentProject() const;
QString relativeCurrentProject() const;
// Top level directory for actions on the top level. Preferably
// the file one.
......
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