Patchwork [2,of,4,V3] largefiles: add a 'debuglfput' command to put largefile into the store

login
register
mail settings
Submitter Boris Feld
Date Jan. 8, 2018, 9:16 p.m.
Message ID <a503a19221d6c6113ad1.1515446206@FB>
Download mbox | patch
Permalink /patch/26619/
State Accepted
Headers show

Comments

Boris Feld - Jan. 8, 2018, 9:16 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1513860806 -3600
#      Thu Dec 21 13:53:26 2017 +0100
# Node ID a503a19221d6c6113ad1e3add9eb084be3177daf
# Parent  4948077b44f3815e1cb83177f349bf9406843e57
# EXP-Topic largefile-url
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r a503a19221d6
largefiles: add a 'debuglfput' command to put largefile into the store

We add a new debug command able to add arbitrary new files into the largefile
store. This will be useful for debugging, testing and other unholy usecase.

Patch

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -593,3 +593,12 @@  def lfpull(ui, repo, source="default", *
         (cached, missing) = cachelfiles(ui, repo, rev)
         numcached += len(cached)
     ui.status(_("%d largefiles cached\n") % numcached)
+
+@command('debuglfput',
+    [] + cmdutil.remoteopts,
+    _('FILE'))
+def debuglfput(ui, repo, filepath, **kwargs):
+    hash = lfutil.hashfile(filepath)
+    storefactory.openstore(repo).put(filepath, hash)
+    ui.write('%s\n' % hash)
+    return 0