927 Public method used to view the log of a file/directory from the |
928 Public method used to view the log of a file/directory from the |
928 Subversion repository. |
929 Subversion repository. |
929 |
930 |
930 @param name file/directory name to show the log of (string) |
931 @param name file/directory name to show the log of (string) |
931 """ |
932 """ |
|
933 isFile = os.path.isfile(name) |
932 noEntries, ok = QInputDialog.getInt( |
934 noEntries, ok = QInputDialog.getInt( |
933 None, |
935 None, |
934 self.trUtf8("Subversion Log"), |
936 self.trUtf8("Subversion Log"), |
935 self.trUtf8("Select number of entries to show."), |
937 self.trUtf8("Select number of entries to show."), |
936 self.getPlugin().getPreferences("LogLimit"), 1, 999999, 1) |
938 self.getPlugin().getPreferences("LogLimit"), 1, 999999, 1) |
937 if ok: |
939 if ok: |
938 from .SvnLogDialog import SvnLogDialog |
940 from .SvnLogDialog import SvnLogDialog |
939 self.log = SvnLogDialog(self) |
941 self.log = SvnLogDialog(self, isFile=isFile) |
940 self.log.show() |
942 self.log.show() |
941 QApplication.processEvents() |
943 QApplication.processEvents() |
942 self.log.start(name, noEntries) |
944 self.log.start(name, noEntries) |
943 |
945 |
944 def vcsDiff(self, name): |
946 def vcsDiff(self, name): |
1995 self.diff = SvnDiffDialog(self) |
1997 self.diff = SvnDiffDialog(self) |
1996 self.diff.show() |
1998 self.diff.show() |
1997 QApplication.processEvents() |
1999 QApplication.processEvents() |
1998 self.diff.start(name, urls=urls, summary=summary) |
2000 self.diff.start(name, urls=urls, summary=summary) |
1999 |
2001 |
2000 def svnLogBrowser(self, path): |
2002 def __svnGetFileForRevision(self, name, rev=""): |
|
2003 """ |
|
2004 Private method to get a file for a specific revision from the repository. |
|
2005 |
|
2006 @param name file name to get from the repository (string) |
|
2007 @keyparam rev revision to retrieve (integer or string) |
|
2008 @return contents of the file (string) and an error message (string) |
|
2009 """ |
|
2010 output = "" |
|
2011 error = "" |
|
2012 |
|
2013 client = self.getClient() |
|
2014 try: |
|
2015 if rev: |
|
2016 if isinstance(rev, int) or rev.isdecimal(): |
|
2017 rev = pysvn.Revision(pysvn.opt_revision_kind.number, int(rev)) |
|
2018 elif rev.startswith("{"): |
|
2019 dateStr = rev[1:-1] |
|
2020 secs = QDateTime.fromString(dateStr, Qt.ISODate).toTime_t() |
|
2021 rev = pysvn.Revision(pysvn.opt_revision_kind.date, secs) |
|
2022 elif rev == "HEAD": |
|
2023 rev = pysvn.Revision(pysvn.opt_revision_kind.head) |
|
2024 elif rev == "COMMITTED": |
|
2025 rev = pysvn.Revision(pysvn.opt_revision_kind.committed) |
|
2026 elif rev == "BASE": |
|
2027 rev = pysvn.Revision(pysvn.opt_revision_kind.base) |
|
2028 elif rev == "WORKING": |
|
2029 rev = pysvn.Revision(pysvn.opt_revision_kind.working) |
|
2030 elif rev == "PREV": |
|
2031 rev = pysvn.Revision(pysvn.opt_revision_kind.previous) |
|
2032 else: |
|
2033 rev = pysvn.Revision(pysvn.opt_revision_kind.unspecified) |
|
2034 output = client.cat(name, revision=rev) |
|
2035 else: |
|
2036 output = client.cat(name) |
|
2037 output = output.decode() |
|
2038 except pysvn.ClientError as e: |
|
2039 error = str(e) |
|
2040 |
|
2041 return output, error |
|
2042 |
|
2043 def svnSbsDiff(self, name, extended=False, revisions=None): |
|
2044 """ |
|
2045 Public method used to view the difference of a file to the Mercurial repository |
|
2046 side-by-side. |
|
2047 |
|
2048 @param name file name to be diffed (string) |
|
2049 @keyparam extended flag indicating the extended variant (boolean) |
|
2050 @keyparam revisions tuple of two revisions (tuple of strings) |
|
2051 """ |
|
2052 if isinstance(name, list): |
|
2053 raise ValueError("Wrong parameter type") |
|
2054 |
|
2055 if extended: |
|
2056 from .SvnRevisionSelectionDialog import SvnRevisionSelectionDialog |
|
2057 dlg = SvnRevisionSelectionDialog() |
|
2058 if dlg.exec_() == QDialog.Accepted: |
|
2059 rev1, rev2 = dlg.getRevisions() |
|
2060 if rev1 == "WORKING": |
|
2061 rev1 = "" |
|
2062 if rev2 == "WORKING": |
|
2063 rev2 = "" |
|
2064 elif revisions: |
|
2065 rev1, rev2 = revisions[0], revisions[1] |
|
2066 else: |
|
2067 rev1, rev2 = "", "" |
|
2068 |
|
2069 output1, error = self.__svnGetFileForRevision(name, rev=rev1) |
|
2070 if error: |
|
2071 E5MessageBox.critical(self.__ui, |
|
2072 self.trUtf8("Subversion Side-by-Side Difference"), |
|
2073 error) |
|
2074 return |
|
2075 name1 = "{0} (rev. {1})".format(name, rev1 and rev1 or ".") |
|
2076 |
|
2077 if rev2: |
|
2078 output2, error = self.__svnGetFileForRevision(name, rev=rev2) |
|
2079 if error: |
|
2080 E5MessageBox.critical(self.__ui, |
|
2081 self.trUtf8("Subversion Side-by-Side Difference"), |
|
2082 error) |
|
2083 return |
|
2084 name2 = "{0} (rev. {1})".format(name, rev2) |
|
2085 else: |
|
2086 try: |
|
2087 f1 = open(name, "r", encoding="utf-8") |
|
2088 output2 = f1.read() |
|
2089 f1.close() |
|
2090 name2 = name |
|
2091 except IOError: |
|
2092 E5MessageBox.critical(self.__ui, |
|
2093 self.trUtf8("Subversion Side-by-Side Difference"), |
|
2094 self.trUtf8("""<p>The file <b>{0}</b> could not be read.</p>""") |
|
2095 .format(name)) |
|
2096 return |
|
2097 |
|
2098 if self.sbsDiff is None: |
|
2099 from UI.CompareDialog import CompareDialog |
|
2100 self.sbsDiff = CompareDialog() |
|
2101 self.sbsDiff.show() |
|
2102 self.sbsDiff.compare(output1, output2, name1, name2) |
|
2103 |
|
2104 def svnLogBrowser(self, path, isFile=False): |
2001 """ |
2105 """ |
2002 Public method used to browse the log of a file/directory from the |
2106 Public method used to browse the log of a file/directory from the |
2003 Subversion repository. |
2107 Subversion repository. |
2004 |
2108 |
2005 @param path file/directory name to show the log of (string) |
2109 @param path file/directory name to show the log of (string) |
|
2110 @param isFile flag indicating log for a file is to be shown (boolean) |
2006 """ |
2111 """ |
2007 from .SvnLogBrowserDialog import SvnLogBrowserDialog |
2112 from .SvnLogBrowserDialog import SvnLogBrowserDialog |
2008 self.logBrowser = SvnLogBrowserDialog(self) |
2113 self.logBrowser = SvnLogBrowserDialog(self, isFile=isFile) |
2009 self.logBrowser.show() |
2114 self.logBrowser.show() |
2010 QApplication.processEvents() |
2115 QApplication.processEvents() |
2011 self.logBrowser.start(path) |
2116 self.logBrowser.start(path) |
2012 |
2117 |
2013 def svnLock(self, name, stealIt=False, parent=None): |
2118 def svnLock(self, name, stealIt=False, parent=None): |