eric6/Plugins/VcsPlugins/vcsMercurial/hg.py

changeset 7153
ca02892fde13
parent 7152
a99df2004bb7
child 7155
334c7d0b5036
equal deleted inserted replaced
7150:cfe71cde2eec 7153:ca02892fde13
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
507 511
508 args = self.initCommand("commit") 512 args = self.initCommand("commit")
509 args.append("-v") 513 args.append("-v")
510 if mq: 514 if mq:
511 args.append("--mq") 515 args.append("--mq")
516 elif merge:
517 if author:
518 args.append("--user")
519 args.append(author)
520 if dateTime:
521 args.append("--date")
522 args.append(dateTime)
512 else: 523 else:
513 if closeBranch: 524 if closeBranch:
514 args.append("--close-branch") 525 args.append("--close-branch")
515 if amend: 526 if amend:
516 args.append("--amend") 527 args.append("--amend")
2132 res = dia.startProcess(args, repodir) 2143 res = dia.startProcess(args, repodir)
2133 if res: 2144 if res:
2134 dia.exec_() 2145 dia.exec_()
2135 self.checkVCSStatus() 2146 self.checkVCSStatus()
2136 2147
2137 def hgCancelMerge(self, name): 2148 def hgAbortMerge(self, name):
2138 """ 2149 """
2139 Public method to cancel an uncommitted merge. 2150 Public method to abort an uncommitted merge.
2140 2151
2141 @param name file/directory name (string) 2152 @param name file/directory name (string)
2142 @return flag indicating, that the cancellation contained an add 2153 @return flag indicating, that the abortion contained an add
2143 or delete (boolean) 2154 or delete (boolean)
2144 """ 2155 """
2145 dname, fname = self.splitPath(name) 2156 dname, fname = self.splitPath(name)
2146 2157
2147 # find the root of the repo 2158 # find the root of the repo
2157 else: 2168 else:
2158 args = self.initCommand("update") 2169 args = self.initCommand("update")
2159 args.append("--clean") 2170 args.append("--clean")
2160 2171
2161 dia = HgDialog( 2172 dia = HgDialog(
2162 self.tr('Canceling uncommitted merge'), 2173 self.tr('Aborting uncommitted merge'),
2163 self) 2174 self)
2164 res = dia.startProcess(args, repodir, False) 2175 res = dia.startProcess(args, repodir, False)
2165 if res: 2176 if res:
2166 dia.exec_() 2177 dia.exec_()
2167 res = dia.hasAddOrDelete() 2178 res = dia.hasAddOrDelete()
3348 self.__defaultConfigured = True 3359 self.__defaultConfigured = True
3349 if line.startswith("paths.default-push=") and \ 3360 if line.startswith("paths.default-push=") and \
3350 not line.strip().endswith("="): 3361 not line.strip().endswith("="):
3351 self.__defaultPushConfigured = True 3362 self.__defaultPushConfigured = True
3352 3363
3364 def canCommitMerge(self, name):
3365 """
3366 Public method to check if the working directory is uncommitted merge.
3367
3368 @param name file/directory name (string)
3369
3370 @return flag indicating commit merge capability (boolean)
3371 """
3372 dname, fname = self.splitPath(name)
3373
3374 # find the root of the repo
3375 repodir = dname
3376 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
3377 repodir = os.path.dirname(repodir)
3378 if os.path.splitdrive(repodir)[1] == os.sep:
3379 return
3380
3381 args = self.initCommand("identify")
3382
3383 output = ""
3384 if self.__client is None:
3385 process = QProcess()
3386 process.setWorkingDirectory(repodir)
3387 process.start('hg', args)
3388 procStarted = process.waitForStarted(5000)
3389 if procStarted:
3390 finished = process.waitForFinished(30000)
3391 if finished and process.exitCode() == 0:
3392 output = str(process.readAllStandardOutput(),
3393 self.getEncoding(), 'replace')
3394 else:
3395 output, error = self.__client.runcommand(args)
3396
3397 if output.count('+') == 2:
3398 return True
3399 else:
3400 return False
3401
3353 def canPull(self): 3402 def canPull(self):
3354 """ 3403 """
3355 Public method to check, if pull is possible. 3404 Public method to check, if pull is possible.
3356 3405
3357 @return flag indicating pull capability (boolean) 3406 @return flag indicating pull capability (boolean)

eric ide

mercurial