[PATCH] largefiles: makes verify to work on local content by default (issue4242) (BC)

liscju piotr.listkiewicz at gmail.com
Wed Mar 2 08:05:13 EST 2016


# HG changeset patch
# User liscju <piotr.listkiewicz at gmail.com>
# Date 1456917749 -3600
#      Wed Mar 02 12:22:29 2016 +0100
# Node ID 184b0386fad4aff1ec64f0076c74c13e2cf5d036
# Parent  c7f89ad87baef87f00c507545dfd4cc824bc3131
largefiles: makes verify to work on local content by default (issue4242) (BC)

Before this patch largefiles verify options always tried to do
verification on remote store by default. This patch makes verification
always done locally unless user specify --remote option.

Implementation of checking locally was implemented before this
patch in basestore._openstore as special case when ui.expandpath
had problem with expanding lfpullsource or default. This patch adds
forcelocal parameter to basestore._openstore function making it
(when set) returns localstore class with remote assigned to
local repository.

diff -r c7f89ad87bae -r 184b0386fad4 hgext/largefiles/basestore.py
--- a/hgext/largefiles/basestore.py	Mon Feb 29 17:52:17 2016 -0600
+++ b/hgext/largefiles/basestore.py	Wed Mar 02 12:22:29 2016 +0100
@@ -174,27 +174,31 @@ import localstore, wirestore
 # During clone this function is passed the src's ui object
 # but it needs the dest's ui object so it can read out of
 # the config file. Use repo.ui instead.
-def _openstore(repo, remote=None, put=False):
+def _openstore(repo, remote=None, put=False, forcelocal=False):
     ui = repo.ui
 
     if not remote:
-        lfpullsource = getattr(repo, 'lfpullsource', None)
-        if lfpullsource:
-            path = ui.expandpath(lfpullsource)
-        elif put:
-            path = ui.expandpath('default-push', 'default')
-        else:
-            path = ui.expandpath('default')
-
-        # ui.expandpath() leaves 'default-push' and 'default' alone if
-        # they cannot be expanded: fallback to the empty string,
-        # meaning the current directory.
-        if path == 'default-push' or path == 'default':
+        if forcelocal:
             path = ''
             remote = repo
         else:
-            path, _branches = hg.parseurl(path)
-            remote = hg.peer(repo, {}, path)
+            lfpullsource = getattr(repo, 'lfpullsource', None)
+            if lfpullsource:
+                path = ui.expandpath(lfpullsource)
+            elif put:
+                path = ui.expandpath('default-push', 'default')
+            else:
+                path = ui.expandpath('default')
+
+            # ui.expandpath() leaves 'default-push' and 'default' alone if
+            # they cannot be expanded: fallback to the empty string,
+            # meaning the current directory.
+            if path == 'default-push' or path == 'default':
+                path = ''
+                remote = repo
+            else:
+                path, _branches = hg.parseurl(path)
+                remote = hg.peer(repo, {}, path)
 
     # The path could be a scheme so use Mercurial's normal functionality
     # to resolve the scheme to a repository and use its path
diff -r c7f89ad87bae -r 184b0386fad4 hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py	Mon Feb 29 17:52:17 2016 -0600
+++ b/hgext/largefiles/lfcommands.py	Wed Mar 02 12:22:29 2016 +0100
@@ -357,7 +357,7 @@ def uploadlfiles(ui, rsrc, rdst, files):
         at += 1
     ui.progress(_('uploading largefiles'), None)
 
-def verifylfiles(ui, repo, all=False, contents=False):
+def verifylfiles(ui, repo, all=False, contents=False, forcelocal=False):
     '''Verify that every largefile revision in the current changeset
     exists in the central store.  With --contents, also verify that
     the contents of each local largefile file revision are correct (SHA-1 hash
@@ -368,7 +368,7 @@ def verifylfiles(ui, repo, all=False, co
     else:
         revs = ['.']
 
-    store = basestore._openstore(repo)
+    store = basestore._openstore(repo, forcelocal=forcelocal)
     return store.verify(revs, contents=contents)
 
 def cachelfiles(ui, repo, node, filelist=None):
diff -r c7f89ad87bae -r 184b0386fad4 hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Mon Feb 29 17:52:17 2016 -0600
+++ b/hgext/largefiles/overrides.py	Wed Mar 02 12:22:29 2016 +0100
@@ -395,10 +395,12 @@ def overrideverify(orig, ui, repo, *pats
     large = opts.pop('large', False)
     all = opts.pop('lfa', False)
     contents = opts.pop('lfc', False)
+    forcelocal = not opts.pop('remote', False)
 
     result = orig(ui, repo, *pats, **opts)
     if large or all or contents:
-        result = result or lfcommands.verifylfiles(ui, repo, all, contents)
+        result = result or \
+                 lfcommands.verifylfiles(ui, repo, all, contents, forcelocal)
     return result
 
 def overridedebugstate(orig, ui, repo, *pats, **opts):
diff -r c7f89ad87bae -r 184b0386fad4 hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py	Mon Feb 29 17:52:17 2016 -0600
+++ b/hgext/largefiles/uisetup.py	Wed Mar 02 12:22:29 2016 +0100
@@ -57,7 +57,9 @@ def uisetup(ui):
                  ('', 'lfa', None,
                   _('verify largefiles in all revisions, not just current')),
                  ('', 'lfc', None,
-                  _('verify local largefile contents, not just existence'))]
+                  _('verify local largefile contents, not just existence')),
+                 ('', 'remote', None,
+                  _('makes largefiles verify checking in the remote store'))]
     entry[1].extend(verifyopt)
 
     entry = extensions.wrapcommand(commands.table, 'debugstate',
diff -r c7f89ad87bae -r 184b0386fad4 tests/test-largefiles-wireproto.t
--- a/tests/test-largefiles-wireproto.t	Mon Feb 29 17:52:17 2016 -0600
+++ b/tests/test-largefiles-wireproto.t	Wed Mar 02 12:22:29 2016 +0100
@@ -232,7 +232,7 @@ test 'verify' with remotestore:
 
   $ rm "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90
   $ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 .
-  $ hg -R http-clone verify --large --lfa
+  $ hg -R http-clone verify --large --lfa --remote
   checking changesets
   checking manifests
   crosschecking files in changesets and manifests
@@ -243,7 +243,7 @@ test 'verify' with remotestore:
   verified existence of 1 revisions of 1 largefiles
   [1]
   $ mv 02a439e5c31c526465ab1a0ca1f431f76b827b90 empty/.hg/largefiles/
-  $ hg -R http-clone -q verify --large --lfa
+  $ hg -R http-clone -q verify --large --lfa --remote
 
 largefiles pulled on update - a largefile missing on the server:
   $ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 .
@@ -268,6 +268,17 @@ largefiles pulled on update - a largefil
   $ [ ! -f http-clone/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 ]
   $ [ ! -f http-clone/f1 ]
   $ [ ! -f http-clone-usercache ]
+  $ hg -R http-clone verify --large --lfc --remote
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  1 files, 1 changesets, 1 total revisions
+  searching 1 changesets for largefiles
+  verified contents of 1 revisions of 1 largefiles
+
+- locally lacks f1 large file:
+
   $ hg -R http-clone verify --large --lfc
   checking changesets
   checking manifests
@@ -275,7 +286,9 @@ largefiles pulled on update - a largefil
   checking files
   1 files, 1 changesets, 1 total revisions
   searching 1 changesets for largefiles
+  changeset 0:cf03e5bb9936: f1 references missing $TESTTMP/http-clone/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 (glob)
   verified contents of 1 revisions of 1 largefiles
+  [1]
   $ hg -R http-clone up -Cqr null
 
 largefiles pulled on update - no server side problems:
diff -r c7f89ad87bae -r 184b0386fad4 tests/test-largefiles.t
--- a/tests/test-largefiles.t	Mon Feb 29 17:52:17 2016 -0600
+++ b/tests/test-largefiles.t	Wed Mar 02 12:22:29 2016 +0100
@@ -1535,7 +1535,7 @@ revert some files to an older revision
 
 - introduce missing blob in local store repo and make sure that this is caught:
   $ mv $TESTTMP/d/.hg/largefiles/e166e74c7303192238d60af5a9c4ce9bef0b7928 .
-  $ hg verify --large
+  $ hg verify --large --remote
   checking changesets
   checking manifests
   crosschecking files in changesets and manifests
@@ -1546,18 +1546,31 @@ revert some files to an older revision
   verified existence of 3 revisions of 3 largefiles
   [1]
 
+- but missing blob is on remote repo, so locally everything should be fine
+  $ hg verify --large
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  10 files, 10 changesets, 28 total revisions
+  searching 1 changesets for largefiles
+  verified existence of 3 revisions of 3 largefiles
+
 - introduce corruption and make sure that it is caught when checking content:
   $ echo '5 cents' > $TESTTMP/d/.hg/largefiles/e166e74c7303192238d60af5a9c4ce9bef0b7928
-  $ hg verify -q --large --lfc
+  $ hg verify -q --large --lfc --remote
   changeset 9:598410d3eb9a: sub/large4 references corrupted $TESTTMP/d/.hg/largefiles/e166e74c7303192238d60af5a9c4ce9bef0b7928 (glob)
   [1]
 
+- but corruption is only on remote side, locally everything should be fine
+  $ hg verify -q --large --lfc
+
 - cleanup
   $ mv e166e74c7303192238d60af5a9c4ce9bef0b7928 $TESTTMP/d/.hg/largefiles/
 
 - verifying all revisions will fail because we didn't clone all largefiles to d:
   $ echo 'T-shirt' > $TESTTMP/d/.hg/largefiles/eb7338044dc27f9bc59b8dd5a246b065ead7a9c4
-  $ hg verify -q --lfa --lfc
+  $ hg verify -q --lfa --lfc --remote
   changeset 0:30d30fe6a5be: large1 references missing $TESTTMP/d/.hg/largefiles/4669e532d5b2c093a78eca010077e708a071bb64 (glob)
   changeset 0:30d30fe6a5be: sub/large2 references missing $TESTTMP/d/.hg/largefiles/1deebade43c8c498a3c8daddac0244dc55d1331d (glob)
   changeset 1:ce8896473775: large1 references missing $TESTTMP/d/.hg/largefiles/5f78770c0e77ba4287ad6ef3071c9bf9c379742f (glob)


More information about the Mercurial-devel mailing list