118 cfgFile = getConfigPath() |
118 cfgFile = getConfigPath() |
119 if os.path.exists(cfgFile): |
119 if os.path.exists(cfgFile): |
120 self.__iniWatcher.addPath(cfgFile) |
120 self.__iniWatcher.addPath(cfgFile) |
121 |
121 |
122 self.__client = None |
122 self.__client = None |
|
123 |
|
124 self.__repoDir = "" |
|
125 self.__repoIniFile = "" |
|
126 self.__defaultConfigured = False |
|
127 self.__defaultPushConfigured = False |
123 |
128 |
124 # instantiate the extensions |
129 # instantiate the extensions |
125 from .BookmarksExtension.bookmarks import Bookmarks |
130 from .BookmarksExtension.bookmarks import Bookmarks |
126 from .QueuesExtension.queues import Queues |
131 from .QueuesExtension.queues import Queues |
127 from .FetchExtension.fetch import Fetch |
132 from .FetchExtension.fetch import Fetch |
3214 subrepoPath = removedSubrepo.split("=", 1)[0].strip() |
3219 subrepoPath = removedSubrepo.split("=", 1)[0].strip() |
3215 subrepoAbsPath = os.path.join(ppath, subrepoPath) |
3220 subrepoAbsPath = os.path.join(ppath, subrepoPath) |
3216 shutil.rmtree(subrepoAbsPath, True) |
3221 shutil.rmtree(subrepoAbsPath, True) |
3217 |
3222 |
3218 ########################################################################### |
3223 ########################################################################### |
3219 ## Methods to handle extensions are below. |
3224 ## Methods to handle configuration dependent stuff are below. |
3220 ########################################################################### |
3225 ########################################################################### |
|
3226 |
|
3227 def __checkDefaults(self): |
|
3228 """ |
|
3229 Private method to check, if the default and default-push URLs |
|
3230 have been configured. |
|
3231 """ |
|
3232 args = [] |
|
3233 args.append('showconfig') |
|
3234 args.append('paths') |
|
3235 |
|
3236 output = "" |
|
3237 if self.__client is None: |
|
3238 process = QProcess() |
|
3239 self.__repoDir and process.setWorkingDirectory(self.__repoDir) |
|
3240 process.start('hg', args) |
|
3241 procStarted = process.waitForStarted(5000) |
|
3242 if procStarted: |
|
3243 finished = process.waitForFinished(30000) |
|
3244 if finished and process.exitCode() == 0: |
|
3245 output = str( |
|
3246 process.readAllStandardOutput(), |
|
3247 Preferences.getSystem("IOEncoding"), 'replace') |
|
3248 else: |
|
3249 output, error = self.__client.runcommand(args) |
|
3250 |
|
3251 if output: |
|
3252 self.__defaultConfigured = False |
|
3253 self.__defaultPushConfigured = False |
|
3254 for line in output.splitlines(): |
|
3255 if line.startswith("paths.default=") and \ |
|
3256 not line.strip().endswith("="): |
|
3257 self.__defaultConfigured = True |
|
3258 if line.startswith("paths.default-push=") and \ |
|
3259 not line.strip().endswith("="): |
|
3260 self.__defaultPushConfigured = True |
|
3261 |
|
3262 def canPull(self): |
|
3263 """ |
|
3264 Public method to check, if pull is possible. |
|
3265 |
|
3266 @return flag indicating pull capability (boolean) |
|
3267 """ |
|
3268 return self.__defaultConfigured |
|
3269 |
|
3270 def canPush(self): |
|
3271 """ |
|
3272 Public method to check, if push is possible. |
|
3273 |
|
3274 @return flag indicating push capability (boolean) |
|
3275 """ |
|
3276 return self.__defaultPushConfigured or self.__defaultConfigured |
3221 |
3277 |
3222 def __iniFileChanged(self, path): |
3278 def __iniFileChanged(self, path): |
3223 """ |
3279 """ |
3224 Private slot to handle a change of the Mercurial configuration file. |
3280 Private slot to handle a change of the Mercurial configuration file. |
3225 |
3281 |
3235 self.tr("Mercurial Command Server"), |
3291 self.tr("Mercurial Command Server"), |
3236 self.tr( |
3292 self.tr( |
3237 """<p>The Mercurial Command Server could not be""" |
3293 """<p>The Mercurial Command Server could not be""" |
3238 """ restarted.</p><p>Reason: {0}</p>""").format(err)) |
3294 """ restarted.</p><p>Reason: {0}</p>""").format(err)) |
3239 self.__client = None |
3295 self.__client = None |
|
3296 |
|
3297 if self.__repoIniFile and path == self.__repoIniFile: |
|
3298 self.__checkDefaults() |
3240 |
3299 |
3241 def __monitorRepoIniFile(self, name): |
3300 def __monitorRepoIniFile(self, name): |
3242 """ |
3301 """ |
3243 Private slot to add a repository configuration file to the list of |
3302 Private slot to add a repository configuration file to the list of |
3244 monitored files. |
3303 monitored files. |
3255 return |
3314 return |
3256 |
3315 |
3257 cfgFile = os.path.join(repodir, self.adminDir, "hgrc") |
3316 cfgFile = os.path.join(repodir, self.adminDir, "hgrc") |
3258 if os.path.exists(cfgFile): |
3317 if os.path.exists(cfgFile): |
3259 self.__iniWatcher.addPath(cfgFile) |
3318 self.__iniWatcher.addPath(cfgFile) |
|
3319 self.__repoIniFile = cfgFile |
|
3320 self.__checkDefaults() |
|
3321 |
|
3322 ########################################################################### |
|
3323 ## Methods to handle extensions are below. |
|
3324 ########################################################################### |
3260 |
3325 |
3261 def __getExtensionsInfo(self): |
3326 def __getExtensionsInfo(self): |
3262 """ |
3327 """ |
3263 Private method to get the active extensions from Mercurial. |
3328 Private method to get the active extensions from Mercurial. |
3264 """ |
3329 """ |
3270 args.append('extensions') |
3335 args.append('extensions') |
3271 |
3336 |
3272 output = "" |
3337 output = "" |
3273 if self.__client is None: |
3338 if self.__client is None: |
3274 process = QProcess() |
3339 process = QProcess() |
|
3340 self.__repoDir and process.setWorkingDirectory(self.__repoDir) |
3275 process.start('hg', args) |
3341 process.start('hg', args) |
3276 procStarted = process.waitForStarted(5000) |
3342 procStarted = process.waitForStarted(5000) |
3277 if procStarted: |
3343 if procStarted: |
3278 finished = process.waitForFinished(30000) |
3344 finished = process.waitForFinished(30000) |
3279 if finished and process.exitCode() == 0: |
3345 if finished and process.exitCode() == 0: |
3347 Public method to instantiate a helper object for the project. |
3413 Public method to instantiate a helper object for the project. |
3348 |
3414 |
3349 @param project reference to the project object |
3415 @param project reference to the project object |
3350 @return the project helper object |
3416 @return the project helper object |
3351 """ |
3417 """ |
|
3418 # find the root of the repo |
|
3419 repodir = project.getProjectPath() |
|
3420 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
|
3421 repodir = os.path.dirname(repodir) |
|
3422 if not repodir or os.path.splitdrive(repodir)[1] == os.sep: |
|
3423 repodir = "" |
|
3424 break |
|
3425 if repodir: |
|
3426 self.__repoDir = repodir |
|
3427 |
3352 self.__projectHelper = self.__plugin.getProjectHelper() |
3428 self.__projectHelper = self.__plugin.getProjectHelper() |
3353 self.__projectHelper.setObjects(self, project) |
3429 self.__projectHelper.setObjects(self, project) |
3354 self.__monitorRepoIniFile(project.getProjectPath()) |
3430 self.__monitorRepoIniFile(project.getProjectPath()) |
3355 |
3431 |
3356 if not Utilities.isMacPlatform() and self.version >= (1, 9): |
3432 if not Utilities.isMacPlatform() and \ |
3357 # find the root of the repo |
3433 self.version >= (1, 9) and \ |
3358 repodir = project.getProjectPath() |
3434 repodir: |
3359 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
3435 from .HgClient import HgClient |
3360 repodir = os.path.dirname(repodir) |
3436 client = HgClient(repodir, "utf-8", self) |
3361 if not repodir or os.path.splitdrive(repodir)[1] == os.sep: |
3437 ok, err = client.startServer() |
3362 repodir = "" |
3438 if ok: |
3363 break |
3439 self.__client = client |
3364 if repodir: |
3440 else: |
3365 from .HgClient import HgClient |
3441 E5MessageBox.warning( |
3366 client = HgClient(repodir, "utf-8", self) |
3442 None, |
3367 ok, err = client.startServer() |
3443 self.tr("Mercurial Command Server"), |
3368 if ok: |
3444 self.tr( |
3369 self.__client = client |
3445 """<p>The Mercurial Command Server could not be""" |
3370 else: |
3446 """ started.</p><p>Reason: {0}</p>""").format(err)) |
3371 E5MessageBox.warning( |
|
3372 None, |
|
3373 self.tr("Mercurial Command Server"), |
|
3374 self.tr( |
|
3375 """<p>The Mercurial Command Server could not be""" |
|
3376 """ started.</p><p>Reason: {0}</p>""").format(err)) |
|
3377 |
3447 |
3378 return self.__projectHelper |
3448 return self.__projectHelper |
3379 |
3449 |
3380 ########################################################################### |
3450 ########################################################################### |
3381 ## Status Monitor Thread methods |
3451 ## Status Monitor Thread methods |