largefiles: add --normal option to hg add (issue3061) stable
authorNa'Tosha Bard <natosha@unity3d.com>
Fri, 02 Dec 2011 18:20:32 +0100
branchstable
changeset 15944 f19d5c852f9b
parent 15943 f9efb325ea32
child 15945 cd42f77d30c4
largefiles: add --normal option to hg add (issue3061)
hgext/largefiles/overrides.py
hgext/largefiles/uisetup.py
tests/test-largefiles.t
--- a/hgext/largefiles/overrides.py	Fri Jan 20 11:56:12 2012 +0100
+++ b/hgext/largefiles/overrides.py	Fri Dec 02 18:20:32 2011 +0100
@@ -179,6 +179,11 @@
 # matcher which matches only the normal files and runs the original
 # version of add.
 def override_add(orig, ui, repo, *pats, **opts):
+    normal = opts.pop('normal')
+    if normal:
+        if opts.get('large'):
+            raise util.Abort(_('--normal cannot be used with --large'))
+        return orig(ui, repo, *pats, **opts)
     bad = add_largefiles(ui, repo, *pats, **opts)
     installnormalfilesmatchfn(repo[None].manifest())
     result = orig(ui, repo, *pats, **opts)
--- a/hgext/largefiles/uisetup.py	Fri Jan 20 11:56:12 2012 +0100
+++ b/hgext/largefiles/uisetup.py	Fri Dec 02 18:20:32 2011 +0100
@@ -23,6 +23,7 @@
     entry = extensions.wrapcommand(commands.table, 'add',
                                    overrides.override_add)
     addopt = [('', 'large', None, _('add as largefile')),
+              ('', 'normal', None, _('add as normal file')),
               ('', 'lfsize', '', _('add all files above this size '
                                    '(in megabytes) as largefiles '
                                    '(default: 10)'))]
--- a/tests/test-largefiles.t	Fri Jan 20 11:56:12 2012 +0100
+++ b/tests/test-largefiles.t	Fri Dec 02 18:20:32 2011 +0100
@@ -768,7 +768,18 @@
   $ hg st
   A sub2/large6-renamed
   R sub2/large6
-  $ cd ../..
+  $ cd ..
+
+Test --normal flag
+
+  $ dd if=/dev/urandom bs=2k count=11k > new-largefile 2> /dev/null
+  $ hg add --normal --large new-largefile
+  abort: --normal cannot be used with --large
+  [255]
+  $ hg add --normal new-largefile
+  new-largefile: up to 69 MB of RAM may be required to manage this file
+  (use 'hg revert new-largefile' to cancel the pending addition)
+  $ cd ..
 
 vanilla clients not locked out from largefiles servers on vanilla repos
   $ mkdir r1