Merge branch 'fc/remote-hg' (early part)
* 'fc/remote-hg' (early part): remote-hg: update bookmarks when pulling remote-hg: don't push fake 'master' bookmark remote-hg: disable forced push by default remote-hg: fix new branch creation remote-hg: add new get_config_bool() helper remote-hg: enable track-branches in hg-git mode remote-hg: get rid of unused exception checks remote-hg: trivial cleanups
This commit is contained in:
commit
0c2b1cf812
@ -87,6 +87,15 @@ def get_config(config):
|
|||||||
output, _ = process.communicate()
|
output, _ = process.communicate()
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
def get_config_bool(config, default=False):
|
||||||
|
value = get_config(config).rstrip('\n')
|
||||||
|
if value == "true":
|
||||||
|
return True
|
||||||
|
elif value == "false":
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return default
|
||||||
|
|
||||||
class Marks:
|
class Marks:
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
@ -327,11 +336,8 @@ def get_repo(url, alias):
|
|||||||
myui.setconfig('ui', 'interactive', 'off')
|
myui.setconfig('ui', 'interactive', 'off')
|
||||||
myui.fout = sys.stderr
|
myui.fout = sys.stderr
|
||||||
|
|
||||||
try:
|
if get_config_bool('remote-hg.insecure'):
|
||||||
if get_config('remote-hg.insecure') == 'true\n':
|
|
||||||
myui.setconfig('web', 'cacerts', '')
|
myui.setconfig('web', 'cacerts', '')
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mod = extensions.load(myui, 'hgext.schemes', None)
|
mod = extensions.load(myui, 'hgext.schemes', None)
|
||||||
@ -357,6 +363,9 @@ def get_repo(url, alias):
|
|||||||
die('Repository error')
|
die('Repository error')
|
||||||
repo.pull(peer, heads=None, force=True)
|
repo.pull(peer, heads=None, force=True)
|
||||||
|
|
||||||
|
rb = peer.listkeys('bookmarks')
|
||||||
|
bookmarks.updatefromremote(myui, repo, rb, url)
|
||||||
|
|
||||||
return repo
|
return repo
|
||||||
|
|
||||||
def rev_to_mark(rev):
|
def rev_to_mark(rev):
|
||||||
@ -538,7 +547,7 @@ def list_head(repo, cur):
|
|||||||
g_head = (head, node)
|
g_head = (head, node)
|
||||||
|
|
||||||
def do_list(parser):
|
def do_list(parser):
|
||||||
global branches, bmarks, mode, track_branches
|
global branches, bmarks, track_branches
|
||||||
|
|
||||||
repo = parser.repo
|
repo = parser.repo
|
||||||
for bmark, node in bookmarks.listbookmarks(repo).iteritems():
|
for bmark, node in bookmarks.listbookmarks(repo).iteritems():
|
||||||
@ -850,7 +859,7 @@ def do_export(parser):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if peer:
|
if peer:
|
||||||
parser.repo.push(peer, force=force_push)
|
parser.repo.push(peer, force=force_push, newbranch=True)
|
||||||
|
|
||||||
# handle bookmarks
|
# handle bookmarks
|
||||||
for bmark, node in p_bmarks:
|
for bmark, node in p_bmarks:
|
||||||
@ -867,7 +876,8 @@ def do_export(parser):
|
|||||||
|
|
||||||
if bmark == 'master' and 'master' not in parser.repo._bookmarks:
|
if bmark == 'master' and 'master' not in parser.repo._bookmarks:
|
||||||
# fake bookmark
|
# fake bookmark
|
||||||
pass
|
print "ok %s" % ref
|
||||||
|
continue
|
||||||
elif bookmarks.pushbookmark(parser.repo, bmark, old, new):
|
elif bookmarks.pushbookmark(parser.repo, bmark, old, new):
|
||||||
# updated locally
|
# updated locally
|
||||||
pass
|
pass
|
||||||
@ -906,20 +916,9 @@ def main(args):
|
|||||||
url = args[2]
|
url = args[2]
|
||||||
peer = None
|
peer = None
|
||||||
|
|
||||||
hg_git_compat = False
|
hg_git_compat = get_config_bool('remote-hg.hg-git-compat')
|
||||||
track_branches = True
|
track_branches = get_config_bool('remote-hg.track-branches', True)
|
||||||
force_push = True
|
force_push = get_config_bool('remote-hg.force-push')
|
||||||
|
|
||||||
try:
|
|
||||||
if get_config('remote-hg.hg-git-compat') == 'true\n':
|
|
||||||
hg_git_compat = True
|
|
||||||
track_branches = False
|
|
||||||
if get_config('remote-hg.track-branches') == 'false\n':
|
|
||||||
track_branches = False
|
|
||||||
if get_config('remote-hg.force-push') == 'false\n':
|
|
||||||
force_push = False
|
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if hg_git_compat:
|
if hg_git_compat:
|
||||||
mode = 'hg'
|
mode = 'hg'
|
||||||
|
@ -102,6 +102,7 @@ setup () {
|
|||||||
) >> "$HOME"/.hgrc &&
|
) >> "$HOME"/.hgrc &&
|
||||||
git config --global receive.denycurrentbranch warn
|
git config --global receive.denycurrentbranch warn
|
||||||
git config --global remote-hg.hg-git-compat true
|
git config --global remote-hg.hg-git-compat true
|
||||||
|
git config --global remote-hg.track-branches false
|
||||||
|
|
||||||
HGEDITOR=/usr/bin/true
|
HGEDITOR=/usr/bin/true
|
||||||
|
|
||||||
@ -455,8 +456,6 @@ test_expect_success 'hg author' '
|
|||||||
git_log gitrepo-$x > git-log-$x
|
git_log gitrepo-$x > git-log-$x
|
||||||
done &&
|
done &&
|
||||||
|
|
||||||
test_cmp git-log-hg git-log-git &&
|
|
||||||
|
|
||||||
test_cmp hg-log-hg hg-log-git &&
|
test_cmp hg-log-hg hg-log-git &&
|
||||||
test_cmp git-log-hg git-log-git
|
test_cmp git-log-hg git-log-git
|
||||||
'
|
'
|
||||||
|
Loading…
Reference in New Issue
Block a user