# eric4.VCS.VersionControl

Module implementing an abstract base class to be subclassed by all specific VCS interfaces.

### Global Attributes

None

### Classes

VersionControl | Class implementing an abstract base class to be subclassed by all specific VCS interfaces.

### Functions

None

## VersionControl

Class implementing an abstract base class to be subclassed by all specific VCS interfaces.

It defines the vcs interface to be implemented by subclasses and the common methods.

### Signals

vcsStatusMonitorData(QStringList)
  emitted to update the VCS status
vcsStatusMonitorStatus(QString, QString)
  emitted to signal the status of the monitoring thread (ok, nok, op, off) and a status message

### Derived from

QObject

### Class Attributes

canBeAdded
canBeCommitted

### Class Methods

None

### Methods

VersionControl | Constructor
__statusMonitorData | Private method to receive the status monitor status.
__statusMonitorStatus | Private method to receive the status monitor status.
_createStatusMonitorThread | Protected method to create an instance of the VCS status monitor thread.
addArguments | Protected method to add an argument list to the already present arguments.
checkVCSStatus | Public method to wake up the VCS status monitor thread.
clearStatusCache | Public method to clear the status cache.
clearStatusMonitorCachedState | Public method to clear the cached VCS state of a file/directory.
getStatusMonitorAutoUpdate | Public method to retrieve the status of the auto update function.
getStatusMonitorInterval | Public method to get the monitor interval.
setStatusMonitorAutoUpdate | Public method to enable the auto update function.
setStatusMonitorInterval | Public method to change the monitor interval.
splitPath | Public method splitting name into a directory part and a file part.
splitPathList | Public method splitting the list of names into a common directory part and a file list.
startStatusMonitor | Public method to start the VCS status monitor thread.
startSynchronizedProcess | Public method to start a synchroneous process
stopStatusMonitor | Public method to stop the VCS status monitor thread.
vcsAdd | Public method used to add a file/directory in the vcs.
vcsAddBinary | Public method used to add a file/directory in binary mode in the vcs.
vcsAddTree | Public method to add a directory tree rooted at path in the vcs.
vcsAllRegisteredStates | Public method used to get the registered states of a number of files in the vcs.
vcsCheckout | Public method used to check the project out of the vcs.
vcsCleanup | Public method used to cleanup the local copy.
vcsCommandLine | Public method used to execute arbitrary vcs commands.
vcsCommit | Public method used to make the change of a file/directory permanent in the vcs.
vcsConvertProject | Public method to convert an uncontrolled project to a version controlled project.
vcsDefaultOptions | Public method used to retrieve the default options for the vcs.
vcsDiff | Public method used to view the diff of a file/directory in the vcs.
vcsExists | Public method used to test for the presence of the vcs.
vcsExport | Public method used to export a directory from the vcs.
vcsGetOptions | Public method used to retrieve the options of the vcs.
vcsGetOtherData | Public method used to retrieve vcs specific data.
vcsGetProjectBrowserHelper | Public method to instanciate a helper object for the different project browsers.
vcsGetProjectHelper | Public method to instanciate a helper object for the project.
vcsHistory | Public method used to view the history of a file/directory in the vcs.
vcsImport | Public method used to import the project into the vcs.
vcsInit | Public method used to initialize the vcs.
vcsLog | Public method used to view the log of a file/directory in the vcs.
vcsMerge | Public method used to merge a tag/branch into the local project.
vcsMove | Public method used to move a file/directory.
vcsName | Public method returning the name of the vcs.
vcsNewProjectOptionsDialog | Public method to get a dialog to enter repository info for getting a new project.
vcsOptionsDialog | Public method to get a dialog to enter repository info.
vcsRegisteredState | Public method used to get the registered state of a file in the vcs.
vcsRemove | Public method used to add a file/directory in the vcs.
vcsRepositoryInfos | Public method to retrieve information about the repository.
vcsRevert | Public method used to revert changes made to a file/directory.
vcsSetData | Public method used to set an entry in the otherData dictionary.
vcsSetDataFromDict | Public method used to set entries in the otherData dictionary.
vcsSetOptions | Public method used to set the options for the vcs.
vcsSetOtherData | Public method used to set vcs specific data.
vcsShutdown | Public method used to shutdown the vcs interface.
vcsStatus | Public method used to view the status of a file/directory in the vcs.
vcsSwitch | Public method used to switch a directory to a different tag/branch.
vcsTag | Public method used to set the tag of a file/directory in the vcs.
vcsUpdate | Public method used to update a file/directory in the vcs.

### Static Methods

None

#### VersionControl (Constructor)

VersionControl(parent=None, name=None)

Constructor

parent
  parent widget (QWidget)
name
  name of this object (string or QString)

#### VersionControl.__statusMonitorData

__statusMonitorData(statusList)

Private method to receive the status monitor status.

It simply reemits the received status list.

statusList
  list of status records (QStringList)

#### VersionControl.__statusMonitorStatus

__statusMonitorStatus(status, statusMsg)

Private method to receive the status monitor status.

It simply reemits the received status.

status
  status of the monitoring thread (QString, ok, nok or off)
statusMsg
  explanotory text for the signaled status (QString)

#### VersionControl._createStatusMonitorThread

_createStatusMonitorThread(interval, project)

Protected method to create an instance of the VCS status monitor thread.

Note: This method should be overwritten in subclasses in order to support VCS status monitoring.

interval
  check interval for the monitor thread in seconds (integer)
project
  reference to the project object

Returns:
  reference to the monitor thread (QThread)

#### VersionControl.addArguments

addArguments(args, argslist)

Protected method to add an argument list to the already present arguments.

args
  current arguments list (QStringList)
argslist
  list of arguments (list of strings or list of QStrings or a QStringList)

#### VersionControl.checkVCSStatus

checkVCSStatus()

Public method to wake up the VCS status monitor thread.

#### VersionControl.clearStatusCache

clearStatusCache()

Public method to clear the status cache.

#### VersionControl.clearStatusMonitorCachedState

clearStatusMonitorCachedState(name)

Public method to clear the cached VCS state of a file/directory.

name
  name of the entry to be cleared (QString or string)

#### VersionControl.getStatusMonitorAutoUpdate

getStatusMonitorAutoUpdate()

Public method to retrieve the status of the auto update function.

Returns:
  status of the auto update function (boolean)

#### VersionControl.getStatusMonitorInterval

getStatusMonitorInterval()

Public method to get the monitor interval.

Returns:
  interval in seconds (integer)

#### VersionControl.setStatusMonitorAutoUpdate

setStatusMonitorAutoUpdate(auto)

Public method to enable the auto update function.

auto
  status of the auto update function (boolean)

#### VersionControl.setStatusMonitorInterval

setStatusMonitorInterval(interval, project)

Public method to change the monitor interval.

interval
  new interval in seconds (integer)
project
  reference to the project object

#### VersionControl.splitPath

splitPath(name)

Public method splitting name into a directory part and a file part.

name
  path name (string)

Returns:
  a tuple of 2 strings (dirname, filename).

#### VersionControl.splitPathList

splitPathList(names)

Public method splitting the list of names into a common directory part and a file list.

names
  list of paths (list of strings)

Returns:
  a tuple of string and list of strings (dirname, filenamelist)

#### VersionControl.startStatusMonitor

startStatusMonitor(project)

Public method to start the VCS status monitor thread.

project
  reference to the project object

Returns:
  reference to the monitor thread (QThread)

#### VersionControl.startSynchronizedProcess

startSynchronizedProcess(proc, program, arguments, workingDir = None)

Public method to start a synchroneous process

This method starts a process and waits for its end while still serving the Qt event loop.

proc
  process to start (QProcess)
program
  path of the executable to start (string or QString)
arguments
  list of arguments for the process (QStringList)
workingDir
  working directory for the process (string or QString)

Returns:
  flag indicating normal exit (boolean)

#### VersionControl.stopStatusMonitor

stopStatusMonitor()

Public method to stop the VCS status monitor thread.

#### VersionControl.vcsAdd

vcsAdd(name, isDir = False, noDialog = False)

Public method used to add a file/directory in the vcs.

It must not return anything.

name
  file/directory name to be added (string)
isDir
  flag indicating name is a directory (boolean)
noDialog
  flag indicating quiet operations (boolean)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsAddBinary

vcsAddBinary(name, isDir = False)

Public method used to add a file/directory in binary mode in the vcs.

It must not return anything.

name
  file/directory name to be added (string)
isDir
  flag indicating name is a directory (boolean)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsAddTree

vcsAddTree(path)

Public method to add a directory tree rooted at path in the vcs.

It must not return anything.

path
  root directory of the tree to be added (string)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsAllRegisteredStates

vcsAllRegisteredStates(names, dname)

Public method used to get the registered states of a number of files in the vcs.

names
  dictionary with all filenames to be checked as keys
dname
  directory to check in (string)

Returns:
  the received dictionary completed with a combination of canBeCommited and canBeAdded or None in order to signal an error

Raises RuntimeError:
  not implemented

#### VersionControl.vcsCheckout

vcsCheckout(vcsDataDict, projectDir, noDialog = False)

Public method used to check the project out of the vcs.

vcsDataDict
  dictionary of data required for the checkout
projectDir
  project directory to create (string)
noDialog
  flag indicating quiet operations

Returns:
  flag indicating an execution without errors (boolean)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsCleanup

vcsCleanup(name)

Public method used to cleanup the local copy.

name
  directory name to be cleaned up (string)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsCommandLine

vcsCommandLine(name)

Public method used to execute arbitrary vcs commands.

name
  directory name of the working directory (string)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsCommit

vcsCommit(name, message, noDialog = False)

Public method used to make the change of a file/directory permanent in the vcs.

It must return a boolean to indicate an execution without errors.

name
  file/directory name to be committed (string)
message
  message for this operation (string)
noDialog
  flag indicating quiet operations

Raises RuntimeError:
  not implemented

#### VersionControl.vcsConvertProject

vcsConvertProject(vcsDataDict, project)

Public method to convert an uncontrolled project to a version controlled project.

vcsDataDict
  dictionary of data required for the conversion
project
  reference to the project object

Raises RuntimeError:
  not implemented

#### VersionControl.vcsDefaultOptions

vcsDefaultOptions()

Public method used to retrieve the default options for the vcs.

Returns:
  a dictionary with the vcs operations as key and the respective options as values. The key 'global' must contain the global options. The other keys must be 'commit', 'update', 'add', 'remove', 'diff', 'log', 'history', 'tag', 'status' and 'export'.

#### VersionControl.vcsDiff

vcsDiff(name)

Public method used to view the diff of a file/directory in the vcs.

It must not return anything.

name
  file/directory name to be diffed (string)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsExists

vcsExists()

Public method used to test for the presence of the vcs.

It must return a bool to indicate the existance and a QString giving an error message in case of failure.

Raises RuntimeError:
  not implemented

#### VersionControl.vcsExport

vcsExport(vcsDataDict, projectDir)

Public method used to export a directory from the vcs.

It must return a boolean to indicate an execution without errors.

vcsDataDict
  dictionary of data required for the export
projectDir
  project directory to create (string)

Returns:
  flag indicating an execution without errors (boolean)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsGetOptions

vcsGetOptions()

Public method used to retrieve the options of the vcs.

Returns:
  a dictionary of option strings that can be passed to vcsSetOptions.

#### VersionControl.vcsGetOtherData

vcsGetOtherData()

Public method used to retrieve vcs specific data.

Returns:
  a dictionary of vcs specific data

#### VersionControl.vcsGetProjectBrowserHelper

vcsGetProjectBrowserHelper(browser, project, isTranslationsBrowser = False)

Public method to instanciate a helper object for the different project browsers.

browser
  reference to the project browser object
project
  reference to the project object
isTranslationsBrowser
  flag indicating, the helper is requested for the translations browser (this needs some special treatment)

Returns:
  the project browser helper object

#### VersionControl.vcsGetProjectHelper

vcsGetProjectHelper(project)

Public method to instanciate a helper object for the project.

project
  reference to the project object

Returns:
  the project helper object

#### VersionControl.vcsHistory

vcsHistory(name)

Public method used to view the history of a file/directory in the vcs.

It must not return anything.

name
  file/directory name to show the history for (string)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsImport

vcsImport(vcsDataDict, projectDir, noDialog = False)

Public method used to import the project into the vcs.

vcsDataDict
  dictionary of data required for the import
projectDir
  project directory (string)
noDialog
  flag indicating quiet operations

Returns:
  flag indicating an execution without errors (boolean) and a flag indicating the version controll status (boolean)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsInit

vcsInit(vcsDir, noDialog = False)

Public method used to initialize the vcs.

It must return a boolean to indicate an execution without errors.

vcsDir
  name of the VCS directory (string)
noDialog
  flag indicating quiet operations (boolean)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsLog

vcsLog(name)

Public method used to view the log of a file/directory in the vcs.

It must not return anything.

name
  file/directory name to show the log for (string)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsMerge

vcsMerge(name)

Public method used to merge a tag/branch into the local project.

It must not return anything.

name
  file/directory name to be merged (string)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsMove

vcsMove(name, project, target = None, noDialog = False)

Public method used to move a file/directory.

name
  file/directory name to be moved (string)
project
  reference to the project object
target
  new name of the file/directory (string)
noDialog
  flag indicating quiet operations

Returns:
  flag indicating successfull operation (boolean)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsName

vcsName()

Public method returning the name of the vcs.

Returns:
  name of the vcs (string)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsNewProjectOptionsDialog

vcsNewProjectOptionsDialog(parent = None)

Public method to get a dialog to enter repository info for getting a new project.

parent
  parent widget (QWidget)

#### VersionControl.vcsOptionsDialog

vcsOptionsDialog(project, archive, editable = False, parent = None)

Public method to get a dialog to enter repository info.

project
  reference to the project object
archive
  name of the project in the repository (string)
editable
  flag indicating that the project name is editable (boolean)
parent
  parent widget (QWidget)

#### VersionControl.vcsRegisteredState

vcsRegisteredState(name)

Public method used to get the registered state of a file in the vcs.

name
  filename to check (string)

Returns:
  a combination of canBeCommited and canBeAdded or 0 in order to signal an error

Raises RuntimeError:
  not implemented

#### VersionControl.vcsRemove

vcsRemove(name, project = False, noDialog = False)

Public method used to add a file/directory in the vcs.

It must return a flag indicating successfull operation

name
  file/directory name to be removed (string)
project
  flag indicating deletion of a project tree (boolean)
noDialog
  flag indicating quiet operations

Raises RuntimeError:
  not implemented

#### VersionControl.vcsRepositoryInfos

vcsRepositoryInfos(ppath)

Public method to retrieve information about the repository.

ppath
  local path to get the repository infos (string)

Returns:
  string with ready formated info for display (QString)

#### VersionControl.vcsRevert

vcsRevert(name)

Public method used to revert changes made to a file/directory.

It must not return anything.

name
  file/directory name to be reverted (string)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsSetData

vcsSetData(key, value)

Public method used to set an entry in the otherData dictionary.

key
  the key of the data (string)
value
  the value of the data

#### VersionControl.vcsSetDataFromDict

vcsSetDataFromDict(dict)

Public method used to set entries in the otherData dictionary.

dict
  dictionary to pick entries from

#### VersionControl.vcsSetOptions

vcsSetOptions(options)

Public method used to set the options for the vcs.

options
  a dictionary of option strings with keys as defined by the default options

#### VersionControl.vcsSetOtherData

vcsSetOtherData(data)

Public method used to set vcs specific data.

data
  a dictionary of vcs specific data

#### VersionControl.vcsShutdown

vcsShutdown()

Public method used to shutdown the vcs interface.

#### VersionControl.vcsStatus

vcsStatus(name)

Public method used to view the status of a file/directory in the vcs.

It must not return anything.

name
  file/directory name to show the status for (string)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsSwitch

vcsSwitch(name)

Public method used to switch a directory to a different tag/branch.

It must not return anything.

name
  directory name to be switched (string)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsTag

vcsTag(name)

Public method used to set the tag of a file/directory in the vcs.

It must not return anything.

name
  file/directory name to be tagged (string)

Raises RuntimeError:
  not implemented

#### VersionControl.vcsUpdate

vcsUpdate(name, noDialog = False)

Public method used to update a file/directory in the vcs.

It must not return anything.

name
  file/directory name to be updated (string)
noDialog
  flag indicating quiet operations (boolean)

Returns:
  flag indicating, that the update contained an add or delete (boolean)

Raises RuntimeError:
  not implemented

Up