Sat, 11 Apr 2015 14:18:27 +0200
Corrected some code style issues.
4130
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

1  # * coding: utf8 * 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

2  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

3  # Copyright (c) 2015 Detlev Offenbach <detlev@dieoffenbachs.de> 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

4  # 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

5  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

6  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

7  Module implementing a class to generate the output of the hg diff command. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

8  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

9  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

10  from __future__ import unicode_literals 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

11  try: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

12  str = unicode 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

13  except NameError: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

14  pass 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

15  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

16  import os 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

17  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

18  from PyQt5.QtCore import pyqtSignal, QProcess, QTimer, QObject 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

19  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

20  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

21  class HgDiffGenerator(QObject): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

22  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

23  Class implementing the generation of output of the hg diff command. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

24  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

25  @signal finished() emitted when all processes have finished 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

26  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

27  finished = pyqtSignal() 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

28  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

29  def __init__(self, vcs, parent=None): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

30  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

31  Constructor 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

32  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

33  @param vcs reference to the vcs object 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

34  @param parent parent widget (QWidget) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

35  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

36  super(HgDiffGenerator, self).__init__(parent) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

37  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

38  self.vcs = vcs 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

39  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

40  self.__hgClient = self.vcs.getClient() 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

41  if self.__hgClient: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

42  self.process = None 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

43  else: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

44  self.process = QProcess() 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

45  self.process.finished.connect(self.__finish) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

46  self.process.readyReadStandardOutput.connect(self.__readStdout) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

47  self.process.readyReadStandardError.connect(self.__readStderr) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

48  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

49  def stopProcess(self): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

50  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

51  Public slot to stop the diff process. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

52  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

53  if self.__hgClient: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

54  if self.__hgClient.isExecuting(): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

55  self.__hgClient.cancel() 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

56  else: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

57  if self.process is not None and \ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

58  self.process.state() != QProcess.NotRunning: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

59  self.process.terminate() 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

60  QTimer.singleShot(2000, self.process.kill) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

61  self.process.waitForFinished(3000) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

62  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

63  def __getVersionArg(self, version): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

64  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

65  Private method to get a hg revision argument for the given revision. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

66  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

67  @param version revision (integer or string) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

68  @return version argument (string) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

69  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

70  if version == "WORKING": 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

71  return None 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

72  else: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

73  return str(version) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

74  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

75  def start(self, fn, versions=None, bundle=None, qdiff=False): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

76  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

77  Public slot to start the hg diff command. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

78  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

79  @param fn filename to be diffed (string) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

80  @keyparam versions list of versions to be diffed (list of up to 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

81  2 strings or None) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

82  @keyparam bundle name of a bundle file (string) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

83  @keyparam qdiff flag indicating qdiff command shall be used (boolean) 
4212
530b953eb623
Corrected some code style issues.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
4130
diff
changeset

84  @return flag indicating a successful start of the diff command 
530b953eb623
Corrected some code style issues.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
4130
diff
changeset

85  (boolean) 
4130
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

86  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

87  if qdiff: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

88  args = self.vcs.initCommand("qdiff") 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

89  else: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

90  args = self.vcs.initCommand("diff") 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

91  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

92  if self.vcs.hasSubrepositories(): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

93  args.append("subrepos") 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

94  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

95  if bundle: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

96  args.append('repository') 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

97  args.append(bundle) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

98  elif self.vcs.bundleFile and os.path.exists(self.vcs.bundleFile): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

99  args.append('repository') 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

100  args.append(self.vcs.bundleFile) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

101  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

102  if versions is not None: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

103  rev1 = self.__getVersionArg(versions[0]) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

104  rev2 = None 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

105  if len(versions) == 2: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

106  rev2 = self.__getVersionArg(versions[1]) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

107  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

108  if rev1 is not None or rev2 is not None: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

109  args.append('r') 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

110  if rev1 is not None and rev2 is not None: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

111  args.append('{0}:{1}'.format(rev1, rev2)) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

112  elif rev2 is None: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

113  args.append(rev1) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

114  elif rev1 is None: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

115  args.append(':{0}'.format(rev2)) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

116  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

117  if isinstance(fn, list): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

118  dname, fnames = self.vcs.splitPathList(fn) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

119  self.vcs.addArguments(args, fn) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

120  else: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

121  dname, fname = self.vcs.splitPath(fn) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

122  args.append(fn) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

123  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

124  self.__oldFile = "" 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

125  self.__oldFileLine = 1 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

126  self.__fileSeparators = [] 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

127  self.__output = [] 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

128  self.__errors = [] 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

129  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

130  if self.__hgClient: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

131  out, err = self.__hgClient.runcommand(args) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

132  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

133  if err: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

134  self.__errors = err.splitlines(True) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

135  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

136  if out: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

137  for line in out.splitlines(True): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

138  self.__processOutputLine(line) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

139  if self.__hgClient.wasCanceled(): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

140  break 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

141  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

142  self.__finish() 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

143  else: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

144  # find the root of the repo 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

145  repodir = dname 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

146  while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

147  repodir = os.path.dirname(repodir) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

148  if os.path.splitdrive(repodir)[1] == os.sep: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

149  return 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

150  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

151  self.process.kill() 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

152  self.process.setWorkingDirectory(repodir) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

153  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

154  self.process.start('hg', args) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

155  procStarted = self.process.waitForStarted(5000) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

156  if not procStarted: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

157  return False 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

158  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

159  return True 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

160  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

161  def __finish(self): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

162  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

163  Private slot called when the process finished or the user pressed 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

164  the button. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

165  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

166  self.finished.emit() 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

167  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

168  def getResult(self): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

169  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

170  Public method to return the result data. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

171  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

172  @return tuple of lists of string containing lines of the diff, the 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

173  list of errors and a list of tuples of filenames and the line 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

174  into the diff output. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

175  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

176  return (self.__output, self.__errors, self.__fileSeparators) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

177  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

178  def __extractFileName(self, line): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

179  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

180  Private method to extract the file name out of a file separator line. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

181  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

182  @param line line to be processed (string) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

183  @return extracted file name (string) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

184  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

185  f = line.split(None, 1)[1] 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

186  f = f.rsplit(None, 6)[0] 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

187  if f == "/dev/null": 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

188  f = "__NULL__" 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

189  else: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

190  f = f.split("/", 1)[1] 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

191  return f 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

192  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

193  def __processFileLine(self, line): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

194  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

195  Private slot to process a line giving the old/new file. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

196  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

197  @param line line to be processed (string) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

198  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

199  if line.startswith(''): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

200  self.__oldFileLine = len(self.__output) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

201  self.__oldFile = self.__extractFileName(line) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

202  else: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

203  newFile = self.__extractFileName(line) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

204  if self.__oldFile == "__NULL__": 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

205  self.__fileSeparators.append( 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

206  (newFile, newFile, self.__oldFileLine)) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

207  else: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

208  self.__fileSeparators.append( 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

209  (self.__oldFile, newFile, self.__oldFileLine)) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

210  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

211  def __processOutputLine(self, line): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

212  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

213  Private method to process the lines of output. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

214  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

215  @param line output line to be processed (string) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

216  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

217  if line.startswith(" ") or \ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

218  line.startswith("+++ "): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

219  self.__processFileLine(line) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

220  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

221  self.__output.append(line) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

222  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

223  def __readStdout(self): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

224  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

225  Private slot to handle the readyReadStandardOutput signal. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

226  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

227  It reads the output of the process, formats it and inserts it into 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

228  the contents pane. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

229  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

230  self.process.setReadChannel(QProcess.StandardOutput) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

231  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

232  while self.process.canReadLine(): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

233  line = str(self.process.readLine(), self.vcs.getEncoding(), 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

234  'replace') 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

235  self.__processOutputLine(line) 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

236  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

237  def __readStderr(self): 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

238  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

239  Private slot to handle the readyReadStandardError signal. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

240  
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

241  It reads the error output of the process and inserts it into the 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

242  error pane. 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

243  """ 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

244  if self.process is not None: 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

245  s = str(self.process.readAllStandardError(), 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

246  self.vcs.getEncoding(), 'replace') 
c5af9f10a061
Moved logic to generate a Mercurial diff to a separate module in order to reuse it.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

247  self.__errors.append(s) 