# License: MIT <http://www.opensource.org/licenses/mit-license.php>
from mercurial import repo,hg,cmdutil,util,ui,revlog,node
-from hg2git import setup_repo,fixup_user,get_branch,get_changeset,load_cache,save_cache,get_git_sha1
+from hg2git import setup_repo,fixup_user,get_branch,get_changeset
+from hg2git import load_cache,save_cache,get_git_sha1,set_default_branch
from tempfile import mkstemp
from optparse import OptionParser
import re
help="Read authormap from AUTHORFILE")
parser.add_option("-f","--force",action="store_true",dest="force",
default=False,help="Ignore validation errors by force")
+ parser.add_option("-M","--default-branch",dest="default_branch",
+ help="Set the default branch")
(options,args)=parser.parse_args()
if options.authorfile!=None:
a=load_authors(options.authorfile)
+ if options.default_branch!=None:
+ set_default_branch(options.default_branch)
+
sys.exit(hg2git(options.repourl,m,options.marksfile,options.headsfile,
options.statusfile,authors=a,sob=options.sob,force=options.force))
QUIET=""
PYTHON=${PYTHON:-python}
-USAGE="[--quiet] [-r <repo>] [-m <max>] [-s] [-A <file>]"
+USAGE="[--quiet] [-r <repo>] [-m <max>] [-s] [-A <file>] [-M <branch_name>]"
LONG_USAGE="Import hg repository <repo> up to either tip or <max>
If <repo> is omitted, use last hg repository as obtained from state file,
GIT_DIR/$PFX-$SFX_STATE by default.
-A Read author map from file
(Same as in git-svnimport(1) and git-cvsimport(1))
-r Mercurial repository to import
+ -M Set the default branch name
"
. "$(git --exec-path)/git-sh-setup"
# silly regex to clean out user names
user_clean_re=re.compile('^["]([^"]+)["]$')
+def set_default_branch(name):
+ global cfg_master
+ cfg_master = name
+
def setup_repo(url):
myui=ui.ui(interactive=False)
return myui,hg.repository(myui,url)