[PATCH] Add --normal option to hg add (issue3061)

Na'Tosha Bard natosha at unity3d.com
Fri Dec 2 11:21:02 CST 2011


# HG changeset patch
# User Na'Tosha Bard <natosha at unity3d.com>
# Date 1322846432 -3600
# Node ID 793e905c473fbfb0efee8297e646b26c7c34d0e0
# Parent  36d7a0c7505f7b526303bb140f7bc106f7df457e
Add --normal option to hg add (issue3061)

diff -r 36d7a0c7505f -r 793e905c473f hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Thu Dec 01 15:57:10 2011 -0600
+++ b/hgext/largefiles/overrides.py	Fri Dec 02 18:20:32 2011 +0100
@@ -58,7 +58,12 @@
 # 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', None)
     large = opts.pop('large', None)
+    if normal and large:
+        raise util.Abort(_('--normal cannot be used with --large'))
+    if normal:
+        return orig(ui, repo, *pats, **opts)
     lfsize = lfutil.getminsize(
         ui, lfutil.islfilesrepo(repo), opts.pop('lfsize', None))
 
diff -r 36d7a0c7505f -r 793e905c473f hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py	Thu Dec 01 15:57:10 2011 -0600
+++ b/hgext/largefiles/uisetup.py	Fri Dec 02 18:20:32 2011 +0100
@@ -23,6 +23,8 @@
     entry = extensions.wrapcommand(commands.table, 'add',
                                    overrides.override_add)
     addopt = [('', 'large', None, _('add as largefile')),
+            ('', 'normal', None, _('add as normal file (even if it matches '
+                                   'largefile patterns)')),
             ('', 'lfsize', '', _('add all files above this size (in megabytes) '
                                  'as largefiles (default: 10)'))]
     entry[1].extend(addopt)
diff -r 36d7a0c7505f -r 793e905c473f tests/test-largefiles.t
--- a/tests/test-largefiles.t	Thu Dec 01 15:57:10 2011 -0600
+++ b/tests/test-largefiles.t	Fri Dec 02 18:20:32 2011 +0100
@@ -713,7 +713,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


More information about the Mercurial-devel mailing list