392 if os.path.exists(os.path.join(projectDir, Hg.IgnoreFileName)): |
392 if os.path.exists(os.path.join(projectDir, Hg.IgnoreFileName)): |
393 os.remove(os.path.join(projectDir, Hg.IgnoreFileName)) |
393 os.remove(os.path.join(projectDir, Hg.IgnoreFileName)) |
394 return status |
394 return status |
395 |
395 |
396 def vcsCommit(self, name, message, noDialog=False, closeBranch=False, |
396 def vcsCommit(self, name, message, noDialog=False, closeBranch=False, |
397 mq=False): |
397 mq=False, merge=False): |
398 """ |
398 """ |
399 Public method used to make the change of a file/directory permanent |
399 Public method used to make the change of a file/directory permanent |
400 in the Mercurial repository. |
400 in the Mercurial repository. |
401 |
401 |
402 @param name file/directory name to be committed (string or list of |
402 @param name file/directory name to be committed (string or list of |
403 strings) |
403 strings) |
404 @param message message for this operation (string) |
404 @param message message for this operation (string) |
405 @param noDialog flag indicating quiet operations |
405 @param noDialog flag indicating quiet operations |
406 @keyparam closeBranch flag indicating a close branch commit (boolean) |
406 @keyparam closeBranch flag indicating a close branch commit (boolean) |
407 @keyparam mq flag indicating a queue commit (boolean) |
407 @keyparam mq flag indicating a queue commit (boolean) |
|
408 @keyparam merge flag indicating a merge commit (boolean) |
408 """ |
409 """ |
409 msg = message |
410 msg = message |
410 |
411 |
411 if mq: |
412 if mq or merge: |
412 # ensure dialog is shown for a queue commit |
413 # ensure dialog is shown for a queue commit |
413 noDialog = False |
414 noDialog = False |
414 |
415 |
415 if not noDialog: |
416 if not noDialog: |
416 # call CommitDialog and get message from there |
417 # call CommitDialog and get message from there |
417 if self.__commitDialog is None: |
418 if self.__commitDialog is None: |
418 from .HgCommitDialog import HgCommitDialog |
419 from .HgCommitDialog import HgCommitDialog |
419 self.__commitDialog = HgCommitDialog(self, msg, mq, self.__ui) |
420 self.__commitDialog = HgCommitDialog(self, msg, mq, merge, |
|
421 self.__ui) |
420 self.__commitDialog.accepted.connect(self.__vcsCommit_Step2) |
422 self.__commitDialog.accepted.connect(self.__vcsCommit_Step2) |
421 self.__commitDialog.show() |
423 self.__commitDialog.show() |
422 self.__commitDialog.raise_() |
424 self.__commitDialog.raise_() |
423 self.__commitDialog.activateWindow() |
425 self.__commitDialog.activateWindow() |
424 |
426 |
425 self.__commitData["name"] = name |
427 self.__commitData["name"] = name |
426 self.__commitData["msg"] = msg |
428 self.__commitData["msg"] = msg |
427 self.__commitData["noDialog"] = noDialog |
429 self.__commitData["noDialog"] = noDialog |
428 self.__commitData["closeBranch"] = closeBranch |
430 self.__commitData["closeBranch"] = closeBranch |
429 self.__commitData["mq"] = mq |
431 self.__commitData["mq"] = mq |
|
432 self.__commitData["merge"] = merge |
430 |
433 |
431 if noDialog: |
434 if noDialog: |
432 self.__vcsCommit_Step2() |
435 self.__vcsCommit_Step2() |
433 |
436 |
434 def __vcsCommit_Step2(self): |
437 def __vcsCommit_Step2(self): |
438 name = self.__commitData["name"] |
441 name = self.__commitData["name"] |
439 msg = self.__commitData["msg"] |
442 msg = self.__commitData["msg"] |
440 noDialog = self.__commitData["noDialog"] |
443 noDialog = self.__commitData["noDialog"] |
441 closeBranch = self.__commitData["closeBranch"] |
444 closeBranch = self.__commitData["closeBranch"] |
442 mq = self.__commitData["mq"] |
445 mq = self.__commitData["mq"] |
|
446 merge = self.__commitData["merge"] |
443 |
447 |
444 if not noDialog: |
448 if not noDialog: |
445 # check, if there are unsaved changes, that should be committed |
449 # check, if there are unsaved changes, that should be committed |
446 if isinstance(name, list): |
450 if isinstance(name, list): |
447 nameList = name |
451 nameList = name |
2132 res = dia.startProcess(args, repodir) |
2138 res = dia.startProcess(args, repodir) |
2133 if res: |
2139 if res: |
2134 dia.exec_() |
2140 dia.exec_() |
2135 self.checkVCSStatus() |
2141 self.checkVCSStatus() |
2136 |
2142 |
2137 def hgCancelMerge(self, name): |
2143 def hgAbortMerge(self, name): |
2138 """ |
2144 """ |
2139 Public method to cancel an uncommitted merge. |
2145 Public method to abort an uncommitted merge. |
2140 |
2146 |
2141 @param name file/directory name (string) |
2147 @param name file/directory name (string) |
2142 @return flag indicating, that the cancellation contained an add |
2148 @return flag indicating, that the abortion contained an add |
2143 or delete (boolean) |
2149 or delete (boolean) |
2144 """ |
2150 """ |
2145 dname, fname = self.splitPath(name) |
2151 dname, fname = self.splitPath(name) |
2146 |
2152 |
2147 # find the root of the repo |
2153 # find the root of the repo |
3348 self.__defaultConfigured = True |
3354 self.__defaultConfigured = True |
3349 if line.startswith("paths.default-push=") and \ |
3355 if line.startswith("paths.default-push=") and \ |
3350 not line.strip().endswith("="): |
3356 not line.strip().endswith("="): |
3351 self.__defaultPushConfigured = True |
3357 self.__defaultPushConfigured = True |
3352 |
3358 |
|
3359 def canCommitMerge(self, name): |
|
3360 """ |
|
3361 Public method to check if the working directory is uncommitted merge. |
|
3362 |
|
3363 @param name file/directory name (string) |
|
3364 |
|
3365 @return flag indicating commit merge capability (boolean) |
|
3366 """ |
|
3367 dname, fname = self.splitPath(name) |
|
3368 |
|
3369 # find the root of the repo |
|
3370 repodir = dname |
|
3371 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
|
3372 repodir = os.path.dirname(repodir) |
|
3373 if os.path.splitdrive(repodir)[1] == os.sep: |
|
3374 return |
|
3375 |
|
3376 args = self.initCommand("identify") |
|
3377 |
|
3378 output = "" |
|
3379 if self.__client is None: |
|
3380 process = QProcess() |
|
3381 process.setWorkingDirectory(repodir) |
|
3382 process.start('hg', args) |
|
3383 procStarted = process.waitForStarted(5000) |
|
3384 if procStarted: |
|
3385 finished = process.waitForFinished(30000) |
|
3386 if finished and process.exitCode() == 0: |
|
3387 output = str(process.readAllStandardOutput(), |
|
3388 self.getEncoding(), 'replace') |
|
3389 else: |
|
3390 output, error = self.__client.runcommand(args) |
|
3391 |
|
3392 if output.count('+') == 2: |
|
3393 return True |
|
3394 else: |
|
3395 return False |
|
3396 |
3353 def canPull(self): |
3397 def canPull(self): |
3354 """ |
3398 """ |
3355 Public method to check, if pull is possible. |
3399 Public method to check, if pull is possible. |
3356 |
3400 |
3357 @return flag indicating pull capability (boolean) |
3401 @return flag indicating pull capability (boolean) |