Mercurial > public > mercurial-scm > hg
comparison mercurial/graphmod.py @ 39286:3c4b2e880273
log: respect graphshorten on terminal nodes (collapsing o-~ to just o~)
Internally we have a custom template that's inspired by ones that we have seen
in the community. Normally, this looks something like:
o 0834ec17 spectral tip
| crecord: support x to toggle single, X to toggle a range
o ee932990 spectral @
| filemerge: allow specifying $hgeditor as merge-tools.X.executable
@ 66f04611 matt_harbison
| cext: fix truncation warnings in revlog on Windows
o 42cc76d0 matt_harbison
| cext: fix revlog compiler error on Windows
~
o bd63ada7 stable boris
| phases: drop dead code in `newheads`
~
With graphshorten on, and the descriptions of the public nodes hidden, it looks
like this, note that the commits right before the ~ are still "full height":
o 0834ec17 spectral tip
| crecord: support x to toggle single, X to toggle a range
o ee932990 spectral @
| filemerge: allow specifying $hgeditor as merge-tools.X.executable
@ 66f04611 matt_harbison
o 42cc76d0 matt_harbison
|
~
o bd63ada7 stable boris
|
~
This patch makes them look like this, removing the | but keeping the ~:
o 0834ec17 spectral tip
| crecord: support x to toggle single, X to toggle a range
o ee932990 spectral @
| filemerge: allow specifying $hgeditor as merge-tools.X.executable
@ 66f04611 matt_harbison
o 42cc76d0 matt_harbison
~
o bd63ada7 stable boris
~
This originally removed the ~s entirely, but this was determined to be too much
information loss and potentially confusing. This would have looked like the
following (note that the last commit is on a different branch than all of the
ones above it, and they are *not* linearly related):
o 0834ec17 spectral tip
| crecord: support x to toggle single, X to toggle a range
o ee932990 spectral @
| filemerge: allow specifying $hgeditor as merge-tools.X.executable
@ 66f04611 matt_harbison
o 42cc76d0 matt_harbison
o bd63ada7 stable boris
Differential Revision: https://phab.mercurial-scm.org/D4363
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Thu, 23 Aug 2018 13:33:19 -0700 |
parents | e7aa113b14f7 |
children | fb9e11fdcbba |
comparison
equal
deleted
inserted
replaced
39285:a3fd84f4fb38 | 39286:3c4b2e880273 |
---|---|
279 remainder = ncols - idx - 1 | 279 remainder = ncols - idx - 1 |
280 if remainder > 0: | 280 if remainder > 0: |
281 line.extend(echars[-(remainder * 2):]) | 281 line.extend(echars[-(remainder * 2):]) |
282 return line | 282 return line |
283 | 283 |
284 def _drawendinglines(lines, extra, edgemap, seen): | 284 def _drawendinglines(lines, extra, edgemap, seen, state): |
285 """Draw ending lines for missing parent edges | 285 """Draw ending lines for missing parent edges |
286 | 286 |
287 None indicates an edge that ends at between this node and the next | 287 None indicates an edge that ends at between this node and the next |
288 Replace with a short line ending in ~ and add / lines to any edges to | 288 Replace with a short line ending in ~ and add / lines to any edges to |
289 the right. | 289 the right. |
296 # We need enough space to draw adjustment lines for these. | 296 # We need enough space to draw adjustment lines for these. |
297 edgechars = extra[::2] | 297 edgechars = extra[::2] |
298 while edgechars and edgechars[-1] is None: | 298 while edgechars and edgechars[-1] is None: |
299 edgechars.pop() | 299 edgechars.pop() |
300 shift_size = max((edgechars.count(None) * 2) - 1, 0) | 300 shift_size = max((edgechars.count(None) * 2) - 1, 0) |
301 while len(lines) < 3 + shift_size: | 301 minlines = 3 if not state['graphshorten'] else 2 |
302 while len(lines) < minlines + shift_size: | |
302 lines.append(extra[:]) | 303 lines.append(extra[:]) |
303 | 304 |
304 if shift_size: | 305 if shift_size: |
305 empties = [] | 306 empties = [] |
306 toshift = [] | 307 toshift = [] |
317 for i in range(len(positions)): | 318 for i in range(len(positions)): |
318 pos = positions[i] - 1 | 319 pos = positions[i] - 1 |
319 positions[i] = max(pos, targets[i]) | 320 positions[i] = max(pos, targets[i]) |
320 line[pos] = '/' if pos > targets[i] else extra[toshift[i]] | 321 line[pos] = '/' if pos > targets[i] else extra[toshift[i]] |
321 | 322 |
322 map = {1: '|', 2: '~'} | 323 map = {1: '|', 2: '~'} if not state['graphshorten'] else {1: '~'} |
323 for i, line in enumerate(lines): | 324 for i, line in enumerate(lines): |
324 if None not in line: | 325 if None not in line: |
325 continue | 326 continue |
326 line[:] = [c or map.get(i, ' ') for c in line] | 327 line[:] = [c or map.get(i, ' ') for c in line] |
327 | 328 |
461 extra_interline = echars[:(ncols + coldiff) * 2] | 462 extra_interline = echars[:(ncols + coldiff) * 2] |
462 if len(lines) < len(text): | 463 if len(lines) < len(text): |
463 while len(lines) < len(text): | 464 while len(lines) < len(text): |
464 lines.append(extra_interline[:]) | 465 lines.append(extra_interline[:]) |
465 | 466 |
466 _drawendinglines(lines, extra_interline, edgemap, seen) | 467 _drawendinglines(lines, extra_interline, edgemap, seen, state) |
467 | 468 |
468 while len(text) < len(lines): | 469 while len(text) < len(lines): |
469 text.append("") | 470 text.append("") |
470 | 471 |
471 if any(len(char) > 1 for char in edgemap.values()): | 472 if any(len(char) > 1 for char in edgemap.values()): |