1. Dan Villiom Podlaski Christiansen
  2. hgsubversion-queue

Commits

Dan Villiom Podlaski Christiansen  committed 207448e

New patch.

  • Participants
  • Parent commits 2c2f9ab
  • Branches default

Comments (0)

Files changed (2)

File bug-171.diff

View file
+# HG changeset patch
+# User Dan Villiom Podlaski Christiansen <dan@cabo.dk>
+# Date 1353063573 -3600
+# Node ID 9f1831114d7ba4c66aad84d3b8ecca7895e3b457
+# Parent ea8ef4dd967e806ed3d12aa9b8347e3b49c4ccd4
+verify editor: check file in close_file()
+
+The server may send file properties after the last chunk of data,
+leading us to report a false negative.
+
+diff --git a/hgsubversion/verify.py b/hgsubversion/verify.py
+--- a/hgsubversion/verify.py
++++ b/hgsubversion/verify.py
+@@ -1,8 +1,14 @@
+ import difflib
+ import posixpath
+ 
++try:
++    from hashlib import md5
++except ImportError:
++    from md5 import md5
++
+ from mercurial import util as hgutil
+ from mercurial import error
++from mercurial import node
+ 
+ import svnwrap
+ import svnrepo
+@@ -105,53 +111,13 @@ def verify(ui, repo, args=None, **opts):
+                 self.total = len(self.unexpected)
+                 self.seen = 0
+ 
+-            def open_root(self, base_revnum, pool=None):
+-                pass
+-
+-            def add_directory(self, path, parent_baton, copyfrom_path,
+-                              copyfrom_revision, pool=None):
+-                self.file = None
+-                self.props = None
+-
+-            def open_directory(self, path, parent_baton, base_revision, pool=None):
+-                self.file = None
+-                self.props = None
+-
+-            def add_file(self, path, parent_baton=None, copyfrom_path=None,
+-                         copyfrom_revision=None, file_pool=None):
+-
+-                if path in self.unexpected:
+-                    self.unexpected.remove(path)
+-                    self.file = path
+-                    self.props = {}
+-                else:
+-                    self.total += 1
+-                    self.missing.add(path)
+-                    self.failed = True
+-                    self.file = None
+-                    self.props = None
+-
+-                self.seen += 1
+-                util.progress(self.ui, 'verify', self.seen, total=self.total)
+-
+-            def open_file(self, path, base_revnum):
+-                raise NotImplementedError()
+-
+-            def apply_textdelta(self, file_baton, base_checksum, pool=None):
+-                stream = svnwrap.SimpleStringIO(closing=False)
+-                handler = svnwrap.apply_txdelta('', stream)
+-                if not callable(handler):
+-                    raise hgutil.Abort('Error in Subversion bindings: '
+-                                       'cannot call handler!')
+-                def txdelt_window(window):
+-                    handler(window)
+-                    # window being None means we're done
+-                    if window:
+-                        return
+-
++            def _verify(self):
++                if (getattr(self, 'stream', None) and
++                      getattr(self, 'file', None)):
+                     fctx = self.ctx[self.file]
+                     hgdata = fctx.data()
+-                    svndata = stream.getvalue()
++                    svndata = self.stream.getvalue()
++                    self.stream = None
+ 
+                     if 'svn:executable' in self.props:
+                         if fctx.flags() != 'x':
+@@ -171,6 +137,52 @@ def verify(ui, repo, args=None, **opts):
+                         diff_file(self.file, svndata)
+                         self.failed = True
+ 
++
++            def open_root(self, base_revnum, pool=None):
++                pass
++
++            def add_directory(self, path, parent_baton, copyfrom_path,
++                              copyfrom_revision, pool=None):
++                self.file = None
++                self.props = None
++
++            def open_directory(self, path, parent_baton, base_revision, pool=None):
++                self._verify()
++                self.file = None
++                self.props = None
++
++            def add_file(self, path, parent_baton=None, copyfrom_path=None,
++                         copyfrom_revision=None, file_pool=None):
++                self._verify()
++                self.stream = None
++                if path in self.unexpected:
++                    self.unexpected.remove(path)
++                    self.file = path
++                    self.props = {}
++                    self.open = True
++                else:
++                    self.total += 1
++                    self.missing.add(path)
++                    self.failed = True
++                    self.file = None
++                    self.props = None
++
++                self.seen += 1
++                util.progress(self.ui, 'verify', self.seen, total=self.total)
++
++            def open_file(self, path, base_revnum):
++                raise NotImplementedError()
++
++            def apply_textdelta(self, file_baton, base_checksum, pool=None):
++                self.stream = svnwrap.SimpleStringIO(closing=False)
++                handler = svnwrap.apply_txdelta('', self.stream)
++                if not callable(handler):
++                    raise hgutil.Abort('Error in Subversion bindings: '
++                                       'cannot call handler!')
++
++                def txdelt_window(window):
++                    handler(window)
++
+                 if self.file is not None:
+                     return txdelt_window
+ 
+@@ -182,7 +194,7 @@ def verify(ui, repo, args=None, **opts):
+                     self.props[name] = value
+ 
+             def close_file(self, file_baton, checksum, pool=None):
+-                pass
++                self._verify()
+ 
+             def close_directory(self, dir_baton, pool=None):
+                 pass
+diff --git a/tests/test_utility_commands.py b/tests/test_utility_commands.py
+--- a/tests/test_utility_commands.py
++++ b/tests/test_utility_commands.py
+@@ -320,7 +320,8 @@ missing file: binary3
+             'unexpected file: empty-file',
+         ])
+ 
+-        self.assertEqual((FAILURE, expected), (code, actual))
++        self.assertEqual(FAILURE, code)
++        self.assertEqual(expected, actual)
+ 
+     def test_corruption_stupid(self):
+         self.test_corruption(True)

File series

View file
+bug-171.diff
 test-hex.diff
 drop-unused-flags.diff
 listauthors-optimize.diff