sapling/hgext/lfs
Matt Glazar 07d2e285c0 Fix crash when uploading to LFS
Summary:
D9478744 broke ad-hoc uploading to LFS. In the `memlocal` class, `self.vfs` is already defined as a property method, so assigning `self.vfs` to `None` shadows the property. This causes publish_watchman_for_windows_to_chocolatey to crash with a TypeError when uploading `watchman.zip`:

```
Traceback (most recent call last):
  File "<string>", line 44, in <module>
  File "<string>", line 42, in __run
  File "/usr/local/fbcode/gcc-5-glibc-2.23/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/fbcode/gcc-5-glibc-2.23/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/mnt/btrfs/trunk-hg-fbcode-fbsource-6-1535742021/fbcode/buck-out/dev/gen/watchman/facebook/windows/publish_watchman_for_windows_to_chocolatey#link-tree/watchman/facebook/windows/publish_watchman_for_windows_to_chocolatey.py", line 160, in <module>
    main(sys.argv)
  File "/mnt/btrfs/trunk-hg-fbcode-fbsource-6-1535742021/fbcode/buck-out/dev/gen/watchman/facebook/windows/publish_watchman_for_windows_to_chocolatey#link-tree/watchman/facebook/windows/publish_watchman_for_windows_to_chocolatey.py", line 52, in main
    package=package, archive_uploader=archive_uploader, credentials=credentials
  File "/mnt/btrfs/trunk-hg-fbcode-fbsource-6-1535742021/fbcode/buck-out/dev/gen/watchman/facebook/windows/publish_watchman_for_windows_to_chocolatey#link-tree/fb_choco/corp_chocolatey.py", line 80, in publish_package_from_template
    package.upload_archives(uploader=archive_uploader)
  File "/mnt/btrfs/trunk-hg-fbcode-fbsource-6-1535742021/fbcode/buck-out/dev/gen/watchman/facebook/windows/publish_watchman_for_windows_to_chocolatey#link-tree/watchman/facebook/windows/watchman_windows_package.py", line 60, in upload_archives
    archive_url = uploader.upload_file(file=archive_file)
  File "/mnt/btrfs/trunk-hg-fbcode-fbsource-6-1535742021/fbcode/buck-out/dev/gen/watchman/facebook/windows/publish_watchman_for_windows_to_chocolatey#link-tree/fb_choco/upload_archive.py", line 33, in upload_file
    oid, _size = hg_lfs.upload_only(content)
  File "/mnt/btrfs/trunk-hg-fbcode-fbsource-6-1535742021/fbcode/buck-out/dev/gen/watchman/facebook/windows/publish_watchman_for_windows_to_chocolatey#link-tree/tools/lfs/lfs.py", line 145, in upload_only
    out, err = runhgcmd("debuglfssend", LFS_URL, stdin=data)
  File "/mnt/btrfs/trunk-hg-fbcode-fbsource-6-1535742021/fbcode/buck-out/dev/gen/watchman/facebook/windows/publish_watchman_for_windows_to_chocolatey#link-tree/tools/lfs/lfs.py", line 123, in runhgcmd
    "%r exited with %s:\nstdout:\n%s\nstderr:\n%s" % (cmd, exitcode, out, err)
RuntimeError: ['hg', '--traceback', '--config=extensions.lfs=', 'debuglfssend', 'https://dewey-lfs.vip.facebook.com/lfs'] exited with 255:
stdout:
b''
stderr:
b'Traceback (most recent call last):\n  File "/usr/lib64/python2.7/site-packages/mercurial/scmutil.py", line 160, in callcatch\n    return func()\n[snip]\n  File "/usr/lib64/python2.7/site-packages/hgext/lfs/__init__.py", line 240, in debuglfssend\n    remote.writebatch(pointers, local)\n  File "/usr/lib64/python2.7/site-packages/hgext/lfs/blobstore.py", line 182, in writebatch\n    self._batch(pointers, fromstore, "upload")\n  File "/usr/lib64/python2.7/site-packages/hgext/lfs/blobstore.py", line 344, in _batch\n    for _one, oid in oids:\n  File "/usr/lib64/python2.7/site-packages/hgext/lfs/blobstore.py", line 322, in transfer\n    self._basictransfer(obj, action, localstore)\n  File "/usr/lib64/python2.7/site-packages/hgext/lfs/blobstore.py", line 270, in _basictransfer\n    request.data = filewithprogress(localstore.vfs(oid), None)\nTypeError: \'NoneType\' object is not callable\n** unknown exception encountered, please report by visiting\n** Source Control @ FB group (https://fb.facebook.com/groups/scm/)\n** Python 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]\n** Mercurial Distributed SCM (version 4.4.2_20180830_022112_16a83f70aeda)\n[snip]  File "/usr/lib64/python2.7/site-packages/hgext/lfs/blobstore.py", line 270, in _basictransfer\n    request.data = filewithprogress(localstore.vfs(oid), None)\nTypeError: \'NoneType\' object is not callable\n'
```

Remove the bogus assignment to fix the crash.

Note: The test-lfs-test-server.t test would have caught the crash. Unfortunately, that test has two issues: it requires manual setup, and it was failing before D9478744. D9619647 fixes the other failure, but the manual setup issue remains.

Reviewed By: quark-zju

Differential Revision: D9619464

fbshipit-source-id: bc11d805cf34eb441988aa43270fae1ce8c2c8fe
2018-09-01 13:20:34 -07:00
..
__init__.py lfs: add a config to skip writing to localstore 2018-08-23 11:01:07 -07:00
blobstore.py Fix crash when uploading to LFS 2018-09-01 13:20:34 -07:00
pointer.py codemod: reformat rest of the code 2018-07-05 17:52:43 -07:00
wrapper.py lfs: add a config to skip writing to localstore 2018-08-23 11:01:07 -07:00