hg-fast-export: Make default branch customizable

Add -M, --default-branch <branch_name> to allow user to set
the default branch where to pull into

Signed-off-by: Fabrizio Chiarello <ponch@autistici.org>
This commit is contained in:
Fabrizio Chiarello
2008-09-18 21:10:16 +02:00
committed by Rocco Rutte
parent 02bc08886f
commit 1ab60e492b
3 changed files with 13 additions and 2 deletions

View File

@@ -4,7 +4,8 @@
# 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
@@ -380,6 +381,8 @@ if __name__=='__main__':
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()
@@ -395,5 +398,8 @@ if __name__=='__main__':
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))

View File

@@ -12,7 +12,7 @@ SFX_STATE="state"
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.
@@ -26,6 +26,7 @@ Options:
-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"

View File

@@ -15,6 +15,10 @@ user_re=re.compile('([^<]+) (<[^>]+>)$')
# 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)