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

stable chunks: be more careful during file size checks

In changeset db27310504c4, I made the status tool pass a wctx to check_max_diff
when it is operating on the working copy. I did not realize a wctx will happily
generate a fctx for an unrevisioned file. So when the commit tool tried to
query the diff status of a subrepository (directory), it make it all the way to
the point where it tried to read the file data, where it then encountered a
predictable IOError.

This changeset fixes the problems in two ways. First, we explicitly verify that
we are inspecting a regular file. Then we also catch EnvironmentErrors from the
fctx.data() call, since this could run into various file locks on Windows.

Closes #1340

Changeset ab6ad158218f

Parent 130ad83392ce

by Steve Borho

Changes to one file · Browse files at ab6ad158218f Showing diff from parent 130ad83392ce Diff from another changeset...

 
9
10
11
 
12
13
14
 
59
60
61
62
63
64
65
 
 
66
67
68
 
72
73
74
75
 
 
 
 
 
 
76
77
78
79
80
81
82
 
 
83
84
85
 
9
10
11
12
13
14
15
 
60
61
62
 
63
64
65
66
67
68
69
70
 
74
75
76
 
77
78
79
80
81
82
83
84
85
86
87
88
 
89
90
91
92
93
@@ -9,6 +9,7 @@
 # GNU General Public License version 2, incorporated herein by reference.    import gtk +import os  import pango  import cStringIO   @@ -59,10 +60,11 @@
     def check_max_diff(ctx, wfile): - lines = []   try:   fctx = ctx.filectx(wfile)   size = fctx.size() + if not os.path.isfile(ctx._repo.wjoin(wfile)): + return []   except (EnvironmentError, error.LookupError):   return []   if size > hglib.getmaxdiffsize(ctx._repo.ui): @@ -72,14 +74,20 @@
  lines.append(_('Hunk selection is disabled for this file.\n'))   lines.append('--- a/%s\n' % wfile)   lines.append('+++ b/%s\n' % wfile) - elif '\0' in fctx.data(): + return lines + try: + contents = fctx.data() + except (EnvironmentError, util.Abort): + return [] + if '\0' in contents:   # Fake patch that displays binary file warning   lines = ['diff --git a/%s b/%s\n' % (wfile, wfile)]   lines.append(_('File is binary.\n'))   lines.append(_('Hunk selection is disabled for this file.\n'))   lines.append('--- a/%s\n' % wfile)   lines.append('+++ b/%s\n' % wfile) - return lines + return lines + return []      class chunks(object):