Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 38080:dabc2237963c
crecord: fallback to text mode if diffs are too big for curses mode
crecord uses curses.newpad to create a region that we can then scroll around in
by moving the main 'screen' as a veiwport into the (probably larger than the
actual screen) pad. Internally, at least in ncurses, pads are implemented using
windows, which have their dimensions limited to a certain size. Depending on
compilation options for ncurses, this size might be pretty small: (signed)
short, or it might be larger ((signed) int).
crecord wants to have enough room to have all of the contents of the main area
of the chunkselector in the pad; this means that the full size with everything
expanded must be less than these (undocumented, afaict) limits.
It's not easy to write tests for this because the limits are platform- and
installation- dependent and undocumented / unqueryable, as far as I can tell.
Differential Revision: https://phab.mercurial-scm.org/D3577
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Thu, 17 May 2018 23:11:24 -0700 |
parents | 14f4449711b8 |
children | c974320d20b9 |
comparison
equal
deleted
inserted
replaced
38079:ee7b6fa52d9d | 38080:dabc2237963c |
---|---|
195 return wrapwrite(oldwrite, *args, **kwargs) | 195 return wrapwrite(oldwrite, *args, **kwargs) |
196 setattr(ui, 'write', wrap) | 196 setattr(ui, 'write', wrap) |
197 return oldwrite | 197 return oldwrite |
198 | 198 |
199 def filterchunks(ui, originalhunks, usecurses, testfile, operation=None): | 199 def filterchunks(ui, originalhunks, usecurses, testfile, operation=None): |
200 if usecurses: | 200 try: |
201 if testfile: | 201 if usecurses: |
202 recordfn = crecordmod.testdecorator(testfile, | 202 if testfile: |
203 crecordmod.testchunkselector) | 203 recordfn = crecordmod.testdecorator( |
204 else: | 204 testfile, crecordmod.testchunkselector) |
205 recordfn = crecordmod.chunkselector | 205 else: |
206 | 206 recordfn = crecordmod.chunkselector |
207 return crecordmod.filterpatch(ui, originalhunks, recordfn, operation) | 207 |
208 | 208 return crecordmod.filterpatch(ui, originalhunks, recordfn, |
209 else: | 209 operation) |
210 return patch.filterpatch(ui, originalhunks, operation) | 210 except crecordmod.fallbackerror as e: |
211 ui.warn('%s\n' % e.message) | |
212 ui.warn(_('falling back to text mode\n')) | |
213 | |
214 return patch.filterpatch(ui, originalhunks, operation) | |
211 | 215 |
212 def recordfilter(ui, originalhunks, operation=None): | 216 def recordfilter(ui, originalhunks, operation=None): |
213 """ Prompts the user to filter the originalhunks and return a list of | 217 """ Prompts the user to filter the originalhunks and return a list of |
214 selected hunks. | 218 selected hunks. |
215 *operation* is used for to build ui messages to indicate the user what | 219 *operation* is used for to build ui messages to indicate the user what |