mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
remotenames: refactor outputname to outputbranches
Now that we have outputbookmarks that sorts differently for bookmarks, rename outputname and make it simpler and less generic
This commit is contained in:
parent
13e6ed237a
commit
4d32a9e3bd
@ -133,20 +133,19 @@ def extsetup(ui):
|
||||
entry[1].append(('a', 'all', None, 'show both remote and local branches'))
|
||||
entry[1].append(('', 'remote', None, 'show only remote branches'))
|
||||
|
||||
def outputname(cmd, orig, ui, repo, *args, **opts):
|
||||
def outputbranches(orig, ui, repo, *args, **opts):
|
||||
if not opts.get('remote'):
|
||||
orig(ui, repo, *args, **opts)
|
||||
|
||||
if opts.get('all') or opts.get('remote'):
|
||||
# exit early if namespace doesn't even exist
|
||||
namespace = 'remote' + cmd
|
||||
namespace = 'remotebranches'
|
||||
if namespace not in repo.names:
|
||||
return
|
||||
|
||||
ns = repo.names['remote' + cmd]
|
||||
ns = repo.names[namespace]
|
||||
label = 'log.' + ns.colorname
|
||||
fm = ui.formatter(cmd, opts)
|
||||
|
||||
if opts.get('all') or opts.get('remote'):
|
||||
fm = ui.formatter('branches', opts)
|
||||
|
||||
# create a sorted by descending rev list
|
||||
revs = set()
|
||||
@ -160,12 +159,6 @@ def outputname(cmd, orig, ui, repo, *args, **opts):
|
||||
fm.startitem()
|
||||
padsize = max(31 - len(str(r)) - encoding.colwidth(name), 0)
|
||||
|
||||
# bookmarks have a slightly different padding
|
||||
if cmd == 'bookmarks':
|
||||
if not ui.quiet:
|
||||
fm.plain(' ')
|
||||
padsize = max(25 - encoding.colwidth(name), 0)
|
||||
|
||||
fm.write(ns.colorname, '%s', name, label=label)
|
||||
fmt = ' ' * padsize + ' %d:%s'
|
||||
fm.condwrite(not ui.quiet, 'rev node', fmt, r,
|
||||
@ -212,7 +205,7 @@ def bookmarks(orig, ui, repo, *args, **opts):
|
||||
outputbookmarks(orig, ui, repo, *args, **opts)
|
||||
|
||||
def branches(orig, ui, repo, *args, **opts):
|
||||
outputname('branches', orig, ui, repo, *args, **opts)
|
||||
outputbranches(orig, ui, repo, *args, **opts)
|
||||
|
||||
def activepath(ui, remote):
|
||||
realpath = ''
|
||||
|
Loading…
Reference in New Issue
Block a user