1625 revisions = dlg.getRevisions() |
1625 revisions = dlg.getRevisions() |
1626 from .HgDiffDialog import HgDiffDialog |
1626 from .HgDiffDialog import HgDiffDialog |
1627 self.diff = HgDiffDialog(self) |
1627 self.diff = HgDiffDialog(self) |
1628 self.diff.show() |
1628 self.diff.show() |
1629 self.diff.start(name, revisions) |
1629 self.diff.start(name, revisions) |
|
1630 |
|
1631 def hgSbsDiff(self, name): |
|
1632 """ |
|
1633 Public method used to view the difference of a file to the Mercurial repository |
|
1634 side-by-side. |
|
1635 |
|
1636 @param name file name to be diffed (string) |
|
1637 """ |
|
1638 if isinstance(name, list): |
|
1639 raise ValueError("Wrong parameter type") |
|
1640 |
|
1641 args = [] |
|
1642 args.append("cat") |
|
1643 args.append(name) |
|
1644 |
|
1645 output1 = "" |
|
1646 if self.__client is None: |
|
1647 # find the root of the repo |
|
1648 repodir = self.splitPath(name)[0] |
|
1649 while not os.path.isdir(os.path.join(repodir, self.adminDir)): |
|
1650 repodir = os.path.dirname(repodir) |
|
1651 if os.path.splitdrive(repodir)[1] == os.sep: |
|
1652 return |
|
1653 |
|
1654 process = QProcess() |
|
1655 process.setWorkingDirectory(repodir) |
|
1656 process.start('hg', args) |
|
1657 procStarted = process.waitForStarted(5000) |
|
1658 if procStarted: |
|
1659 finished = process.waitForFinished(30000) |
|
1660 if finished and process.exitCode() == 0: |
|
1661 output1 = str(process.readAllStandardOutput(), |
|
1662 Preferences.getSystem("IOEncoding"), 'replace') |
|
1663 else: |
|
1664 output1, error = self.__client.runcommand(args) |
|
1665 |
|
1666 try: |
|
1667 f1 = open(name, "r", encoding="utf-8") |
|
1668 output2 = f1.read() |
|
1669 f1.close() |
|
1670 except IOError: |
|
1671 E5MessageBox.critical(self, |
|
1672 self.trUtf8("Mercurial Side-by-Side Difference"), |
|
1673 self.trUtf8("""<p>The file <b>{0}</b> could not be read.</p>""") |
|
1674 .format(name)) |
|
1675 return |
|
1676 |
|
1677 if output1 and output2: |
|
1678 from UI.CompareDialog import CompareDialog |
|
1679 self.sbsDiff = CompareDialog() |
|
1680 self.sbsDiff.show() |
|
1681 self.sbsDiff.compare(output1, output2, "{0}@.".format(name), name) |
1630 |
1682 |
1631 def hgLogBrowser(self, path): |
1683 def hgLogBrowser(self, path): |
1632 """ |
1684 """ |
1633 Public method used to browse the log of a file/directory from the |
1685 Public method used to browse the log of a file/directory from the |
1634 Mercurial repository. |
1686 Mercurial repository. |