[PATCH 3 of 3] largefiles: add --large to init command to immediately mark as a largefiles repo
Na'Tosha Bard
natosha at unity3d.com
Tue Aug 7 04:35:43 CDT 2012
2012/8/7 Matt Harbison <matt_harbison at yahoo.com>
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1343696201 14400
> # Node ID e45f7b1b766e67c56c40a92c86dd823b903eaf96
> # Parent 40fc3ecfffc7727537a11f5a26064e97f1dd0e7b
> largefiles: add --large to init command to immediately mark as a
> largefiles repo
>
> This will allow 'add', 'addremove' and 'ci -A' to honor the largefiles
> pattern
> or size configuration immediately after init. Previously, an 'add
> --large' was
> required first, otherwise files matching the configured largefile
> parameters
> were silently added as normal files.
>
> Checking for the absence of the 'largefiles' requirement and the presence
> of any
> standin in the store makes sense when deciding to write out the
> requirement.
> However, once the requirement is written, I don't see a purpose to also
> looking
> to see if there are standins in the store, other than perhaps to handle a
> rollback immediately after a largefile enabling commit. However, the
> requirement will remain in the file in this case, so any command will
> abort if
> the extension is disabled at that point anyway.
>
> diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
> --- a/hgext/largefiles/lfutil.py
> +++ b/hgext/largefiles/lfutil.py
> @@ -435,8 +435,7 @@
> return util.pconvert(os.path.normpath(path))
>
> def islfilesrepo(repo):
> - if ('largefiles' in repo.requirements and
> - util.any(shortname + '/' in f[0] for f in
> repo.store.datafiles())):
> + if 'largefiles' in repo.requirements:
> return True
>
> return util.any(openlfdirstate(repo.ui, repo, False))
> diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
> --- a/hgext/largefiles/overrides.py
> +++ b/hgext/largefiles/overrides.py
> @@ -188,6 +188,18 @@
>
> # -- Wrappers: modify existing commands --------------------------------
>
> +# Allow --large to set the largefiles requirement on creation, so that
> addremove
> +# and ci -A work out of the box.
> +def overrideinit(orig, ui, dest=".", **opts):
> + large = opts.pop('large')
> +
> + orig(ui, dest, **opts)
> +
> + if large:
> + repo = hg.repository(ui, ui.expandpath(dest))
> + repo.requirements.add('largefiles')
> + repo._writerequirements()
> +
> # Add works by going through the files that the user wanted to add and
> # checking if they should be added as largefiles. Then it makes a new
> # matcher which matches only the normal files and runs the original
> diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
> --- a/hgext/largefiles/uisetup.py
> +++ b/hgext/largefiles/uisetup.py
> @@ -21,6 +21,10 @@
> # Disable auto-status for some commands which assume that all
> # files in the result are under Mercurial's control
>
> + entry = extensions.wrapcommand(commands.table, 'init',
> + overrides.overrideinit)
> + entry[1].extend([('', 'large', None, _('mark as supporting
> largefiles'))])
> +
> entry = extensions.wrapcommand(commands.table, 'add',
> overrides.overrideadd)
> addopt = [('', 'large', None, _('add as largefile')),
> diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
> --- a/tests/test-largefiles.t
> +++ b/tests/test-largefiles.t
> @@ -1520,3 +1520,19 @@
> .hglf/large2.dat
>
> $ cd ..
> +
> +Test that init --large immediately enables largefile config
> +
> + $ hg init --large addrm3
> + $ cd addrm3
> + $ touch large.dat
> + $ touch normal.txt
> + $ hg addremove -v
> + adding large.dat as a largefile
> + adding normal.txt
> + $ hg ci -m "commit"
> + Invoking status precommit hook
> + A large.dat
> + A normal.txt
> +
> + $ cd ..
>
How does this work out in the following use case:
1) User creates a normal repo, then adds and commits a file with "-large",
turning the repo into a largefiles repo.
2) User strips this commit, so now the repo now has no largefiles.
I think expected behavior would be that the repo is now no longer a
largefiles repo, and subsequent "hg add" calls will not possibly add files
as largefiles, but I don't think that would happen with this change.
If the user had run "hg init -large", (instead of running plain "hg init"
and then adding a file with -large), then I believe expected behavior would
be that the repo would forever be a largefiles repo. However I'm not sure
how we can distinguish this.
Cheers,
Na'Tosha
--
*Na'Tosha Bard*
Software Developer | Unity Technologies - Copenhagen
*E-Mail:* natosha at unity3d.com
*Skype:* natosha.bard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120807/56392ece/attachment.html>
More information about the Mercurial-devel
mailing list