Patchwork [6,of,8] bundlerepo: fix raw handling in revision()

login
register
mail settings
Submitter Jun Wu
Date April 7, 2017, 2:08 a.m.
Message ID <e0a0b153549d27354789.1491530894@x1c>
Download mbox | patch
Permalink /patch/19989/
State Accepted
Headers show

Comments

Jun Wu - April 7, 2017, 2:08 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1491525947 25200
#      Thu Apr 06 17:45:47 2017 -0700
# Node ID e0a0b153549d2735478923ff0eab02fb34d66ef6
# Parent  352c6f9914fc04c9b3251896a8a3382eb35b0289
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r e0a0b153549d
bundlerepo: fix raw handling in revision()

Similar to fixes in revlog.py, this patch uses "rawtext" to explicitly label
contents expected to be raw, and makes sure content stored in _cache is raw
text.

Now test-flagprocessor.t points us to another issue.

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -132,5 +132,5 @@  class bundlerevlog(revlog.revlog):
             return ""
 
-        text = None
+        rawtext = None
         chain = []
         iterrev = rev
@@ -138,20 +138,20 @@  class bundlerevlog(revlog.revlog):
         while iterrev > self.repotiprev:
             if self._cache and self._cache[1] == iterrev:
-                text = self._cache[2]
+                rawtext = self._cache[2]
                 break
             chain.append(iterrev)
             iterrev = self.index[iterrev][3]
-        if text is None:
-            text = self.baserevision(iterrev)
+        if rawtext is None:
+            rawtext = self.baserevision(iterrev)
 
         while chain:
             delta = self._chunk(chain.pop())
-            text = mdiff.patches(text, [delta])
+            rawtext = mdiff.patches(rawtext, [delta])
 
-        text, validatehash = self._processflags(text, self.flags(rev),
+        text, validatehash = self._processflags(rawtext, self.flags(rev),
                                                 'read', raw=raw)
         if validatehash:
             self.checkhash(text, node, rev=rev)
-        self._cache = (node, rev, text)
+        self._cache = (node, rev, rawtext)
         return text
 
diff --git a/tests/test-flagprocessor.t b/tests/test-flagprocessor.t
--- a/tests/test-flagprocessor.t
+++ b/tests/test-flagprocessor.t
@@ -189,10 +189,32 @@ 
   $ hg --config extensions.strip= strip -r 2 --no-backup --force -q
   $ hg -R bundle.hg log --stat -T '{rev} {desc}\n' base64 2>&1 | egrep -v '^(\*\*|  )'
-  Traceback (most recent call last):
-  mercurial.mpatch.mpatchError: invalid patch
+  5 branching
+   base64 |  2 +-
+   1 files changed, 1 insertions(+), 1 deletions(-)
+  
+  4 base64-4
+   base64 |  2 +-
+   1 files changed, 1 insertions(+), 1 deletions(-)
+  
+  3 base64-three
+   base64 |  2 +-
+   1 files changed, 1 insertions(+), 1 deletions(-)
+  
+  2 base64-two
+   base64 |  2 +-
+   1 files changed, 1 insertions(+), 1 deletions(-)
+  
+  1 base64-single
+   base64 |  2 +-
+   1 files changed, 1 insertions(+), 1 deletions(-)
+  
+  0 base64-0
+   base64 |  1 +
+   1 files changed, 1 insertions(+), 0 deletions(-)
+  
 
   $ hg bundle -R bundle.hg --base 1 bundle-again.hg -q 2>&1 | egrep -v '^(\*\*|  )'
+  [1]
+  $ hg -R bundle-again.hg log --stat -T '{rev} {desc}\n' base64 2>&1 | egrep -v '^(\*\*|  )'
   Traceback (most recent call last):
-  mercurial.mpatch.mpatchError: invalid patch
-  $ hg -R bundle-again.hg log --stat -T '{rev} {desc}\n' base64 2>&1 | egrep -v '^(\*\*|  )'
-  abort: repository bundle-again.hg not found!
+  TypeError: Incorrect padding