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