Mercurial > hg
comparison hgext/histedit.py @ 42233:4ad191041be2
histedit: Show file names in multiple line format
author | Yu Feng <rainwoodman@gmail.com> |
---|---|
date | Thu, 02 May 2019 16:43:34 -0700 |
parents | 9e40c5892714 |
children | c4a50e863ee2 |
comparison
equal
deleted
inserted
replaced
42231:d345627d104b | 42233:4ad191041be2 |
---|---|
1225 if color: | 1225 if color: |
1226 win.addstr(y, x, line, color) | 1226 win.addstr(y, x, line, color) |
1227 else: | 1227 else: |
1228 win.addstr(y, x, line) | 1228 win.addstr(y, x, line) |
1229 | 1229 |
1230 def _trunc_head(line, n): | |
1231 if len(line) <= n: | |
1232 return line | |
1233 return '> ' + line[-(n - 2):] | |
1234 def _trunc_tail(line, n): | |
1235 if len(line) <= n: | |
1236 return line | |
1237 return line[:n - 2] + ' >' | |
1238 | |
1230 def patchcontents(state): | 1239 def patchcontents(state): |
1231 repo = state['repo'] | 1240 repo = state['repo'] |
1232 rule = state['rules'][state['pos']] | 1241 rule = state['rules'][state['pos']] |
1233 displayer = logcmdutil.changesetdisplayer(repo.ui, repo, { | 1242 displayer = logcmdutil.changesetdisplayer(repo.ui, repo, { |
1234 "patch": True, "template": "status" | 1243 "patch": True, "template": "status" |
1282 | 1291 |
1283 bms = repo.nodebookmarks(ctx.node()) | 1292 bms = repo.nodebookmarks(ctx.node()) |
1284 line = "bookmark: {0}".format(' '.join(bms)) | 1293 line = "bookmark: {0}".format(' '.join(bms)) |
1285 win.addstr(3, 1, line[:length]) | 1294 win.addstr(3, 1, line[:length]) |
1286 | 1295 |
1287 line = "files: {0}".format(','.join(ctx.files())) | 1296 line = "summary: {0}".format(ctx.description().splitlines()[0]) |
1288 win.addstr(4, 1, line[:length]) | 1297 win.addstr(4, 1, line[:length]) |
1289 | 1298 |
1290 line = "summary: {0}".format(ctx.description().splitlines()[0]) | 1299 line = "files: " |
1291 win.addstr(5, 1, line[:length]) | 1300 win.addstr(5, 1, line) |
1301 fnx = 1 + len(line) | |
1302 fnmaxx = length - fnx + 1 | |
1303 y = 5 | |
1304 fnmaxn = maxy - (1 + y) - 1 | |
1305 files = ctx.files() | |
1306 for i, line1 in enumerate(files): | |
1307 if len(files) > fnmaxn and i == fnmaxn - 1: | |
1308 win.addstr(y, fnx, _trunc_tail(','.join(files[i:]), fnmaxx)) | |
1309 y = y + 1 | |
1310 break | |
1311 win.addstr(y, fnx, _trunc_head(line1, fnmaxx)) | |
1312 y = y + 1 | |
1292 | 1313 |
1293 conflicts = rule.conflicts | 1314 conflicts = rule.conflicts |
1294 if len(conflicts) > 0: | 1315 if len(conflicts) > 0: |
1295 conflictstr = ','.join(map(lambda r: str(r.ctx), conflicts)) | 1316 conflictstr = ','.join(map(lambda r: str(r.ctx), conflicts)) |
1296 conflictstr = "changed files overlap with {0}".format(conflictstr) | 1317 conflictstr = "changed files overlap with {0}".format(conflictstr) |
1297 else: | 1318 else: |
1298 conflictstr = 'no overlap' | 1319 conflictstr = 'no overlap' |
1299 | 1320 |
1300 win.addstr(6, 1, conflictstr[:length]) | 1321 win.addstr(y, 1, conflictstr[:length]) |
1301 win.noutrefresh() | 1322 win.noutrefresh() |
1302 | 1323 |
1303 def helplines(mode): | 1324 def helplines(mode): |
1304 if mode == MODE_PATCH: | 1325 if mode == MODE_PATCH: |
1305 help = """\ | 1326 help = """\ |
1377 | 1398 |
1378 def layout(mode): | 1399 def layout(mode): |
1379 maxy, maxx = stdscr.getmaxyx() | 1400 maxy, maxx = stdscr.getmaxyx() |
1380 helplen = len(helplines(mode)) | 1401 helplen = len(helplines(mode)) |
1381 return { | 1402 return { |
1382 'commit': (8, maxx), | 1403 'commit': (12, maxx), |
1383 'help': (helplen, maxx), | 1404 'help': (helplen, maxx), |
1384 'main': (maxy - helplen - 8, maxx), | 1405 'main': (maxy - helplen - 12, maxx), |
1385 } | 1406 } |
1386 | 1407 |
1387 def drawvertwin(size, y, x): | 1408 def drawvertwin(size, y, x): |
1388 win = curses.newwin(size[0], size[1], y, x) | 1409 win = curses.newwin(size[0], size[1], y, x) |
1389 y += size[0] | 1410 y += size[0] |