##// END OF EJS Templates
bundle: extract the parsing of the bundle type in a function...
Pierre-Yves David -
r26510:77c13f3c default
parent child Browse files
Show More
@@ -10,7 +10,7 b' from i18n import _'
10 import os, sys, errno, re, tempfile, cStringIO, shutil
10 import os, sys, errno, re, tempfile, cStringIO, shutil
11 import util, scmutil, templater, patch, error, templatekw, revlog, copies
11 import util, scmutil, templater, patch, error, templatekw, revlog, copies
12 import match as matchmod
12 import match as matchmod
13 import repair, graphmod, revset, phases, obsolete, pathutil
13 import repair, graphmod, revset, phases, obsolete, pathutil, changegroup
14 import changelog
14 import changelog
15 import bookmarks
15 import bookmarks
16 import encoding
16 import encoding
@@ -3330,3 +3330,20 b' class dirstateguard(object):'
3330 % self._filename)
3330 % self._filename)
3331 raise util.Abort(msg)
3331 raise util.Abort(msg)
3332 self._abort()
3332 self._abort()
3333
3334 def parsebundletype(bundletype):
3335 """return the internal bundle type to use from a user input
3336
3337 This is parsing user specified bundle type as accepted in:
3338
3339 'hg bundle --type TYPE'.
3340 """
3341 btypes = {'none': 'HG10UN',
3342 'bzip2': 'HG10BZ',
3343 'gzip': 'HG10GZ',
3344 'bundle2': 'HG20'}
3345 bundletype = btypes.get(bundletype)
3346 if bundletype not in changegroup.bundletypes:
3347 raise util.Abort(_('unknown bundle type specified with --type'))
3348 return bundletype
3349
@@ -1238,13 +1238,7 b' def bundle(ui, repo, fname, dest=None, *'
1238 revs = scmutil.revrange(repo, opts['rev'])
1238 revs = scmutil.revrange(repo, opts['rev'])
1239
1239
1240 bundletype = opts.get('type', 'bzip2').lower()
1240 bundletype = opts.get('type', 'bzip2').lower()
1241 btypes = {'none': 'HG10UN',
1241 bundletype = cmdutil.parsebundletype(bundletype)
1242 'bzip2': 'HG10BZ',
1243 'gzip': 'HG10GZ',
1244 'bundle2': 'HG20'}
1245 bundletype = btypes.get(bundletype)
1246 if bundletype not in changegroup.bundletypes:
1247 raise util.Abort(_('unknown bundle type specified with --type'))
1248
1242
1249 if opts.get('all'):
1243 if opts.get('all'):
1250 base = ['null']
1244 base = ['null']
General Comments 0
You need to be logged in to leave comments. Login now