Merge branch 'fc/remote-helper-fixes'
authorJunio C Hamano <gitster@pobox.com>
Fri, 18 Apr 2014 18:17:40 +0000 (11:17 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 18 Apr 2014 18:17:40 +0000 (11:17 -0700)
* 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

1  2 
contrib/remote-helpers/git-remote-bzr
contrib/remote-helpers/git-remote-hg
contrib/remote-helpers/test-bzr.sh
index 5f4b2e3e160f60955e25f8b8fedf8c122dd5c73c,6ca1e975c3e01f1b414d9b186f97492e5f9e44c6..9abb58e6ab45077bf9b5e01658438817ea9b7126
@@@ -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
      branches = {}
      peers = {}
      transports = []
 +    force = False
  
      if alias[5:] == url:
          is_tmp = True
              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()
index 36b526106ba7b3c61b70549770c1ec82f45e1baf,84e3872d5c5344666b0e4b0241cd609b7359fb2b..34cda027597f30ddacf340466778404f3705361d
@@@ -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':
index 4f379c2ab499f2ca5556f844cbdcacb98fffa13c,5d2c5b2a60f59cf96e2e9d9322be82b386b78148..a4656ce412cc8c192a636030a019c156bb58df7f
@@@ -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
        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 <jdoe@example.com>" &&
+       git remote add bzr "bzr::../bzrrepo" &&
+       git push bzr master
+       ) &&
+       (
+       cd bzrrepo &&
+       bzr log | grep "^author: " > ../actual
+       ) &&
+       echo "author: John Doe <jdoe@example.com>" > expected &&
+       test_cmp expected actual
+ '
  test_done