remote-hg: add support for --dry-run
This needs a specific patch from Git not applied yet. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
ba091c200d
commit
e3751a1763
@ -557,6 +557,7 @@ def do_capabilities(parser):
|
|||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
print "*import-marks %s" % path
|
print "*import-marks %s" % path
|
||||||
print "*export-marks %s" % path
|
print "*export-marks %s" % path
|
||||||
|
print "option"
|
||||||
|
|
||||||
print
|
print
|
||||||
|
|
||||||
@ -724,6 +725,11 @@ def parse_commit(parser):
|
|||||||
die('Unknown file command: %s' % line)
|
die('Unknown file command: %s' % line)
|
||||||
files[path] = f
|
files[path] = f
|
||||||
|
|
||||||
|
# only export the commits if we are on an internal proxy repo
|
||||||
|
if dry_run and not peer:
|
||||||
|
parsed_refs[ref] = None
|
||||||
|
return
|
||||||
|
|
||||||
def getfilectx(repo, memctx, f):
|
def getfilectx(repo, memctx, f):
|
||||||
of = files[f]
|
of = files[f]
|
||||||
if 'deleted' in of:
|
if 'deleted' in of:
|
||||||
@ -809,7 +815,10 @@ def parse_reset(parser):
|
|||||||
from_mark = parser.get_mark()
|
from_mark = parser.get_mark()
|
||||||
parser.next()
|
parser.next()
|
||||||
|
|
||||||
rev = mark_to_rev(from_mark)
|
try:
|
||||||
|
rev = mark_to_rev(from_mark)
|
||||||
|
except KeyError:
|
||||||
|
rev = None
|
||||||
parsed_refs[ref] = rev
|
parsed_refs[ref] = rev
|
||||||
|
|
||||||
def parse_tag(parser):
|
def parse_tag(parser):
|
||||||
@ -1007,7 +1016,7 @@ def do_export(parser):
|
|||||||
need_fetch = False
|
need_fetch = False
|
||||||
|
|
||||||
for ref, node in parsed_refs.iteritems():
|
for ref, node in parsed_refs.iteritems():
|
||||||
bnode = hgbin(node)
|
bnode = hgbin(node) if node else None
|
||||||
if ref.startswith('refs/heads/branches'):
|
if ref.startswith('refs/heads/branches'):
|
||||||
branch = ref[len('refs/heads/branches/'):]
|
branch = ref[len('refs/heads/branches/'):]
|
||||||
if branch in branches and bnode in branches[branch]:
|
if branch in branches and bnode in branches[branch]:
|
||||||
@ -1048,6 +1057,9 @@ def do_export(parser):
|
|||||||
|
|
||||||
p_revs[bnode] = ref
|
p_revs[bnode] = ref
|
||||||
elif ref.startswith('refs/tags/'):
|
elif ref.startswith('refs/tags/'):
|
||||||
|
if dry_run:
|
||||||
|
print "ok %s" % ref
|
||||||
|
continue
|
||||||
tag = ref[len('refs/tags/'):]
|
tag = ref[len('refs/tags/'):]
|
||||||
tag = hgref(tag)
|
tag = hgref(tag)
|
||||||
author, msg = parsed_tags.get(tag, (None, None))
|
author, msg = parsed_tags.get(tag, (None, None))
|
||||||
@ -1097,6 +1109,15 @@ def do_export(parser):
|
|||||||
|
|
||||||
print
|
print
|
||||||
|
|
||||||
|
def do_option(parser):
|
||||||
|
global dry_run
|
||||||
|
_, key, value = parser.line.split(' ')
|
||||||
|
if key == 'dry-run':
|
||||||
|
dry_run = (value == 'true')
|
||||||
|
print 'ok'
|
||||||
|
else:
|
||||||
|
print 'unsupported'
|
||||||
|
|
||||||
def fix_path(alias, repo, orig_url):
|
def fix_path(alias, repo, orig_url):
|
||||||
url = urlparse.urlparse(orig_url, 'file')
|
url = urlparse.urlparse(orig_url, 'file')
|
||||||
if url.scheme != 'file' or os.path.isabs(url.path):
|
if url.scheme != 'file' or os.path.isabs(url.path):
|
||||||
@ -1113,6 +1134,7 @@ def main(args):
|
|||||||
global parsed_tags
|
global parsed_tags
|
||||||
global filenodes
|
global filenodes
|
||||||
global fake_bmark, hg_version
|
global fake_bmark, hg_version
|
||||||
|
global dry_run
|
||||||
|
|
||||||
alias = args[1]
|
alias = args[1]
|
||||||
url = args[2]
|
url = args[2]
|
||||||
@ -1151,6 +1173,7 @@ def main(args):
|
|||||||
hg_version = tuple(int(e) for e in util.version().split('.'))
|
hg_version = tuple(int(e) for e in util.version().split('.'))
|
||||||
except:
|
except:
|
||||||
hg_version = None
|
hg_version = None
|
||||||
|
dry_run = False
|
||||||
|
|
||||||
repo = get_repo(url, alias)
|
repo = get_repo(url, alias)
|
||||||
prefix = 'refs/hg/%s' % alias
|
prefix = 'refs/hg/%s' % alias
|
||||||
@ -1175,6 +1198,8 @@ def main(args):
|
|||||||
do_import(parser)
|
do_import(parser)
|
||||||
elif parser.check('export'):
|
elif parser.check('export'):
|
||||||
do_export(parser)
|
do_export(parser)
|
||||||
|
elif parser.check('option'):
|
||||||
|
do_option(parser)
|
||||||
else:
|
else:
|
||||||
die('unhandled command: %s' % line)
|
die('unhandled command: %s' % line)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
@ -594,6 +594,44 @@ test_expect_success 'remote big push fetch first' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_failure 'remote big push dry-run' '
|
||||||
|
test_when_finished "rm -rf hgrepo gitrepo*" &&
|
||||||
|
|
||||||
|
setup_big_push
|
||||||
|
|
||||||
|
(
|
||||||
|
cd gitrepo &&
|
||||||
|
|
||||||
|
check_push 0 --dry-run --all <<-EOF
|
||||||
|
master
|
||||||
|
good_bmark
|
||||||
|
branches/good_branch
|
||||||
|
new_bmark:new
|
||||||
|
branches/new_branch:new
|
||||||
|
bad_bmark1:non-fast-forward
|
||||||
|
bad_bmark2:non-fast-forward
|
||||||
|
branches/bad_branch:non-fast-forward
|
||||||
|
EOF
|
||||||
|
|
||||||
|
check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-EOF
|
||||||
|
master
|
||||||
|
good_bmark
|
||||||
|
branches/good_branch
|
||||||
|
new_bmark:new
|
||||||
|
branches/new_branch:new
|
||||||
|
EOF
|
||||||
|
) &&
|
||||||
|
|
||||||
|
check_branch hgrepo default one &&
|
||||||
|
check_branch hgrepo good_branch "good branch" &&
|
||||||
|
check_branch hgrepo bad_branch "bad branch" &&
|
||||||
|
check_branch hgrepo new_branch '' &&
|
||||||
|
check_bookmark hgrepo good_bmark one &&
|
||||||
|
check_bookmark hgrepo bad_bmark1 one &&
|
||||||
|
check_bookmark hgrepo bad_bmark2 one &&
|
||||||
|
check_bookmark hgrepo new_bmark ''
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'remote double failed push' '
|
test_expect_success 'remote double failed push' '
|
||||||
test_when_finished "rm -rf hgrepo gitrepo*" &&
|
test_when_finished "rm -rf hgrepo gitrepo*" &&
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user