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