Patchwork [6,of,7] revlog: indent block to make review easier

login
register
mail settings
Submitter Jun Wu
Date March 28, 2017, 7:49 a.m.
Message ID <d3d803ed16fe8e9d43f7.1490687347@localhost.localdomain>
Download mbox | patch
Permalink /patch/19776/
State Changes Requested
Headers show

Comments

Jun Wu - March 28, 2017, 7:49 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1490683470 25200
#      Mon Mar 27 23:44:30 2017 -0700
# Node ID d3d803ed16fe8e9d43f7a4daeca079e4022c297a
# Parent  aecce2adbd64b25325e559798baa617e7311e85f
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r d3d803ed16fe
revlog: indent block to make review easier

This patch indents a block in revlog.revision to make reviewing the next
patch easier.
Ryan McElroy - March 29, 2017, 12:41 p.m.
On 3/28/17 8:49 AM, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1490683470 25200
> #      Mon Mar 27 23:44:30 2017 -0700
> # Node ID d3d803ed16fe8e9d43f7a4daeca079e4022c297a
> # Parent  aecce2adbd64b25325e559798baa617e7311e85f
> revlog: indent block to make review easier

Heh, thanks for this a lot actually. This patch is incredibly difficult 
to read but I verified that it is indeed only an indent, haha.

> This patch indents a block in revlog.revision to make reviewing the next
> patch easier.
>
> diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> --- a/mercurial/revlog.py
> +++ b/mercurial/revlog.py
> @@ -1277,17 +1277,18 @@ class revlog(object):
>               rev = self.rev(node)
>   
> -        chain, stopped = self._deltachain(rev, stoprev=cachedrev)
> -        if stopped:
> -            text = self._cache[2]
> -
> -        # drop cache to save memory
> -        self._cache = None
> +        if text is None:
> +            chain, stopped = self._deltachain(rev, stoprev=cachedrev)
> +            if stopped:
> +                text = self._cache[2]
>   
> -        bins = self._chunks(chain, df=_df)
> -        if text is None:
> -            text = bytes(bins[0])
> -            bins = bins[1:]
> +            # drop cache to save memory
> +            self._cache = None
>   
> -        text = mdiff.patches(text, bins)
> +            bins = self._chunks(chain, df=_df)
> +            if text is None:
> +                text = bytes(bins[0])
> +                bins = bins[1:]
> +
> +            text = mdiff.patches(text, bins)
>   
>           if flags is None:
>

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1277,17 +1277,18 @@  class revlog(object):
             rev = self.rev(node)
 
-        chain, stopped = self._deltachain(rev, stoprev=cachedrev)
-        if stopped:
-            text = self._cache[2]
-
-        # drop cache to save memory
-        self._cache = None
+        if text is None:
+            chain, stopped = self._deltachain(rev, stoprev=cachedrev)
+            if stopped:
+                text = self._cache[2]
 
-        bins = self._chunks(chain, df=_df)
-        if text is None:
-            text = bytes(bins[0])
-            bins = bins[1:]
+            # drop cache to save memory
+            self._cache = None
 
-        text = mdiff.patches(text, bins)
+            bins = self._chunks(chain, df=_df)
+            if text is None:
+                text = bytes(bins[0])
+                bins = bins[1:]
+
+            text = mdiff.patches(text, bins)
 
         if flags is None: