Details
Details
- Reviewers
yuja - Group Reviewers
hg-reviewers - Commits
- rHGfc0e6d298cd4: py3: handle keyword arguments in hgext/hgk.py
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
| yuja |
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| nullid, | nullid, | ||||
| nullrev, | nullrev, | ||||
| short, | short, | ||||
| ) | ) | ||||
| from mercurial import ( | from mercurial import ( | ||||
| commands, | commands, | ||||
| obsolete, | obsolete, | ||||
| patch, | patch, | ||||
| pycompat, | |||||
| registrar, | registrar, | ||||
| scmutil, | scmutil, | ||||
| util, | util, | ||||
| ) | ) | ||||
| cmdtable = {} | cmdtable = {} | ||||
| command = registrar.command(cmdtable) | command = registrar.command(cmdtable) | ||||
| # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | ||||
| ('P', 'pretty', None, _('pretty')), | ('P', 'pretty', None, _('pretty')), | ||||
| ('s', 'stdin', None, _('stdin')), | ('s', 'stdin', None, _('stdin')), | ||||
| ('C', 'copy', None, _('detect copies')), | ('C', 'copy', None, _('detect copies')), | ||||
| ('S', 'search', "", _('search'))], | ('S', 'search', "", _('search'))], | ||||
| ('[OPTION]... NODE1 NODE2 [FILE]...'), | ('[OPTION]... NODE1 NODE2 [FILE]...'), | ||||
| inferrepo=True) | inferrepo=True) | ||||
| def difftree(ui, repo, node1=None, node2=None, *files, **opts): | def difftree(ui, repo, node1=None, node2=None, *files, **opts): | ||||
| """diff trees from two commits""" | """diff trees from two commits""" | ||||
| def __difftree(repo, node1, node2, files=None): | def __difftree(repo, node1, node2, files=None): | ||||
| assert node2 is not None | assert node2 is not None | ||||
| if files is None: | if files is None: | ||||
| files = [] | files = [] | ||||
| mmap = repo[node1].manifest() | mmap = repo[node1].manifest() | ||||
| mmap2 = repo[node2].manifest() | mmap2 = repo[node2].manifest() | ||||
| m = scmutil.match(repo[node1], files) | m = scmutil.match(repo[node1], files) | ||||
| modified, added, removed = repo.status(node1, node2, m)[:3] | modified, added, removed = repo.status(node1, node2, m)[:3] | ||||
| empty = short(nullid) | empty = short(nullid) | ||||
| for f in modified: | for f in modified: | ||||
| # TODO get file permissions | # TODO get file permissions | ||||
| ui.write((":100664 100664 %s %s M\t%s\t%s\n") % | ui.write((":100664 100664 %s %s M\t%s\t%s\n") % | ||||
| (short(mmap[f]), short(mmap2[f]), f, f)) | (short(mmap[f]), short(mmap2[f]), f, f)) | ||||
| for f in added: | for f in added: | ||||
| ui.write((":000000 100664 %s %s N\t%s\t%s\n") % | ui.write((":000000 100664 %s %s N\t%s\t%s\n") % | ||||
| (empty, short(mmap2[f]), f, f)) | (empty, short(mmap2[f]), f, f)) | ||||
| for f in removed: | for f in removed: | ||||
| ui.write((":100664 000000 %s %s D\t%s\t%s\n") % | ui.write((":100664 000000 %s %s D\t%s\t%s\n") % | ||||
| (short(mmap[f]), empty, f, f)) | (short(mmap[f]), empty, f, f)) | ||||
| ## | ## | ||||
| while True: | while True: | ||||
| if opts['stdin']: | if opts[r'stdin']: | ||||
| try: | try: | ||||
| line = util.bytesinput(ui.fin, ui.fout).split(' ') | line = util.bytesinput(ui.fin, ui.fout).split(' ') | ||||
| node1 = line[0] | node1 = line[0] | ||||
| if len(line) > 1: | if len(line) > 1: | ||||
| node2 = line[1] | node2 = line[1] | ||||
| else: | else: | ||||
| node2 = None | node2 = None | ||||
| except EOFError: | except EOFError: | ||||
| break | break | ||||
| node1 = repo.lookup(node1) | node1 = repo.lookup(node1) | ||||
| if node2: | if node2: | ||||
| node2 = repo.lookup(node2) | node2 = repo.lookup(node2) | ||||
| else: | else: | ||||
| node2 = node1 | node2 = node1 | ||||
| node1 = repo.changelog.parents(node1)[0] | node1 = repo.changelog.parents(node1)[0] | ||||
| if opts['patch']: | if opts[r'patch']: | ||||
| if opts['pretty']: | if opts[r'pretty']: | ||||
| catcommit(ui, repo, node2, "") | catcommit(ui, repo, node2, "") | ||||
| m = scmutil.match(repo[node1], files) | m = scmutil.match(repo[node1], files) | ||||
| diffopts = patch.difffeatureopts(ui) | diffopts = patch.difffeatureopts(ui) | ||||
| diffopts.git = True | diffopts.git = True | ||||
| chunks = patch.diff(repo, node1, node2, match=m, | chunks = patch.diff(repo, node1, node2, match=m, | ||||
| opts=diffopts) | opts=diffopts) | ||||
| for chunk in chunks: | for chunk in chunks: | ||||
| ui.write(chunk) | ui.write(chunk) | ||||
| else: | else: | ||||
| __difftree(repo, node1, node2, files=files) | __difftree(repo, node1, node2, files=files) | ||||
| if not opts['stdin']: | if not opts[r'stdin']: | ||||
| break | break | ||||
| def catcommit(ui, repo, n, prefix, ctx=None): | def catcommit(ui, repo, n, prefix, ctx=None): | ||||
| nlprefix = '\n' + prefix | nlprefix = '\n' + prefix | ||||
| if ctx is None: | if ctx is None: | ||||
| ctx = repo[n] | ctx = repo[n] | ||||
| # use ctx.node() instead ?? | # use ctx.node() instead ?? | ||||
| ui.write(("tree %s\n" % short(ctx.changeset()[0]))) | ui.write(("tree %s\n" % short(ctx.changeset()[0]))) | ||||
| inferrepo=True) | inferrepo=True) | ||||
| def catfile(ui, repo, type=None, r=None, **opts): | def catfile(ui, repo, type=None, r=None, **opts): | ||||
| """cat a specific revision""" | """cat a specific revision""" | ||||
| # in stdin mode, every line except the commit is prefixed with two | # in stdin mode, every line except the commit is prefixed with two | ||||
| # spaces. This way the our caller can find the commit without magic | # spaces. This way the our caller can find the commit without magic | ||||
| # strings | # strings | ||||
| # | # | ||||
| prefix = "" | prefix = "" | ||||
| if opts['stdin']: | if opts[r'stdin']: | ||||
| try: | try: | ||||
| (type, r) = util.bytesinput(ui.fin, ui.fout).split(' ') | (type, r) = util.bytesinput(ui.fin, ui.fout).split(' ') | ||||
| prefix = " " | prefix = " " | ||||
| except EOFError: | except EOFError: | ||||
| return | return | ||||
| else: | else: | ||||
| if not type or not r: | if not type or not r: | ||||
| ui.warn(_("cat-file: type or revision not supplied\n")) | ui.warn(_("cat-file: type or revision not supplied\n")) | ||||
| commands.help_(ui, 'cat-file') | commands.help_(ui, 'cat-file') | ||||
| while r: | while r: | ||||
| if type != "commit": | if type != "commit": | ||||
| ui.warn(_("aborting hg cat-file only understands commits\n")) | ui.warn(_("aborting hg cat-file only understands commits\n")) | ||||
| return 1 | return 1 | ||||
| n = repo.lookup(r) | n = repo.lookup(r) | ||||
| catcommit(ui, repo, n, prefix) | catcommit(ui, repo, n, prefix) | ||||
| if opts['stdin']: | if opts[r'stdin']: | ||||
| try: | try: | ||||
| (type, r) = util.bytesinput(ui.fin, ui.fout).split(' ') | (type, r) = util.bytesinput(ui.fin, ui.fout).split(' ') | ||||
| except EOFError: | except EOFError: | ||||
| break | break | ||||
| else: | else: | ||||
| break | break | ||||
| # git rev-tree is a confusing thing. You can supply a number of | # git rev-tree is a confusing thing. You can supply a number of | ||||
| ('[OPTION]... REV...')) | ('[OPTION]... REV...')) | ||||
| def revlist(ui, repo, *revs, **opts): | def revlist(ui, repo, *revs, **opts): | ||||
| """print revisions""" | """print revisions""" | ||||
| if opts['header']: | if opts['header']: | ||||
| full = "commit" | full = "commit" | ||||
| else: | else: | ||||
| full = None | full = None | ||||
| copy = [x for x in revs] | copy = [x for x in revs] | ||||
| revtree(ui, copy, repo, full, opts['max_count'], opts['parents']) | revtree(ui, copy, repo, full, opts[r'max_count'], opts[r'parents']) | ||||
| @command('view', | @command('view', | ||||
| [('l', 'limit', '', | [('l', 'limit', '', | ||||
| _('limit number of changes displayed'), _('NUM'))], | _('limit number of changes displayed'), _('NUM'))], | ||||
| _('[-l LIMIT] [REVRANGE]')) | _('[-l LIMIT] [REVRANGE]')) | ||||
| def view(ui, repo, *etc, **opts): | def view(ui, repo, *etc, **opts): | ||||
| "start interactive history viewer" | "start interactive history viewer" | ||||
| opts = pycompat.byteskwargs(opts) | |||||
| os.chdir(repo.root) | os.chdir(repo.root) | ||||
| optstr = ' '.join(['--%s %s' % (k, v) for k, v in opts.iteritems() if v]) | optstr = ' '.join(['--%s %s' % (k, v) for k, v in opts.iteritems() if v]) | ||||
| if repo.filtername is None: | if repo.filtername is None: | ||||
| optstr += '--hidden' | optstr += '--hidden' | ||||
| cmd = ui.config("hgk", "path") + " %s %s" % (optstr, " ".join(etc)) | cmd = ui.config("hgk", "path") + " %s %s" % (optstr, " ".join(etc)) | ||||
| ui.debug("running %s\n" % cmd) | ui.debug("running %s\n" % cmd) | ||||
| ui.system(cmd, blockedtag='hgk_view') | ui.system(cmd, blockedtag='hgk_view') | ||||