Commit graph

253 commits

Author SHA1 Message Date
Sebastian Schuberth b8686c661d contrib: git-remote-{bzr,hg} placeholders don't need Python
It does not make sense for these placeholder scripts to depend on Python
just because the real scripts do. At the example of Git for Windows, we
would not even be able to see those warnings as it does not ship with
Python. So just use plain shell scripts instead.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-03 11:09:34 -08:00
Junio C Hamano b2c851a8e6 Revert "Merge branch 'jc/graduate-remote-hg-bzr' (early part)"
Instead of showing a warning and working as before, fail and show
the message and force immediate upgrade from their upstream
repositories when these tools are run, per request from their
primary author.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-05-20 14:48:11 -07:00
Junio C Hamano 896ba14d65 remote-helpers: point at their upstream repositories
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-05-19 17:10:03 -07:00
Felipe Contreras 0311086351 contrib: remote-helpers: add move warnings (v2.0)
The tools are now maintained out-of-tree, and they have a regression
in v2.0. It's better to start warning the users as soon as possible.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-05-19 17:10:03 -07:00
Junio C Hamano 8f87d548b6 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
2014-04-18 11:17:40 -07:00
Felipe Contreras 7569accf41 remote-bzr: trivial test fix
So that the committer is reset properly.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-04-14 13:25:28 -07:00
dequis 62210887f7 remote-bzr: include authors field in pushed commits
Tests-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-04-09 14:20:48 -07:00
Felipe Contreras 5ff569908d remote-bzr: add support for older versions
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-04-09 14:20:48 -07:00
Felipe Contreras 867bf7b490 remote-hg: always normalize paths
Apparently Mercurial can have paths such as 'foo//bar', so normalize all
paths.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-04-09 14:20:48 -07:00
Felipe Contreras fe45cfb518 remote-helpers: allow all tests running from any dir
Commit d3243d7 (test-bzr.sh, test-hg.sh: allow running from any dir)
allowed the tests to run from any directory, however, it didn't update
all the tests.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-04-09 14:20:47 -07:00
Junio C Hamano 125d8ecefe Merge branch 'ap/remote-hg-skip-null-bookmarks'
* ap/remote-hg-skip-null-bookmarks:
  remote-hg: do not fail on invalid bookmarks
2014-04-02 14:18:23 -07:00
Max Horn 51be46ec4d remote-hg: do not fail on invalid bookmarks
Mercurial can have bookmarks pointing to "nullid" (the empty root
revision), while Git can not have references to it. When cloning or
fetching from a Mercurial repository that has such a bookmark, the
import failed because git-remote-hg was not be able to create the
corresponding reference.

Warn the user about the invalid reference, and do not advertise these
bookmarks as head refs, but otherwise continue the import. In
particular, we still keep track of the fact that the remote repository
has a bookmark of the given name, in case the user wants to modify that
bookmark.

Also add some test cases for this issue.

Reported-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Max Horn <max@quendi.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-03-25 12:05:24 -07:00
Junio C Hamano 90e6255a6d Merge branch 'fc/transport-helper-fixes'
Updates transport-helper, fast-import and fast-export to allow the
ref mapping and ref deletion in a way similar to the natively
supported transports.

* fc/transport-helper-fixes:
  remote-bzr: support the new 'force' option
  test-hg.sh: tests are now expected to pass
  transport-helper.c: do not overwrite forced bit
  transport-helper: check for 'forced update' message
  transport-helper: add 'force' to 'export' helpers
  transport-helper: don't update refs in dry-run
  transport-helper: mismerge fix
2014-03-18 13:49:33 -07:00
Richard Hansen a7cb1276cc remote-bzr: support the new 'force' option
Signed-off-by: Richard Hansen <rhansen@bbn.com>
Acked-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-02-24 09:04:27 -08:00
Richard Hansen fdec195f89 test-hg.sh: tests are now expected to pass
Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-02-24 09:04:27 -08:00
Antoine Pelisse 1f7feb7753 remote-hg: test 'shared_path' in a moved clone
Since e71d1378 (remote-hg: fix 'shared path' path, 2013-12-07),
Mercurial 'shared_path' file is correctly updated whenever a clone is
moved. Make sure it keeps working, especially as this is depending on a
private Mercurial file.

Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-26 10:43:56 -08:00
Felipe Contreras 8d784daebf remote-hg: add tests for special filenames
So that we check that UTF-8 and spaces work fine.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-09 13:18:44 -08:00
Felipe Contreras e71d137879 remote-hg: fix 'shared path' path
If the repository is moved, the absolute path of the shared repository
would fail.

Make sure it's always up-to-date.

Reported-by: Michael Davis <mjmdavis@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-09 13:18:44 -08:00
Felipe Contreras 0c0ebc1fdf remote-helpers: add extra safety checks
Suggested-by: Roman Ovchinnikov <coolthecold@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-09 13:18:43 -08:00
jcb91 257ec841b8 remote-hg: avoid buggy strftime()
error on pull: fatal: Invalid raw date "" in ident: remote-hg <>

Neither %s nor %z are officially supported by python, they may work on
some (most?) platforms, but not all.

removed strftime use of %s and %z, which are not officially supported by python, with standard formats

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-09 13:18:43 -08:00
Richard Hansen 6c68a404e6 remote-bzr, remote-hg: fix email address regular expression
Before, strings like "foo.bar@example.com" would be converted to
"foo. <bar@example.com>" when they should be "unknown
<foo.bar@example.com>".

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-18 13:46:00 -08:00
Richard Hansen b2bff43170 test-hg.sh: help user correlate verbose output with email test
It's hard to tell which author conversion test failed when the email
addresses look similar.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-18 13:45:59 -08:00
Richard Hansen 962df3dab7 test-hg.sh: fix duplicate content strings in author tests
"beta" was used twice.  Change the second copy to "gamma" and
increment the remaining content strings.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-18 13:45:59 -08:00
Richard Hansen 25607db2c3 test-hg.sh: avoid obsolete 'test' syntax
The POSIX spec says that the '-a', '-o', and parentheses operands to
the 'test' utility are obsolete extensions due to the potential for
ambiguity.  Replace '-o' with '|| test' to avoid unspecified behavior.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-18 13:45:58 -08:00
Richard Hansen 5105edd411 test-hg.sh: eliminate 'local' bashism
Unlike bash, POSIX shell does not specify a 'local' command for
declaring function-local variable scope.  Except for IFS, the variable
names are not used anywhere else in the script so simply remove the
'local'.  For IFS, move the assignment to the 'read' command to
prevent it from affecting code outside the function.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-18 13:45:58 -08:00
Richard Hansen 4945725c64 test-bzr.sh, test-hg.sh: prepare for change to push.default=simple
Change 'git push <remote>' to 'git push <remote> <branch>' in one of
the test-bzr.sh tests to ensure that the test continues to pass when
the default value of push.default changes to simple.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-18 13:45:57 -08:00
Felipe Contreras d3243d738d test-bzr.sh, test-hg.sh: allow running from any dir
Set TEST_DIRECTORY to the t/ directory (if TEST_DIRECTORY is not
already set) so that the user doesn't already have to be in the test
directory to run these test scripts.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Based-on-patch-by: Richard Hansen <rhansen@bbn.com>
Reviewed-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-18 13:45:57 -08:00
Richard Hansen c939d24167 remote-hg: don't decode UTF-8 paths into Unicode objects
The internal mercurial API expects ordinary 8-bit string objects, not
Unicode string objects.  With this change, the test-hg.sh unit tests
pass again.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-18 13:45:56 -08:00
Junio C Hamano 583736c0bc Merge branch 'ap/remote-hg-unquote-cquote'
A fast-import stream expresses a pathname with funny characters by
quoting them in C style; remote-hg remote helper forgot to unquote
such a path.

* ap/remote-hg-unquote-cquote:
  remote-hg: unquote C-style paths when exporting
2013-11-01 07:38:35 -07:00
Antoine Pelisse 1136265377 remote-hg: unquote C-style paths when exporting
git-fast-import documentation says that paths can be C-style quoted.
Unfortunately, the current remote-hg helper doesn't unquote quoted
path and pass them as-is to Mercurial when the commit is created.

This results in the following situation:

 - clone a mercurial repository with git
 - add a file with space in a directory: `>dir/foo\ bar`
 - commit that new file, and push the change to mercurial
 - the mercurial repository now has a new directory named '"dir',
   which contains a file named 'foo bar"'

Use Python str.decode('string-escape') to unquote the string if it
starts and ends with ".  It has been tested with quotes, spaces, and
utf-8 encoded file-names.

Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-23 09:45:53 -07:00
Junio C Hamano 751e2b3718 Merge branch 'fc/contrib-bzr-hg-fixes'
* fc/contrib-bzr-hg-fixes:
  contrib/remote-helpers: quote variable references in redirection targets
  contrib/remote-helpers: style updates for test scripts
  remote-hg: use notes to keep track of Hg revisions
  remote-helpers: cleanup more global variables
  remote-helpers: trivial style fixes
  remote-hg: improve basic test
  remote-hg: add missing &&s in the test
  remote-hg: fix test
  remote-bzr: make bzr branches configurable per-repo
  remote-bzr: fix export of utf-8 authors
2013-09-18 11:45:49 -07:00
Richard Hansen bd5424f0d6 remote-bzr: reuse bzrlib transports when possible
Pass a list of open bzrlib.transport.Transport objects to each bzrlib
function that might create a transport.  This enables bzrlib to reuse
existing transports when possible, avoiding multiple concurrent
connections to the same remote server.

If the remote server is accessed via ssh, this fixes a couple of
problems:
  * If the user does not have keys loaded into an ssh agent, the user
    may be prompted for a password multiple times.
  * If the user is using OpenSSH and the ControlMaster setting is set
    to auto, git-remote-bzr might hang.  This is because bzrlib closes
    the multiple ssh sessions in an undefined order and might try to
    close the master ssh session before the other sessions.  The
    master ssh process will not exit until the other sessions have
    exited, causing a deadlock.  (The ssh sessions are closed in an
    undefined order because bzrlib relies on the Python garbage
    collector to trigger ssh session termination.)

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Acked-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-08 11:15:33 -07:00
Junio C Hamano 4f5e9726e1 Merge branch 'fc/remote-hg-shared-setup'
* fc/remote-hg-shared-setup:
  remote-hg: add shared repo upgrade
  remote-hg: ensure shared repo is initialized
2013-09-04 12:36:32 -07:00
Junio C Hamano 5d21adcbfe contrib/remote-helpers: quote variable references in redirection targets
Even though it is not required by POSIX to double-quote the
redirection target in a variable, our code does so because some
versions of bash issue a warning without the quotes.

Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-03 10:25:58 -07:00
Junio C Hamano ff867963f0 contrib/remote-helpers: style updates for test scripts
During the review of the main series it was noticed that these test
scripts can use updates to conform to our coding style better, but
fixing the style should be done in a patch separate from the main
series.

This updates the test-*.sh scripts only for style issues:

 * We do not leave SP between a redirection operator and the
   filename;

 * We change line before "then", "do", etc. rather than terminating
   the condition for "if"/"while" and list for "for" with a
   semicolon;

 * When HERE document does not use any expansion, we quote the end
   marker (e.g. "cat <<\EOF" not "cat <<EOF") to signal the readers
   that there is no funny substitution to worry about when reading
   the code.

 * We use "test" rather than "[".

Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-03 10:25:19 -07:00
Felipe Contreras c587d65512 remote-hg: use notes to keep track of Hg revisions
Keep track of Mercurial revisions as Git notes under the 'refs/notes/hg'
ref.  This way, the user can easily see which Mercurial revision
corresponds to certain Git commit.

Unfortunately, there's no way to efficiently update the notes after
doing an export (push), so they'll have to be updated when importing
(fetching).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-30 10:37:23 -07:00
Felipe Contreras 641a2b5bee remote-helpers: cleanup more global variables
They don't need to be specified if they are not going to be set.

Suggested-by: Dusty Phillips <dusty@linux.ca>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-29 11:40:57 -07:00
Felipe Contreras 670dda85d6 remote-helpers: trivial style fixes
In accordance with pep8.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-29 11:40:56 -07:00
Felipe Contreras 2a6981833d remote-hg: improve basic test
It appears 'let' is not present in all shells.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-29 11:40:55 -07:00
Felipe Contreras 8493fd14b2 remote-hg: add missing &&s in the test
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-29 11:40:54 -07:00
Felipe Contreras 0fdc9b0939 remote-hg: fix test
It wasn't being checked properly before; those refs never existed.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-29 11:40:52 -07:00
Felipe Contreras a11b0ac9e1 remote-bzr: make bzr branches configurable per-repo
Different repositories have different branches, some are are even
branches themselves.

Reported-by: Peter Niederlag <netservice@niekom.de>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-29 11:40:51 -07:00
Felipe Contreras a8c0b74718 remote-bzr: fix export of utf-8 authors
Reported-by: Joakim Verona <joakim@verona.se>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-29 11:39:45 -07:00
Felipe Contreras 3baacc5cc6 remote-hg: add shared repo upgrade
If we have an old organization (v1.8.3), and want to upgrade to a newer
one (v1.8.4), the user would have to fetch the whole repository, instead
we can just move the repository, so the user would not notice any
difference.

Also, remove other clones, so in time they get set up as shared.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Reviewed-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-11 23:17:10 -07:00
Felipe Contreras 52f0856a7b remote-hg: ensure shared repo is initialized
6796d49 (remote-hg: use a shared repository store) introduced a bug by
making the shared repository '.git/hg', which is already used before
that patch, so clones that happened before that patch, fail after that
patch, because there's no shared Mercurial repo.

So, instead of simply checking if the directory exists, let's always try
to create an empty shared repository to ensure it's there. This works
because we don't need the initial clone, if the repository is shared,
pulling from the child updates the parent's storage; it's exactly the
same as cloning, so we can simplify the shared repo setup this way while
at the same time fixing the problem.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Reviewed-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-11 23:16:59 -07:00
Antoine Pelisse 33f66b25e1 remote-hg: fix path when cloning with tilde expansion
The current code fixes the path to make it absolute when cloning, but
doesn't consider tilde expansion, so that scenario fails throwing an
exception because /home/myuser/~/my/repository doesn't exists:

    $ git clone hg::~/my/repository && cd repository && git fetch

Expand the tilde when checking if the path is absolute, so that we don't
fix a path that doesn't need to be.

Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-09 15:33:02 -07:00
Junio C Hamano 221ea21e88 Merge branch 'fc/remote-bzr'
* fc/remote-bzr:
  remote-bzr: add fallback check for a partial clone
  remote-bzr: reorganize the way 'wanted' works
  remote-bzr: trivial cleanups
  remote-bzr: change global repo
  remote-bzr: delay cloning/pulling
  remote-bzr: simplify get_remote_branch()
  remote-bzr: fix for files with spaces
  remote-bzr: recover from failed clones
2013-06-11 13:30:26 -07:00
Felipe Contreras c9eaef125b remote-hg: add support for --force
And get rid of the remote-hg.force-push option hack.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-28 08:02:25 -07:00
Felipe Contreras e3751a1763 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>
2013-05-28 08:02:24 -07:00
Felipe Contreras ba091c200d remote-hg: check if a fetch is needed
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-28 08:02:24 -07:00