Mercurial > hg
changeset 6570:626cb86a6523
add compression type type parameter to bundle command
author | Benoit Allard <benoit@aeteurope.nl> |
---|---|
date | Thu, 24 Apr 2008 17:16:02 +0200 |
parents | c15bfe9cdcd6 |
children | e6f71ca3de8a |
files | mercurial/commands.py tests/test-bundle-type tests/test-bundle-type.out |
diffstat | 3 files changed, 108 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Apr 24 11:48:07 2008 +0200 +++ b/mercurial/commands.py Thu Apr 24 17:16:02 2008 +0200 @@ -406,7 +406,8 @@ If no destination repository is specified the destination is assumed to have all the nodes specified by one or more --base parameters. To create a bundle containing all changesets, use - --all (or --base null). + --all (or --base null). To change the compression method applied, + use the -t option (by default, bundles are compressed using bz2). The bundle file can then be transferred using conventional means and applied to another repository with the unbundle or pull command. @@ -460,7 +461,14 @@ cg = repo.changegroupsubset(o, revs, 'bundle') else: cg = repo.changegroup(o, 'bundle') - changegroup.writebundle(cg, fname, "HG10BZ") + + bundletype = opts.get('type', 'bzip2').lower() + btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'} + bundletype = btypes.get(bundletype) + if bundletype not in changegroup.bundletypes: + raise util.Abort(_('unknown bundle type specified with --type')) + + changegroup.writebundle(cg, fname, bundletype) def cat(ui, repo, file1, *pats, **opts): """output the current or given revision of files @@ -2985,8 +2993,8 @@ _('a changeset up to which you would like to bundle')), ('', 'base', [], _('a base changeset to specify instead of a destination')), - ('a', 'all', None, - _('bundle all changesets in the repository')), + ('a', 'all', None, _('bundle all changesets in the repository')), + ('t', 'type', 'bzip2', _('bundle compression type to use')), ] + remoteopts, _('hg bundle [-f] [-a] [-r REV]... [--base REV]... FILE [DEST]')), "cat":
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-bundle-type Thu Apr 24 17:16:02 2008 +0200 @@ -0,0 +1,41 @@ +#!/bin/sh + +echo % bundle w/o type option +hg init t1 +hg init t2 +cd t1 +echo blablablablabla > file.txt +hg ci -Ama +hg log | grep summary +hg bundle ../b1 ../t2 + +cd ../t2 +hg pull ../b1 +hg up +hg log | grep summary +cd .. + +for t in "None" "bzip2" "gzip"; do + echo % test bundle type $t + hg init t$t + cd t1 + hg bundle -t $t ../b$t ../t$t + head -c 6 ../b$t + cd ../t$t + hg pull ../b$t + hg up + hg log | grep summary + cd .. +done + +echo % test garbage file +echo garbage > bgarbage +hg init tgarbage +cd tgarbage +hg pull ../bgarbage +cd .. + +echo % test invalid bundle type +cd t1 +hg bundle -a -t garbage ../bgarbage +cd ..
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-bundle-type.out Thu Apr 24 17:16:02 2008 +0200 @@ -0,0 +1,55 @@ +% bundle w/o type option +adding file.txt +summary: a +searching for changes +1 changesets found +pulling from ../b1 +requesting all changes +adding changesets +adding manifests +adding file changes +added 1 changesets with 1 changes to 1 files +(run 'hg update' to get a working copy) +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +summary: a +% test bundle type None +searching for changes +1 changesets found +HG10UNpulling from ../bNone +requesting all changes +adding changesets +adding manifests +adding file changes +added 1 changesets with 1 changes to 1 files +(run 'hg update' to get a working copy) +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +summary: a +% test bundle type bzip2 +searching for changes +1 changesets found +HG10BZpulling from ../bbzip2 +requesting all changes +adding changesets +adding manifests +adding file changes +added 1 changesets with 1 changes to 1 files +(run 'hg update' to get a working copy) +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +summary: a +% test bundle type gzip +searching for changes +1 changesets found +HG10GZpulling from ../bgzip +requesting all changes +adding changesets +adding manifests +adding file changes +added 1 changesets with 1 changes to 1 files +(run 'hg update' to get a working copy) +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +summary: a +% test garbage file +abort: ../bgarbage: not a Mercurial bundle file +% test invalid bundle type +1 changesets found +abort: unknown bundle type specified with --type