##// END OF EJS Templates
graphlog: implement --copies
Patrick Mezard -
r16180:46a96cc8 default
parent child Browse files
Show More
@@ -17,7 +17,7 b' from mercurial.commands import templateo'
17 17 from mercurial.i18n import _
18 18 from mercurial.node import nullrev
19 19 from mercurial import cmdutil, commands, extensions, scmutil
20 from mercurial import hg, util, graphmod
20 from mercurial import hg, util, graphmod, templatekw
21 21
22 22 cmdtable = {}
23 23 command = cmdutil.command(cmdtable)
@@ -237,7 +237,7 b' def get_revs(repo, rev_opt):'
237 237 return (len(repo) - 1, 0)
238 238
239 239 def check_unsupported_flags(pats, opts):
240 for op in ["copies", "newest_first"]:
240 for op in ["newest_first"]:
241 241 if op in opts and opts[op]:
242 242 raise util.Abort(_("-G/--graph option is incompatible with --%s")
243 243 % op.replace("_", "-"))
@@ -350,11 +350,18 b' def revset(repo, pats, opts):'
350 350 revset = 'all()'
351 351 return revset
352 352
353 def generate(ui, dag, displayer, showparents, edgefn):
353 def generate(ui, dag, displayer, showparents, edgefn, getrenamed=None):
354 354 seen, state = [], asciistate()
355 355 for rev, type, ctx, parents in dag:
356 356 char = ctx.node() in showparents and '@' or 'o'
357 displayer.show(ctx)
357 copies = None
358 if getrenamed and ctx.rev():
359 copies = []
360 for fn in ctx.files():
361 rename = getrenamed(fn, ctx.rev())
362 if rename:
363 copies.append((fn, rename[0]))
364 displayer.show(ctx, copies=copies)
358 365 lines = displayer.hunk.pop(rev).split('\n')[:-1]
359 366 displayer.flush(rev)
360 367 edges = edgefn(type, char, lines, seen, rev, parents)
@@ -387,9 +394,15 b' def graphlog(ui, repo, *pats, **opts):'
387 394 revs = revs[:limit]
388 395 revdag = graphmod.dagwalker(repo, revs)
389 396
397 getrenamed = None
398 if opts.get('copies'):
399 endrev = None
400 if opts.get('rev'):
401 endrev = max(scmutil.revrange(repo, opts.get('rev'))) + 1
402 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
390 403 displayer = show_changeset(ui, repo, opts, buffered=True)
391 404 showparents = [ctx.node() for ctx in repo[None].parents()]
392 generate(ui, revdag, displayer, showparents, asciiedges)
405 generate(ui, revdag, displayer, showparents, asciiedges, getrenamed)
393 406
394 407 def graphrevs(repo, nodes, opts):
395 408 limit = cmdutil.loglimit(opts)
@@ -1642,3 +1642,21 b' Cannot compare with log --follow-first F'
1642 1642 o | 5 add another e
1643 1643 | |
1644 1644
1645 Test --copies
1646
1647 $ hg log -G --copies --template "{rev} {desc|firstline} \
1648 > copies: {file_copies_switch}\n"
1649 @ 6 merge 5 and 4 copies:
1650 |\
1651 | o 5 add another e copies:
1652 | |
1653 o | 4 mv dir/b e copies: e (dir/b)
1654 |/
1655 o 3 mv a b; add d copies: b (a)g (f)
1656 |
1657 o 2 mv b dir/b copies: dir/b (b)
1658 |
1659 o 1 copy a b copies: b (a)g (f)
1660 |
1661 o 0 add a copies:
1662
General Comments 0
You need to be logged in to leave comments. Login now