[PATCH] largefiles: respect config settings in a pristine repo

michalsznajder at gmail.com michalsznajder at gmail.com
Sun Dec 25 16:30:05 CST 2011


# HG changeset patch
# User Michal Sznajder <michalsznajder at gmail.com>
# Date 1324852023 -3600
# Node ID c4130b507277eeccede1b8feef8506f76e552753
# Parent  3bcfea777efc41c87918c1bb594615ff4fb6a34b
largefiles: respect config settings in a pristine repo

largefiles config settings (patterns and minsize) are not respected until
at least one file is added and commited with --large option. it gives
an impression for newcommers that largefiles are broken.

this patch solves this by relaxing some checks during add command processing

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -60,13 +60,12 @@
 def override_add(orig, ui, repo, *pats, **opts):
     large = opts.pop('large', None)
     lfsize = lfutil.getminsize(
-        ui, lfutil.islfilesrepo(repo), opts.pop('lfsize', None))
+        ui, True, opts.pop('lfsize', None))
 
     lfmatcher = None
-    if os.path.exists(repo.wjoin(lfutil.shortname)):
-        lfpats = ui.configlist(lfutil.longname, 'patterns', default=[])
-        if lfpats:
-            lfmatcher = match_.match(repo.root, '', list(lfpats))
+    lfpats = ui.configlist(lfutil.longname, 'patterns', default=[])
+    if lfpats:
+        lfmatcher = match_.match(repo.root, '', list(lfpats))
 
     lfnames = []
     m = scmutil.match(repo[None], pats, opts)
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -11,11 +11,22 @@
   > patterns=glob:**.dat
   > EOF
 
-Create the repo with a couple of revisions of both large and normal
-files, testing that status correctly shows largefiles.
+Create the repo and check that config settings (pattern **.dat, minsize 2 MB)
+are respected in a pristine repo.
 
   $ hg init a
   $ cd a
+  $ echo testdata > test.dat
+  $ dd bs=1m count=3 if=/dev/zero of=reallylarge > /dev/null 2> /dev/null
+  $ hg add
+  adding reallylarge as a largefile
+  adding test.dat as a largefile
+  $ hg forget test.dat reallylarge
+  $ rm test.dat reallylarge
+
+Create couple of revisions of both large and normal
+files, testing that status correctly shows largefiles.
+
   $ mkdir sub
   $ echo normal1 > normal1
   $ echo normal2 > sub/normal2


More information about the Mercurial-devel mailing list