508 """ changes. Shall the commit be continued?"""), |
508 """ changes. Shall the commit be continued?"""), |
509 icon=E5MessageBox.Warning) |
509 icon=E5MessageBox.Warning) |
510 if not res: |
510 if not res: |
511 return |
511 return |
512 |
512 |
|
513 if isinstance(name, list): |
|
514 dname, fnames = self.splitPathList(name) |
|
515 else: |
|
516 dname, fname = self.splitPath(name) |
|
517 |
|
518 # find the root of the repo |
|
519 repodir = dname |
|
520 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
|
521 repodir = os.path.dirname(repodir) |
|
522 if os.path.splitdrive(repodir)[1] == os.sep: |
|
523 return |
|
524 |
513 if self.__commitDialog is not None: |
525 if self.__commitDialog is not None: |
514 msg = self.__commitDialog.logMessage() |
526 msg = self.__commitDialog.logMessage() |
515 amend = self.__commitDialog.amend() |
527 amend = self.__commitDialog.amend() |
516 commitSubrepositories = self.__commitDialog.commitSubrepositories() |
528 commitSubrepositories = self.__commitDialog.commitSubrepositories() |
517 self.__commitDialog.deleteLater() |
529 self.__commitDialog.deleteLater() |
518 self.__commitDialog = None |
530 self.__commitDialog = None |
|
531 if amend and not msg: |
|
532 msg = self.__getMostRecentCommitMessage(repodir) |
519 else: |
533 else: |
520 amend = False |
534 amend = False |
521 commitSubrepositories = False |
535 commitSubrepositories = False |
522 |
536 |
523 if not msg and not amend: |
537 if not msg and not amend: |
535 if commitSubrepositories: |
549 if commitSubrepositories: |
536 args.append("--subrepos") |
550 args.append("--subrepos") |
537 if msg: |
551 if msg: |
538 args.append("--message") |
552 args.append("--message") |
539 args.append(msg) |
553 args.append(msg) |
540 if isinstance(name, list): |
|
541 dname, fnames = self.splitPathList(name) |
|
542 else: |
|
543 dname, fname = self.splitPath(name) |
|
544 |
|
545 # find the root of the repo |
|
546 repodir = dname |
|
547 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
|
548 repodir = os.path.dirname(repodir) |
|
549 if os.path.splitdrive(repodir)[1] == os.sep: |
|
550 return |
|
551 |
|
552 if self.__client: |
554 if self.__client: |
553 if isinstance(name, list): |
555 if isinstance(name, list): |
554 self.addArguments(args, name) |
556 self.addArguments(args, name) |
555 else: |
557 else: |
556 if dname != repodir or fname != ".": |
558 if dname != repodir or fname != ".": |
576 model = e5App().getObject("Project").getModel() |
578 model = e5App().getObject("Project").getModel() |
577 for name in self.__forgotNames: |
579 for name in self.__forgotNames: |
578 model.updateVCSStatus(name) |
580 model.updateVCSStatus(name) |
579 self.__forgotNames = [] |
581 self.__forgotNames = [] |
580 self.checkVCSStatus() |
582 self.checkVCSStatus() |
|
583 |
|
584 def __getMostRecentCommitMessage(self, repodir): |
|
585 """ |
|
586 Private method to get the most recent commit message. |
|
587 |
|
588 Note: This message is extracted from the parent commit of the |
|
589 working directory. |
|
590 |
|
591 @param repodir path containing the repository (string) |
|
592 @return most recent commit message (string) |
|
593 """ |
|
594 args = self.initCommand("log") |
|
595 args.append("--rev") |
|
596 args.append(".") |
|
597 args.append('--template') |
|
598 args.append('{desc}') |
|
599 |
|
600 output = "" |
|
601 if self.__client is None: |
|
602 process = QProcess() |
|
603 process.setWorkingDirectory(repodir) |
|
604 process.start('hg', args) |
|
605 procStarted = process.waitForStarted(5000) |
|
606 if procStarted: |
|
607 finished = process.waitForFinished(30000) |
|
608 if finished and process.exitCode() == 0: |
|
609 output = str(process.readAllStandardOutput(), |
|
610 self.getEncoding(), 'replace') |
|
611 else: |
|
612 output, error = self.__client.runcommand(args) |
|
613 |
|
614 return output |
581 |
615 |
582 def vcsUpdate(self, name, noDialog=False, revision=None): |
616 def vcsUpdate(self, name, noDialog=False, revision=None): |
583 """ |
617 """ |
584 Public method used to update a file/directory with the Mercurial |
618 Public method used to update a file/directory with the Mercurial |
585 repository. |
619 repository. |