D5485: log: fixes line wrap on diffstat (issue5800)

navaneeth.suresh (Navaneeth Suresh) phabricator at mercurial-scm.org
Sun Dec 30 08:27:54 EST 2018


navaneeth.suresh updated this revision to Diff 12995.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5485?vs=12983&id=12995

REVISION DETAIL
  https://phab.mercurial-scm.org/D5485

AFFECTED FILES
  mercurial/logcmdutil.py

CHANGE DETAILS

diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -55,8 +55,8 @@
     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, graphwidth=0, fp=None,
+                   prefix='', root='', listsubrepos=False, hunksfilterfn=None):
     '''show diff or diffstat.'''
     if root:
         relroot = pathutil.canonpath(repo.root, repo.getcwd(), root)
@@ -76,7 +76,7 @@
         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 @@
     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,9 @@
     def _show(self, ctx, copies, props):
         '''show a single changeset or file revision'''
         changenode = ctx.node()
+        graphwidth = props.get('graphwidth')
+        if not graphwidth:
+            graphwidth = 0
 
         if self.ui.quiet:
             self.ui.write("%s\n" % scmutil.formatchangeid(ctx),
@@ -285,7 +289,7 @@
                               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 +308,15 @@
         '''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")
 



To: navaneeth.suresh, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list