##// END OF EJS Templates
hgk: add --limit, and revranges
Brendan Cully -
r3093:edefbb3a default
parent child Browse files
Show More
@@ -30,15 +30,29 b' proc getcommits {rargs} {'
30 30 set startmsecs [clock clicks -milliseconds]
31 31 set nextupdate [expr $startmsecs + 100]
32 32 set ncmupdate 1
33 set limit 0
34 set revargs {}
35 for {set i 0} {$i < [llength $rargs]} {incr i} {
36 set opt [lindex $rargs $i]
37 if {$opt == "--limit"} {
38 incr i
39 set limit [lindex $rargs $i]
40 } else {
41 lappend revargs $opt
42 }
43 }
33 44 if [catch {
34 set parse_args [concat --default HEAD $rargs]
45 set parse_args [concat --default HEAD $revargs]
35 46 set parsed_args [split [eval exec hg debug-rev-parse $parse_args] "\n"]
36 }] {
47 } err] {
37 48 # if git-rev-parse failed for some reason...
38 49 if {$rargs == {}} {
39 set rargs HEAD
50 set revargs HEAD
40 51 }
41 set parsed_args $rargs
52 set parsed_args $revargs
53 }
54 if {$limit > 0} {
55 set parsed_args [concat -n $limit $parsed_args]
42 56 }
43 57 if [catch {
44 58 set commfd [open "|hg debug-rev-list --header --topo-order --parents $parsed_args" r]
@@ -7,7 +7,7 b''
7 7
8 8 from mercurial.demandload import *
9 9 demandload(globals(), 'time sys signal os')
10 demandload(globals(), 'mercurial:hg,fancyopts,commands,ui,util,patch')
10 demandload(globals(), 'mercurial:hg,fancyopts,commands,ui,util,patch,revlog')
11 11
12 12 def difftree(ui, repo, node1=None, node2=None, *files, **opts):
13 13 """diff trees from two commits"""
@@ -217,7 +217,6 b' def revtree(args, repo, full="tree", max'
217 217
218 218 # walk the repository looking for commits that are in our
219 219 # reachability graph
220 #for i in range(repo.changelog.count()-1, -1, -1):
221 220 for i, changes in chlogwalk():
222 221 n = repo.changelog.node(i)
223 222 mask = is_reachable(want_sha1, reachable, n)
@@ -252,6 +251,19 b' def revtree(args, repo, full="tree", max'
252 251 break
253 252 count += 1
254 253
254 def revparse(ui, repo, *revs, **opts):
255 """Parse given revisions"""
256 def revstr(rev):
257 if rev == 'HEAD':
258 rev = 'tip'
259 return revlog.hex(repo.lookup(rev))
260
261 for r in revs:
262 revrange = r.split(':', 1)
263 ui.write('%s\n' % revstr(revrange[0]))
264 if len(revrange) == 2:
265 ui.write('^%s\n' % revstr(revrange[1]))
266
255 267 # git rev-list tries to order things by date, and has the ability to stop
256 268 # at a given commit without walking the whole repo. TODO add the stop
257 269 # parameter
@@ -264,13 +276,16 b' def revlist(ui, repo, *revs, **opts):'
264 276 copy = [x for x in revs]
265 277 revtree(copy, repo, full, opts['max_count'], opts['parents'])
266 278
267 def view(ui, repo, *etc):
279 def view(ui, repo, *etc, **opts):
268 280 "start interactive history viewer"
269 281 os.chdir(repo.root)
270 os.system(ui.config("hgk", "path", "hgk") + " " + " ".join(etc))
282 optstr = ' '.join(['--%s %s' % (k, v) for k, v in opts.iteritems()])
283 os.system(ui.config("hgk", "path", "hgk") + " %s %s" % (optstr, " ".join(etc)))
271 284
272 285 cmdtable = {
273 "view": (view, [], 'hg view'),
286 "view": (view,
287 [('l', 'limit', '', 'limit number of changes displayed')],
288 'hg view [-l LIMIT] [REVRANGE]'),
274 289 "debug-diff-tree": (difftree, [('p', 'patch', None, 'generate patch'),
275 290 ('r', 'recursive', None, 'recursive'),
276 291 ('P', 'pretty', None, 'pretty'),
@@ -281,6 +296,9 b' cmdtable = {'
281 296 "debug-cat-file": (catfile, [('s', 'stdin', None, 'stdin')],
282 297 "hg debug-cat-file [options] type file"),
283 298 "debug-merge-base": (base, [], "hg debug-merge-base node node"),
299 'debug-rev-parse': (revparse,
300 [('', 'default', '', 'ignored')],
301 "hg debug-rev-parse rev"),
284 302 "debug-rev-list": (revlist, [('H', 'header', None, 'header'),
285 303 ('t', 'topo-order', None, 'topo-order'),
286 304 ('p', 'parents', None, 'parents'),
General Comments 0
You need to be logged in to leave comments. Login now