Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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>
  • Loading branch information...
commit 1ab60e492b406ae5dba5f115c605486aa2564caa 1 parent 02bc088
Fabrizio Chiarello authored Rocco Rutte committed
Showing with 13 additions and 2 deletions.
  1. +7 −1 hg-fast-export.py
  2. +2 −1  hg-fast-export.sh
  3. +4 −0 hg2git.py
View
8 hg-fast-export.py
@@ -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 @@ def bail(parser,opt):
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 @@ def bail(parser,opt):
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
3  hg-fast-export.sh
@@ -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
4 hg2git.py
@@ -15,6 +15,10 @@
# 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)
Please sign in to comment.
Something went wrong with that request. Please try again.