829 Public method used to view the log of a file/directory from the |
832 Public method used to view the log of a file/directory from the |
830 Subversion repository. |
833 Subversion repository. |
831 |
834 |
832 @param name file/directory name to show the log of (string) |
835 @param name file/directory name to show the log of (string) |
833 """ |
836 """ |
|
837 isFile = os.path.isfile(name) |
834 noEntries, ok = QInputDialog.getInt( |
838 noEntries, ok = QInputDialog.getInt( |
835 None, |
839 None, |
836 self.trUtf8("Subversion Log"), |
840 self.trUtf8("Subversion Log"), |
837 self.trUtf8("Select number of entries to show."), |
841 self.trUtf8("Select number of entries to show."), |
838 self.getPlugin().getPreferences("LogLimit"), 1, 999999, 1) |
842 self.getPlugin().getPreferences("LogLimit"), 1, 999999, 1) |
839 if ok: |
843 if ok: |
840 from .SvnLogDialog import SvnLogDialog |
844 from .SvnLogDialog import SvnLogDialog |
841 self.log = SvnLogDialog(self) |
845 self.log = SvnLogDialog(self, isFile=isFile) |
842 self.log.show() |
846 self.log.show() |
843 self.log.start(name, noEntries) |
847 self.log.start(name, noEntries) |
844 |
848 |
845 def vcsDiff(self, name): |
849 def vcsDiff(self, name): |
846 """ |
850 """ |
1829 self.diff = SvnDiffDialog(self) |
1833 self.diff = SvnDiffDialog(self) |
1830 self.diff.show() |
1834 self.diff.show() |
1831 QApplication.processEvents() |
1835 QApplication.processEvents() |
1832 self.diff.start(name, urls=urls, summary=summary) |
1836 self.diff.start(name, urls=urls, summary=summary) |
1833 |
1837 |
1834 def svnLogBrowser(self, path): |
1838 def __svnGetFileForRevision(self, name, rev=""): |
|
1839 """ |
|
1840 Private method to get a file for a specific revision from the repository. |
|
1841 |
|
1842 @param name file name to get from the repository (string) |
|
1843 @keyparam rev revision to retrieve (integer or string) |
|
1844 @return contents of the file (string) and an error message (string) |
|
1845 """ |
|
1846 args = [] |
|
1847 args.append("cat") |
|
1848 if rev: |
|
1849 args.append("--revision") |
|
1850 args.append(str(rev)) |
|
1851 args.append(name) |
|
1852 |
|
1853 output = "" |
|
1854 error = "" |
|
1855 |
|
1856 process = QProcess() |
|
1857 process.start('svn', args) |
|
1858 procStarted = process.waitForStarted(5000) |
|
1859 if procStarted: |
|
1860 finished = process.waitForFinished(30000) |
|
1861 if finished: |
|
1862 if process.exitCode() == 0: |
|
1863 output = str(process.readAllStandardOutput(), |
|
1864 Preferences.getSystem("IOEncoding"), 'replace') |
|
1865 else: |
|
1866 error = str(process.readAllStandardError(), |
|
1867 Preferences.getSystem("IOEncoding"), 'replace') |
|
1868 else: |
|
1869 error = self.trUtf8("The svn process did not finish within 30s.") |
|
1870 else: |
|
1871 error = self.trUtf8('The process {0} could not be started. ' |
|
1872 'Ensure, that it is in the search path.').format('svn') |
|
1873 |
|
1874 return output, error |
|
1875 |
|
1876 def svnSbsDiff(self, name, extended=False, revisions=None): |
|
1877 """ |
|
1878 Public method used to view the difference of a file to the Mercurial repository |
|
1879 side-by-side. |
|
1880 |
|
1881 @param name file name to be diffed (string) |
|
1882 @keyparam extended flag indicating the extended variant (boolean) |
|
1883 @keyparam revisions tuple of two revisions (tuple of strings) |
|
1884 """ |
|
1885 if isinstance(name, list): |
|
1886 raise ValueError("Wrong parameter type") |
|
1887 |
|
1888 if extended: |
|
1889 from .SvnRevisionSelectionDialog import SvnRevisionSelectionDialog |
|
1890 dlg = SvnRevisionSelectionDialog() |
|
1891 if dlg.exec_() == QDialog.Accepted: |
|
1892 rev1, rev2 = dlg.getRevisions() |
|
1893 if rev1 == "WORKING": |
|
1894 rev1 = "" |
|
1895 if rev2 == "WORKING": |
|
1896 rev2 = "" |
|
1897 elif revisions: |
|
1898 rev1, rev2 = revisions[0], revisions[1] |
|
1899 else: |
|
1900 rev1, rev2 = "", "" |
|
1901 |
|
1902 output1, error = self.__svnGetFileForRevision(name, rev=rev1) |
|
1903 if error: |
|
1904 E5MessageBox.critical(self.__ui, |
|
1905 self.trUtf8("Subversion Side-by-Side Difference"), |
|
1906 error) |
|
1907 return |
|
1908 name1 = "{0} (rev. {1})".format(name, rev1 and rev1 or ".") |
|
1909 |
|
1910 if rev2: |
|
1911 output2, error = self.__svnGetFileForRevision(name, rev=rev2) |
|
1912 if error: |
|
1913 E5MessageBox.critical(self.__ui, |
|
1914 self.trUtf8("Subversion Side-by-Side Difference"), |
|
1915 error) |
|
1916 return |
|
1917 name2 = "{0} (rev. {1})".format(name, rev2) |
|
1918 else: |
|
1919 try: |
|
1920 f1 = open(name, "r", encoding="utf-8") |
|
1921 output2 = f1.read() |
|
1922 f1.close() |
|
1923 name2 = name |
|
1924 except IOError: |
|
1925 E5MessageBox.critical(self.__ui, |
|
1926 self.trUtf8("Subversion Side-by-Side Difference"), |
|
1927 self.trUtf8("""<p>The file <b>{0}</b> could not be read.</p>""") |
|
1928 .format(name)) |
|
1929 return |
|
1930 |
|
1931 if self.sbsDiff is None: |
|
1932 from UI.CompareDialog import CompareDialog |
|
1933 self.sbsDiff = CompareDialog() |
|
1934 self.sbsDiff.show() |
|
1935 self.sbsDiff.compare(output1, output2, name1, name2) |
|
1936 |
|
1937 def svnLogBrowser(self, path, isFile=False): |
1835 """ |
1938 """ |
1836 Public method used to browse the log of a file/directory from the |
1939 Public method used to browse the log of a file/directory from the |
1837 Subversion repository. |
1940 Subversion repository. |
1838 |
1941 |
1839 @param path file/directory name to show the log of (string) |
1942 @param path file/directory name to show the log of (string) |
|
1943 @param isFile flag indicating log for a file is to be shown (boolean) |
1840 """ |
1944 """ |
1841 from .SvnLogBrowserDialog import SvnLogBrowserDialog |
1945 from .SvnLogBrowserDialog import SvnLogBrowserDialog |
1842 self.logBrowser = SvnLogBrowserDialog(self) |
1946 self.logBrowser = SvnLogBrowserDialog(self, isFile=isFile) |
1843 self.logBrowser.show() |
1947 self.logBrowser.show() |
1844 self.logBrowser.start(path) |
1948 self.logBrowser.start(path) |
1845 |
1949 |
1846 def svnLock(self, name, stealIt=False, parent=None): |
1950 def svnLock(self, name, stealIt=False, parent=None): |
1847 """ |
1951 """ |