| 1 |
# Minimal support for git commands on an hg repository |
| 2 |
# |
| 3 |
# Copyright 2005, 2006 Chris Mason <[email protected]> |
| 4 |
# |
| 5 |
# This software may be used and distributed according to the terms of the |
| 6 |
# GNU General Public License version 2 or any later version. |
| 7 |
|
| 8 |
'''browse the repository in a graphical way |
| 9 |
|
| 10 |
The hgk extension allows browsing the history of a repository in a |
| 11 |
graphical way. It requires Tcl/Tk version 8.4 or later. (Tcl/Tk is not |
| 12 |
distributed with Mercurial.) |
| 13 |
|
| 14 |
hgk consists of two parts: a Tcl script that does the displaying and |
| 15 |
querying of information, and an extension to Mercurial named hgk.py, |
| 16 |
which provides hooks for hgk to get information. hgk can be found in |
| 17 |
the contrib directory, and the extension is shipped in the hgext |
| 18 |
repository, and needs to be enabled. |
| 19 |
|
| 20 |
The :hg:`view` command will launch the hgk Tcl script. For this command |
| 21 |
to work, hgk must be in your search path. Alternately, you can specify |
| 22 |
the path to hgk in your configuration file:: |
| 23 |
|
| 24 |
[hgk] |
| 25 |
path = /location/of/hgk |
| 26 |
|
| 27 |
hgk can make use of the extdiff extension to visualize revisions. |
| 28 |
Assuming you had already configured extdiff vdiff command, just add:: |
| 29 |
|
| 30 |
[hgk] |
| 31 |
vdiff=vdiff |
| 32 |
|
| 33 |
Revisions context menu will now display additional entries to fire |
| 34 |
vdiff on hovered and selected revisions. |
| 35 |
''' |
| 36 |
|
| 37 |
from __future__scip-python python python-stdlib 3.11 __future__/__init__: import annotationsscip-python python python-stdlib 3.11 __future__/annotations.annotations. |
| 38 |
|
| 39 |
import osscip-python python python-stdlib 3.11 os/__init__: |
| 40 |
|
| 41 |
from mercurial.i18nscip-python python mercurial 7.2.2 `mercurial.i18n`/__init__: import _scip-python python mercurial 7.2.2 `mercurial.i18n`/_(). |
| 42 |
from mercurial.nodescip-python python mercurial 7.2.2 `mercurial.node`/__init__: import ( |
| 43 |
nullrevscip-python python mercurial 7.2.2 `mercurial.node`/nullrev., |
| 44 |
shortscip-python python mercurial 7.2.2 `mercurial.node`/short()., |
| 45 |
) |
| 46 |
from mercurialscip-python python mercurial 7.2.2 mercurial/__init__: import ( |
| 47 |
commandsscip-python python mercurial 7.2.2 `mercurial.commands`/__init__:, |
| 48 |
obsoletescip-python python mercurial 7.2.2 `mercurial.obsolete`/__init__:, |
| 49 |
patchscip-python python mercurial 7.2.2 `mercurial.patch`/__init__:, |
| 50 |
pycompatscip-python python mercurial 7.2.2 `mercurial.pycompat`/__init__:, |
| 51 |
registrarscip-python python mercurial 7.2.2 `mercurial.registrar`/__init__:, |
| 52 |
scmutilscip-python python mercurial 7.2.2 `mercurial.scmutil`/__init__:, |
| 53 |
) |
| 54 |
|
| 55 |
cmdtablescip-python python mercurial 7.2.2 `hgext.hgk`/cmdtable. = {} |
| 56 |
commandscip-python python mercurial 7.2.2 `hgext.hgk`/command. = registrarscip-python python mercurial 7.2.2 `mercurial.registrar`/__init__:.commandscip-python python mercurial 7.2.2 `mercurial.registrar`/command#(cmdtablescip-python python mercurial 7.2.2 `hgext.hgk`/cmdtable.) |
| 57 |
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
| 58 |
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
| 59 |
# be specifying the version(s) of Mercurial they are tested with, or |
| 60 |
# leave the attribute unspecified. |
| 61 |
testedwithscip-python python mercurial 7.2.2 `hgext.hgk`/testedwith. = b'ships-with-hg-core' |
| 62 |
|
| 63 |
configtablescip-python python mercurial 7.2.2 `hgext.hgk`/configtable. = {} |
| 64 |
configitemscip-python python mercurial 7.2.2 `hgext.hgk`/configitem. = registrarscip-python python mercurial 7.2.2 `mercurial.registrar`/__init__:.configitemscip-python python mercurial 7.2.2 `mercurial.registrar`/configitem.(configtablescip-python python mercurial 7.2.2 `hgext.hgk`/configtable.) |
| 65 |
|
| 66 |
configitemscip-python python mercurial 7.2.2 `hgext.hgk`/configitem.( |
| 67 |
b'hgk', |
| 68 |
b'path', |
| •69 |
default=b'/usr/share/mercurial/hgk', |
| 70 |
) |
| 71 |
|
| 72 |
|
| 73 |
@commandscip-python python mercurial 7.2.2 `hgext.hgk`/command.( |
| 74 |
b'debug-diff-tree', |
| 75 |
[ |
| 76 |
(b'p', b'patch', None, _(b'generate patch')), |
| 77 |
(b'r', b'recursive', None, _(b'recursive')), |
| 78 |
(b'P', b'pretty', None, _(b'pretty')), |
| 79 |
(b's', b'stdin', None, _(b'stdin')), |
| 80 |
(b'C', b'copy', None, _(b'detect copies')), |
| 81 |
(b'S', b'search', b"", _(b'search')), |
| 82 |
], |
| 83 |
b'[OPTION]... NODE1 NODE2 [FILE]...', |
| 84 |
inferrepo=True, |
| 85 |
) |
| 86 |
def difftreescip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(uiscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(ui), reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(repo), node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node1)=None, node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node2)=None, *filesscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(files), **optsscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(opts)): |
| 87 |
"""diff trees from two commits""" |
| 88 |
|
| 89 |
def __difftreescip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(repo), node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(node1), node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(node2), filesscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(files)=None): |
| 90 |
assert node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(node2) is not None |
| 91 |
if filesscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(files) is None: |
| 92 |
filesscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(files) = [] |
| 93 |
mmap = reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(repo)[node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(node1)].manifest() |
| 94 |
mmap2 = reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(repo)[node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(node2)].manifest() |
| 95 |
m = scmutilscip-python python mercurial 7.2.2 `mercurial.scmutil`/__init__:.matchscip-python python mercurial 7.2.2 `mercurial.scmutil`/match().(reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(repo)[node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(node1)], filesscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(files)) |
| 96 |
st = reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(repo).status(node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(node1), node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(node2), m) |
| 97 |
empty = shortscip-python python mercurial 7.2.2 `mercurial.node`/short().(reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(repo).nullid) |
| 98 |
|
| 99 |
for f in st.modified: |
| 100 |
# TODO get file permissions |
| 101 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(ui).writenoi18n( |
| 102 |
b":100664 100664 %s %s M\t%s\t%s\n" |
| 103 |
% (shortscip-python python mercurial 7.2.2 `mercurial.node`/short().(mmap[f]), shortscip-python python mercurial 7.2.2 `mercurial.node`/short().(mmap2[f]), f, f) |
| 104 |
) |
| 105 |
for f in st.added: |
| 106 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(ui).writenoi18n( |
| 107 |
b":000000 100664 %s %s N\t%s\t%s\n" |
| 108 |
% (empty, shortscip-python python mercurial 7.2.2 `mercurial.node`/short().(mmap2[f]), f, f) |
| 109 |
) |
| 110 |
for f in st.removed: |
| 111 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(ui).writenoi18n( |
| 112 |
b":100664 000000 %s %s D\t%s\t%s\n" |
| 113 |
% (shortscip-python python mercurial 7.2.2 `mercurial.node`/short().(mmap[f]), empty, f, f) |
| 114 |
) |
| 115 |
|
| 116 |
## |
| 117 |
|
| 118 |
while True: |
| 119 |
if optsscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(opts)['stdin']: |
| 120 |
line = uiscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(ui).fin.readline() |
| 121 |
if not line: |
| 122 |
break |
| 123 |
line = line.rstrip(pycompatscip-python python mercurial 7.2.2 `mercurial.pycompat`/__init__:.oslinesepscip-python python mercurial 7.2.2 `mercurial.pycompat`/oslinesep.oslinesep.).split(b' ') |
| 124 |
node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node1) = line[0] |
| 125 |
if len(line) > 1: |
| 126 |
node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node2) = line[1] |
| 127 |
else: |
| 128 |
node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node2) = None |
| 129 |
node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node1) = reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(repo).lookup(node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node1)) |
| 130 |
if node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node2): |
| 131 |
node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node2) = reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(repo).lookup(node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node2)) |
| 132 |
else: |
| 133 |
node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node2) = node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node1) |
| 134 |
node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node1) = reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(repo).changelog.parents(node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node1))[0] |
| 135 |
if optsscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(opts)['patch']: |
| 136 |
if optsscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(opts)['pretty']: |
| 137 |
catcommitscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(uiscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(ui), reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(repo), node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node2), b"") |
| 138 |
m = scmutilscip-python python mercurial 7.2.2 `mercurial.scmutil`/__init__:.matchscip-python python mercurial 7.2.2 `mercurial.scmutil`/match().(reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(repo)[node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node1)], filesscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(files)) |
| 139 |
diffopts = patchscip-python python mercurial 7.2.2 `mercurial.patch`/__init__:.difffeatureoptsscip-python python mercurial 7.2.2 `mercurial.patch`/difffeatureopts.(uiscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(ui)) |
| 140 |
diffopts.git = True |
| 141 |
chunks = patchscip-python python mercurial 7.2.2 `mercurial.patch`/__init__:.diffscip-python python mercurial 7.2.2 `mercurial.patch`/diff().(reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(repo), node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node1), node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node2), matchscip-python python mercurial 7.2.2 `mercurial.patch`/diff().(match)=m, optsscip-python python mercurial 7.2.2 `mercurial.patch`/diff().(opts)=diffopts) |
| 142 |
for chunk in chunks: |
| 143 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(ui).write(chunk) |
| 144 |
else: |
| 145 |
__difftreescip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(reposcip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(repo), node1scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node1), node2scip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(node2), filesscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().__difftree().(files)=filesscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(files)) |
| 146 |
if not optsscip-python python mercurial 7.2.2 `hgext.hgk`/difftree().(opts)['stdin']: |
| 147 |
break |
| 148 |
|
| 149 |
|
| 150 |
def catcommitscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(uiscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ui), reposcip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(repo), nscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(n), prefixscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(prefix), ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx)=None): |
| 151 |
nlprefix = b'\n' + prefixscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(prefix) |
| 152 |
if ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx) is None: |
| 153 |
ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx) = reposcip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(repo)[nscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(n)] |
| 154 |
# use ctx.node() instead ?? |
| 155 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ui).writenoi18n(b"tree %s\n" % shortscip-python python mercurial 7.2.2 `mercurial.node`/short().(ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx).changeset()[0])) |
| 156 |
for p in ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx).parents(): |
| 157 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ui).writenoi18n(b"parent %s\n" % p) |
| 158 |
|
| 159 |
date = ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx).date() |
| 160 |
description = ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx).description().replace(b"\0", b"") |
| 161 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ui).writenoi18n(b"author %s %d %d\n" % (ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx).user(), intscip-python python python-stdlib 3.11 builtins/int#(date[0]), date[1])) |
| 162 |
|
| 163 |
if b'committer' in ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx).extra(): |
| 164 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ui).writenoi18n(b"committer %s\n" % ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx).extra()[b'committer']) |
| 165 |
|
| 166 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ui).writenoi18n(b"revision %d\n" % ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx).rev()) |
| 167 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ui).writenoi18n(b"branch %s\n" % ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx).branch()) |
| 168 |
if obsoletescip-python python mercurial 7.2.2 `mercurial.obsolete`/__init__:.isenabledscip-python python mercurial 7.2.2 `mercurial.obsolete`/isenabled().(reposcip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(repo), obsoletescip-python python mercurial 7.2.2 `mercurial.obsolete`/__init__:.createmarkersoptscip-python python mercurial 7.2.2 `mercurial.obsolete`/createmarkersopt.): |
| 169 |
if ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx).obsolete(): |
| 170 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ui).writenoi18n(b"obsolete\n") |
| 171 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ui).writenoi18n(b"phase %s\n\n" % ctxscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ctx).phasestr()) |
| 172 |
|
| 173 |
if prefixscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(prefix) != b"": |
| 174 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ui).write( |
| 175 |
b"%s%s\n" % (prefixscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(prefix), description.replace(b'\n', nlprefix).strip()) |
| 176 |
) |
| 177 |
else: |
| 178 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ui).write(description + b"\n") |
| 179 |
if prefixscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(prefix): |
| 180 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(ui).write(b'\0') |
| 181 |
|
| 182 |
|
| 183 |
@commandscip-python python mercurial 7.2.2 `hgext.hgk`/command.(b'debug-merge-base', [], _(b'REV REV')) |
| 184 |
def basescip-python python mercurial 7.2.2 `hgext.hgk`/base().(uiscip-python python mercurial 7.2.2 `hgext.hgk`/base().(ui), reposcip-python python mercurial 7.2.2 `hgext.hgk`/base().(repo), node1scip-python python mercurial 7.2.2 `hgext.hgk`/base().(node1), node2scip-python python mercurial 7.2.2 `hgext.hgk`/base().(node2)): |
| 185 |
"""output common ancestor information""" |
| 186 |
node1scip-python python mercurial 7.2.2 `hgext.hgk`/base().(node1) = reposcip-python python mercurial 7.2.2 `hgext.hgk`/base().(repo).lookup(node1scip-python python mercurial 7.2.2 `hgext.hgk`/base().(node1)) |
| 187 |
node2scip-python python mercurial 7.2.2 `hgext.hgk`/base().(node2) = reposcip-python python mercurial 7.2.2 `hgext.hgk`/base().(repo).lookup(node2scip-python python mercurial 7.2.2 `hgext.hgk`/base().(node2)) |
| 188 |
n = reposcip-python python mercurial 7.2.2 `hgext.hgk`/base().(repo).changelog.ancestor(node1scip-python python mercurial 7.2.2 `hgext.hgk`/base().(node1), node2scip-python python mercurial 7.2.2 `hgext.hgk`/base().(node2)) |
| 189 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/base().(ui).write(shortscip-python python mercurial 7.2.2 `mercurial.node`/short().(n) + b"\n") |
| 190 |
|
| 191 |
|
| 192 |
@commandscip-python python mercurial 7.2.2 `hgext.hgk`/command.( |
| 193 |
b'debug-cat-file', |
| 194 |
[(b's', b'stdin', None, _(b'stdin'))], |
| 195 |
_(b'[OPTION]... TYPE FILE'), |
| 196 |
inferrepo=True, |
| 197 |
) |
| 198 |
def catfilescip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(uiscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(ui), reposcip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(repo), typescip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(type)=None, rscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(r)=None, **optsscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(opts)): |
| 199 |
"""cat a specific revision""" |
| 200 |
# in stdin mode, every line except the commit is prefixed with two |
| 201 |
# spaces. This way the our caller can find the commit without magic |
| 202 |
# strings |
| 203 |
# |
| 204 |
prefix = b"" |
| 205 |
if optsscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(opts)['stdin']: |
| 206 |
line = uiscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(ui).fin.readline() |
| 207 |
if not line: |
| 208 |
return |
| 209 |
(typescip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(type), rscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(r)) = line.rstrip(pycompatscip-python python mercurial 7.2.2 `mercurial.pycompat`/__init__:.oslinesepscip-python python mercurial 7.2.2 `mercurial.pycompat`/oslinesep.oslinesep.).split(b' ') |
| 210 |
prefix = b" " |
| 211 |
else: |
| 212 |
if not typescip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(type) or not rscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(r): |
| 213 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(ui).warn(_(b"cat-file: type or revision not supplied\n")) |
| 214 |
commandsscip-python python mercurial 7.2.2 `mercurial.commands`/__init__:.help_scip-python python mercurial 7.2.2 `mercurial.commands`/help_().(uiscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(ui), b'cat-file') |
| 215 |
|
| 216 |
while rscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(r): |
| 217 |
if typescip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(type) != b"commit": |
| 218 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(ui).warn(_(b"aborting hg cat-file only understands commits\n")) |
| 219 |
return 1 |
| 220 |
n = reposcip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(repo).lookup(rscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(r)) |
| 221 |
catcommitscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(uiscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(ui), reposcip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(repo), n, prefix) |
| 222 |
if optsscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(opts)['stdin']: |
| 223 |
line = uiscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(ui).fin.readline() |
| 224 |
if not line: |
| 225 |
break |
| 226 |
(typescip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(type), rscip-python python mercurial 7.2.2 `hgext.hgk`/catfile().(r)) = line.rstrip(pycompatscip-python python mercurial 7.2.2 `mercurial.pycompat`/__init__:.oslinesepscip-python python mercurial 7.2.2 `mercurial.pycompat`/oslinesep.oslinesep.).split(b' ') |
| 227 |
else: |
| 228 |
break |
| 229 |
|
| 230 |
|
| 231 |
# git rev-tree is a confusing thing. You can supply a number of |
| 232 |
# commit sha1s on the command line, and it walks the commit history |
| 233 |
# telling you which commits are reachable from the supplied ones via |
| 234 |
# a bitmask based on arg position. |
| 235 |
# you can specify a commit to stop at by starting the sha1 with ^ |
| 236 |
def revtreescip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(uiscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(ui), argsscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(args), reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo), fullscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(full)=b"tree", maxnrscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(maxnr)=0, parentsscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(parents)=False): |
| 237 |
def chlogwalkscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().chlogwalk().(): |
| 238 |
count = len(reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo)) |
| 239 |
i = count |
| 240 |
l = [0] * 100 |
| 241 |
chunk = 100 |
| 242 |
while True: |
| 243 |
if chunk > i: |
| 244 |
chunk = i |
| 245 |
i = 0 |
| 246 |
else: |
| 247 |
i -= chunk |
| 248 |
|
| 249 |
for x in rangescip-python python python-stdlib 3.11 builtins/range#(chunk): |
| 250 |
if i + x >= count: |
| 251 |
l[chunk - x :] = [0] * (chunk - x) |
| 252 |
break |
| 253 |
if fullscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(full) is not None: |
| 254 |
if (i + x) in reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo): |
| 255 |
l[x] = reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo)[i + x] |
| 256 |
l[x].changeset() # force reading |
| 257 |
else: |
| 258 |
if (i + x) in reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo): |
| 259 |
l[x] = 1 |
| 260 |
for x in rangescip-python python python-stdlib 3.11 builtins/range#(chunk - 1, -1, -1): |
| 261 |
if l[x] != 0: |
| 262 |
yield (i + x, fullscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(full) is not None and l[x] or None) |
| 263 |
if i == 0: |
| 264 |
break |
| 265 |
|
| 266 |
# calculate and return the reachability bitmask for sha |
| 267 |
def is_reachablescip-python python mercurial 7.2.2 `hgext.hgk`/revtree().is_reachable().(arscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().is_reachable().(ar), reachablescip-python python mercurial 7.2.2 `hgext.hgk`/revtree().is_reachable().(reachable), shascip-python python mercurial 7.2.2 `hgext.hgk`/revtree().is_reachable().(sha)): |
| 268 |
if len(arscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().is_reachable().(ar)) == 0: |
| 269 |
return 1 |
| 270 |
mask = 0 |
| 271 |
for i in rangescip-python python python-stdlib 3.11 builtins/range#(len(arscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().is_reachable().(ar))): |
| 272 |
if shascip-python python mercurial 7.2.2 `hgext.hgk`/revtree().is_reachable().(sha) in reachablescip-python python mercurial 7.2.2 `hgext.hgk`/revtree().is_reachable().(reachable)[i]: |
| 273 |
mask |= 1 << i |
| 274 |
|
| 275 |
return mask |
| 276 |
|
| 277 |
reachable = [] |
| 278 |
stop_sha1 = [] |
| 279 |
want_sha1 = [] |
| 280 |
count = 0 |
| 281 |
|
| 282 |
# figure out which commits they are asking for and which ones they |
| 283 |
# want us to stop on |
| 284 |
for i, arg in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(argsscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(args)): |
| 285 |
if arg.startswith(b'^'): |
| 286 |
s = reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo).lookup(arg[1:]) |
| 287 |
stop_sha1.appendscip-python python python-stdlib 3.11 builtins/list#append().(s) |
| 288 |
want_sha1.appendscip-python python python-stdlib 3.11 builtins/list#append().(s) |
| 289 |
elif arg != b'HEAD': |
| 290 |
want_sha1.appendscip-python python python-stdlib 3.11 builtins/list#append().(reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo).lookup(arg)) |
| 291 |
|
| 292 |
# calculate the graph for the supplied commits |
| 293 |
for i, n in enumeratescip-python python python-stdlib 3.11 builtins/enumerate#(want_sha1): |
| 294 |
reachable.appendscip-python python python-stdlib 3.11 builtins/list#append().(setscip-python python python-stdlib 3.11 builtins/set#()) |
| 295 |
visit = [n] |
| 296 |
reachable[i].add(n) |
| 297 |
while visit: |
| 298 |
n = visit.popscip-python python python-stdlib 3.11 builtins/list#pop().(0) |
| 299 |
if n in stop_sha1: |
| 300 |
continue |
| 301 |
for p in reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo).changelog.parents(n): |
| 302 |
if p not in reachable[i]: |
| 303 |
reachable[i].add(p) |
| 304 |
visit.appendscip-python python python-stdlib 3.11 builtins/list#append().(p) |
| 305 |
if p in stop_sha1: |
| 306 |
continue |
| 307 |
|
| 308 |
# walk the repository looking for commits that are in our |
| 309 |
# reachability graph |
| 310 |
for i, ctx in chlogwalkscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().chlogwalk().(): |
| 311 |
if i not in reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo): |
| 312 |
continue |
| 313 |
n = reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo).changelog.node(i) |
| 314 |
mask = is_reachablescip-python python mercurial 7.2.2 `hgext.hgk`/revtree().is_reachable().(want_sha1, reachable, n) |
| 315 |
if mask: |
| 316 |
parentstr = b"" |
| 317 |
if parentsscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(parents): |
| 318 |
pp = reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo).changelog.parents(n) |
| 319 |
if pp[0] != reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo).nullid: |
| 320 |
parentstr += b" " + shortscip-python python mercurial 7.2.2 `mercurial.node`/short().(pp[0]) |
| 321 |
if pp[1] != reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo).nullid: |
| 322 |
parentstr += b" " + shortscip-python python mercurial 7.2.2 `mercurial.node`/short().(pp[1]) |
| 323 |
if not fullscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(full): |
| 324 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(ui).write(b"%s%s\n" % (shortscip-python python mercurial 7.2.2 `mercurial.node`/short().(n), parentstr)) |
| 325 |
elif fullscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(full) == b"commit": |
| 326 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(ui).write(b"%s%s\n" % (shortscip-python python mercurial 7.2.2 `mercurial.node`/short().(n), parentstr)) |
| 327 |
catcommitscip-python python mercurial 7.2.2 `hgext.hgk`/catcommit().(uiscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(ui), reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo), n, b' ', ctx) |
| 328 |
else: |
| 329 |
(p1, p2) = reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo).changelog.parents(n) |
| 330 |
(h, h1, h2) = mapscip-python python python-stdlib 3.11 builtins/map#(shortscip-python python mercurial 7.2.2 `mercurial.node`/short()., (n, p1, p2)) |
| 331 |
(i1, i2) = mapscip-python python python-stdlib 3.11 builtins/map#(reposcip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(repo).changelog.rev, (p1, p2)) |
| 332 |
|
| 333 |
date = ctx.date()[0] |
| 334 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(ui).write(b"%s %s:%s" % (date, h, mask)) |
| 335 |
mask = is_reachablescip-python python mercurial 7.2.2 `hgext.hgk`/revtree().is_reachable().(want_sha1, reachable, p1) |
| 336 |
if i1 != nullrevscip-python python mercurial 7.2.2 `mercurial.node`/nullrev. and mask > 0: |
| 337 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(ui).write(b"%s:%s " % (h1, mask)), |
| 338 |
mask = is_reachablescip-python python mercurial 7.2.2 `hgext.hgk`/revtree().is_reachable().(want_sha1, reachable, p2) |
| 339 |
if i2 != nullrevscip-python python mercurial 7.2.2 `mercurial.node`/nullrev. and mask > 0: |
| 340 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(ui).write(b"%s:%s " % (h2, mask)) |
| 341 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(ui).write(b"\n") |
| 342 |
if maxnrscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(maxnr) and count >= maxnrscip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(maxnr): |
| 343 |
break |
| 344 |
count += 1 |
| 345 |
|
| 346 |
|
| 347 |
# git rev-list tries to order things by date, and has the ability to stop |
| 348 |
# at a given commit without walking the whole repo. TODO add the stop |
| 349 |
# parameter |
| 350 |
@commandscip-python python mercurial 7.2.2 `hgext.hgk`/command.( |
| 351 |
b'debug-rev-list', |
| 352 |
[ |
| 353 |
(b'H', b'header', None, _(b'header')), |
| 354 |
(b't', b'topo-order', None, _(b'topo-order')), |
| 355 |
(b'p', b'parents', None, _(b'parents')), |
| 356 |
(b'n', b'max-count', 0, _(b'max-count')), |
| 357 |
], |
| 358 |
b'[OPTION]... REV...', |
| 359 |
) |
| 360 |
def revlistscip-python python mercurial 7.2.2 `hgext.hgk`/revlist().(uiscip-python python mercurial 7.2.2 `hgext.hgk`/revlist().(ui), reposcip-python python mercurial 7.2.2 `hgext.hgk`/revlist().(repo), *revsscip-python python mercurial 7.2.2 `hgext.hgk`/revlist().(revs), **optsscip-python python mercurial 7.2.2 `hgext.hgk`/revlist().(opts)): |
| 361 |
"""print revisions""" |
| 362 |
if optsscip-python python mercurial 7.2.2 `hgext.hgk`/revlist().(opts)['header']: |
| 363 |
full = b"commit" |
| 364 |
else: |
| 365 |
full = None |
| 366 |
copy = [x for x in revsscip-python python mercurial 7.2.2 `hgext.hgk`/revlist().(revs)] |
| 367 |
revtreescip-python python mercurial 7.2.2 `hgext.hgk`/revtree().(uiscip-python python mercurial 7.2.2 `hgext.hgk`/revlist().(ui), copy, reposcip-python python mercurial 7.2.2 `hgext.hgk`/revlist().(repo), full, optsscip-python python mercurial 7.2.2 `hgext.hgk`/revlist().(opts)['max_count'], optsscip-python python mercurial 7.2.2 `hgext.hgk`/revlist().(opts)[r'parents']) |
| 368 |
|
| 369 |
|
| 370 |
@commandscip-python python mercurial 7.2.2 `hgext.hgk`/command.( |
| 371 |
b'view', |
| 372 |
[(b'l', b'limit', b'', _(b'limit number of changes displayed'), _(b'NUM'))], |
| 373 |
_(b'[-l LIMIT] [REVRANGE]'), |
| 374 |
helpcategory=commandscip-python python mercurial 7.2.2 `hgext.hgk`/command..CATEGORY_CHANGE_NAVIGATIONscip-python python mercurial 7.2.2 `mercurial.registrar`/command#CATEGORY_CHANGE_NAVIGATION., |
| 375 |
) |
| 376 |
def viewscip-python python mercurial 7.2.2 `hgext.hgk`/view().(uiscip-python python mercurial 7.2.2 `hgext.hgk`/view().(ui), reposcip-python python mercurial 7.2.2 `hgext.hgk`/view().(repo), *etcscip-python python mercurial 7.2.2 `hgext.hgk`/view().(etc), **optsscip-python python mercurial 7.2.2 `hgext.hgk`/view().(opts)): |
| 377 |
"""start interactive history viewer""" |
| 378 |
optsscip-python python mercurial 7.2.2 `hgext.hgk`/view().(opts) = pycompatscip-python python mercurial 7.2.2 `mercurial.pycompat`/__init__:.byteskwargsscip-python python mercurial 7.2.2 `mercurial.pycompat`/byteskwargs().(optsscip-python python mercurial 7.2.2 `hgext.hgk`/view().(opts)) |
| 379 |
osscip-python python python-stdlib 3.11 os/__init__:.chdirscip-python python python-stdlib 3.11 os/chdir().(reposcip-python python mercurial 7.2.2 `hgext.hgk`/view().(repo).root) |
| 380 |
optstr = b' '.joinscip-python python python-stdlib 3.11 builtins/bytes#join().([b'--%s %s' % (k, v) for k, v in optsscip-python python mercurial 7.2.2 `hgext.hgk`/view().(opts).itemsscip-python python python-stdlib 3.11 builtins/dict#items().() if v]) |
| 381 |
if reposcip-python python mercurial 7.2.2 `hgext.hgk`/view().(repo).filtername is None: |
| 382 |
optstr += b'--hidden' |
| 383 |
|
| 384 |
cmd = uiscip-python python mercurial 7.2.2 `hgext.hgk`/view().(ui).config(b"hgk", b"path") + b" %s %s" % (optstr, b" ".joinscip-python python python-stdlib 3.11 builtins/bytes#join().(etcscip-python python mercurial 7.2.2 `hgext.hgk`/view().(etc))) |
| 385 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/view().(ui).debug(b"running %s\n" % cmd) |
| 386 |
uiscip-python python mercurial 7.2.2 `hgext.hgk`/view().(ui).system(cmd, blockedtag=b'hgk_view') |