Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 26510:77c13f3c01ca
bundle: extract the parsing of the bundle type in a function
We are going to introduce significant extensions of the bundle parsing code to
support creation of bundle2 through the bundle command. As an early step, we
extract the logic in its own function.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 01 Oct 2015 18:01:24 -0700 |
parents | 882b170ae616 |
children | 15ce78517d4b |
comparison
equal
deleted
inserted
replaced
26509:83d82fbefccb | 26510:77c13f3c01ca |
---|---|
8 from node import hex, bin, nullid, nullrev, short | 8 from node import hex, bin, nullid, nullrev, short |
9 from i18n import _ | 9 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 |
17 import formatter | 17 import formatter |
18 import crecord as crecordmod | 18 import crecord as crecordmod |
3328 if not self._active: # already inactivated | 3328 if not self._active: # already inactivated |
3329 msg = (_("can't release already inactivated backup: %s") | 3329 msg = (_("can't release already inactivated backup: %s") |
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 |