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