Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.1, 1.1.1, and 1.1.2

status: move read_file_chunks to chunks.py

Changeset c9f8f5ac2344

Parent 3167426739c0

by Adrian Buehlmann

Changes to 2 files · Browse files at c9f8f5ac2344 Showing diff from parent 3167426739c0 Diff from another changeset...

 
12
13
14
 
 
15
16
17
 
173
174
175
176
 
177
178
179
 
191
192
193
194
 
195
196
197
 
289
290
291
292
 
293
294
295
 
331
332
333
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
13
14
15
16
17
18
19
 
175
176
177
 
178
179
180
181
 
193
194
195
 
196
197
198
199
 
291
292
293
 
294
295
296
297
 
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
@@ -12,6 +12,8 @@
 import pango  import cStringIO   +from mercurial import cmdutil, util, patch, mdiff, error +  from tortoisehg.util import hglib, hgshelve    from tortoisehg.hgtk import gtklib @@ -173,7 +175,7 @@
  if wfile in self.filechunks:   chunks = self.filechunks[wfile]   else: - chunks = self.stat.read_file_chunks(wfile) + chunks = self.read_file_chunks(wfile)   for c in chunks:   c.active = True   self.filechunks[wfile] = chunks @@ -191,7 +193,7 @@
    def append_diff_hunks(self, wfile, checked):   'Append diff hunks of one file to the diffmodel' - chunks = self.stat.read_file_chunks(wfile) + chunks = self.read_file_chunks(wfile)   if not chunks:   if wfile in self.filechunks:   del self.filechunks[wfile] @@ -289,7 +291,7 @@
  if wfile in self.filechunks:   chunks = self.filechunks[wfile]   else: - chunks = self.stat.read_file_chunks(wfile) + chunks = self.read_file_chunks(wfile)   for c in chunks:   c.active = True   for i, chunk in enumerate(chunks): @@ -331,3 +333,23 @@
  fp.seek(0)   self.stat.clipboard.set_text(fp.read())   + def read_file_chunks(self, wfile): + 'Get diffs of working file, parse into (c)hunks' + difftext = cStringIO.StringIO() + pfile = util.pconvert(wfile) + lines = self.stat.check_max_diff(pfile) + if lines: + difftext.writelines(lines) + difftext.seek(0) + else: + matcher = cmdutil.matchfiles(self.stat.repo, [pfile]) + diffopts = mdiff.diffopts(git=True, nodates=True) + try: + node1, node2 = self.stat.nodes() + for s in patch.diff(self.stat.repo, node1, node2, + match=matcher, opts=diffopts): + difftext.writelines(s.splitlines(True)) + except (IOError, error.RepoError, error.LookupError, util.Abort), e: + self.stat.stbar.set_text(str(e)) + difftext.seek(0) + return hgshelve.parsepatch(difftext)
 
14
15
16
17
 
18
19
20
 
721
722
723
 
 
 
724
725
726
 
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
 
14
15
16
 
17
18
19
20
 
721
722
723
724
725
726
727
728
729
 
969
970
971
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
972
973
974
@@ -14,7 +14,7 @@
 import gobject  import threading   -from mercurial import cmdutil, util, patch, mdiff, error, hg +from mercurial import cmdutil, util, patch, error, hg  from mercurial import merge as merge_    from tortoisehg.util.i18n import _ @@ -721,6 +721,9 @@
  gobject.timeout_add(50, status_wait, thread)   return True   + def nodes(self): + return (self._node1, self._node2) +   def set_file_states(self, paths, state=True):   for p in paths:   self.filemodel[p][FM_CHECKED] = state @@ -966,26 +969,6 @@
  lines.append('+++ b/%s\n' % pfile)   return lines   - def read_file_chunks(self, wfile): - 'Get diffs of working file, parse into (c)hunks' - difftext = cStringIO.StringIO() - pfile = util.pconvert(wfile) - lines = self.check_max_diff(pfile) - if lines: - difftext.writelines(lines) - difftext.seek(0) - else: - matcher = cmdutil.matchfiles(self.repo, [pfile]) - diffopts = mdiff.diffopts(git=True, nodates=True) - try: - for s in patch.diff(self.repo, self._node1, self._node2, - match=matcher, opts=diffopts): - difftext.writelines(s.splitlines(True)) - except (IOError, error.RepoError, error.LookupError, util.Abort), e: - self.stbar.set_text(str(e)) - difftext.seek(0) - return hgshelve.parsepatch(difftext) -   def update_check_state(self, wfile, partial, newvalue):   for fr in self.filemodel:   if fr[FM_PATH] == wfile: