diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py --- a/mercurial/logcmdutil.py +++ b/mercurial/logcmdutil.py @@ -55,8 +55,8 @@ def getlimit(opts): return limit def diffordiffstat(ui, repo, diffopts, node1, node2, match, - changes=None, stat=False, fp=None, prefix='', - root='', listsubrepos=False, hunksfilterfn=None): + changes=None, stat=False, fp=None, graphwidth=0, + prefix='', root='', listsubrepos=False, hunksfilterfn=None): '''show diff or diffstat.''' if root: relroot = pathutil.canonpath(repo.root, repo.getcwd(), root) @@ -76,7 +76,7 @@ def diffordiffstat(ui, repo, diffopts, n diffopts = diffopts.copy(context=0, noprefix=False) width = 80 if not ui.plain(): - width = ui.termwidth() + width = ui.termwidth() - graphwidth chunks = repo[node2].diff(repo[node1], match, changes, opts=diffopts, prefix=prefix, relroot=relroot, @@ -130,12 +130,13 @@ class changesetdiffer(object): def _makehunksfilter(self, ctx): return None - def showdiff(self, ui, ctx, diffopts, stat=False): + def showdiff(self, ui, ctx, diffopts, graphwidth=0, stat=False): repo = ctx.repo() node = ctx.node() prev = ctx.p1().node() diffordiffstat(ui, repo, diffopts, prev, node, match=self._makefilematcher(ctx), stat=stat, + graphwidth=graphwidth, hunksfilterfn=self._makehunksfilter(ctx)) def changesetlabels(ctx): @@ -193,6 +194,7 @@ class changesetprinter(object): def _show(self, ctx, copies, props): '''show a single changeset or file revision''' changenode = ctx.node() + graphwidth = props.get('graphwidth', 0) if self.ui.quiet: self.ui.write("%s\n" % scmutil.formatchangeid(ctx), @@ -285,7 +287,7 @@ class changesetprinter(object): label='log.summary') self.ui.write("\n") - self._showpatch(ctx) + self._showpatch(ctx, graphwidth) def _showobsfate(self, ctx): # TODO: do not depend on templater @@ -304,13 +306,15 @@ class changesetprinter(object): '''empty method used by extension as a hook point ''' - def _showpatch(self, ctx): + def _showpatch(self, ctx, graphwidth=0): if self._includestat: - self._differ.showdiff(self.ui, ctx, self._diffopts, stat=True) + self._differ.showdiff(self.ui, ctx, self._diffopts, + graphwidth, stat=True) if self._includestat and self._includediff: self.ui.write("\n") if self._includediff: - self._differ.showdiff(self.ui, ctx, self._diffopts, stat=False) + self._differ.showdiff(self.ui, ctx, self._diffopts, + graphwidth, stat=False) if self._includestat or self._includediff: self.ui.write("\n") @@ -433,6 +437,7 @@ class changesettemplater(changesetprinte props['ctx'] = ctx props['index'] = index = next(self._counter) props['revcache'] = {'copies': copies} + graphwidth = props.get('graphwidth', 0) # write separator, which wouldn't work well with the header part below # since there's inherently a conflict between header (across items) and @@ -453,7 +458,7 @@ class changesettemplater(changesetprinte # write changeset metadata, then patch if requested key = self._parts[self._tref] self.ui.write(self.t.render(key, props)) - self._showpatch(ctx) + self._showpatch(ctx, graphwidth) if self._parts['footer']: if not self.footer: diff --git a/tests/test-log.t b/tests/test-log.t --- a/tests/test-log.t +++ b/tests/test-log.t @@ -2637,3 +2637,123 @@ Log -f on B should reports current chang summary: A1B1C1 $ cd .. + +--- going to test line wrap fix on using both --stat and -G (issue5800) + $ hg init issue5800 + $ cd issue5800 + $ touch a + $ hg ci -Am 'add a' + adding a +---- now we are going to add 300 lines to a + $ for i in `$TESTDIR/seq.py 1 300`; do echo $i >> a; done + $ hg ci -m 'modify a' + $ hg log + changeset: 1:a98683e6a834 + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: modify a + + changeset: 0:ac82d8b1f7c4 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: add a + +---- now visualise the changes we made without template + $ hg log -l1 -r a98683e6a834 --stat -G + @ changeset: 1:a98683e6a834 + | tag: tip + ~ user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: modify a + + a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 300 insertions(+), 0 deletions(-) + +---- with template + $ hg log -l1 -r a98683e6a834 --stat -G -T bisect + @ changeset: 1:a98683e6a834 + | bisect: + ~ tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: modify a + + a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 300 insertions(+), 0 deletions(-) + + $ hg log -l1 -r a98683e6a834 --stat -G -T changelog + 1970-01-01 test + + @ * a: + | modify a + ~ [a98683e6a834] [tip] + + a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 300 insertions(+), 0 deletions(-) + + $ hg log -l1 -r a98683e6a834 --stat -G -T compact + @ 1[tip] a98683e6a834 1970-01-01 00:00 +0000 test + | modify a + ~ + a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 300 insertions(+), 0 deletions(-) + + $ hg log -l1 -r a98683e6a834 --stat -G -T default + @ changeset: 1:a98683e6a834 + | tag: tip + ~ user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: modify a + + a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 300 insertions(+), 0 deletions(-) + + $ hg log -l1 -r a98683e6a834 --stat -G -T phases + @ changeset: 1:a98683e6a834 + | tag: tip + ~ phase: draft + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: modify a + + a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 300 insertions(+), 0 deletions(-) + + $ hg log -l1 -r a98683e6a834 --stat -G -T show + @ changeset: 1:a98683e6a834 + | tag: tip + ~ user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: modify a + + a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 300 insertions(+), 0 deletions(-) + + $ hg log -l1 -r a98683e6a834 --stat -G -T status + @ changeset: 1:a98683e6a834 + | tag: tip + ~ user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: modify a + files: + M a + + a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 300 insertions(+), 0 deletions(-) + + $ hg log -l1 -r a98683e6a834 --stat -G -T xml + + + @ + | tip + ~ test + 1970-01-01T00:00:00+00:00 + modify a + + a | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 300 insertions(+), 0 deletions(-) + + + + $ cd ..