##// END OF EJS Templates
log: fix line wrap on diffstat with -G/--graph (issue5800)...
Navaneeth Suresh -
r41129:6a63ba61 default
parent child Browse files
Show More
@@ -55,8 +55,8 b' def getlimit(opts):'
55 55 return limit
56 56
57 57 def diffordiffstat(ui, repo, diffopts, node1, node2, match,
58 changes=None, stat=False, fp=None, prefix='',
59 root='', listsubrepos=False, hunksfilterfn=None):
58 changes=None, stat=False, fp=None, graphwidth=0,
59 prefix='', root='', listsubrepos=False, hunksfilterfn=None):
60 60 '''show diff or diffstat.'''
61 61 if root:
62 62 relroot = pathutil.canonpath(repo.root, repo.getcwd(), root)
@@ -76,7 +76,7 b' def diffordiffstat(ui, repo, diffopts, n'
76 76 diffopts = diffopts.copy(context=0, noprefix=False)
77 77 width = 80
78 78 if not ui.plain():
79 width = ui.termwidth()
79 width = ui.termwidth() - graphwidth
80 80
81 81 chunks = repo[node2].diff(repo[node1], match, changes, opts=diffopts,
82 82 prefix=prefix, relroot=relroot,
@@ -130,12 +130,13 b' class changesetdiffer(object):'
130 130 def _makehunksfilter(self, ctx):
131 131 return None
132 132
133 def showdiff(self, ui, ctx, diffopts, stat=False):
133 def showdiff(self, ui, ctx, diffopts, graphwidth=0, stat=False):
134 134 repo = ctx.repo()
135 135 node = ctx.node()
136 136 prev = ctx.p1().node()
137 137 diffordiffstat(ui, repo, diffopts, prev, node,
138 138 match=self._makefilematcher(ctx), stat=stat,
139 graphwidth=graphwidth,
139 140 hunksfilterfn=self._makehunksfilter(ctx))
140 141
141 142 def changesetlabels(ctx):
@@ -193,6 +194,7 b' class changesetprinter(object):'
193 194 def _show(self, ctx, copies, props):
194 195 '''show a single changeset or file revision'''
195 196 changenode = ctx.node()
197 graphwidth = props.get('graphwidth', 0)
196 198
197 199 if self.ui.quiet:
198 200 self.ui.write("%s\n" % scmutil.formatchangeid(ctx),
@@ -285,7 +287,7 b' class changesetprinter(object):'
285 287 label='log.summary')
286 288 self.ui.write("\n")
287 289
288 self._showpatch(ctx)
290 self._showpatch(ctx, graphwidth)
289 291
290 292 def _showobsfate(self, ctx):
291 293 # TODO: do not depend on templater
@@ -304,13 +306,15 b' class changesetprinter(object):'
304 306 '''empty method used by extension as a hook point
305 307 '''
306 308
307 def _showpatch(self, ctx):
309 def _showpatch(self, ctx, graphwidth=0):
308 310 if self._includestat:
309 self._differ.showdiff(self.ui, ctx, self._diffopts, stat=True)
311 self._differ.showdiff(self.ui, ctx, self._diffopts,
312 graphwidth, stat=True)
310 313 if self._includestat and self._includediff:
311 314 self.ui.write("\n")
312 315 if self._includediff:
313 self._differ.showdiff(self.ui, ctx, self._diffopts, stat=False)
316 self._differ.showdiff(self.ui, ctx, self._diffopts,
317 graphwidth, stat=False)
314 318 if self._includestat or self._includediff:
315 319 self.ui.write("\n")
316 320
@@ -433,6 +437,7 b' class changesettemplater(changesetprinte'
433 437 props['ctx'] = ctx
434 438 props['index'] = index = next(self._counter)
435 439 props['revcache'] = {'copies': copies}
440 graphwidth = props.get('graphwidth', 0)
436 441
437 442 # write separator, which wouldn't work well with the header part below
438 443 # since there's inherently a conflict between header (across items) and
@@ -453,7 +458,7 b' class changesettemplater(changesetprinte'
453 458 # write changeset metadata, then patch if requested
454 459 key = self._parts[self._tref]
455 460 self.ui.write(self.t.render(key, props))
456 self._showpatch(ctx)
461 self._showpatch(ctx, graphwidth)
457 462
458 463 if self._parts['footer']:
459 464 if not self.footer:
@@ -2637,3 +2637,123 b' Log -f on B should reports current chang'
2637 2637 summary: A1B1C1
2638 2638
2639 2639 $ cd ..
2640
2641 --- going to test line wrap fix on using both --stat and -G (issue5800)
2642 $ hg init issue5800
2643 $ cd issue5800
2644 $ touch a
2645 $ hg ci -Am 'add a'
2646 adding a
2647 ---- now we are going to add 300 lines to a
2648 $ for i in `$TESTDIR/seq.py 1 300`; do echo $i >> a; done
2649 $ hg ci -m 'modify a'
2650 $ hg log
2651 changeset: 1:a98683e6a834
2652 tag: tip
2653 user: test
2654 date: Thu Jan 01 00:00:00 1970 +0000
2655 summary: modify a
2656
2657 changeset: 0:ac82d8b1f7c4
2658 user: test
2659 date: Thu Jan 01 00:00:00 1970 +0000
2660 summary: add a
2661
2662 ---- now visualise the changes we made without template
2663 $ hg log -l1 -r a98683e6a834 --stat -G
2664 @ changeset: 1:a98683e6a834
2665 | tag: tip
2666 ~ user: test
2667 date: Thu Jan 01 00:00:00 1970 +0000
2668 summary: modify a
2669
2670 a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2671 1 files changed, 300 insertions(+), 0 deletions(-)
2672
2673 ---- with template
2674 $ hg log -l1 -r a98683e6a834 --stat -G -T bisect
2675 @ changeset: 1:a98683e6a834
2676 | bisect:
2677 ~ tag: tip
2678 user: test
2679 date: Thu Jan 01 00:00:00 1970 +0000
2680 summary: modify a
2681
2682 a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2683 1 files changed, 300 insertions(+), 0 deletions(-)
2684
2685 $ hg log -l1 -r a98683e6a834 --stat -G -T changelog
2686 1970-01-01 test <test>
2687
2688 @ * a:
2689 | modify a
2690 ~ [a98683e6a834] [tip]
2691
2692 a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2693 1 files changed, 300 insertions(+), 0 deletions(-)
2694
2695 $ hg log -l1 -r a98683e6a834 --stat -G -T compact
2696 @ 1[tip] a98683e6a834 1970-01-01 00:00 +0000 test
2697 | modify a
2698 ~
2699 a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2700 1 files changed, 300 insertions(+), 0 deletions(-)
2701
2702 $ hg log -l1 -r a98683e6a834 --stat -G -T default
2703 @ changeset: 1:a98683e6a834
2704 | tag: tip
2705 ~ user: test
2706 date: Thu Jan 01 00:00:00 1970 +0000
2707 summary: modify a
2708
2709 a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2710 1 files changed, 300 insertions(+), 0 deletions(-)
2711
2712 $ hg log -l1 -r a98683e6a834 --stat -G -T phases
2713 @ changeset: 1:a98683e6a834
2714 | tag: tip
2715 ~ phase: draft
2716 user: test
2717 date: Thu Jan 01 00:00:00 1970 +0000
2718 summary: modify a
2719
2720 a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2721 1 files changed, 300 insertions(+), 0 deletions(-)
2722
2723 $ hg log -l1 -r a98683e6a834 --stat -G -T show
2724 @ changeset: 1:a98683e6a834
2725 | tag: tip
2726 ~ user: test
2727 date: Thu Jan 01 00:00:00 1970 +0000
2728 summary: modify a
2729
2730 a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2731 1 files changed, 300 insertions(+), 0 deletions(-)
2732
2733 $ hg log -l1 -r a98683e6a834 --stat -G -T status
2734 @ changeset: 1:a98683e6a834
2735 | tag: tip
2736 ~ user: test
2737 date: Thu Jan 01 00:00:00 1970 +0000
2738 summary: modify a
2739 files:
2740 M a
2741
2742 a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2743 1 files changed, 300 insertions(+), 0 deletions(-)
2744
2745 $ hg log -l1 -r a98683e6a834 --stat -G -T xml
2746 <?xml version="1.0"?>
2747 <log>
2748 @ <logentry revision="1" node="a98683e6a8340830a7683909768b62871e84bc9d">
2749 | <tag>tip</tag>
2750 ~ <author email="test">test</author>
2751 <date>1970-01-01T00:00:00+00:00</date>
2752 <msg xml:space="preserve">modify a</msg>
2753 </logentry>
2754 a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2755 1 files changed, 300 insertions(+), 0 deletions(-)
2756
2757 </log>
2758
2759 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now