aboutsummaryrefslogtreecommitdiff
path: root/contrib/remote-helpers
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2013-05-24 21:30:03 -0500
committerJunio C Hamano <gitster@pobox.com>2013-05-28 08:02:24 -0700
commite3751a1763112b301f2269dd268190900d7ddd29 (patch)
tree798c7ffd29c08e5d607d357cc8da204f94f487cb /contrib/remote-helpers
parentba091c200d88b27a0bd9027f24a7250f196fc304 (diff)
downloadgit-e3751a1763112b301f2269dd268190900d7ddd29.tar.gz
git-e3751a1763112b301f2269dd268190900d7ddd29.tar.xz
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>
Diffstat (limited to 'contrib/remote-helpers')
-rwxr-xr-xcontrib/remote-helpers/git-remote-hg29
-rwxr-xr-xcontrib/remote-helpers/test-hg.sh38
2 files changed, 65 insertions, 2 deletions
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index b983627ce..20abb3480 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -557,6 +557,7 @@ def do_capabilities(parser):
if os.path.exists(path):
print "*import-marks %s" % path
print "*export-marks %s" % path
+ print "option"
print
@@ -724,6 +725,11 @@ def parse_commit(parser):
die('Unknown file command: %s' % line)
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):
of = files[f]
if 'deleted' in of:
@@ -809,7 +815,10 @@ def parse_reset(parser):
from_mark = parser.get_mark()
parser.next()
- rev = mark_to_rev(from_mark)
+ try:
+ rev = mark_to_rev(from_mark)
+ except KeyError:
+ rev = None
parsed_refs[ref] = rev
def parse_tag(parser):
@@ -1007,7 +1016,7 @@ def do_export(parser):
need_fetch = False
for ref, node in parsed_refs.iteritems():
- bnode = hgbin(node)
+ bnode = hgbin(node) if node else None
if ref.startswith('refs/heads/branches'):
branch = ref[len('refs/heads/branches/'):]
if branch in branches and bnode in branches[branch]:
@@ -1048,6 +1057,9 @@ def do_export(parser):
p_revs[bnode] = ref
elif ref.startswith('refs/tags/'):
+ if dry_run:
+ print "ok %s" % ref
+ continue
tag = ref[len('refs/tags/'):]
tag = hgref(tag)
author, msg = parsed_tags.get(tag, (None, None))
@@ -1097,6 +1109,15 @@ def do_export(parser):
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):
url = urlparse.urlparse(orig_url, 'file')
if url.scheme != 'file' or os.path.isabs(url.path):
@@ -1113,6 +1134,7 @@ def main(args):
global parsed_tags
global filenodes
global fake_bmark, hg_version
+ global dry_run
alias = args[1]
url = args[2]
@@ -1151,6 +1173,7 @@ def main(args):
hg_version = tuple(int(e) for e in util.version().split('.'))
except:
hg_version = None
+ dry_run = False
repo = get_repo(url, alias)
prefix = 'refs/hg/%s' % alias
@@ -1175,6 +1198,8 @@ def main(args):
do_import(parser)
elif parser.check('export'):
do_export(parser)
+ elif parser.check('option'):
+ do_option(parser)
else:
die('unhandled command: %s' % line)
sys.stdout.flush()
diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index 41ea2e808..51f3c0387 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -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_when_finished "rm -rf hgrepo gitrepo*" &&