diff options
author | dt <qtc-committer@nokia.com> | 2010-05-11 14:13:38 +0200 |
---|---|---|
committer | dt <qtc-committer@nokia.com> | 2010-05-12 14:14:44 +0200 |
commit | 9bc9fe73e160f9ef87979a3cf5f1276b5f1ae0cf (patch) | |
tree | 1384611d81dcba7bfc2b25f02409322603e6931e /src/plugins/git | |
parent | e65e011706915a90e98ee67046a150ade84757e6 (diff) | |
download | qt-creator-9bc9fe73e160f9ef87979a3cf5f1276b5f1ae0cf.tar.gz |
File renaming
Reviewed-By: con
Reviewed-By: Friedemann Kleint
We now support renaming files. The version control system tries first to
rename, if that doesn't support or can't rename the file we do a normal
rename. (Note: git, hg, perforce > 2009.02 support renaming, cvs not.
(perforce untested)). We correctly notify all editors of the renamed
file and tell the project manager to rename the file in the project.
Note: Only the qt4projectmanager knows how to rename files.
Note: renaming folders, moving files to different folders, renaming
.pro/.pri files is not supported. Those things can be later added after
this has proven to work correctly in the simple case.
Also we don't do any actions based on the renaming like renaming
classes, changing include guards or #include lines.
Diffstat (limited to 'src/plugins/git')
-rw-r--r-- | src/plugins/git/gitclient.cpp | 21 | ||||
-rw-r--r-- | src/plugins/git/gitclient.h | 3 | ||||
-rw-r--r-- | src/plugins/git/gitversioncontrol.cpp | 10 | ||||
-rw-r--r-- | src/plugins/git/gitversioncontrol.h | 1 |
4 files changed, 35 insertions, 0 deletions
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 242e42db45..8984813632 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -525,6 +525,27 @@ bool GitClient::synchronousDelete(const QString &workingDirectory, return rc; } +bool GitClient::synchronousMove(const QString &workingDirectory, + const QString &from, + const QString &to) +{ + if (Git::Constants::debug) + qDebug() << Q_FUNC_INFO << workingDirectory << from << to; + QByteArray outputText; + QByteArray errorText; + QStringList arguments; + arguments << QLatin1String("mv"); + arguments << (from); + arguments << (to); + const bool rc = synchronousGit(workingDirectory, arguments, &outputText, &errorText); + if (!rc) { + const QString errorMessage = tr("Unable to move from %1 to %2: %3"). + arg(from, to, commandOutputFromLocal8Bit(errorText)); + outputWindow()->appendError(errorMessage); + } + return rc; +} + bool GitClient::synchronousReset(const QString &workingDirectory, const QStringList &files, QString *errorMessage) diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index 99f95fd6e0..3f0d0dede7 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -101,6 +101,9 @@ public: bool synchronousDelete(const QString &workingDirectory, bool force, const QStringList &files); + bool synchronousMove(const QString &workingDirectory, + const QString &from, + const QString &to); bool synchronousReset(const QString &workingDirectory, const QStringList &files = QStringList(), QString *errorMessage = 0); diff --git a/src/plugins/git/gitversioncontrol.cpp b/src/plugins/git/gitversioncontrol.cpp index 07ff952134..65a46e492e 100644 --- a/src/plugins/git/gitversioncontrol.cpp +++ b/src/plugins/git/gitversioncontrol.cpp @@ -75,6 +75,9 @@ bool GitVersionControl::supportsOperation(Operation operation) const case DeleteOperation: rc = true; break; + case MoveOperation: + rc = true; + break; case OpenOperation: break; case CreateRepositoryOperation: @@ -107,6 +110,13 @@ bool GitVersionControl::vcsDelete(const QString & fileName) return gitClient()->synchronousDelete(fi.absolutePath(), true, QStringList(fi.fileName())); } +bool GitVersionControl::vcsMove(const QString &from, const QString &to) +{ + const QFileInfo fromInfo(from); + const QFileInfo toInfo(to); + return gitClient()->synchronousMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath()); +} + bool GitVersionControl::vcsCreateRepository(const QString &directory) { return gitClient()->synchronousInit(directory); diff --git a/src/plugins/git/gitversioncontrol.h b/src/plugins/git/gitversioncontrol.h index c53c1f2ab5..098d8bef52 100644 --- a/src/plugins/git/gitversioncontrol.h +++ b/src/plugins/git/gitversioncontrol.h @@ -53,6 +53,7 @@ public: virtual bool vcsOpen(const QString &fileName); virtual bool vcsAdd(const QString &fileName); virtual bool vcsDelete(const QString &filename); + virtual bool vcsMove(const QString &from, const QString &to); virtual bool vcsCreateRepository(const QString &directory); virtual QString vcsCreateSnapshot(const QString &topLevel); virtual QStringList vcsSnapshots(const QString &topLevel); |