From: Junio C Hamano Date: Fri, 18 Apr 2014 18:17:40 +0000 (-0700) Subject: Merge branch 'fc/remote-helper-fixes' X-Git-Tag: v2.0.0-rc0~2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/8f87d548b6c1fad5f13886f2b1a5acba2764f3b3?ds=inline;hp=-c Merge branch 'fc/remote-helper-fixes' * fc/remote-helper-fixes: remote-bzr: trivial test fix remote-bzr: include authors field in pushed commits remote-bzr: add support for older versions remote-hg: always normalize paths remote-helpers: allow all tests running from any dir --- 8f87d548b6c1fad5f13886f2b1a5acba2764f3b3 diff --combined contrib/remote-helpers/git-remote-bzr index 5f4b2e3e16,6ca1e975c3..9abb58e6ab --- a/contrib/remote-helpers/git-remote-bzr +++ b/contrib/remote-helpers/git-remote-bzr @@@ -618,10 -618,12 +618,12 @@@ def parse_commit(parser) files[path] = f committer, date, tz = committer + author, _, _ = author parents = [mark_to_rev(p) for p in parents] revid = bzrlib.generate_ids.gen_revision_id(committer, date) props = {} props['branch-nick'] = branch.nick + props['authors'] = author mtree = CustomTree(branch, revid, parents, files) changes = mtree.iter_changes() @@@ -684,8 -686,7 +686,8 @@@ def do_export(parser) peer = bzrlib.branch.Branch.open(peers[name], possible_transports=transports) try: - peer.bzrdir.push_branch(branch, revision_id=revid) + peer.bzrdir.push_branch(branch, revision_id=revid, + overwrite=force) except bzrlib.errors.DivergedBranches: print "error %s non-fast forward" % ref continue @@@ -719,32 -720,8 +721,32 @@@ def do_capabilities(parser) print "*import-marks %s" % path print "*export-marks %s" % path + print "option" print +class InvalidOptionValue(Exception): + pass + +def get_bool_option(val): + if val == 'true': + return True + elif val == 'false': + return False + else: + raise InvalidOptionValue() + +def do_option(parser): + global force + opt, val = parser[1:3] + try: + if opt == 'force': + force = get_bool_option(val) + print 'ok' + else: + print 'unsupported' + except InvalidOptionValue: + print "error '%s' is not a valid value for option '%s'" % (val, opt) + def ref_is_valid(name): return not True in [c in name for c in '~^: \\'] @@@ -784,7 -761,7 +786,7 @@@ def clone(path, remote_branch) def get_remote_branch(name): remote_branch = bzrlib.branch.Branch.open(branches[name], possible_transports=transports) - if isinstance(remote_branch.user_transport, bzrlib.transport.local.LocalTransport): + if isinstance(remote_branch.bzrdir.root_transport, bzrlib.transport.local.LocalTransport): return remote_branch branch_path = os.path.join(dirname, 'clone', name) @@@ -867,7 -844,7 +869,7 @@@ def get_repo(url, alias) if not wanted: try: repo = origin.open_repository() - if not repo.user_transport.listable(): + if not repo.bzrdir.root_transport.listable(): # this repository is not usable for us raise bzrlib.errors.NoRepositoryPresent(repo.bzrdir) except bzrlib.errors.NoRepositoryPresent: @@@ -907,7 -884,6 +909,7 @@@ def main(args) global is_tmp global branches, peers global transports + global force marks = None is_tmp = False @@@ -930,7 -906,6 +932,7 @@@ branches = {} peers = {} transports = [] + force = False if alias[5:] == url: is_tmp = True @@@ -963,8 -938,6 +965,8 @@@ 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 --combined contrib/remote-helpers/git-remote-hg index 36b526106b,84e3872d5c..34cda02759 --- a/contrib/remote-helpers/git-remote-hg +++ b/contrib/remote-helpers/git-remote-hg @@@ -260,6 -260,7 +260,7 @@@ class Parser return (user, int(date), -tz) def fix_file_path(path): + path = os.path.normpath(path) if not os.path.isabs(path): return path return os.path.relpath(path, '/') @@@ -643,10 -644,7 +644,10 @@@ def do_list(parser) print "? refs/heads/branches/%s" % gitref(branch) for bmark in bmarks: - print "? refs/heads/%s" % gitref(bmark) + if bmarks[bmark].hex() == '0000000000000000000000000000000000000000': + warn("Ignoring invalid bookmark '%s'", bmark) + else: + print "? refs/heads/%s" % gitref(bmark) for tag, node in repo.tagslist(): if tag == 'tip': diff --combined contrib/remote-helpers/test-bzr.sh index 4f379c2ab4,5d2c5b2a60..a4656ce412 --- a/contrib/remote-helpers/test-bzr.sh +++ b/contrib/remote-helpers/test-bzr.sh @@@ -66,33 -66,13 +66,33 @@@ test_expect_success 'pushing' test_cmp expected actual ' +test_expect_success 'forced pushing' ' + ( + cd gitrepo && + echo three-new >content && + git commit -a --amend -m three-new && + git push -f + ) && + + ( + cd bzrrepo && + # the forced update overwrites the bzr branch but not the bzr + # working directory (it tries to merge instead) + bzr revert + ) && + + echo three-new >expected && + cat bzrrepo/content >actual && + test_cmp expected actual +' + test_expect_success 'roundtrip' ' ( cd gitrepo && git pull && git log --format="%s" -1 origin/master >actual ) && - echo three >expected && + echo three-new >expected && test_cmp expected actual && (cd gitrepo && git push && git pull) && @@@ -382,7 -362,7 +382,7 @@@ test_expect_success 'strip' ' test_expect_success 'export utf-8 authors' ' - test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && unset GIT_COMMITTER_NAME" && + test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && GIT_COMMITTER_NAME=\"C O Mitter\"" LC_ALL=en_US.UTF-8 export LC_ALL @@@ -411,4 -391,28 +411,28 @@@ test_cmp expected actual ' + test_expect_success 'push different author' ' + test_when_finished "rm -rf bzrrepo gitrepo" && + + bzr init bzrrepo && + + ( + git init gitrepo && + cd gitrepo && + echo john >> content && + git add content && + git commit -m john --author "John Doe " && + git remote add bzr "bzr::../bzrrepo" && + git push bzr master + ) && + + ( + cd bzrrepo && + bzr log | grep "^author: " > ../actual + ) && + + echo "author: John Doe " > expected && + test_cmp expected actual + ' + test_done