Patchwork [6,of,6] lfs: allow to run 'debugupgraderepo' on repo with largefiles

login
register
mail settings
Submitter Boris Feld
Date Dec. 8, 2017, 11:19 a.m.
Message ID <7cacbb9241087919b600.1512731960@FB>
Download mbox | patch
Permalink /patch/26101/
State Accepted
Headers show

Comments

Boris Feld - Dec. 8, 2017, 11:19 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1512680178 -3600
#      Thu Dec 07 21:56:18 2017 +0100
# Node ID 7cacbb9241087919b600713e3f3aad76ca17cac3
# Parent  f020935650c9a3ba2c762524bde86243fbd39fe3
# EXP-Topic upgrade.config
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 7cacbb924108
lfs: allow to run 'debugupgraderepo' on repo with largefiles

The extensions wrap the necessary function to ensure the 'lfs' requirements
won't be dropped.

It is now possible to run `hg debugupgraderepo` on a repository with lfs.

Patch

diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -46,6 +46,7 @@  from mercurial import (
     registrar,
     revlog,
     scmutil,
+    upgrade,
     vfs as vfsmod,
 )
 
@@ -139,6 +140,12 @@  def extsetup(ui):
 
     wrapfunction(scmutil, 'wrapconvertsink', wrapper.convertsink)
 
+    wrapfunction(upgrade, 'preservedrequirements',
+                 wrapper.upgraderequirements)
+
+    wrapfunction(upgrade, 'supporteddestrequirements',
+                 wrapper.upgraderequirements)
+
     wrapfunction(changegroup,
                  'supportedoutgoingversions',
                  wrapper.supportedoutgoingversions)
diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -302,3 +302,9 @@  def uploadblobs(repo, pointers):
 
     remoteblob = repo.svfs.lfsremoteblobstore
     remoteblob.writebatch(pointers, repo.svfs.lfslocalblobstore)
+
+def upgraderequirements(orig, repo):
+    reqs = orig(repo)
+    if 'lfs' in repo.requirements:
+        reqs.add('lfs')
+    return reqs