Patchwork [3,of,3] lfs: enable the extension locally after converting to an 'lfs' repo

login
register
mail settings
Submitter Matt Harbison
Date Dec. 1, 2017, 4:07 a.m.
Message ID <0eceec4b6383ab2cf78e.1512101236@Envy>
Download mbox | patch
Permalink /patch/25843/
State Accepted
Headers show

Comments

Matt Harbison - Dec. 1, 2017, 4:07 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1511748888 18000
#      Sun Nov 26 21:14:48 2017 -0500
# Node ID 0eceec4b6383ab2cf78e9ccbf17421d7b5bce75c
# Parent  0fb5fd7ca340d2c975117de8b798c037557e9bd6
lfs: enable the extension locally after converting to an 'lfs' repo

This is consistent with clone and share in the previous commits.
Augie Fackler - Dec. 4, 2017, 9:27 p.m.
On Thu, Nov 30, 2017 at 11:07:16PM -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1511748888 18000
> #      Sun Nov 26 21:14:48 2017 -0500
> # Node ID 0eceec4b6383ab2cf78e9ccbf17421d7b5bce75c
> # Parent  0fb5fd7ca340d2c975117de8b798c037557e9bd6
> lfs: enable the extension locally after converting to an 'lfs' repo

queued, thanks

Patch

diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -184,6 +184,10 @@ 
                         self.repo.requirements.add('lfs')
                         self.repo._writerequirements()
 
+                        # Permanently enable lfs locally
+                        with self.repo.vfs('hgrc', 'a', text=True) as fp:
+                            fp.write('\n[extensions]\nlfs=\n')
+
                 return node
 
         sink.__class__ = lfssink
diff --git a/tests/test-lfs-largefiles.t b/tests/test-lfs-largefiles.t
--- a/tests/test-lfs-largefiles.t
+++ b/tests/test-lfs-largefiles.t
@@ -290,7 +290,8 @@ 
   0 remove large_by_size.bin
   $ cd nolargefiles
 
-The requirement is added to the destination repo
+The requirement is added to the destination repo, and the extension is enabled
+locally.
 
   $ cat .hg/requires
   dotencode
@@ -299,6 +300,8 @@ 
   lfs
   revlogv1
   store
+  $ hg config --debug extensions | grep lfs
+  $TESTTMP/nolargefiles/.hg/hgrc:*: extensions.lfs= (glob)
 
   $ hg log -r 'all()' -G -T '{rev} {join(lfs_files, ", ")} ({desc})\n'
   o  8  (remove large_by_size.bin)
diff --git a/tests/test-lfs.t b/tests/test-lfs.t
--- a/tests/test-lfs.t
+++ b/tests/test-lfs.t
@@ -644,3 +644,6 @@ 
   oid sha256:66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
   size 39
   x-is-binary 0
+
+  $ hg -R convert_lfs2 config --debug extensions | grep lfs
+  $TESTTMP/convert_lfs2/.hg/hgrc:*: extensions.lfs= (glob)