Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
989e1b5a
Commit
989e1b5a
authored
Sep 15, 2009
by
Brian McGillion
Browse files
Mercurial plugin, merge request with suggested fixes.
parent
0915342d
Changes
42
Hide whitespace changes
Inline
Side-by-side
src/plugins/mercurial/Mercurial.pluginspec
0 → 100644
View file @
989e1b5a
<plugin name="Mercurial" version="1.2.91" compatVersion="1.2.91">
<vendor>Brian McGillion</vendor>
<copyright>(C) 2008-2009 Brian McGillion</copyright>
<license>
Commercial Usage
Licensees holding valid Qt Commercial licenses may use this plugin in
accordance with the Qt Commercial License Agreement provided with the
Software or, alternatively, in accordance with the terms contained in
a written agreement between you and Nokia.
GNU Lesser General Public License Usage
Alternatively, this plugin may be used under the terms of the GNU Lesser
General Public License version 2.1 as published by the Free Software
Foundation. Please review the following information to
ensure the GNU Lesser General Public License version 2.1 requirements
will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license>
<description>Mercurial integration.</description>
<url>http://www.qtsoftware.com</url>
<dependencyList>
<dependency name="TextEditor" version="1.2.91"/>
<dependency name="ProjectExplorer" version="1.2.91"/>
<dependency name="Core" version="1.2.91"/>
<dependency name="VCSBase" version="1.2.91"/>
</dependencyList>
</plugin>
src/plugins/mercurial/annotationhighlighter.cpp
0 → 100644
View file @
989e1b5a
#include "annotationhighlighter.h"
#include "constants.h"
using
namespace
Mercurial
::
Internal
;
using
namespace
Mercurial
;
MercurialAnnotationHighlighter
::
MercurialAnnotationHighlighter
(
const
ChangeNumbers
&
changeNumbers
,
QTextDocument
*
document
)
:
VCSBase
::
BaseAnnotationHighlighter
(
changeNumbers
,
document
),
changeset
(
Constants
::
CHANGESETID12
)
{
}
QString
MercurialAnnotationHighlighter
::
changeNumber
(
const
QString
&
block
)
const
{
if
(
changeset
.
indexIn
(
block
)
!=
-
1
)
return
changeset
.
cap
(
1
);
return
QString
();
}
src/plugins/mercurial/annotationhighlighter.h
0 → 100644
View file @
989e1b5a
#ifndef ANNOTATIONHIGHLIGHTER_H
#define ANNOTATIONHIGHLIGHTER_H
#include <vcsbase/baseannotationhighlighter.h>
namespace
Mercurial
{
namespace
Internal
{
class
MercurialAnnotationHighlighter
:
public
VCSBase
::
BaseAnnotationHighlighter
{
public:
explicit
MercurialAnnotationHighlighter
(
const
ChangeNumbers
&
changeNumbers
,
QTextDocument
*
document
=
0
);
private:
virtual
QString
changeNumber
(
const
QString
&
block
)
const
;
QRegExp
changeset
;
};
}
//namespace Internal
}
// namespace Mercurial
#endif // ANNOTATIONHIGHLIGHTER_H
src/plugins/mercurial/clonewizard.cpp
0 → 100644
View file @
989e1b5a
#include "clonewizard.h"
#include "clonewizardpage.h"
#include "mercurialplugin.h"
#include "mercurialsettings.h"
#include <QtCore/QDebug>
using
namespace
Mercurial
::
Internal
;
CloneWizard
::
CloneWizard
(
QObject
*
parent
)
:
VCSBase
::
BaseCheckoutWizard
(
parent
),
m_icon
(
QIcon
(
":/mercurial/images/hg.png"
))
{
}
QIcon
CloneWizard
::
icon
()
const
{
return
m_icon
;
}
QString
CloneWizard
::
description
()
const
{
return
tr
(
"Clone a Mercurial repository"
);
}
QString
CloneWizard
::
name
()
const
{
return
tr
(
"Mercurial Clone"
);
}
QList
<
QWizardPage
*>
CloneWizard
::
createParameterPages
(
const
QString
&
path
)
{
QList
<
QWizardPage
*>
wizardPageList
;
CloneWizardPage
*
page
=
new
CloneWizardPage
;
page
->
setPath
(
path
);
wizardPageList
.
push_back
(
page
);
return
wizardPageList
;
}
QSharedPointer
<
VCSBase
::
AbstractCheckoutJob
>
CloneWizard
::
createJob
(
const
QList
<
QWizardPage
*>
&
parameterPages
,
QString
*
checkoutPath
)
{
const
CloneWizardPage
*
page
=
qobject_cast
<
const
CloneWizardPage
*>
(
parameterPages
.
front
());
if
(
!
page
)
return
QSharedPointer
<
VCSBase
::
AbstractCheckoutJob
>
();
MercurialSettings
*
settings
=
MercurialPlugin
::
instance
()
->
settings
();
QStringList
args
=
settings
->
standardArguments
();
QString
path
=
page
->
path
();
QString
directory
=
page
->
directory
();
args
<<
"clone"
<<
page
->
repository
()
<<
directory
;
*
checkoutPath
=
path
+
"/"
+
directory
;
return
QSharedPointer
<
VCSBase
::
AbstractCheckoutJob
>
(
new
VCSBase
::
ProcessCheckoutJob
(
settings
->
binary
(),
args
,
path
));
}
src/plugins/mercurial/clonewizard.h
0 → 100644
View file @
989e1b5a
#ifndef CLONEWIZARD_H
#define CLONEWIZARD_H
#include <vcsbase/basecheckoutwizard.h>
#include <vcsbase/checkoutjobs.h>
#include <QtGui/QIcon>
namespace
Mercurial
{
namespace
Internal
{
class
CloneWizard
:
public
VCSBase
::
BaseCheckoutWizard
{
public:
CloneWizard
(
QObject
*
parent
=
0
);
QIcon
icon
()
const
;
QString
description
()
const
;
QString
name
()
const
;
protected:
QList
<
QWizardPage
*>
createParameterPages
(
const
QString
&
path
);
QSharedPointer
<
VCSBase
::
AbstractCheckoutJob
>
createJob
(
const
QList
<
QWizardPage
*>
&
parameterPages
,
QString
*
checkoutPath
);
private:
QIcon
m_icon
;
};
}
//namespace Internal
}
//namespace Mercurial
#endif // CLONEWIZARD_H
src/plugins/mercurial/clonewizardpage.cpp
0 → 100644
View file @
989e1b5a
#include "clonewizardpage.h"
using
namespace
Mercurial
::
Internal
;
CloneWizardPage
::
CloneWizardPage
(
QWidget
*
parent
)
:
VCSBase
::
BaseCheckoutWizardPage
(
parent
)
{
setRepositoryLabel
(
"Clone URL:"
);
}
QString
CloneWizardPage
::
directoryFromRepository
(
const
QString
&
repository
)
const
{
//mercruial repositories are generally of the form protocol://repositoryUrl/repository/
//we are just looking for repository.
QString
repo
=
repository
.
trimmed
();
if
(
repo
.
endsWith
(
'/'
))
repo
=
repo
.
remove
(
-
1
,
1
);
//Take the basename or the repository url
return
repo
.
mid
(
repo
.
lastIndexOf
(
'/'
)
+
1
);
}
src/plugins/mercurial/clonewizardpage.h
0 → 100644
View file @
989e1b5a
#ifndef CLONEWIZARDPAGE_H
#define CLONEWIZARDPAGE_H
#include <vcsbase/basecheckoutwizardpage.h>
namespace
Mercurial
{
namespace
Internal
{
class
CloneWizardPage
:
public
VCSBase
::
BaseCheckoutWizardPage
{
Q_OBJECT
public:
CloneWizardPage
(
QWidget
*
parent
=
0
);
protected:
QString
directoryFromRepository
(
const
QString
&
rrepository
)
const
;
};
}
//namespace Internal
}
//namespace Mercurial
#endif // CLONEWIZARDPAGE_H
src/plugins/mercurial/commiteditor.cpp
0 → 100644
View file @
989e1b5a
#include "commiteditor.h"
#include "mercurialcommitwidget.h"
#include <vcsbase/submitfilemodel.h>
#include <QtCore/QDebug>
#include <QDir> //TODO REMOVE WHEN BASE FILE CHANGES ARE PULLED
using
namespace
Mercurial
::
Internal
;
CommitEditor
::
CommitEditor
(
const
VCSBase
::
VCSBaseSubmitEditorParameters
*
parameters
,
QWidget
*
parent
)
:
VCSBase
::
VCSBaseSubmitEditor
(
parameters
,
new
MercurialCommitWidget
(
parent
)),
fileModel
(
0
)
{
setDisplayName
(
tr
(
"Commit Editor"
));
}
MercurialCommitWidget
*
CommitEditor
::
commitWidget
()
{
return
static_cast
<
MercurialCommitWidget
*>
(
widget
());
}
void
CommitEditor
::
setFields
(
const
QFileInfo
&
repositoryRoot
,
const
QString
&
branch
,
const
QString
&
userName
,
const
QString
&
email
,
const
QList
<
QPair
<
QString
,
QString
>
>
&
repoStatus
)
{
MercurialCommitWidget
*
mercurialWidget
=
commitWidget
();
if
(
!
mercurialWidget
)
return
;
mercurialWidget
->
setFields
(
repositoryRoot
.
absoluteFilePath
(),
branch
,
userName
,
email
);
fileModel
=
new
VCSBase
::
SubmitFileModel
(
this
);
//TODO Messy tidy this up
typedef
QPair
<
QString
,
QString
>
PAIR
;
QStringList
shouldTrack
;
foreach
(
PAIR
status
,
repoStatus
)
{
if
(
status
.
first
==
"Untracked"
)
shouldTrack
.
append
(
status
.
second
);
else
fileModel
->
addFile
(
status
.
second
,
status
.
first
,
false
);
}
VCSBase
::
VCSBaseSubmitEditor
::
filterUntrackedFilesOfProject
(
repositoryRoot
.
absoluteFilePath
(),
&
shouldTrack
);
foreach
(
QString
track
,
shouldTrack
)
{
foreach
(
PAIR
status
,
repoStatus
)
{
if
(
status
.
second
==
track
)
fileModel
->
addFile
(
status
.
second
,
status
.
first
,
false
);
}
}
setFileModel
(
fileModel
);
}
QString
CommitEditor
::
committerInfo
()
{
return
commitWidget
()
->
committer
();
}
QString
CommitEditor
::
repoRoot
()
{
return
commitWidget
()
->
repoRoot
();
}
src/plugins/mercurial/commiteditor.h
0 → 100644
View file @
989e1b5a
#ifndef COMMITEDITOR_H
#define COMMITEDITOR_H
#include <vcsbase/vcsbasesubmiteditor.h>
#include <QtCore/QFileInfo>
namespace
VCSBase
{
class
SubmitFileModel
;
}
namespace
Mercurial
{
namespace
Internal
{
class
MercurialCommitWidget
;
class
CommitEditor
:
public
VCSBase
::
VCSBaseSubmitEditor
{
Q_OBJECT
public:
explicit
CommitEditor
(
const
VCSBase
::
VCSBaseSubmitEditorParameters
*
parameters
,
QWidget
*
parent
);
void
setFields
(
const
QFileInfo
&
repositoryRoot
,
const
QString
&
branch
,
const
QString
&
userName
,
const
QString
&
email
,
const
QList
<
QPair
<
QString
,
QString
>
>
&
repoStatus
);
QString
committerInfo
();
QString
repoRoot
();
private:
inline
MercurialCommitWidget
*
commitWidget
();
VCSBase
::
SubmitFileModel
*
fileModel
;
};
}
}
#endif // COMMITEDITOR_H
src/plugins/mercurial/constants.h
0 → 100644
View file @
989e1b5a
#ifndef CONSTANTS_H
#define CONSTANTS_H
namespace
Mercurial
{
namespace
Constants
{
enum
{
debug
=
1
};
const
char
*
const
MERCURIAL
=
"mercurial"
;
const
char
*
const
MECURIALREPO
=
".hg"
;
const
char
*
const
MERCURIALDEFAULT
=
"hg"
;
//options page items
const
char
*
const
MERCURIALPATH
=
"Mercurial_Path"
;
const
char
*
const
MERCURIALUSERNAME
=
"Mercurial_Username"
;
const
char
*
const
MERCURIALEMAIL
=
"Mercurial_Email"
;
const
char
*
const
MERCURIALLOGCOUNT
=
"Mercurial_LogCount"
;
const
char
*
const
MERCURIALTIMEOUT
=
"Mercurial_Timeout"
;
const
char
*
const
MERCURIALPROMPTSUBMIT
=
"Mercurial_PromptOnSubmit"
;
//changeset identifiers
const
char
*
const
CHANGESETID12
=
" ([a-f0-9]{12,12}) "
;
//match 12 hex chars and capture
const
char
*
const
CHANGESETID40
=
" ([a-f0-9]{40,40}) "
;
const
char
*
const
CHANGEIDEXACT12
=
"[a-f0-9]{12,12}"
;
//match 12 hex chars a
const
char
*
const
CHANGEIDEXACT40
=
"[a-f0-9]{40,40}"
;
const
char
*
const
DIFFIDENTIFIER
=
"^[-+]{3,3} [ab]{1,1}.*"
;
// match e.g. +++ b/filename
//Errors
const
char
*
const
ERRORSTARTING
=
"Unable to start Mercurial Process"
;
const
char
*
const
TIMEDOUT
=
"Timed out waiting for Mercurail Process to Finish"
;
//BaseEditorParameters
const
char
*
const
COMMANDLOG
=
"Mercurial Command Log Editor"
;
const
char
*
const
COMMANDAPP
=
"application/vnd.nokia.text.scs_mercurial_commandlog"
;
const
char
*
const
COMMANDEXT
=
"vcsMercurialCommand"
;
const
char
*
const
FILELOG
=
"Mercurial File Log Editor"
;
const
char
*
const
LOGAPP
=
"application/vnd.nokia.text.scs_mercurial_log"
;
const
char
*
const
LOGEXT
=
"vcsMercurialLog"
;
const
char
*
const
ANNOTATELOG
=
"Mercurial Annotation Editor"
;
const
char
*
const
ANNOTATEAPP
=
"application/vnd.nokia.text.scs_mercurial_annotatelog"
;
const
char
*
const
ANNOTATEEXT
=
"vcsMercurialAnnotate"
;
const
char
*
const
DIFFLOG
=
"Mercurial Diff Editor"
;
const
char
*
const
DIFFAPP
=
"text/x-patch"
;
const
char
*
const
DIFFEXT
=
"diff"
;
//SubmitEditorParameters
const
char
*
const
COMMITKIND
=
"Mercurial Commit Log Editor"
;
const
char
*
const
COMMITMIMETYPE
=
"application/vnd.nokia.text.scs_mercurial_commitlog"
;
#ifndef Q_WS_MAC
const
char
*
const
MODIFIER
=
"Alt+"
;
const
char
*
const
MENUKEY
=
"Alt+H, "
;
#else
const
char
*
const
MODIFIER
=
"Meta+"
;
const
char
*
const
MENUKEY
=
"Meta+H, "
;
#endif
//menu items
//File menu actions
const
char
*
const
ANNOTATE
=
"Mercurial.Annotate"
;
const
char
*
const
DIFF
=
"Mercurial.DiffSingleFile"
;
const
char
*
const
LOG
=
"Mercurial.LogSingleFile"
;
const
char
*
const
REVERT
=
"Mercurial.RevertSingleFile"
;
const
char
*
const
STATUS
=
"Mercurial.Status"
;
//directory menu Actions
const
char
*
const
DIFFMULTI
=
"Mercurial.Action.DiffMulti"
;
const
char
*
const
REVERTMULTI
=
"Mercurial.Action.RevertMulti"
;
const
char
*
const
STATUSMULTI
=
"Mercurial.Action.StatusMulti"
;
const
char
*
const
LOGMULTI
=
"Mercurial.Action.Logmulti"
;
//repository menu actions
const
char
*
const
PULL
=
"Mercurial.Action.Pull"
;
const
char
*
const
PUSH
=
"Mercurial.Action.Push"
;
const
char
*
const
UPDATE
=
"Mercurial.Action.Update"
;
const
char
*
const
IMPORT
=
"Mercurial.Action.Import"
;
const
char
*
const
INCOMING
=
"Mercurial.Action.Incoming"
;
const
char
*
const
OUTGOING
=
"Mercurial.Action.Outgoing"
;
const
char
*
const
COMMIT
=
"Mercurial.Action.Commit"
;
//Repository Management
const
char
*
const
MERGE
=
"Mercurial.Action.Merge"
;
const
char
*
const
BRANCH
=
"Mercurial.Action.Branch"
;
const
char
*
const
HEADS
=
"Mercurial.Action.Heads"
;
const
char
*
const
PARENTS
=
"Mercurial.Action.Parents"
;
const
char
*
const
TAGS
=
"Mercurial.Action.Tags"
;
const
char
*
const
TIP
=
"Mercurial.Action.TIP"
;
const
char
*
const
PATHS
=
"Mercurial.Action.Paths"
;
//Less commonly used menu actions
const
char
*
const
CLONE
=
"Mercurial.Action.Clone"
;
const
char
*
const
INIT
=
"Mercurial.Action.Init"
;
const
char
*
const
SERVE
=
"Mercurial.Action.Serve"
;
//submit editor actions
const
char
*
const
COMMITEDITOR
=
"Mercurial.Action.Editor.Commit"
;
const
char
*
const
DIFFEDITOR
=
"Mercurial.Action.Editor.Diff"
;
}
// namespace Constants
}
// namespace mercurial
#endif // CONSTANTS_H
src/plugins/mercurial/images/hg.png
0 → 100644
View file @
989e1b5a
2.15 KB
src/plugins/mercurial/mercurial.pro
0 → 100644
View file @
989e1b5a
TARGET
=
Mercurial
TEMPLATE
=
lib
include
(..
/../
qtcreatorplugin
.
pri
)
include
(
mercurial_dependencies
.
pri
)
SOURCES
+=
mercurialplugin
.
cpp
\
optionspage
.
cpp
\
mercurialoutputwindow
.
cpp
\
mercurialcontrol
.
cpp
\
mercurialclient
.
cpp
\
mercurialjobrunner
.
cpp
\
annotationhighlighter
.
cpp
\
mercurialeditor
.
cpp
\
revertdialog
.
cpp
\
srcdestdialog
.
cpp
\
mercurialcommitwidget
.
cpp
\
commiteditor
.
cpp
\
clonewizardpage
.
cpp
\
clonewizard
.
cpp
\
mercurialsettings
.
cpp
HEADERS
+=
mercurialplugin
.
h
\
constants
.
h
\
optionspage
.
h
\
mercurialoutputwindow
.
h
\
mercurialcontrol
.
h
\
mercurialclient
.
h
\
mercurialjobrunner
.
h
\
annotationhighlighter
.
h
\
mercurialeditor
.
h
\
revertdialog
.
h
\
srcdestdialog
.
h
\
mercurialcommitwidget
.
h
\
commiteditor
.
h
\
clonewizardpage
.
h
\
clonewizard
.
h
\
mercurialsettings
.
h
OTHER_FILES
+=
Mercurial
.
pluginspec
FORMS
+=
optionspage
.
ui
\
revertdialog
.
ui
\
srcdestdialog
.
ui
\
mercurialcommitpanel
.
ui
RESOURCES
+=
mercurial
.
qrc
src/plugins/mercurial/mercurial.qrc
0 → 100644
View file @
989e1b5a
<RCC>
<qresource prefix="/mercurial" >
<file>images/hg.png</file>
</qresource>
</RCC>
src/plugins/mercurial/mercurial_dependencies.pri
0 → 100644
View file @
989e1b5a
include(../../plugins/projectexplorer/projectexplorer.pri)
include(../../plugins/texteditor/texteditor.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/vcsbase/vcsbase.pri)
include(../../libs/utils/utils.pri)
src/plugins/mercurial/mercurialclient.cpp
0 → 100644
View file @
989e1b5a
#include "mercurialclient.h"
#include "mercurialjobrunner.h"
#include "constants.h"
#include "mercurialsettings.h"
#include "mercurialplugin.h"
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <utils/qtcassert.h>
#include <vcsbase/vcsbaseeditor.h>
#include <QtCore/QStringList>
#include <QtCore/QSharedPointer>
#include <QtCore/QDir>
#include <QtCore/QProcess>
#include <QtCore/QTextCodec>
#include <QtCore/QtDebug>
using
namespace
Mercurial
::
Internal
;
using
namespace
Mercurial
;
inline
Core
::
IEditor
*
locateEditor
(
const
Core
::
ICore
*
core
,
const
char
*
property
,
const
QString
&
entry
)
{
foreach
(
Core
::
IEditor
*
ed
,
core
->
editorManager
()
->
openedEditors
())
if
(
ed
->
file
()
->
property
(
property
).
toString
()
==
entry
)
return
ed
;
return
0
;
}
MercurialClient
::
MercurialClient
()
:
core
(
Core
::
ICore
::
instance
())
{
jobManager
=
new
MercurialJobRunner
();
jobManager
->
start
();
}
MercurialClient
::~
MercurialClient
()
{
if
(
jobManager
)
{
delete
jobManager
;
jobManager
=
0
;
}
}
bool
MercurialClient
::
add
(
const
QString
&
filename
)
{
QFileInfo
file
(
filename
);
QStringList
args
;
args
<<
"add"
<<
file
.
absoluteFilePath
();
return
hgProcessSync
(
file
,
args
);
}
bool
MercurialClient
::
remove
(
const
QString
&
filename
)
{
QFileInfo
file
(
filename
);
QStringList
args
;
args
<<
"remove"
<<
file
.
absoluteFilePath
();
return
hgProcessSync
(
file
,
args
);
}
bool
MercurialClient
::
manifestSync
(
const
QString
&
filename
)
{
QFileInfo
file
(
filename
);
QStringList
args
(
"manifest"
);
QByteArray
output
;
hgProcessSync
(
file
,
args
,
&
output
);
QStringList
files
=
QString
::
fromLocal8Bit
(
output
).
split
(
'\n'
);
foreach
(
QString
fileName
,
files
)
{
QFileInfo
managedFile
(
filename
);
if
(
file
==
managedFile
)
return
true
;
}
return
false
;
}
bool
MercurialClient
::
hgProcessSync
(
const
QFileInfo
&
file
,
const
QStringList
&
args
,
QByteArray
*
output
)
const
{
QProcess
hgProcess
;
hgProcess
.
setWorkingDirectory
(
file
.
isDir
()
?
file
.
absoluteFilePath
()
:
file
.
absolutePath
());
MercurialSettings
*
settings
=
MercurialPlugin
::
instance
()
->
settings
();
QStringList
arguments
=
settings
->
standardArguments
();
arguments
<<
args
;
hgProcess
.
start
(
settings
->
binary
(),
arguments
);
if
(
!
hgProcess
.
waitForStarted
())
return
false
;
hgProcess
.
closeWriteChannel
();
if
(
!
hgProcess
.
waitForFinished
(
settings
->
timeout
()))
{
hgProcess
.
terminate
();
return
false
;
}
if
((
hgProcess
.
exitStatus
()
==
QProcess
::
NormalExit
)
&&
(
hgProcess
.
exitCode
()
==
0
))
{
if
(
output
)
*
output
=
hgProcess
.
readAllStandardOutput
();
return
true
;
}
return
false
;
}
QString
MercurialClient
::
branchQuerySync
(
const
QFileInfo
&
repositoryRoot
)
{
QByteArray
output
;
if
(
hgProcessSync
(
repositoryRoot
,
QStringList
(
"branch"
),
&
output
))
return
QTextCodec
::
codecForLocale
()
->
toUnicode
(
output
).
trimmed
();