{"thread":{"id":"33815","subject":"[PATCH 00/47] remote-hg: fixes for next","startedAt":"2013-05-14T04:36:23Z","lastAt":"2013-05-14T21:12:32Z","messageCount":50,"participants":["Felipe Contreras","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":47},"messages":[{"id":"217263","messageId":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":null,"subject":"[PATCH 00/47] remote-hg: fixes for next","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:23Z","receivedAt":"2013-05-14T04:36:23Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nI've been cooking these for some time now, and they seem to be mostly ready.\nThe major changes are:\n\n 1) Use our own custom push() method that allows us to push bookmarks without\n    having to force a push.\n\n 2) Switch from revision numbers to SHA-1s in the marks.\n\n 3) Use a common repsitory so multiple remotes chan share the same objects.\n\n 4) Cleaned up and add a ton of tests\n\nWith these, we pass all the tests from gitifyhg as well as our own.\n\nFelipe Contreras (47):\n  remote-hg: trivial cleanups\n  remote-hg: get rid of unused exception checks\n  remote-hg: enable track-branches in hg-git mode\n  remote-hg: add new get_config_bool() helper\n  remote-hg: fix new branch creation\n  remote-hg: disable forced push by default\n  remote-hg: don't push fake 'master' bookmark\n  remote-hg: update bookmarks when pulling\n  remote-hg: test: be a little more quiet\n  remote-hg: trivial reorganization\n  remote-helpers: test: cleanup white-spaces\n  remote-helpers: test: cleanup style\n  remote-helpers: tests: general improvements\n  remote-helpers: test: simplify remote URLs\n  remote-hg: test: simplify previous branch checkout\n  remote-hg: load all extensions\n  remote-hg: use a shared repository store\n  remote-hg: shuffle some code\n  remote-hg: improve node traversing\n  remote-hg: add version checks to the marks\n  remote-hg: switch from revisions to SHA-1 noteids\n  remote-hg: upgrade version 1 marks\n  remote-hg: ensure remote rebasing works\n  remote-hg: trivial cleanups\n  remote-hg: improve progress calculation\n  remote-hg: always point HEAD to master\n  remote-bzr: simplify test checks\n  remote-hg: add check_bookmark() test helper\n  remote-hg: add remote tests\n  remote-hg: add test to push new bookmark\n  remote-hg: add test for diverged push\n  remote-hg: add test for bookmark diverge\n  remote-hg: add test for new bookmark special\n  remote-hg: add test for big push\n  remote-hg: add test for failed double push\n  remote-hg: reorganize bookmark handling\n  remote-hg: force remote bookmark push selectively\n  remote-hg: only update necessary revisions\n  remote-hg: implement custom  push()\n  remote-hg: implement custom checkheads()\n  remote-hg: pass around revision refs\n  remote-hg: check diverged bookmarks\n  remote-hg: simplify branch_tip()\n  remote-hg: improve branch listing\n  remote-hg: use remote 'default' not local one\n  remote-hg: improve lightweight tag author\n  remote-hg: remove files before modifications\n\n contrib/remote-helpers/git-remote-hg     | 444 ++++++++++++++++++----------\n contrib/remote-helpers/test-bzr.sh       | 490 +++++++++++++++---------------\n contrib/remote-helpers/test-hg-bidi.sh   |  33 +--\n contrib/remote-helpers/test-hg-hg-git.sh |  47 ++-\n contrib/remote-helpers/test-hg.sh        | 492 +++++++++++++++++++++++++------\n 5 files changed, 974 insertions(+), 532 deletions(-)\n\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217264","messageId":"1368506230-19614-2-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 01/47] remote-hg: trivial cleanups","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:24Z","receivedAt":"2013-05-14T04:36:24Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg     | 2 +-\n contrib/remote-helpers/test-hg-hg-git.sh | 2 --\n 2 files changed, 1 insertion(+), 3 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 96ad30d..d33c7ba 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -538,7 +538,7 @@ def list_head(repo, cur):\n     g_head = (head, node)\n \n def do_list(parser):\n-    global branches, bmarks, mode, track_branches\n+    global branches, bmarks, track_branches\n \n     repo = parser.repo\n     for bmark, node in bookmarks.listbookmarks(repo).iteritems():\ndiff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh\nindex 8440341..0c36573 100755\n--- a/contrib/remote-helpers/test-hg-hg-git.sh\n+++ b/contrib/remote-helpers/test-hg-hg-git.sh\n@@ -455,8 +455,6 @@ test_expect_success 'hg author' '\n \t\tgit_log gitrepo-$x > git-log-$x\n \tdone &&\n \n-\ttest_cmp git-log-hg git-log-git &&\n-\n \ttest_cmp hg-log-hg hg-log-git &&\n \ttest_cmp git-log-hg git-log-git\n '\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217265","messageId":"1368506230-19614-3-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 02/47] remote-hg: get rid of unused exception checks","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:25Z","receivedAt":"2013-05-14T04:36:25Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We are not calling check_output() anymore.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 24 +++++++++---------------\n 1 file changed, 9 insertions(+), 15 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex d33c7ba..9d6940b 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -327,11 +327,8 @@ def get_repo(url, alias):\n     myui.setconfig('ui', 'interactive', 'off')\n     myui.fout = sys.stderr\n \n-    try:\n-        if get_config('remote-hg.insecure') == 'true\\n':\n-            myui.setconfig('web', 'cacerts', '')\n-    except subprocess.CalledProcessError:\n-        pass\n+    if get_config('remote-hg.insecure') == 'true\\n':\n+        myui.setconfig('web', 'cacerts', '')\n \n     try:\n         mod = extensions.load(myui, 'hgext.schemes', None)\n@@ -910,16 +907,13 @@ def main(args):\n     track_branches = True\n     force_push = True\n \n-    try:\n-        if get_config('remote-hg.hg-git-compat') == 'true\\n':\n-            hg_git_compat = True\n-            track_branches = False\n-        if get_config('remote-hg.track-branches') == 'false\\n':\n-            track_branches = False\n-        if get_config('remote-hg.force-push') == 'false\\n':\n-            force_push = False\n-    except subprocess.CalledProcessError:\n-        pass\n+    if get_config('remote-hg.hg-git-compat') == 'true\\n':\n+        hg_git_compat = True\n+        track_branches = False\n+    if get_config('remote-hg.track-branches') == 'false\\n':\n+        track_branches = False\n+    if get_config('remote-hg.force-push') == 'false\\n':\n+        force_push = False\n \n     if hg_git_compat:\n         mode = 'hg'\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217266","messageId":"1368506230-19614-4-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 03/47] remote-hg: enable track-branches in hg-git mode","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:26Z","receivedAt":"2013-05-14T04:36:26Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The user can turn this off.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg     | 1 -\n contrib/remote-helpers/test-hg-hg-git.sh | 1 +\n 2 files changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 9d6940b..de3a96e 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -909,7 +909,6 @@ def main(args):\n \n     if get_config('remote-hg.hg-git-compat') == 'true\\n':\n         hg_git_compat = True\n-        track_branches = False\n     if get_config('remote-hg.track-branches') == 'false\\n':\n         track_branches = False\n     if get_config('remote-hg.force-push') == 'false\\n':\ndiff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh\nindex 0c36573..7f579c8 100755\n--- a/contrib/remote-helpers/test-hg-hg-git.sh\n+++ b/contrib/remote-helpers/test-hg-hg-git.sh\n@@ -102,6 +102,7 @@ setup () {\n \t) >> \"$HOME\"/.hgrc &&\n \tgit config --global receive.denycurrentbranch warn\n \tgit config --global remote-hg.hg-git-compat true\n+\tgit config --global remote-hg.track-branches false\n \n \tHGEDITOR=/usr/bin/true\n \n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217267","messageId":"1368506230-19614-5-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 04/47] remote-hg: add new get_config_bool() helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:27Z","receivedAt":"2013-05-14T04:36:27Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"No functional changes.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 24 +++++++++++++-----------\n 1 file changed, 13 insertions(+), 11 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex de3a96e..4a5c72f 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -87,6 +87,15 @@ def get_config(config):\n     output, _ = process.communicate()\n     return output\n \n+def get_config_bool(config, default=False):\n+    value = get_config(config).rstrip('\\n')\n+    if value == \"true\":\n+        return True\n+    elif value == \"false\":\n+        return False\n+    else:\n+        return default\n+\n class Marks:\n \n     def __init__(self, path):\n@@ -327,7 +336,7 @@ def get_repo(url, alias):\n     myui.setconfig('ui', 'interactive', 'off')\n     myui.fout = sys.stderr\n \n-    if get_config('remote-hg.insecure') == 'true\\n':\n+    if get_config_bool('remote-hg.insecure'):\n         myui.setconfig('web', 'cacerts', '')\n \n     try:\n@@ -903,16 +912,9 @@ def main(args):\n     url = args[2]\n     peer = None\n \n-    hg_git_compat = False\n-    track_branches = True\n-    force_push = True\n-\n-    if get_config('remote-hg.hg-git-compat') == 'true\\n':\n-        hg_git_compat = True\n-    if get_config('remote-hg.track-branches') == 'false\\n':\n-        track_branches = False\n-    if get_config('remote-hg.force-push') == 'false\\n':\n-        force_push = False\n+    hg_git_compat = get_config_bool('remote-hg.hg-git-compat')\n+    track_branches = get_config_bool('remote-hg.track-branches', True)\n+    force_push = get_config_bool('remote-hg.force-push', True)\n \n     if hg_git_compat:\n         mode = 'hg'\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217268","messageId":"1368506230-19614-6-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 05/47] remote-hg: fix new branch creation","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:28Z","receivedAt":"2013-05-14T04:36:28Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"When force_push is disabled, we need to turn the argument to True.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 4a5c72f..3cf9b4c 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -856,7 +856,7 @@ def do_export(parser):\n             continue\n \n     if peer:\n-        parser.repo.push(peer, force=force_push)\n+        parser.repo.push(peer, force=force_push, newbranch=True)\n \n     # handle bookmarks\n     for bmark, node in p_bmarks:\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217269","messageId":"1368506230-19614-7-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 06/47] remote-hg: disable forced push by default","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:29Z","receivedAt":"2013-05-14T04:36:29Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"In certain situations we might end up pushing garbage revisions (e.g. in\na rebase), and the patches to deal with that haven't been merged yet.\n\nSo let's disable forced pushes by default.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 3cf9b4c..53412dd 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -914,7 +914,7 @@ def main(args):\n \n     hg_git_compat = get_config_bool('remote-hg.hg-git-compat')\n     track_branches = get_config_bool('remote-hg.track-branches', True)\n-    force_push = get_config_bool('remote-hg.force-push', True)\n+    force_push = get_config_bool('remote-hg.force-push')\n \n     if hg_git_compat:\n         mode = 'hg'\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217270","messageId":"1368506230-19614-8-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 07/47] remote-hg: don't push fake 'master' bookmark","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:30Z","receivedAt":"2013-05-14T04:36:30Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We skip it locally, but not for the remote, so let's do so.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 53412dd..beb864b 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -873,7 +873,8 @@ def do_export(parser):\n \n         if bmark == 'master' and 'master' not in parser.repo._bookmarks:\n             # fake bookmark\n-            pass\n+            print \"ok %s\" % ref\n+            continue\n         elif bookmarks.pushbookmark(parser.repo, bmark, old, new):\n             # updated locally\n             pass\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217271","messageId":"1368506230-19614-9-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 08/47] remote-hg: update bookmarks when pulling","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:31Z","receivedAt":"2013-05-14T04:36:31Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex beb864b..dc276af 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -363,6 +363,9 @@ def get_repo(url, alias):\n                 die('Repository error')\n             repo.pull(peer, heads=None, force=True)\n \n+        rb = peer.listkeys('bookmarks')\n+        bookmarks.updatefromremote(myui, repo, rb, url)\n+\n     return repo\n \n def rev_to_mark(rev):\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217274","messageId":"1368506230-19614-10-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 09/47] remote-hg: test: be a little more quiet","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:32Z","receivedAt":"2013-05-14T04:36:32Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-hg.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 8de2aa7..f8d1f9e 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -109,10 +109,10 @@ test_expect_success 'update bookmark' '\n   (\n   git clone \"hg::$PWD/hgrepo\" gitrepo &&\n   cd gitrepo &&\n-  git checkout devel &&\n+  git checkout --quiet devel &&\n   echo devel > content &&\n   git commit -a -m devel &&\n-  git push\n+  git push --quiet\n   ) &&\n \n   hg -R hgrepo bookmarks | egrep \"devel[\t ]+3:\"\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217273","messageId":"1368506230-19614-11-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 10/47] remote-hg: trivial reorganization","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:33Z","receivedAt":"2013-05-14T04:36:33Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We only need to get the remote dict once.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex dc276af..96bed8d 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -860,6 +860,7 @@ def do_export(parser):\n \n     if peer:\n         parser.repo.push(peer, force=force_push, newbranch=True)\n+        remote_bmarks = peer.listkeys('bookmarks')\n \n     # handle bookmarks\n     for bmark, node in p_bmarks:\n@@ -886,8 +887,7 @@ def do_export(parser):\n             continue\n \n         if peer:\n-            rb = peer.listkeys('bookmarks')\n-            old = rb.get(bmark, '')\n+            old = remote_bmarks.get(bmark, '')\n             if not peer.pushkey('bookmarks', bmark, old, new):\n                 print \"error %s\" % ref\n                 continue\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217272","messageId":"1368506230-19614-12-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 11/47] remote-helpers: test: cleanup white-spaces","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:34Z","receivedAt":"2013-05-14T04:36:34Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We prefer tabs to spaces.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-bzr.sh | 460 ++++++++++++++++++-------------------\n contrib/remote-helpers/test-hg.sh  | 176 +++++++-------\n 2 files changed, 318 insertions(+), 318 deletions(-)\n\ndiff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh\nindex d9c32f4..00df2d1 100755\n--- a/contrib/remote-helpers/test-bzr.sh\n+++ b/contrib/remote-helpers/test-bzr.sh\n@@ -29,69 +29,69 @@ check () {\n bzr whoami \"A U Thor <author@example.com>\"\n \n test_expect_success 'cloning' '\n-  (bzr init bzrrepo &&\n-  cd bzrrepo &&\n-  echo one > content &&\n-  bzr add content &&\n-  bzr commit -m one\n-  ) &&\n-\n-  git clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n-  check gitrepo one master\n+\t(bzr init bzrrepo &&\n+\tcd bzrrepo &&\n+\techo one > content &&\n+\tbzr add content &&\n+\tbzr commit -m one\n+\t) &&\n+\n+\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n+\tcheck gitrepo one master\n '\n \n test_expect_success 'pulling' '\n-  (cd bzrrepo &&\n-  echo two > content &&\n-  bzr commit -m two\n-  ) &&\n+\t(cd bzrrepo &&\n+\techo two > content &&\n+\tbzr commit -m two\n+\t) &&\n \n-  (cd gitrepo && git pull) &&\n+\t(cd gitrepo && git pull) &&\n \n-  check gitrepo two master\n+\tcheck gitrepo two master\n '\n \n test_expect_success 'pushing' '\n-  (cd gitrepo &&\n-  echo three > content &&\n-  git commit -a -m three &&\n-  git push\n-  ) &&\n-\n-  echo three > expected &&\n-  cat bzrrepo/content > actual &&\n-  test_cmp expected actual\n+\t(cd gitrepo &&\n+\techo three > content &&\n+\tgit commit -a -m three &&\n+\tgit push\n+\t) &&\n+\n+\techo three > expected &&\n+\tcat bzrrepo/content > actual &&\n+\ttest_cmp expected actual\n '\n \n test_expect_success 'roundtrip' '\n-  (cd gitrepo &&\n-  git pull &&\n-  git log --format=\"%s\" -1 origin/master > actual) &&\n-  echo three > expected &&\n-  test_cmp expected actual &&\n+\t(cd gitrepo &&\n+\tgit pull &&\n+\tgit log --format=\"%s\" -1 origin/master > actual) &&\n+\techo three > expected &&\n+\ttest_cmp expected actual &&\n \n-  (cd gitrepo && git push && git pull) &&\n+\t(cd gitrepo && git push && git pull) &&\n \n-  (cd bzrrepo &&\n-  echo four > content &&\n-  bzr commit -m four\n-  ) &&\n+\t(cd bzrrepo &&\n+\techo four > content &&\n+\tbzr commit -m four\n+\t) &&\n \n-  (cd gitrepo && git pull && git push) &&\n+\t(cd gitrepo && git pull && git push) &&\n \n-  check gitrepo four master &&\n+\tcheck gitrepo four master &&\n \n-  (cd gitrepo &&\n-  echo five > content &&\n-  git commit -a -m five &&\n-  git push && git pull\n-  ) &&\n+\t(cd gitrepo &&\n+\techo five > content &&\n+\tgit commit -a -m five &&\n+\tgit push && git pull\n+\t) &&\n \n-  (cd bzrrepo && bzr revert) &&\n+\t(cd bzrrepo && bzr revert) &&\n \n-  echo five > expected &&\n-  cat bzrrepo/content > actual &&\n-  test_cmp expected actual\n+\techo five > expected &&\n+\tcat bzrrepo/content > actual &&\n+\ttest_cmp expected actual\n '\n \n cat > expected <<EOF\n@@ -101,29 +101,29 @@ cat > expected <<EOF\n EOF\n \n test_expect_success 'special modes' '\n-  (cd bzrrepo &&\n-  echo exec > executable\n-  chmod +x executable &&\n-  bzr add executable\n-  bzr commit -m exec &&\n-  ln -s content link\n-  bzr add link\n-  bzr commit -m link &&\n-  mkdir dir &&\n-  bzr add dir &&\n-  bzr commit -m dir) &&\n-\n-  (cd gitrepo &&\n-  git pull\n-  git ls-tree HEAD > ../actual) &&\n-\n-  test_cmp expected actual &&\n-\n-  (cd gitrepo &&\n-  git cat-file -p HEAD:link > ../actual) &&\n-\n-  printf content > expected &&\n-  test_cmp expected actual\n+\t(cd bzrrepo &&\n+\techo exec > executable\n+\tchmod +x executable &&\n+\tbzr add executable\n+\tbzr commit -m exec &&\n+\tln -s content link\n+\tbzr add link\n+\tbzr commit -m link &&\n+\tmkdir dir &&\n+\tbzr add dir &&\n+\tbzr commit -m dir) &&\n+\n+\t(cd gitrepo &&\n+\tgit pull\n+\tgit ls-tree HEAD > ../actual) &&\n+\n+\ttest_cmp expected actual &&\n+\n+\t(cd gitrepo &&\n+\tgit cat-file -p HEAD:link > ../actual) &&\n+\n+\tprintf content > expected &&\n+\ttest_cmp expected actual\n '\n \n cat > expected <<EOF\n@@ -134,134 +134,134 @@ cat > expected <<EOF\n EOF\n \n test_expect_success 'moving directory' '\n-  (cd bzrrepo &&\n-  mkdir movedir &&\n-  echo one > movedir/one &&\n-  echo two > movedir/two &&\n-  bzr add movedir &&\n-  bzr commit -m movedir &&\n-  bzr mv movedir movedir-new &&\n-  bzr commit -m movedir-new) &&\n-\n-  (cd gitrepo &&\n-  git pull &&\n-  git ls-tree HEAD > ../actual) &&\n-\n-  test_cmp expected actual\n+\t(cd bzrrepo &&\n+\tmkdir movedir &&\n+\techo one > movedir/one &&\n+\techo two > movedir/two &&\n+\tbzr add movedir &&\n+\tbzr commit -m movedir &&\n+\tbzr mv movedir movedir-new &&\n+\tbzr commit -m movedir-new) &&\n+\n+\t(cd gitrepo &&\n+\tgit pull &&\n+\tgit ls-tree HEAD > ../actual) &&\n+\n+\ttest_cmp expected actual\n '\n \n test_expect_success 'different authors' '\n-  (cd bzrrepo &&\n-  echo john >> content &&\n-  bzr commit -m john \\\n-    --author \"Jane Rey <jrey@example.com>\" \\\n-    --author \"John Doe <jdoe@example.com>\") &&\n-\n-  (cd gitrepo &&\n-  git pull &&\n-  git show --format=\"%an <%ae>, %cn <%ce>\" --quiet > ../actual) &&\n-\n-  echo \"Jane Rey <jrey@example.com>, A U Thor <author@example.com>\" > expected &&\n-  test_cmp expected actual\n+\t(cd bzrrepo &&\n+\techo john >> content &&\n+\tbzr commit -m john \\\n+\t  --author \"Jane Rey <jrey@example.com>\" \\\n+\t  --author \"John Doe <jdoe@example.com>\") &&\n+\n+\t(cd gitrepo &&\n+\tgit pull &&\n+\tgit show --format=\"%an <%ae>, %cn <%ce>\" --quiet > ../actual) &&\n+\n+\techo \"Jane Rey <jrey@example.com>, A U Thor <author@example.com>\" > expected &&\n+\ttest_cmp expected actual\n '\n \n test_expect_success 'fetch utf-8 filenames' '\n-  mkdir -p tmp && cd tmp &&\n-  test_when_finished \"cd .. && rm -rf tmp && LC_ALL=C\" &&\n-\n-  LC_ALL=en_US.UTF-8\n-  export LC_ALL\n-  (\n-  bzr init bzrrepo &&\n-  cd bzrrepo &&\n-\n-  echo test >> \"ærø\" &&\n-  bzr add \"ærø\" &&\n-  echo test >> \"ø~?\" &&\n-  bzr add \"ø~?\" &&\n-  bzr commit -m add-utf-8 &&\n-  echo test >> \"ærø\" &&\n-  bzr commit -m test-utf-8 &&\n-  bzr rm \"ø~?\" &&\n-  bzr mv \"ærø\" \"ø~?\" &&\n-  bzr commit -m bzr-mv-utf-8\n-  ) &&\n-\n-  (\n-  git clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n-  cd gitrepo &&\n-  git -c core.quotepath=false ls-files > ../actual\n-  ) &&\n-  echo \"ø~?\" > expected &&\n-  test_cmp expected actual\n+\tmkdir -p tmp && cd tmp &&\n+\ttest_when_finished \"cd .. && rm -rf tmp && LC_ALL=C\" &&\n+\n+\tLC_ALL=en_US.UTF-8\n+\texport LC_ALL\n+\t(\n+\tbzr init bzrrepo &&\n+\tcd bzrrepo &&\n+\n+\techo test >> \"ærø\" &&\n+\tbzr add \"ærø\" &&\n+\techo test >> \"ø~?\" &&\n+\tbzr add \"ø~?\" &&\n+\tbzr commit -m add-utf-8 &&\n+\techo test >> \"ærø\" &&\n+\tbzr commit -m test-utf-8 &&\n+\tbzr rm \"ø~?\" &&\n+\tbzr mv \"ærø\" \"ø~?\" &&\n+\tbzr commit -m bzr-mv-utf-8\n+\t) &&\n+\n+\t(\n+\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n+\tcd gitrepo &&\n+\tgit -c core.quotepath=false ls-files > ../actual\n+\t) &&\n+\techo \"ø~?\" > expected &&\n+\ttest_cmp expected actual\n '\n \n test_expect_success 'push utf-8 filenames' '\n-  mkdir -p tmp && cd tmp &&\n-  test_when_finished \"cd .. && rm -rf tmp && LC_ALL=C\" &&\n+\tmkdir -p tmp && cd tmp &&\n+\ttest_when_finished \"cd .. && rm -rf tmp && LC_ALL=C\" &&\n \n-  LC_ALL=en_US.UTF-8\n-  export LC_ALL\n+\tLC_ALL=en_US.UTF-8\n+\texport LC_ALL\n \n-  (\n-  bzr init bzrrepo &&\n-  cd bzrrepo &&\n+\t(\n+\tbzr init bzrrepo &&\n+\tcd bzrrepo &&\n \n-  echo one >> content &&\n-  bzr add content &&\n-  bzr commit -m one\n-  ) &&\n+\techo one >> content &&\n+\tbzr add content &&\n+\tbzr commit -m one\n+\t) &&\n \n-  (\n-  git clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n-  cd gitrepo &&\n+\t(\n+\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n+\tcd gitrepo &&\n \n-  echo test >> \"ærø\" &&\n-  git add \"ærø\" &&\n-  git commit -m utf-8 &&\n+\techo test >> \"ærø\" &&\n+\tgit add \"ærø\" &&\n+\tgit commit -m utf-8 &&\n \n-  git push\n-  ) &&\n+\tgit push\n+\t) &&\n \n-  (cd bzrrepo && bzr ls > ../actual) &&\n-  printf \"content\\nærø\\n\" > expected &&\n-  test_cmp expected actual\n+\t(cd bzrrepo && bzr ls > ../actual) &&\n+\tprintf \"content\\nærø\\n\" > expected &&\n+\ttest_cmp expected actual\n '\n \n test_expect_success 'pushing a merge' '\n-  mkdir -p tmp && cd tmp &&\n-  test_when_finished \"cd .. && rm -rf tmp\" &&\n-\n-  (\n-  bzr init bzrrepo &&\n-  cd bzrrepo &&\n-  echo one > content &&\n-  bzr add content &&\n-  bzr commit -m one\n-  ) &&\n-\n-  git clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n-\n-  (\n-  cd bzrrepo &&\n-  echo two > content &&\n-  bzr commit -m two\n-  ) &&\n-\n-  (\n-  cd gitrepo &&\n-  echo three > content &&\n-  git commit -a -m three &&\n-  git fetch &&\n-  git merge origin/master || true &&\n-  echo three > content &&\n-  git commit -a --no-edit &&\n-  git push\n-  ) &&\n-\n-  echo three > expected &&\n-  cat bzrrepo/content > actual &&\n-  test_cmp expected actual\n+\tmkdir -p tmp && cd tmp &&\n+\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\n+\t(\n+\tbzr init bzrrepo &&\n+\tcd bzrrepo &&\n+\techo one > content &&\n+\tbzr add content &&\n+\tbzr commit -m one\n+\t) &&\n+\n+\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n+\n+\t(\n+\tcd bzrrepo &&\n+\techo two > content &&\n+\tbzr commit -m two\n+\t) &&\n+\n+\t(\n+\tcd gitrepo &&\n+\techo three > content &&\n+\tgit commit -a -m three &&\n+\tgit fetch &&\n+\tgit merge origin/master || true &&\n+\techo three > content &&\n+\tgit commit -a --no-edit &&\n+\tgit push\n+\t) &&\n+\n+\techo three > expected &&\n+\tcat bzrrepo/content > actual &&\n+\ttest_cmp expected actual\n '\n \n cat > expected <<EOF\n@@ -271,71 +271,71 @@ origin/trunk\n EOF\n \n test_expect_success 'proper bzr repo' '\n-  mkdir -p tmp && cd tmp &&\n-  test_when_finished \"cd .. && rm -rf tmp\" &&\n-\n-  bzr init-repo bzrrepo &&\n-\n-  bzr init bzrrepo/trunk &&\n-  (\n-  cd bzrrepo/trunk &&\n-  echo one >> content &&\n-  bzr add content &&\n-  bzr commit -m one\n-  ) &&\n-\n-  bzr branch bzrrepo/trunk bzrrepo/branch &&\n-  (\n-  cd bzrrepo/branch &&\n-  echo two >> content &&\n-  bzr commit -m one\n-  ) &&\n-\n-  git clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n-  (\n-  cd gitrepo &&\n-  git for-each-ref --format \"%(refname:short)\" refs/remotes/origin > ../actual\n-  ) &&\n-\n-  test_cmp ../expected actual\n+\tmkdir -p tmp && cd tmp &&\n+\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\n+\tbzr init-repo bzrrepo &&\n+\n+\tbzr init bzrrepo/trunk &&\n+\t(\n+\tcd bzrrepo/trunk &&\n+\techo one >> content &&\n+\tbzr add content &&\n+\tbzr commit -m one\n+\t) &&\n+\n+\tbzr branch bzrrepo/trunk bzrrepo/branch &&\n+\t(\n+\tcd bzrrepo/branch &&\n+\techo two >> content &&\n+\tbzr commit -m one\n+\t) &&\n+\n+\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n+\t(\n+\tcd gitrepo &&\n+\tgit for-each-ref --format \"%(refname:short)\" refs/remotes/origin > ../actual\n+\t) &&\n+\n+\ttest_cmp ../expected actual\n '\n \n test_expect_success 'strip' '\n-  # Do not imitate this style; always chdir inside a subshell instead\n-  mkdir -p tmp && cd tmp &&\n-  test_when_finished \"cd .. && rm -rf tmp\" &&\n+\t# Do not imitate this style; always chdir inside a subshell instead\n+\tmkdir -p tmp && cd tmp &&\n+\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n \n-  (\n-  bzr init bzrrepo &&\n-  cd bzrrepo &&\n+\t(\n+\tbzr init bzrrepo &&\n+\tcd bzrrepo &&\n \n-  echo one >> content &&\n-  bzr add content &&\n-  bzr commit -m one &&\n+\techo one >> content &&\n+\tbzr add content &&\n+\tbzr commit -m one &&\n \n-  echo two >> content &&\n-  bzr commit -m two\n-  ) &&\n+\techo two >> content &&\n+\tbzr commit -m two\n+\t) &&\n \n-  git clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n+\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n \n-  (\n-  cd bzrrepo &&\n-  bzr uncommit --force &&\n+\t(\n+\tcd bzrrepo &&\n+\tbzr uncommit --force &&\n \n-  echo three >> content &&\n-  bzr commit -m three &&\n+\techo three >> content &&\n+\tbzr commit -m three &&\n \n-  echo four >> content &&\n-  bzr commit -m four &&\n-  bzr log --line | sed -e \"s/^[0-9]\\+: //\" > ../expected\n-  ) &&\n+\techo four >> content &&\n+\tbzr commit -m four &&\n+\tbzr log --line | sed -e \"s/^[0-9]\\+: //\" > ../expected\n+\t) &&\n \n-  (cd gitrepo &&\n-  git fetch &&\n-  git log --format=\"%an %ad %s\" --date=short origin/master > ../actual) &&\n+\t(cd gitrepo &&\n+\tgit fetch &&\n+\tgit log --format=\"%an %ad %s\" --date=short origin/master > ../actual) &&\n \n-  test_cmp expected actual\n+\ttest_cmp expected actual\n '\n \n test_done\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex f8d1f9e..dac3756 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -39,119 +39,119 @@ setup () {\n setup\n \n test_expect_success 'cloning' '\n-  test_when_finished \"rm -rf gitrepo*\" &&\n-\n-  (\n-  hg init hgrepo &&\n-  cd hgrepo &&\n-  echo zero > content &&\n-  hg add content &&\n-  hg commit -m zero\n-  ) &&\n-\n-  git clone \"hg::$PWD/hgrepo\" gitrepo &&\n-  check gitrepo zero master\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n+\n+\t(\n+\thg init hgrepo &&\n+\tcd hgrepo &&\n+\techo zero > content &&\n+\thg add content &&\n+\thg commit -m zero\n+\t) &&\n+\n+\tgit clone \"hg::$PWD/hgrepo\" gitrepo &&\n+\tcheck gitrepo zero master\n '\n \n test_expect_success 'cloning with branches' '\n-  test_when_finished \"rm -rf gitrepo*\" &&\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n \n-  (\n-  cd hgrepo &&\n-  hg branch next &&\n-  echo next > content &&\n-  hg commit -m next\n-  ) &&\n+\t(\n+\tcd hgrepo &&\n+\thg branch next &&\n+\techo next > content &&\n+\thg commit -m next\n+\t) &&\n \n-  git clone \"hg::$PWD/hgrepo\" gitrepo &&\n-  check gitrepo next next &&\n+\tgit clone \"hg::$PWD/hgrepo\" gitrepo &&\n+\tcheck gitrepo next next &&\n \n-  (cd hgrepo && hg checkout default) &&\n+\t(cd hgrepo && hg checkout default) &&\n \n-  git clone \"hg::$PWD/hgrepo\" gitrepo2 &&\n-  check gitrepo2 zero master\n+\tgit clone \"hg::$PWD/hgrepo\" gitrepo2 &&\n+\tcheck gitrepo2 zero master\n '\n \n test_expect_success 'cloning with bookmarks' '\n-  test_when_finished \"rm -rf gitrepo*\" &&\n-\n-  (\n-  cd hgrepo &&\n-  hg bookmark feature-a &&\n-  echo feature-a > content &&\n-  hg commit -m feature-a\n-  ) &&\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n \n-  git clone \"hg::$PWD/hgrepo\" gitrepo &&\n-  check gitrepo feature-a feature-a\n+\t(\n+\tcd hgrepo &&\n+\thg bookmark feature-a &&\n+\techo feature-a > content &&\n+\thg commit -m feature-a\n+\t) &&\n+\n+\tgit clone \"hg::$PWD/hgrepo\" gitrepo &&\n+\tcheck gitrepo feature-a feature-a\n '\n \n test_expect_success 'cloning with detached head' '\n-  test_when_finished \"rm -rf gitrepo*\" &&\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n \n-  (\n-  cd hgrepo &&\n-  hg update -r 0\n-  ) &&\n+\t(\n+\tcd hgrepo &&\n+\thg update -r 0\n+\t) &&\n \n-  git clone \"hg::$PWD/hgrepo\" gitrepo &&\n-  check gitrepo zero master\n+\tgit clone \"hg::$PWD/hgrepo\" gitrepo &&\n+\tcheck gitrepo zero master\n '\n \n test_expect_success 'update bookmark' '\n-  test_when_finished \"rm -rf gitrepo*\" &&\n-\n-  (\n-  cd hgrepo &&\n-  hg bookmark devel\n-  ) &&\n-\n-  (\n-  git clone \"hg::$PWD/hgrepo\" gitrepo &&\n-  cd gitrepo &&\n-  git checkout --quiet devel &&\n-  echo devel > content &&\n-  git commit -a -m devel &&\n-  git push --quiet\n-  ) &&\n-\n-  hg -R hgrepo bookmarks | egrep \"devel[\t ]+3:\"\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n+\n+\t(\n+\tcd hgrepo &&\n+\thg bookmark devel\n+\t) &&\n+\n+\t(\n+\tgit clone \"hg::$PWD/hgrepo\" gitrepo &&\n+\tcd gitrepo &&\n+\tgit checkout --quiet devel &&\n+\techo devel > content &&\n+\tgit commit -a -m devel &&\n+\tgit push --quiet\n+\t) &&\n+\n+\thg -R hgrepo bookmarks | egrep \"devel[\t ]+3:\"\n '\n \n author_test () {\n-  echo $1 >> content &&\n-  hg commit -u \"$2\" -m \"add $1\" &&\n-  echo \"$3\" >> ../expected\n+\techo $1 >> content &&\n+\thg commit -u \"$2\" -m \"add $1\" &&\n+\techo \"$3\" >> ../expected\n }\n \n test_expect_success 'authors' '\n-  mkdir -p tmp && cd tmp &&\n-  test_when_finished \"cd .. && rm -rf tmp\" &&\n-\n-  (\n-  hg init hgrepo &&\n-  cd hgrepo &&\n-\n-  touch content &&\n-  hg add content &&\n-\n-  author_test alpha \"\" \"H G Wells <wells@example.com>\" &&\n-  author_test beta \"test\" \"test <unknown>\" &&\n-  author_test beta \"test <test@example.com> (comment)\" \"test <test@example.com>\" &&\n-  author_test gamma \"<test@example.com>\" \"Unknown <test@example.com>\" &&\n-  author_test delta \"name<test@example.com>\" \"name <test@example.com>\" &&\n-  author_test epsilon \"name <test@example.com\" \"name <test@example.com>\" &&\n-  author_test zeta \" test \" \"test <unknown>\" &&\n-  author_test eta \"test < test@example.com >\" \"test <test@example.com>\" &&\n-  author_test theta \"test >test@example.com>\" \"test <test@example.com>\" &&\n-  author_test iota \"test < test <at> example <dot> com>\" \"test <unknown>\" &&\n-  author_test kappa \"test@example.com\" \"Unknown <test@example.com>\"\n-  ) &&\n-\n-  git clone \"hg::$PWD/hgrepo\" gitrepo &&\n-  git --git-dir=gitrepo/.git log --reverse --format=\"%an <%ae>\" > actual &&\n-\n-  test_cmp expected actual\n+\tmkdir -p tmp && cd tmp &&\n+\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\n+\t(\n+\thg init hgrepo &&\n+\tcd hgrepo &&\n+\n+\ttouch content &&\n+\thg add content &&\n+\n+\tauthor_test alpha \"\" \"H G Wells <wells@example.com>\" &&\n+\tauthor_test beta \"test\" \"test <unknown>\" &&\n+\tauthor_test beta \"test <test@example.com> (comment)\" \"test <test@example.com>\" &&\n+\tauthor_test gamma \"<test@example.com>\" \"Unknown <test@example.com>\" &&\n+\tauthor_test delta \"name<test@example.com>\" \"name <test@example.com>\" &&\n+\tauthor_test epsilon \"name <test@example.com\" \"name <test@example.com>\" &&\n+\tauthor_test zeta \" test \" \"test <unknown>\" &&\n+\tauthor_test eta \"test < test@example.com >\" \"test <test@example.com>\" &&\n+\tauthor_test theta \"test >test@example.com>\" \"test <test@example.com>\" &&\n+\tauthor_test iota \"test < test <at> example <dot> com>\" \"test <unknown>\" &&\n+\tauthor_test kappa \"test@example.com\" \"Unknown <test@example.com>\"\n+\t) &&\n+\n+\tgit clone \"hg::$PWD/hgrepo\" gitrepo &&\n+\tgit --git-dir=gitrepo/.git log --reverse --format=\"%an <%ae>\" > actual &&\n+\n+\ttest_cmp expected actual\n '\n \n test_done\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217275","messageId":"1368506230-19614-13-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 12/47] remote-helpers: test: cleanup style","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:35Z","receivedAt":"2013-05-14T04:36:35Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"So it's more standardized between all the tests.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-bzr.sh | 88 +++++++++++++++++++++++++-------------\n contrib/remote-helpers/test-hg.sh  | 12 ++++--\n 2 files changed, 66 insertions(+), 34 deletions(-)\n\ndiff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh\nindex 00df2d1..6332050 100755\n--- a/contrib/remote-helpers/test-bzr.sh\n+++ b/contrib/remote-helpers/test-bzr.sh\n@@ -18,18 +18,23 @@ if ! \"$PYTHON_PATH\" -c 'import bzrlib'; then\n fi\n \n check () {\n-\t(cd $1 &&\n+\t(\n+\tcd $1 &&\n \tgit log --format='%s' -1 &&\n-\tgit symbolic-ref HEAD) > actual &&\n-\t(echo $2 &&\n-\techo \"refs/heads/$3\") > expected &&\n+\tgit symbolic-ref HEAD\n+\t) > actual &&\n+\t(\n+\techo $2 &&\n+\techo \"refs/heads/$3\"\n+\t) > expected &&\n \ttest_cmp expected actual\n }\n \n bzr whoami \"A U Thor <author@example.com>\"\n \n test_expect_success 'cloning' '\n-\t(bzr init bzrrepo &&\n+\t(\n+\tbzr init bzrrepo &&\n \tcd bzrrepo &&\n \techo one > content &&\n \tbzr add content &&\n@@ -41,7 +46,8 @@ test_expect_success 'cloning' '\n '\n \n test_expect_success 'pulling' '\n-\t(cd bzrrepo &&\n+\t(\n+\tcd bzrrepo &&\n \techo two > content &&\n \tbzr commit -m two\n \t) &&\n@@ -52,7 +58,8 @@ test_expect_success 'pulling' '\n '\n \n test_expect_success 'pushing' '\n-\t(cd gitrepo &&\n+\t(\n+\tcd gitrepo &&\n \techo three > content &&\n \tgit commit -a -m three &&\n \tgit push\n@@ -64,15 +71,18 @@ test_expect_success 'pushing' '\n '\n \n test_expect_success 'roundtrip' '\n-\t(cd gitrepo &&\n+\t(\n+\tcd gitrepo &&\n \tgit pull &&\n-\tgit log --format=\"%s\" -1 origin/master > actual) &&\n+\tgit log --format=\"%s\" -1 origin/master > actual\n+\t) &&\n \techo three > expected &&\n \ttest_cmp expected actual &&\n \n \t(cd gitrepo && git push && git pull) &&\n \n-\t(cd bzrrepo &&\n+\t(\n+\tcd bzrrepo &&\n \techo four > content &&\n \tbzr commit -m four\n \t) &&\n@@ -81,7 +91,8 @@ test_expect_success 'roundtrip' '\n \n \tcheck gitrepo four master &&\n \n-\t(cd gitrepo &&\n+\t(\n+\tcd gitrepo &&\n \techo five > content &&\n \tgit commit -a -m five &&\n \tgit push && git pull\n@@ -101,7 +112,8 @@ cat > expected <<EOF\n EOF\n \n test_expect_success 'special modes' '\n-\t(cd bzrrepo &&\n+\t(\n+\tcd bzrrepo &&\n \techo exec > executable\n \tchmod +x executable &&\n \tbzr add executable\n@@ -111,16 +123,21 @@ test_expect_success 'special modes' '\n \tbzr commit -m link &&\n \tmkdir dir &&\n \tbzr add dir &&\n-\tbzr commit -m dir) &&\n+\tbzr commit -m dir\n+\t) &&\n \n-\t(cd gitrepo &&\n+\t(\n+\tcd gitrepo &&\n \tgit pull\n-\tgit ls-tree HEAD > ../actual) &&\n+\tgit ls-tree HEAD > ../actual\n+\t) &&\n \n \ttest_cmp expected actual &&\n \n-\t(cd gitrepo &&\n-\tgit cat-file -p HEAD:link > ../actual) &&\n+\t(\n+\tcd gitrepo &&\n+\tgit cat-file -p HEAD:link > ../actual\n+\t) &&\n \n \tprintf content > expected &&\n \ttest_cmp expected actual\n@@ -134,32 +151,40 @@ cat > expected <<EOF\n EOF\n \n test_expect_success 'moving directory' '\n-\t(cd bzrrepo &&\n+\t(\n+\tcd bzrrepo &&\n \tmkdir movedir &&\n \techo one > movedir/one &&\n \techo two > movedir/two &&\n \tbzr add movedir &&\n \tbzr commit -m movedir &&\n \tbzr mv movedir movedir-new &&\n-\tbzr commit -m movedir-new) &&\n+\tbzr commit -m movedir-new\n+\t) &&\n \n-\t(cd gitrepo &&\n+\t(\n+\tcd gitrepo &&\n \tgit pull &&\n-\tgit ls-tree HEAD > ../actual) &&\n+\tgit ls-tree HEAD > ../actual\n+\t) &&\n \n \ttest_cmp expected actual\n '\n \n test_expect_success 'different authors' '\n-\t(cd bzrrepo &&\n+\t(\n+\tcd bzrrepo &&\n \techo john >> content &&\n \tbzr commit -m john \\\n \t  --author \"Jane Rey <jrey@example.com>\" \\\n-\t  --author \"John Doe <jdoe@example.com>\") &&\n+\t  --author \"John Doe <jdoe@example.com>\"\n+\t) &&\n \n-\t(cd gitrepo &&\n+\t(\n+\tcd gitrepo &&\n \tgit pull &&\n-\tgit show --format=\"%an <%ae>, %cn <%ce>\" --quiet > ../actual) &&\n+\tgit show --format=\"%an <%ae>, %cn <%ce>\" --quiet > ../actual\n+\t) &&\n \n \techo \"Jane Rey <jrey@example.com>, A U Thor <author@example.com>\" > expected &&\n \ttest_cmp expected actual\n@@ -171,6 +196,7 @@ test_expect_success 'fetch utf-8 filenames' '\n \n \tLC_ALL=en_US.UTF-8\n \texport LC_ALL\n+\n \t(\n \tbzr init bzrrepo &&\n \tcd bzrrepo &&\n@@ -276,23 +302,23 @@ test_expect_success 'proper bzr repo' '\n \n \tbzr init-repo bzrrepo &&\n \n-\tbzr init bzrrepo/trunk &&\n \t(\n+\tbzr init bzrrepo/trunk &&\n \tcd bzrrepo/trunk &&\n \techo one >> content &&\n \tbzr add content &&\n \tbzr commit -m one\n \t) &&\n \n-\tbzr branch bzrrepo/trunk bzrrepo/branch &&\n \t(\n+\tbzr branch bzrrepo/trunk bzrrepo/branch &&\n \tcd bzrrepo/branch &&\n \techo two >> content &&\n \tbzr commit -m one\n \t) &&\n \n-\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n \t(\n+\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n \tcd gitrepo &&\n \tgit for-each-ref --format \"%(refname:short)\" refs/remotes/origin > ../actual\n \t) &&\n@@ -331,9 +357,11 @@ test_expect_success 'strip' '\n \tbzr log --line | sed -e \"s/^[0-9]\\+: //\" > ../expected\n \t) &&\n \n-\t(cd gitrepo &&\n+\t(\n+\tcd gitrepo &&\n \tgit fetch &&\n-\tgit log --format=\"%an %ad %s\" --date=short origin/master > ../actual) &&\n+\tgit log --format=\"%an %ad %s\" --date=short origin/master > ../actual\n+\t) &&\n \n \ttest_cmp expected actual\n '\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex dac3756..8d1154b 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -21,11 +21,15 @@ if ! \"$PYTHON_PATH\" -c 'import mercurial'; then\n fi\n \n check () {\n-\t(cd $1 &&\n+\t(\n+\tcd $1 &&\n \tgit log --format='%s' -1 &&\n-\tgit symbolic-ref HEAD) > actual &&\n-\t(echo $2 &&\n-\techo \"refs/heads/$3\") > expected &&\n+\tgit symbolic-ref HEAD\n+\t) > actual &&\n+\t(\n+\techo $2 &&\n+\techo \"refs/heads/$3\"\n+\t) > expected &&\n \ttest_cmp expected actual\n }\n \n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217276","messageId":"1368506230-19614-14-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 13/47] remote-helpers: tests: general improvements","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:36Z","receivedAt":"2013-05-14T04:36:36Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"So that we don't need a temporary directory.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-bzr.sh       | 21 ++++++++++----------\n contrib/remote-helpers/test-hg-bidi.sh   | 15 +++++----------\n contrib/remote-helpers/test-hg-hg-git.sh | 33 +++++++++++---------------------\n contrib/remote-helpers/test-hg.sh        |  7 +++++--\n 4 files changed, 31 insertions(+), 45 deletions(-)\n\ndiff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh\nindex 6332050..2774f41 100755\n--- a/contrib/remote-helpers/test-bzr.sh\n+++ b/contrib/remote-helpers/test-bzr.sh\n@@ -190,9 +190,11 @@ test_expect_success 'different authors' '\n \ttest_cmp expected actual\n '\n \n+# cleanup previous stuff\n+rm -rf bzrrepo gitrepo\n+\n test_expect_success 'fetch utf-8 filenames' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp && LC_ALL=C\" &&\n+\ttest_when_finished \"rm -rf bzrrepo gitrepo && LC_ALL=C\" &&\n \n \tLC_ALL=en_US.UTF-8\n \texport LC_ALL\n@@ -223,8 +225,9 @@ test_expect_success 'fetch utf-8 filenames' '\n '\n \n test_expect_success 'push utf-8 filenames' '\n+\ttest_when_finished \"rm -rf bzrrepo gitrepo && LC_ALL=C\" &&\n+\n \tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp && LC_ALL=C\" &&\n \n \tLC_ALL=en_US.UTF-8\n \texport LC_ALL\n@@ -255,8 +258,7 @@ test_expect_success 'push utf-8 filenames' '\n '\n \n test_expect_success 'pushing a merge' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf bzrrepo gitrepo\" &&\n \n \t(\n \tbzr init bzrrepo &&\n@@ -297,8 +299,7 @@ origin/trunk\n EOF\n \n test_expect_success 'proper bzr repo' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf bzrrepo gitrepo\" &&\n \n \tbzr init-repo bzrrepo &&\n \n@@ -323,13 +324,11 @@ test_expect_success 'proper bzr repo' '\n \tgit for-each-ref --format \"%(refname:short)\" refs/remotes/origin > ../actual\n \t) &&\n \n-\ttest_cmp ../expected actual\n+\ttest_cmp expected actual\n '\n \n test_expect_success 'strip' '\n-\t# Do not imitate this style; always chdir inside a subshell instead\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf bzrrepo gitrepo\" &&\n \n \t(\n \tbzr init bzrrepo &&\ndiff --git a/contrib/remote-helpers/test-hg-bidi.sh b/contrib/remote-helpers/test-hg-bidi.sh\nindex f569697..490a395 100755\n--- a/contrib/remote-helpers/test-hg-bidi.sh\n+++ b/contrib/remote-helpers/test-hg-bidi.sh\n@@ -77,8 +77,7 @@ setup () {\n setup\n \n test_expect_success 'encoding' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \tgit init -q gitrepo &&\n@@ -115,8 +114,7 @@ test_expect_success 'encoding' '\n '\n \n test_expect_success 'file removal' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \tgit init -q gitrepo &&\n@@ -148,8 +146,7 @@ test_expect_success 'file removal' '\n '\n \n test_expect_success 'git tags' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \tgit init -q gitrepo &&\n@@ -177,8 +174,7 @@ test_expect_success 'git tags' '\n '\n \n test_expect_success 'hg branch' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \tgit init -q gitrepo &&\n@@ -214,8 +210,7 @@ test_expect_success 'hg branch' '\n '\n \n test_expect_success 'hg tags' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \tgit init -q gitrepo &&\ndiff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh\nindex 7f579c8..6f0819c 100755\n--- a/contrib/remote-helpers/test-hg-hg-git.sh\n+++ b/contrib/remote-helpers/test-hg-hg-git.sh\n@@ -114,8 +114,7 @@ setup () {\n setup\n \n test_expect_success 'executable bit' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \tgit init -q gitrepo &&\n@@ -150,8 +149,7 @@ test_expect_success 'executable bit' '\n '\n \n test_expect_success 'symlink' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \tgit init -q gitrepo &&\n@@ -181,8 +179,7 @@ test_expect_success 'symlink' '\n '\n \n test_expect_success 'merge conflict 1' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \thg init hgrepo1 &&\n@@ -216,8 +213,7 @@ test_expect_success 'merge conflict 1' '\n '\n \n test_expect_success 'merge conflict 2' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \thg init hgrepo1 &&\n@@ -251,8 +247,7 @@ test_expect_success 'merge conflict 2' '\n '\n \n test_expect_success 'converged merge' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \thg init hgrepo1 &&\n@@ -287,8 +282,7 @@ test_expect_success 'converged merge' '\n '\n \n test_expect_success 'encoding' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \tgit init -q gitrepo &&\n@@ -327,8 +321,7 @@ test_expect_success 'encoding' '\n '\n \n test_expect_success 'file removal' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \tgit init -q gitrepo &&\n@@ -367,8 +360,7 @@ test_expect_success 'file removal' '\n '\n \n test_expect_success 'git tags' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \t(\n \tgit init -q gitrepo &&\n@@ -394,8 +386,7 @@ test_expect_success 'git tags' '\n '\n \n test_expect_success 'hg author' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \tfor x in hg git; do\n \t\t(\n@@ -461,8 +452,7 @@ test_expect_success 'hg author' '\n '\n \n test_expect_success 'hg branch' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \tfor x in hg git; do\n \t\t(\n@@ -498,8 +488,7 @@ test_expect_success 'hg branch' '\n '\n \n test_expect_success 'hg tags' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf gitrepo* hgrepo*\" &&\n \n \tfor x in hg git; do\n \t\t(\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 8d1154b..043f6c6 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -122,6 +122,9 @@ test_expect_success 'update bookmark' '\n \thg -R hgrepo bookmarks | egrep \"devel[\t ]+3:\"\n '\n \n+# cleanup previous stuff\n+rm -rf hgrepo\n+\n author_test () {\n \techo $1 >> content &&\n \thg commit -u \"$2\" -m \"add $1\" &&\n@@ -129,8 +132,7 @@ author_test () {\n }\n \n test_expect_success 'authors' '\n-\tmkdir -p tmp && cd tmp &&\n-\ttest_when_finished \"cd .. && rm -rf tmp\" &&\n+\ttest_when_finished \"rm -rf hgrepo gitrepo\" &&\n \n \t(\n \thg init hgrepo &&\n@@ -139,6 +141,7 @@ test_expect_success 'authors' '\n \ttouch content &&\n \thg add content &&\n \n+\t> ../expected &&\n \tauthor_test alpha \"\" \"H G Wells <wells@example.com>\" &&\n \tauthor_test beta \"test\" \"test <unknown>\" &&\n \tauthor_test beta \"test <test@example.com> (comment)\" \"test <test@example.com>\" &&\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217280","messageId":"1368506230-19614-15-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 14/47] remote-helpers: test: simplify remote URLs","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:37Z","receivedAt":"2013-05-14T04:36:37Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"No need to specify $PWD any more.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-bzr.sh       | 12 ++++++------\n contrib/remote-helpers/test-hg-bidi.sh   |  6 +++---\n contrib/remote-helpers/test-hg-hg-git.sh |  6 +++---\n contrib/remote-helpers/test-hg.sh        | 14 +++++++-------\n 4 files changed, 19 insertions(+), 19 deletions(-)\n\ndiff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh\nindex 2774f41..90f8c7f 100755\n--- a/contrib/remote-helpers/test-bzr.sh\n+++ b/contrib/remote-helpers/test-bzr.sh\n@@ -41,7 +41,7 @@ test_expect_success 'cloning' '\n \tbzr commit -m one\n \t) &&\n \n-\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n+\tgit clone \"bzr::bzrrepo\" gitrepo &&\n \tcheck gitrepo one master\n '\n \n@@ -216,7 +216,7 @@ test_expect_success 'fetch utf-8 filenames' '\n \t) &&\n \n \t(\n-\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n+\tgit clone \"bzr::bzrrepo\" gitrepo &&\n \tcd gitrepo &&\n \tgit -c core.quotepath=false ls-files > ../actual\n \t) &&\n@@ -242,7 +242,7 @@ test_expect_success 'push utf-8 filenames' '\n \t) &&\n \n \t(\n-\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n+\tgit clone \"bzr::bzrrepo\" gitrepo &&\n \tcd gitrepo &&\n \n \techo test >> \"ærø\" &&\n@@ -268,7 +268,7 @@ test_expect_success 'pushing a merge' '\n \tbzr commit -m one\n \t) &&\n \n-\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n+\tgit clone \"bzr::bzrrepo\" gitrepo &&\n \n \t(\n \tcd bzrrepo &&\n@@ -319,7 +319,7 @@ test_expect_success 'proper bzr repo' '\n \t) &&\n \n \t(\n-\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n+\tgit clone \"bzr::bzrrepo\" gitrepo &&\n \tcd gitrepo &&\n \tgit for-each-ref --format \"%(refname:short)\" refs/remotes/origin > ../actual\n \t) &&\n@@ -342,7 +342,7 @@ test_expect_success 'strip' '\n \tbzr commit -m two\n \t) &&\n \n-\tgit clone \"bzr::$PWD/bzrrepo\" gitrepo &&\n+\tgit clone \"bzr::bzrrepo\" gitrepo &&\n \n \t(\n \tcd bzrrepo &&\ndiff --git a/contrib/remote-helpers/test-hg-bidi.sh b/contrib/remote-helpers/test-hg-bidi.sh\nindex 490a395..4bfbda2 100755\n--- a/contrib/remote-helpers/test-hg-bidi.sh\n+++ b/contrib/remote-helpers/test-hg-bidi.sh\n@@ -22,7 +22,7 @@ fi\n \n # clone to a git repo\n git_clone () {\n-\tgit clone -q \"hg::$PWD/$1\" $2\n+\tgit clone -q \"hg::$1\" $2\n }\n \n # clone to an hg repo\n@@ -31,7 +31,7 @@ hg_clone () {\n \thg init $2 &&\n \thg -R $2 bookmark -i master &&\n \tcd $1 &&\n-\tgit push -q \"hg::$PWD/../$2\" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'\n+\tgit push -q \"hg::../$2\" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'\n \t) &&\n \n \t(cd $2 && hg -q update)\n@@ -43,7 +43,7 @@ hg_push () {\n \tcd $2\n \told=$(git symbolic-ref --short HEAD)\n \tgit checkout -q -b tmp &&\n-\tgit fetch -q \"hg::$PWD/../$1\" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&\n+\tgit fetch -q \"hg::../$1\" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&\n \tgit checkout -q $old &&\n \tgit branch -q -D tmp 2> /dev/null || true\n \t)\ndiff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh\nindex 6f0819c..274a8d5 100755\n--- a/contrib/remote-helpers/test-hg-hg-git.sh\n+++ b/contrib/remote-helpers/test-hg-hg-git.sh\n@@ -27,7 +27,7 @@ fi\n \n # clone to a git repo with git\n git_clone_git () {\n-\tgit clone -q \"hg::$PWD/$1\" $2\n+\tgit clone -q \"hg::$1\" $2\n }\n \n # clone to an hg repo with git\n@@ -36,7 +36,7 @@ hg_clone_git () {\n \thg init $2 &&\n \thg -R $2 bookmark -i master &&\n \tcd $1 &&\n-\tgit push -q \"hg::$PWD/../$2\" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'\n+\tgit push -q \"hg::../$2\" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'\n \t) &&\n \n \t(cd $2 && hg -q update)\n@@ -63,7 +63,7 @@ hg_push_git () {\n \tcd $2\n \told=$(git symbolic-ref --short HEAD)\n \tgit checkout -q -b tmp &&\n-\tgit fetch -q \"hg::$PWD/../$1\" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&\n+\tgit fetch -q \"hg::../$1\" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&\n \tgit checkout -q $old &&\n \tgit branch -q -D tmp 2> /dev/null || true\n \t)\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 043f6c6..4bd7584 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -53,7 +53,7 @@ test_expect_success 'cloning' '\n \thg commit -m zero\n \t) &&\n \n-\tgit clone \"hg::$PWD/hgrepo\" gitrepo &&\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n \tcheck gitrepo zero master\n '\n \n@@ -67,12 +67,12 @@ test_expect_success 'cloning with branches' '\n \thg commit -m next\n \t) &&\n \n-\tgit clone \"hg::$PWD/hgrepo\" gitrepo &&\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n \tcheck gitrepo next next &&\n \n \t(cd hgrepo && hg checkout default) &&\n \n-\tgit clone \"hg::$PWD/hgrepo\" gitrepo2 &&\n+\tgit clone \"hg::hgrepo\" gitrepo2 &&\n \tcheck gitrepo2 zero master\n '\n \n@@ -86,7 +86,7 @@ test_expect_success 'cloning with bookmarks' '\n \thg commit -m feature-a\n \t) &&\n \n-\tgit clone \"hg::$PWD/hgrepo\" gitrepo &&\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n \tcheck gitrepo feature-a feature-a\n '\n \n@@ -98,7 +98,7 @@ test_expect_success 'cloning with detached head' '\n \thg update -r 0\n \t) &&\n \n-\tgit clone \"hg::$PWD/hgrepo\" gitrepo &&\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n \tcheck gitrepo zero master\n '\n \n@@ -111,7 +111,7 @@ test_expect_success 'update bookmark' '\n \t) &&\n \n \t(\n-\tgit clone \"hg::$PWD/hgrepo\" gitrepo &&\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n \tcd gitrepo &&\n \tgit checkout --quiet devel &&\n \techo devel > content &&\n@@ -155,7 +155,7 @@ test_expect_success 'authors' '\n \tauthor_test kappa \"test@example.com\" \"Unknown <test@example.com>\"\n \t) &&\n \n-\tgit clone \"hg::$PWD/hgrepo\" gitrepo &&\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n \tgit --git-dir=gitrepo/.git log --reverse --format=\"%an <%ae>\" > actual &&\n \n \ttest_cmp expected actual\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217281","messageId":"1368506230-19614-16-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 15/47] remote-hg: test: simplify previous branch checkout","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:38Z","receivedAt":"2013-05-14T04:36:38Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"@{-1} does the same thing.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-hg-bidi.sh   | 3 +--\n contrib/remote-helpers/test-hg-hg-git.sh | 3 +--\n 2 files changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/remote-helpers/test-hg-bidi.sh b/contrib/remote-helpers/test-hg-bidi.sh\nindex 4bfbda2..88a33e6 100755\n--- a/contrib/remote-helpers/test-hg-bidi.sh\n+++ b/contrib/remote-helpers/test-hg-bidi.sh\n@@ -41,10 +41,9 @@ hg_clone () {\n hg_push () {\n \t(\n \tcd $2\n-\told=$(git symbolic-ref --short HEAD)\n \tgit checkout -q -b tmp &&\n \tgit fetch -q \"hg::../$1\" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&\n-\tgit checkout -q $old &&\n+\tgit checkout -q @{-1} &&\n \tgit branch -q -D tmp 2> /dev/null || true\n \t)\n }\ndiff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh\nindex 274a8d5..e503293 100755\n--- a/contrib/remote-helpers/test-hg-hg-git.sh\n+++ b/contrib/remote-helpers/test-hg-hg-git.sh\n@@ -61,10 +61,9 @@ hg_clone_hg () {\n hg_push_git () {\n \t(\n \tcd $2\n-\told=$(git symbolic-ref --short HEAD)\n \tgit checkout -q -b tmp &&\n \tgit fetch -q \"hg::../$1\" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&\n-\tgit checkout -q $old &&\n+\tgit checkout -q @{-1} &&\n \tgit branch -q -D tmp 2> /dev/null || true\n \t)\n }\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217309","messageId":"1368506230-19614-17-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 16/47] remote-hg: load all extensions","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:39Z","receivedAt":"2013-05-14T04:36:39Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The user might have then configured differently, plus, all of them will\nbe loaded anyway later on.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 96bed8d..60e875d 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -339,11 +339,7 @@ def get_repo(url, alias):\n     if get_config_bool('remote-hg.insecure'):\n         myui.setconfig('web', 'cacerts', '')\n \n-    try:\n-        mod = extensions.load(myui, 'hgext.schemes', None)\n-        mod.extsetup(myui)\n-    except ImportError:\n-        pass\n+    extensions.loadall(myui)\n \n     if hg.islocal(url):\n         repo = hg.repository(myui, url)\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217277","messageId":"1368506230-19614-18-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 17/47] remote-hg: use a shared repository store","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:40Z","receivedAt":"2013-05-14T04:36:40Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This way we don't have to have duplicated Mercurial objects.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 35 ++++++++++++++++++++---------------\n 1 file changed, 20 insertions(+), 15 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 60e875d..d676c98 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -343,21 +343,29 @@ def get_repo(url, alias):\n \n     if hg.islocal(url):\n         repo = hg.repository(myui, url)\n+        if not os.path.exists(dirname):\n+            os.makedirs(dirname)\n     else:\n-        local_path = os.path.join(dirname, 'clone')\n-        if not os.path.exists(local_path):\n+        shared_path = os.path.join(gitdir, 'hg')\n+        if not os.path.exists(shared_path):\n             try:\n-                peer, dstpeer = hg.clone(myui, {}, url, local_path, update=True, pull=True)\n+                hg.clone(myui, {}, url, shared_path, update=False, pull=True)\n             except:\n                 die('Repository error')\n-            repo = dstpeer.local()\n-        else:\n-            repo = hg.repository(myui, local_path)\n-            try:\n-                peer = hg.peer(myui, {}, url)\n-            except:\n-                die('Repository error')\n-            repo.pull(peer, heads=None, force=True)\n+\n+        if not os.path.exists(dirname):\n+            os.mkdir(dirname)\n+\n+        local_path = os.path.join(dirname, 'clone')\n+        if not os.path.exists(local_path):\n+            hg.share(myui, shared_path, local_path, update=False)\n+\n+        repo = hg.repository(myui, local_path)\n+        try:\n+            peer = hg.peer(myui, {}, url)\n+        except:\n+            die('Repository error')\n+        repo.pull(peer, heads=None, force=True)\n \n         rb = peer.listkeys('bookmarks')\n         bookmarks.updatefromremote(myui, repo, rb, url)\n@@ -901,7 +909,7 @@ def fix_path(alias, repo, orig_url):\n     subprocess.call(cmd)\n \n def main(args):\n-    global prefix, dirname, branches, bmarks\n+    global prefix, gitdir, dirname, branches, bmarks\n     global marks, blob_marks, parsed_refs\n     global peer, mode, bad_mail, bad_name\n     global track_branches, force_push, is_tmp\n@@ -947,9 +955,6 @@ def main(args):\n     if not is_tmp:\n         fix_path(alias, peer or repo, url)\n \n-    if not os.path.exists(dirname):\n-        os.makedirs(dirname)\n-\n     marks_path = os.path.join(dirname, 'marks-hg')\n     marks = Marks(marks_path)\n \n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217278","messageId":"1368506230-19614-19-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 18/47] remote-hg: shuffle some code","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:41Z","receivedAt":"2013-05-14T04:36:41Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"In preparation to shift to SHA-1's.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 30 +++++++++++++++++-------------\n 1 file changed, 17 insertions(+), 13 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex d676c98..8417d1e 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -75,6 +75,9 @@ def hgmode(mode):\n def hghex(node):\n     return hg.node.hex(node)\n \n+def hgbin(node):\n+    return hg.node.bin(node)\n+\n def hgref(ref):\n     return ref.replace('___', ' ')\n \n@@ -261,7 +264,7 @@ def get_filechanges(repo, ctx, parent):\n     removed = set()\n \n     # load earliest manifest first for caching reasons\n-    prev = repo[parent].manifest().copy()\n+    prev = parent.manifest().copy()\n     cur = ctx.manifest()\n \n     for fn in cur:\n@@ -404,7 +407,7 @@ def export_ref(repo, name, kind, head):\n         else:\n             committer = author\n \n-        parents = [p for p in repo.changelog.parentrevs(rev) if p >= 0]\n+        parents = [repo[p] for p in repo.changelog.parentrevs(rev) if p >= 0]\n \n         if len(parents) == 0:\n             modified = c.manifest().keys()\n@@ -453,9 +456,9 @@ def export_ref(repo, name, kind, head):\n         print desc\n \n         if len(parents) > 0:\n-            print \"from :%s\" % (rev_to_mark(parents[0]))\n+            print \"from :%s\" % (rev_to_mark(parents[0].rev()))\n             if len(parents) > 1:\n-                print \"merge :%s\" % (rev_to_mark(parents[1]))\n+                print \"merge :%s\" % (rev_to_mark(parents[1].rev()))\n \n         for f in modified_final:\n             print \"M %s :%u %s\" % f\n@@ -469,10 +472,10 @@ def export_ref(repo, name, kind, head):\n \n     # make sure the ref is updated\n     print \"reset %s/%s\" % (prefix, ename)\n-    print \"from :%u\" % rev_to_mark(rev)\n+    print \"from :%u\" % rev_to_mark(head.rev())\n     print\n \n-    marks.set_tip(ename, rev)\n+    marks.set_tip(ename, head.rev())\n \n def export_tag(repo, tag):\n     export_ref(repo, tag, 'tags', repo[hgref(tag)])\n@@ -742,7 +745,7 @@ def parse_commit(parser):\n     tmp = encoding.encoding\n     encoding.encoding = 'utf-8'\n \n-    node = repo.commitctx(ctx)\n+    node = hghex(repo.commitctx(ctx))\n \n     encoding.encoding = tmp\n \n@@ -766,7 +769,7 @@ def parse_reset(parser):\n     parser.next()\n \n     node = parser.repo.changelog.node(mark_to_rev(from_mark))\n-    parsed_refs[ref] = node\n+    parsed_refs[ref] = hghex(node)\n \n def parse_tag(parser):\n     name = parser[1]\n@@ -791,7 +794,7 @@ def write_tag(repo, tag, node, msg, author):\n             data = fctx.data()\n         except error.ManifestLookupError:\n             data = \"\"\n-        content = data + \"%s %s\\n\" % (hghex(node), tag)\n+        content = data + \"%s %s\\n\" % (node, tag)\n         return context.memfilectx(f, content, False, False, None)\n \n     p1 = tip.hex()\n@@ -835,9 +838,10 @@ def do_export(parser):\n             die('unhandled export command: %s' % line)\n \n     for ref, node in parsed_refs.iteritems():\n+        bnode = hgbin(node)\n         if ref.startswith('refs/heads/branches'):\n             branch = ref[len('refs/heads/branches/'):]\n-            if branch in branches and node in branches[branch]:\n+            if branch in branches and bnode in branches[branch]:\n                 # up to date\n                 continue\n             print \"ok %s\" % ref\n@@ -851,11 +855,11 @@ def do_export(parser):\n             author, msg = parsed_tags.get(tag, (None, None))\n             if mode == 'git':\n                 if not msg:\n-                    msg = 'Added tag %s for changeset %s' % (tag, hghex(node[:6]));\n+                    msg = 'Added tag %s for changeset %s' % (tag, node[:12]);\n                 write_tag(parser.repo, tag, node, msg, author)\n             else:\n                 fp = parser.repo.opener('localtags', 'a')\n-                fp.write('%s %s\\n' % (hghex(node), tag))\n+                fp.write('%s %s\\n' % (node, tag))\n                 fp.close()\n             print \"ok %s\" % ref\n         else:\n@@ -869,7 +873,7 @@ def do_export(parser):\n     # handle bookmarks\n     for bmark, node in p_bmarks:\n         ref = 'refs/heads/' + bmark\n-        new = hghex(node)\n+        new = node\n \n         if bmark in bmarks:\n             old = bmarks[bmark].hex()\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217279","messageId":"1368506230-19614-20-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 19/47] remote-hg: improve node traversing","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:42Z","receivedAt":"2013-05-14T04:36:42Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We won't be able to count the unmarked commits, but we are not going to\nbe able to do that anyway when we switch to SHA-1 ids.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 10 +++++++---\n 1 file changed, 7 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 8417d1e..a3618de 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -392,12 +392,16 @@ def export_ref(repo, name, kind, head):\n     revs = xrange(tip, head.rev() + 1)\n     count = 0\n \n-    revs = [rev for rev in revs if not marks.is_marked(rev)]\n-\n     for rev in revs:\n \n         c = repo[rev]\n-        (manifest, user, (time, tz), files, desc, extra) = repo.changelog.read(c.node())\n+        node = c.node()\n+\n+        if marks.is_marked(c.hex()):\n+            count += 1\n+            continue\n+\n+        (manifest, user, (time, tz), files, desc, extra) = repo.changelog.read(node)\n         rev_branch = extra['branch']\n \n         author = \"%s %d %s\" % (fixup_user(user), time, gittz(tz))\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217310","messageId":"1368506230-19614-21-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 20/47] remote-hg: add version checks to the marks","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:43Z","receivedAt":"2013-05-14T04:36:43Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 16 +++++++++++++---\n 1 file changed, 13 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex a3618de..36b8fd4 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -55,6 +55,8 @@ EMAIL_RE = re.compile('^([^<>]+[^ \\\\\\t<>])?\\\\b(?:[ \\\\t<>]*?)\\\\b([^ \\\\t<>]+@[^ \\\\\n AUTHOR_HG_RE = re.compile('^(.*?) ?<(.*?)(?:>(.+)?)?$')\n RAW_AUTHOR_RE = re.compile('^(\\w+) (?:(.+)? )?<(.*)> (\\d+) ([+-]\\d+)')\n \n+VERSION = 1\n+\n def die(msg, *args):\n     sys.stderr.write('ERROR: %s\\n' % (msg % args))\n     sys.exit(1)\n@@ -103,12 +105,19 @@ class Marks:\n \n     def __init__(self, path):\n         self.path = path\n+        self.clear()\n+        self.load()\n+\n+        if self.version < VERSION:\n+            self.clear()\n+            self.version = VERSION\n+\n+    def clear(self):\n         self.tips = {}\n         self.marks = {}\n         self.rev_marks = {}\n         self.last_mark = 0\n-\n-        self.load()\n+        self.version = 0\n \n     def load(self):\n         if not os.path.exists(self.path):\n@@ -119,12 +128,13 @@ class Marks:\n         self.tips = tmp['tips']\n         self.marks = tmp['marks']\n         self.last_mark = tmp['last-mark']\n+        self.version = tmp.get('version', 1)\n \n         for rev, mark in self.marks.iteritems():\n             self.rev_marks[mark] = int(rev)\n \n     def dict(self):\n-        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark }\n+        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version }\n \n     def store(self):\n         json.dump(self.dict(), open(self.path, 'w'))\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217288","messageId":"1368506230-19614-22-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 21/47] remote-hg: switch from revisions to SHA-1 noteids","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:44Z","receivedAt":"2013-05-14T04:36:44Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Otherwise we won't know if revisions are replaced.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 42 +++++++++++++++++++-----------------\n 1 file changed, 22 insertions(+), 20 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 36b8fd4..fbd70ef 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -55,7 +55,7 @@ EMAIL_RE = re.compile('^([^<>]+[^ \\\\\\t<>])?\\\\b(?:[ \\\\t<>]*?)\\\\b([^ \\\\t<>]+@[^ \\\\\n AUTHOR_HG_RE = re.compile('^(.*?) ?<(.*?)(?:>(.+)?)?$')\n RAW_AUTHOR_RE = re.compile('^(\\w+) (?:(.+)? )?<(.*)> (\\d+) ([+-]\\d+)')\n \n-VERSION = 1\n+VERSION = 2\n \n def die(msg, *args):\n     sys.stderr.write('ERROR: %s\\n' % (msg % args))\n@@ -131,7 +131,7 @@ class Marks:\n         self.version = tmp.get('version', 1)\n \n         for rev, mark in self.marks.iteritems():\n-            self.rev_marks[mark] = int(rev)\n+            self.rev_marks[mark] = rev\n \n     def dict(self):\n         return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version }\n@@ -143,7 +143,7 @@ class Marks:\n         return str(self.dict())\n \n     def from_rev(self, rev):\n-        return self.marks[str(rev)]\n+        return self.marks[rev]\n \n     def to_rev(self, mark):\n         return self.rev_marks[mark]\n@@ -154,19 +154,19 @@ class Marks:\n \n     def get_mark(self, rev):\n         self.last_mark += 1\n-        self.marks[str(rev)] = self.last_mark\n+        self.marks[rev] = self.last_mark\n         return self.last_mark\n \n     def new_mark(self, rev, mark):\n-        self.marks[str(rev)] = mark\n+        self.marks[rev] = mark\n         self.rev_marks[mark] = rev\n         self.last_mark = mark\n \n     def is_marked(self, rev):\n-        return str(rev) in self.marks\n+        return rev in self.marks\n \n     def get_tip(self, branch):\n-        return self.tips.get(branch, 0)\n+        return self.tips.get(branch, None)\n \n     def set_tip(self, branch, tip):\n         self.tips[branch] = tip\n@@ -387,7 +387,7 @@ def get_repo(url, alias):\n \n def rev_to_mark(rev):\n     global marks\n-    return marks.from_rev(rev)\n+    return marks.from_rev(rev.hex())\n \n def mark_to_rev(mark):\n     global marks\n@@ -398,6 +398,10 @@ def export_ref(repo, name, kind, head):\n \n     ename = '%s/%s' % (kind, name)\n     tip = marks.get_tip(ename)\n+    if tip in repo:\n+        tip = repo[tip].rev()\n+    else:\n+        tip = 0\n \n     revs = xrange(tip, head.rev() + 1)\n     count = 0\n@@ -463,16 +467,16 @@ def export_ref(repo, name, kind, head):\n         modified_final = export_files(c.filectx(f) for f in modified)\n \n         print \"commit %s/%s\" % (prefix, ename)\n-        print \"mark :%d\" % (marks.get_mark(rev))\n+        print \"mark :%d\" % (marks.get_mark(c.hex()))\n         print \"author %s\" % (author)\n         print \"committer %s\" % (committer)\n         print \"data %d\" % (len(desc))\n         print desc\n \n         if len(parents) > 0:\n-            print \"from :%s\" % (rev_to_mark(parents[0].rev()))\n+            print \"from :%s\" % (rev_to_mark(parents[0]))\n             if len(parents) > 1:\n-                print \"merge :%s\" % (rev_to_mark(parents[1].rev()))\n+                print \"merge :%s\" % (rev_to_mark(parents[1]))\n \n         for f in modified_final:\n             print \"M %s :%u %s\" % f\n@@ -486,10 +490,10 @@ def export_ref(repo, name, kind, head):\n \n     # make sure the ref is updated\n     print \"reset %s/%s\" % (prefix, ename)\n-    print \"from :%u\" % rev_to_mark(head.rev())\n+    print \"from :%u\" % rev_to_mark(head)\n     print\n \n-    marks.set_tip(ename, head.rev())\n+    marks.set_tip(ename, head.hex())\n \n def export_tag(repo, tag):\n     export_ref(repo, tag, 'tags', repo[hgref(tag)])\n@@ -716,12 +720,12 @@ def parse_commit(parser):\n         extra['committer'] = \"%s %u %u\" % committer\n \n     if from_mark:\n-        p1 = repo.changelog.node(mark_to_rev(from_mark))\n+        p1 = mark_to_rev(from_mark)\n     else:\n         p1 = '\\0' * 20\n \n     if merge_mark:\n-        p2 = repo.changelog.node(mark_to_rev(merge_mark))\n+        p2 = mark_to_rev(merge_mark)\n     else:\n         p2 = '\\0' * 20\n \n@@ -763,10 +767,8 @@ def parse_commit(parser):\n \n     encoding.encoding = tmp\n \n-    rev = repo[node].rev()\n-\n     parsed_refs[ref] = node\n-    marks.new_mark(rev, commit_mark)\n+    marks.new_mark(node, commit_mark)\n \n def parse_reset(parser):\n     global parsed_refs\n@@ -782,8 +784,8 @@ def parse_reset(parser):\n     from_mark = parser.get_mark()\n     parser.next()\n \n-    node = parser.repo.changelog.node(mark_to_rev(from_mark))\n-    parsed_refs[ref] = hghex(node)\n+    rev = mark_to_rev(from_mark)\n+    parsed_refs[ref] = rev\n \n def parse_tag(parser):\n     name = parser[1]\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217289","messageId":"1368506230-19614-23-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 22/47] remote-hg: upgrade version 1 marks","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:45Z","receivedAt":"2013-05-14T04:36:45Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"As suggested by Jed Brown; there's no need to re-import all the commits.\n\nCc: Jed Brown <jed@59a2.org>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 22 ++++++++++++++++++----\n 1 file changed, 18 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex fbd70ef..6cad5cd 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -103,14 +103,20 @@ def get_config_bool(config, default=False):\n \n class Marks:\n \n-    def __init__(self, path):\n+    def __init__(self, path, repo):\n         self.path = path\n+        self.repo = repo\n         self.clear()\n         self.load()\n \n         if self.version < VERSION:\n-            self.clear()\n-            self.version = VERSION\n+            if self.version == 1:\n+                self.upgrade_one()\n+\n+            # upgraded?\n+            if self.version < VERSION:\n+                self.clear()\n+                self.version = VERSION\n \n     def clear(self):\n         self.tips = {}\n@@ -133,6 +139,14 @@ class Marks:\n         for rev, mark in self.marks.iteritems():\n             self.rev_marks[mark] = rev\n \n+    def upgrade_one(self):\n+        def get_id(rev):\n+            return hghex(self.repo.changelog.node(int(rev)))\n+        self.tips = dict((name, get_id(rev)) for name, rev in self.tips.iteritems())\n+        self.marks = dict((get_id(rev), mark) for rev, mark in self.marks.iteritems())\n+        self.rev_marks = dict((mark, get_id(rev)) for mark, rev in self.rev_marks.iteritems())\n+        self.version = 2\n+\n     def dict(self):\n         return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version }\n \n@@ -976,7 +990,7 @@ def main(args):\n         fix_path(alias, peer or repo, url)\n \n     marks_path = os.path.join(dirname, 'marks-hg')\n-    marks = Marks(marks_path)\n+    marks = Marks(marks_path, repo)\n \n     parser = Parser(repo)\n     for line in parser:\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217287","messageId":"1368506230-19614-24-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 23/47] remote-hg: ensure remote rebasing works","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:46Z","receivedAt":"2013-05-14T04:36:46Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg |  1 +\n contrib/remote-helpers/test-hg.sh    | 40 ++++++++++++++++++++++++++++++++++++\n 2 files changed, 41 insertions(+)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 6cad5cd..bc6e8fa 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -624,6 +624,7 @@ def do_import(parser):\n     if os.path.exists(path):\n         print \"feature import-marks=%s\" % path\n     print \"feature export-marks=%s\" % path\n+    print \"feature force\"\n     sys.stdout.flush()\n \n     tmp = encoding.encoding\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 4bd7584..23ff0db 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -37,6 +37,8 @@ setup () {\n \t(\n \techo \"[ui]\"\n \techo \"username = H G Wells <wells@example.com>\"\n+\techo \"[extensions]\"\n+\techo \"mq =\"\n \t) >> \"$HOME\"/.hgrc\n }\n \n@@ -161,4 +163,42 @@ test_expect_success 'authors' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'strip' '\n+\ttest_when_finished \"rm -rf hgrepo gitrepo\" &&\n+\n+\t(\n+\thg init hgrepo &&\n+\tcd hgrepo &&\n+\n+\techo one >> content &&\n+\thg add content &&\n+\thg commit -m one &&\n+\n+\techo two >> content &&\n+\thg commit -m two\n+\t) &&\n+\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\n+\t(\n+\tcd hgrepo &&\n+\thg strip -r 1 &&\n+\n+\techo three >> content &&\n+\thg commit -m three &&\n+\n+\techo four >> content &&\n+\thg commit -m four\n+\t) &&\n+\n+\t(\n+\tcd gitrepo &&\n+\tgit fetch &&\n+\tgit log --format=\"%s\" origin/master > ../actual\n+\t) &&\n+\n+\thg -R hgrepo log --template \"{desc}\\n\" > expected &&\n+\ttest_cmp actual expected\n+'\n+\n test_done\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217282","messageId":"1368506230-19614-25-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 24/47] remote-hg: trivial cleanups","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:47Z","receivedAt":"2013-05-14T04:36:47Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex bc6e8fa..49af8d5 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -74,11 +74,11 @@ def hgmode(mode):\n     m = { '100755': 'x', '120000': 'l' }\n     return m.get(mode, '')\n \n-def hghex(node):\n-    return hg.node.hex(node)\n+def hghex(n):\n+    return node.hex(n)\n \n-def hgbin(node):\n-    return hg.node.bin(node)\n+def hgbin(n):\n+    return node.bin(n)\n \n def hgref(ref):\n     return ref.replace('___', ' ')\n@@ -737,12 +737,12 @@ def parse_commit(parser):\n     if from_mark:\n         p1 = mark_to_rev(from_mark)\n     else:\n-        p1 = '\\0' * 20\n+        p1 = '0' * 40\n \n     if merge_mark:\n         p2 = mark_to_rev(merge_mark)\n     else:\n-        p2 = '\\0' * 20\n+        p2 = '0' * 40\n \n     #\n     # If files changed from any of the parents, hg wants to know, but in git if\n@@ -829,7 +829,7 @@ def write_tag(repo, tag, node, msg, author):\n         return context.memfilectx(f, content, False, False, None)\n \n     p1 = tip.hex()\n-    p2 = '\\0' * 20\n+    p2 = '0' * 40\n     if not author:\n         author = (None, 0, 0)\n     user, date, tz = author\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217284","messageId":"1368506230-19614-26-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 25/47] remote-hg: improve progress calculation","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:48Z","receivedAt":"2013-05-14T04:36:48Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"No need to manually keep track of the revision count.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 9 ++++-----\n 1 file changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 49af8d5..e05106a 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -418,7 +418,7 @@ def export_ref(repo, name, kind, head):\n         tip = 0\n \n     revs = xrange(tip, head.rev() + 1)\n-    count = 0\n+    total = len(revs)\n \n     for rev in revs:\n \n@@ -426,7 +426,6 @@ def export_ref(repo, name, kind, head):\n         node = c.node()\n \n         if marks.is_marked(c.hex()):\n-            count += 1\n             continue\n \n         (manifest, user, (time, tz), files, desc, extra) = repo.changelog.read(node)\n@@ -498,9 +497,9 @@ def export_ref(repo, name, kind, head):\n             print \"D %s\" % (fix_file_path(f))\n         print\n \n-        count += 1\n-        if (count % 100 == 0):\n-            print \"progress revision %d '%s' (%d/%d)\" % (rev, name, count, len(revs))\n+        progress = (rev - tip)\n+        if (progress % 100 == 0):\n+            print \"progress revision %d '%s' (%d/%d)\" % (rev, name, progress, total)\n \n     # make sure the ref is updated\n     print \"reset %s/%s\" % (prefix, ename)\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217283","messageId":"1368506230-19614-27-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 26/47] remote-hg: always point HEAD to master","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:49Z","receivedAt":"2013-05-14T04:36:49Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Mercurial always checks out the 'default' branch, so there's no point in\ncomplicating our lives trying to do something fancier, which causes\ndifferent behavior depending on whether the repository is local or\nremote.\n\nSo let's always use 'default' (which we translate to 'master'), unless\nwe are in hg-git mode, which expects us to use the 'master' bookmark\ninstead.\n\nAlso, update the tests that used to check for different checkout\nbehaviors to simply check that the refs are there, remove unnecessary\nones, and fix the ones that expect something different.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg     | 21 +++++++------------\n contrib/remote-helpers/test-hg-bidi.sh   |  9 ++++----\n contrib/remote-helpers/test-hg-hg-git.sh |  4 +++-\n contrib/remote-helpers/test-hg.sh        | 35 ++++++--------------------------\n 4 files changed, 20 insertions(+), 49 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex e05106a..776c5af 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -565,20 +565,13 @@ def get_branch_tip(repo, branch):\n def list_head(repo, cur):\n     global g_head, bmarks\n \n-    head = bookmarks.readcurrent(repo)\n-    if head:\n-        node = repo[head]\n-    else:\n-        # fake bookmark from current branch\n-        head = cur\n-        node = repo['.']\n-        if not node:\n-            node = repo['tip']\n-        if not node:\n-            return\n-        if head == 'default':\n-            head = 'master'\n-        bmarks[head] = node\n+    if 'default' not in repo:\n+        # empty repo\n+        return\n+\n+    node = repo['default']\n+    head = 'master' if not 'master' in bmarks else 'default'\n+    bmarks[head] = node\n \n     head = gitref(head)\n     print \"@refs/heads/%s HEAD\" % head\ndiff --git a/contrib/remote-helpers/test-hg-bidi.sh b/contrib/remote-helpers/test-hg-bidi.sh\nindex 88a33e6..86a3f10 100755\n--- a/contrib/remote-helpers/test-hg-bidi.sh\n+++ b/contrib/remote-helpers/test-hg-bidi.sh\n@@ -29,7 +29,6 @@ git_clone () {\n hg_clone () {\n \t(\n \thg init $2 &&\n-\thg -R $2 bookmark -i master &&\n \tcd $1 &&\n \tgit push -q \"hg::../$2\" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'\n \t) &&\n@@ -49,8 +48,7 @@ hg_push () {\n }\n \n hg_log () {\n-\thg -R $1 log --graph --debug >log &&\n-\tgrep -v 'tag: *default/' log\n+\thg -R $1 log --graph --debug\n }\n \n setup () {\n@@ -66,6 +64,7 @@ setup () {\n \techo \"graphlog =\"\n \t) >> \"$HOME\"/.hgrc &&\n \tgit config --global remote-hg.hg-git-compat true\n+\tgit config --global remote-hg.track-branches true\n \n \tHGEDITOR=/usr/bin/true\n \tGIT_AUTHOR_DATE=\"2007-01-01 00:00:00 +0230\"\n@@ -189,7 +188,7 @@ test_expect_success 'hg branch' '\n \thg_clone gitrepo hgrepo &&\n \n \tcd hgrepo &&\n-\thg -q co master &&\n+\thg -q co default &&\n \thg mv alpha beta &&\n \thg -q commit -m \"rename alpha to beta\" &&\n \thg branch gamma | grep -v \"permanent and global\" &&\n@@ -225,7 +224,7 @@ test_expect_success 'hg tags' '\n \thg_clone gitrepo hgrepo &&\n \n \tcd hgrepo &&\n-\thg co master &&\n+\thg co default &&\n \thg tag alpha\n \t) &&\n \ndiff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh\nindex e503293..9cb95d8 100755\n--- a/contrib/remote-helpers/test-hg-hg-git.sh\n+++ b/contrib/remote-helpers/test-hg-hg-git.sh\n@@ -27,7 +27,8 @@ fi\n \n # clone to a git repo with git\n git_clone_git () {\n-\tgit clone -q \"hg::$1\" $2\n+\tgit clone -q \"hg::$1\" $2 &&\n+\t(cd $2 && git checkout master && git branch -D default)\n }\n \n # clone to an hg repo with git\n@@ -63,6 +64,7 @@ hg_push_git () {\n \tcd $2\n \tgit checkout -q -b tmp &&\n \tgit fetch -q \"hg::../$1\" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&\n+\tgit branch -D default &&\n \tgit checkout -q @{-1} &&\n \tgit branch -q -D tmp 2> /dev/null || true\n \t)\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 23ff0db..8d1f6e0 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -21,15 +21,8 @@ if ! \"$PYTHON_PATH\" -c 'import mercurial'; then\n fi\n \n check () {\n-\t(\n-\tcd $1 &&\n-\tgit log --format='%s' -1 &&\n-\tgit symbolic-ref HEAD\n-\t) > actual &&\n-\t(\n-\techo $2 &&\n-\techo \"refs/heads/$3\"\n-\t) > expected &&\n+\techo $3 > expected &&\n+\tgit --git-dir=$1/.git log --format='%s' -1 $2 > actual\n \ttest_cmp expected actual\n }\n \n@@ -56,7 +49,7 @@ test_expect_success 'cloning' '\n \t) &&\n \n \tgit clone \"hg::hgrepo\" gitrepo &&\n-\tcheck gitrepo zero master\n+\tcheck gitrepo HEAD zero\n '\n \n test_expect_success 'cloning with branches' '\n@@ -70,12 +63,7 @@ test_expect_success 'cloning with branches' '\n \t) &&\n \n \tgit clone \"hg::hgrepo\" gitrepo &&\n-\tcheck gitrepo next next &&\n-\n-\t(cd hgrepo && hg checkout default) &&\n-\n-\tgit clone \"hg::hgrepo\" gitrepo2 &&\n-\tcheck gitrepo2 zero master\n+\tcheck gitrepo origin/branches/next next\n '\n \n test_expect_success 'cloning with bookmarks' '\n@@ -83,25 +71,14 @@ test_expect_success 'cloning with bookmarks' '\n \n \t(\n \tcd hgrepo &&\n+\thg checkout default &&\n \thg bookmark feature-a &&\n \techo feature-a > content &&\n \thg commit -m feature-a\n \t) &&\n \n \tgit clone \"hg::hgrepo\" gitrepo &&\n-\tcheck gitrepo feature-a feature-a\n-'\n-\n-test_expect_success 'cloning with detached head' '\n-\ttest_when_finished \"rm -rf gitrepo*\" &&\n-\n-\t(\n-\tcd hgrepo &&\n-\thg update -r 0\n-\t) &&\n-\n-\tgit clone \"hg::hgrepo\" gitrepo &&\n-\tcheck gitrepo zero master\n+\tcheck gitrepo origin/feature-a feature-a\n '\n \n test_expect_success 'update bookmark' '\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217286","messageId":"1368506230-19614-28-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 27/47] remote-bzr: simplify test checks","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:50Z","receivedAt":"2013-05-14T04:36:50Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-bzr.sh | 17 +++++------------\n 1 file changed, 5 insertions(+), 12 deletions(-)\n\ndiff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh\nindex 90f8c7f..220e388 100755\n--- a/contrib/remote-helpers/test-bzr.sh\n+++ b/contrib/remote-helpers/test-bzr.sh\n@@ -18,15 +18,8 @@ if ! \"$PYTHON_PATH\" -c 'import bzrlib'; then\n fi\n \n check () {\n-\t(\n-\tcd $1 &&\n-\tgit log --format='%s' -1 &&\n-\tgit symbolic-ref HEAD\n-\t) > actual &&\n-\t(\n-\techo $2 &&\n-\techo \"refs/heads/$3\"\n-\t) > expected &&\n+\techo $3 > expected &&\n+\tgit --git-dir=$1/.git log --format='%s' -1 $2 > actual\n \ttest_cmp expected actual\n }\n \n@@ -42,7 +35,7 @@ test_expect_success 'cloning' '\n \t) &&\n \n \tgit clone \"bzr::bzrrepo\" gitrepo &&\n-\tcheck gitrepo one master\n+\tcheck gitrepo HEAD one\n '\n \n test_expect_success 'pulling' '\n@@ -54,7 +47,7 @@ test_expect_success 'pulling' '\n \n \t(cd gitrepo && git pull) &&\n \n-\tcheck gitrepo two master\n+\tcheck gitrepo HEAD two\n '\n \n test_expect_success 'pushing' '\n@@ -89,7 +82,7 @@ test_expect_success 'roundtrip' '\n \n \t(cd gitrepo && git pull && git push) &&\n \n-\tcheck gitrepo four master &&\n+\tcheck gitrepo HEAD four &&\n \n \t(\n \tcd gitrepo &&\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217285","messageId":"1368506230-19614-29-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 28/47] remote-hg: add check_bookmark() test helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:51Z","receivedAt":"2013-05-14T04:36:51Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"And check in a more proper way.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-hg.sh | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 8d1f6e0..dc71c37 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -26,6 +26,12 @@ check () {\n \ttest_cmp expected actual\n }\n \n+check_bookmark () {\n+\techo $3 > expected &&\n+\thg -R $1 log -r \"bookmark('$2')\" --template '{desc}\\n' > actual &&\n+\ttest_cmp expected actual\n+}\n+\n setup () {\n \t(\n \techo \"[ui]\"\n@@ -98,7 +104,7 @@ test_expect_success 'update bookmark' '\n \tgit push --quiet\n \t) &&\n \n-\thg -R hgrepo bookmarks | egrep \"devel[\t ]+3:\"\n+\tcheck_bookmark hgrepo devel devel\n '\n \n # cleanup previous stuff\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217308","messageId":"1368506230-19614-30-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 29/47] remote-hg: add remote tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:52Z","receivedAt":"2013-05-14T04:36:52Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The logic when working with a local repository is totally different from\nthe one where we work with a remote repository; we need to pull and push\nfrom it.\n\nAll this logic is currently not tested at all, so let's introduce a\nvariable to force the remote behavior.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg |  2 +-\n contrib/remote-helpers/test-hg.sh    | 38 ++++++++++++++++++++++++++++++++++++\n 2 files changed, 39 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 776c5af..6c7392f 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -368,7 +368,7 @@ def get_repo(url, alias):\n \n     extensions.loadall(myui)\n \n-    if hg.islocal(url):\n+    if hg.islocal(url) and not os.environ.get('GIT_REMOTE_HG_TEST_REMOTE'):\n         repo = hg.repository(myui, url)\n         if not os.path.exists(dirname):\n             os.makedirs(dirname)\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex dc71c37..44764a0 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -184,4 +184,42 @@ test_expect_success 'strip' '\n \ttest_cmp actual expected\n '\n \n+GIT_REMOTE_HG_TEST_REMOTE=1\n+export GIT_REMOTE_HG_TEST_REMOTE\n+\n+test_expect_success 'remote cloning' '\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n+\n+\t(\n+\thg init hgrepo &&\n+\tcd hgrepo &&\n+\techo zero > content &&\n+\thg add content &&\n+\thg commit -m zero\n+\t) &&\n+\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\tcheck gitrepo HEAD zero\n+'\n+\n+test_expect_success 'remote update bookmark' '\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n+\n+\t(\n+\tcd hgrepo &&\n+\thg bookmark devel\n+\t) &&\n+\n+\t(\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\tcd gitrepo &&\n+\tgit checkout --quiet devel &&\n+\techo devel > content &&\n+\tgit commit -a -m devel &&\n+\tgit push --quiet\n+\t) &&\n+\n+\tcheck_bookmark hgrepo devel devel\n+'\n+\n test_done\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217290","messageId":"1368506230-19614-31-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 30/47] remote-hg: add test to push new bookmark","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:53Z","receivedAt":"2013-05-14T04:36:53Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-hg.sh | 30 ++++++++++++++++++++++++++++++\n 1 file changed, 30 insertions(+)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 44764a0..5e4f53f 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -107,6 +107,21 @@ test_expect_success 'update bookmark' '\n \tcheck_bookmark hgrepo devel devel\n '\n \n+test_expect_success 'new bookmark' '\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n+\n+\t(\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\tcd gitrepo &&\n+\tgit checkout --quiet -b feature-b &&\n+\techo feature-b > content &&\n+\tgit commit -a -m feature-b &&\n+\tgit push --quiet origin feature-b\n+\t) &&\n+\n+\tcheck_bookmark hgrepo feature-b feature-b\n+'\n+\n # cleanup previous stuff\n rm -rf hgrepo\n \n@@ -222,4 +237,19 @@ test_expect_success 'remote update bookmark' '\n \tcheck_bookmark hgrepo devel devel\n '\n \n+test_expect_success 'remote new bookmark' '\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n+\n+\t(\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\tcd gitrepo &&\n+\tgit checkout --quiet -b feature-b &&\n+\techo feature-b > content &&\n+\tgit commit -a -m feature-b &&\n+\tgit push --quiet origin feature-b\n+\t) &&\n+\n+\tcheck_bookmark hgrepo feature-b feature-b\n+'\n+\n test_done\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217291","messageId":"1368506230-19614-32-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 31/47] remote-hg: add test for diverged push","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:54Z","receivedAt":"2013-05-14T04:36:54Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Neither mercurial nor git allows pushing to a remote when it's a\nnon-fast-forward push. We should be able to detect theses errors and\nreport them properly.\n\nAs opposed to throwing an exception stack-trace.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-hg.sh | 29 +++++++++++++++++++++++++++++\n 1 file changed, 29 insertions(+)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 5e4f53f..06700a8 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -32,6 +32,12 @@ check_bookmark () {\n \ttest_cmp expected actual\n }\n \n+check_branch () {\n+\techo $3 > expected &&\n+\thg -R $1 log -r $2 --template '{desc}\\n' > actual &&\n+\ttest_cmp expected actual\n+}\n+\n setup () {\n \t(\n \techo \"[ui]\"\n@@ -252,4 +258,27 @@ test_expect_success 'remote new bookmark' '\n \tcheck_bookmark hgrepo feature-b feature-b\n '\n \n+test_expect_failure 'remote push diverged' '\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n+\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\n+\t(\n+\tcd hgrepo &&\n+\thg checkout default &&\n+\techo bump > content &&\n+\thg commit -m bump\n+\t) &&\n+\n+\t(\n+\tcd gitrepo &&\n+\techo diverge > content &&\n+\tgit commit -a -m diverged &&\n+\ttest_expect_code 1 git push 2> error &&\n+\tgrep \"^ ! \\[rejected\\] *master -> master (non-fast-forward)$\" error\n+\t) &&\n+\n+\tcheck_branch hgrepo default bump\n+'\n+\n test_done\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217292","messageId":"1368506230-19614-33-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 32/47] remote-hg: add test for bookmark diverge","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:55Z","receivedAt":"2013-05-14T04:36:55Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-hg.sh | 29 +++++++++++++++++++++++++++++\n 1 file changed, 29 insertions(+)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 06700a8..f4e3807 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -281,4 +281,33 @@ test_expect_failure 'remote push diverged' '\n \tcheck_branch hgrepo default bump\n '\n \n+test_expect_failure 'remote update bookmark diverge' '\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n+\n+\t(\n+\tcd hgrepo &&\n+\thg bookmark diverge -r tip^\n+\thg checkout diverge\n+\t) &&\n+\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\n+\t(\n+\tcd hgrepo &&\n+\techo \"bump bookmark\" > content &&\n+\thg commit -m \"bump bookmark\"\n+\t) &&\n+\n+\t(\n+\tcd gitrepo &&\n+\tgit checkout --quiet diverge &&\n+\techo diverge > content &&\n+\tgit commit -a -m diverge &&\n+\ttest_expect_code 1 git push 2> error &&\n+\tgrep \"^ ! \\[rejected\\] *diverge -> diverge (non-fast-forward)$\" error\n+\t) &&\n+\n+\tcheck_bookmark hgrepo diverge \"bump bookmark\"\n+'\n+\n test_done\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217293","messageId":"1368506230-19614-34-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 33/47] remote-hg: add test for new bookmark special","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:56Z","receivedAt":"2013-05-14T04:36:56Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":">From the point of view of Mercurial, this creates a new branch head, and\nrequires a forced push.\n\nIdeally, whoever, we would want it to work just like in git; new\nbranches can be pushed without problems.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-hg.sh | 15 +++++++++++++++\n 1 file changed, 15 insertions(+)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex f4e3807..c3fa04d 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -310,4 +310,19 @@ test_expect_failure 'remote update bookmark diverge' '\n \tcheck_bookmark hgrepo diverge \"bump bookmark\"\n '\n \n+test_expect_failure 'remote new bookmark multiple branch head' '\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n+\n+\t(\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\tcd gitrepo &&\n+\tgit checkout --quiet -b feature-c HEAD^ &&\n+\techo feature-c > content &&\n+\tgit commit -a -m feature-c &&\n+\tgit push --quiet origin feature-c\n+\t) &&\n+\n+\tcheck_bookmark hgrepo feature-c feature-c\n+'\n+\n test_done\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217298","messageId":"1368506230-19614-35-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 34/47] remote-hg: add test for big push","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:57Z","receivedAt":"2013-05-14T04:36:57Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"With lots branches and bookmarks, non-ff, updated and new.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-hg.sh | 113 ++++++++++++++++++++++++++++++++++++--\n 1 file changed, 107 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex c3fa04d..d98c7a7 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -27,15 +27,25 @@ check () {\n }\n \n check_bookmark () {\n-\techo $3 > expected &&\n-\thg -R $1 log -r \"bookmark('$2')\" --template '{desc}\\n' > actual &&\n-\ttest_cmp expected actual\n+\tif [ -n \"$3\" ]; then\n+\t\techo $3 > expected &&\n+\t\thg -R $1 log -r \"bookmark('$2')\" --template '{desc}\\n' > actual &&\n+\t\ttest_cmp expected actual\n+\telse\n+\t\thg -R $1 bookmarks > out &&\n+\t\t! grep $2 out\n+\tfi\n }\n \n check_branch () {\n-\techo $3 > expected &&\n-\thg -R $1 log -r $2 --template '{desc}\\n' > actual &&\n-\ttest_cmp expected actual\n+\tif [ -n \"$3\" ]; then\n+\t\techo $3 > expected &&\n+\t\thg -R $1 log -r $2 --template '{desc}\\n' > actual &&\n+\t\ttest_cmp expected actual\n+\telse\n+\t\thg -R $1 branches > out &&\n+\t\t! grep $2 out\n+\tfi\n }\n \n setup () {\n@@ -325,4 +335,95 @@ test_expect_failure 'remote new bookmark multiple branch head' '\n \tcheck_bookmark hgrepo feature-c feature-c\n '\n \n+# cleanup previous stuff\n+rm -rf hgrepo\n+\n+test_expect_failure 'remote big push' '\n+\ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n+\n+\t(\n+\thg init hgrepo &&\n+\tcd hgrepo &&\n+\techo zero > content &&\n+\thg add content &&\n+\thg commit -m zero &&\n+\thg bookmark bad_bmark1 &&\n+\techo one > content &&\n+\thg commit -m one &&\n+\thg bookmark bad_bmark2 &&\n+\thg bookmark good_bmark &&\n+\thg bookmark -i &&\n+\thg -q branch good_branch &&\n+\techo \"good branch\" > content &&\n+\thg commit -m \"good branch\" &&\n+\thg -q branch bad_branch &&\n+\techo \"bad branch\" > content &&\n+\thg commit -m \"bad branch\"\n+\t) &&\n+\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\n+\t(\n+\tcd gitrepo &&\n+\techo two > content &&\n+\tgit commit -q -a -m two &&\n+\n+\tgit checkout -q good_bmark &&\n+\techo three > content &&\n+\tgit commit -q -a -m three &&\n+\n+\tgit checkout -q bad_bmark1 &&\n+\tgit reset --hard HEAD^ &&\n+\techo four > content &&\n+\tgit commit -q -a -m four &&\n+\n+\tgit checkout -q bad_bmark2 &&\n+\tgit reset --hard HEAD^ &&\n+\techo five > content &&\n+\tgit commit -q -a -m five &&\n+\n+\tgit checkout -q -b new_bmark master &&\n+\techo six > content &&\n+\tgit commit -q -a -m six &&\n+\n+\tgit checkout -q branches/good_branch &&\n+\techo seven > content &&\n+\tgit commit -q -a -m seven &&\n+\techo eight > content &&\n+\tgit commit -q -a -m eight &&\n+\n+\tgit checkout -q branches/bad_branch &&\n+\tgit reset --hard HEAD^ &&\n+\techo nine > content &&\n+\tgit commit -q -a -m nine &&\n+\n+\tgit checkout -q -b branches/new_branch master &&\n+\techo ten > content &&\n+\tgit commit -q -a -m ten &&\n+\n+\ttest_expect_code 1 git push origin master \\\n+\t\tgood_bmark bad_bmark1 bad_bmark2 new_bmark \\\n+\t\tbranches/good_branch branches/bad_branch \\\n+\t\tbranches/new_branch 2> error &&\n+\n+\tgrep \"^   [a-f0-9]*\\.\\.[a-f0-9]* *master -> master$\" error &&\n+\tgrep \"^   [a-f0-9]*\\.\\.[a-f0-9]* *good_bmark -> good_bmark$\" error &&\n+\tgrep \"^ \\* \\[new branch\\] *new_bmark -> new_bmark$\" error &&\n+\tgrep \"^ ! \\[rejected\\] *bad_bmark2 -> bad_bmark2 (non-fast-forward)$\" error &&\n+\tgrep \"^ ! \\[rejected\\] *bad_bmark1 -> bad_bmark1 (non-fast-forward)$\" error &&\n+\tgrep \"^   [a-f0-9]*\\.\\.[a-f0-9]* *branches/good_branch -> branches/good_branch$\" error &&\n+\tgrep \"^ ! \\[rejected\\] *branches/bad_branch -> branches/bad_branch (non-fast-forward)$\" error &&\n+\tgrep \"^ \\* \\[new branch\\] *branches/new_branch -> branches/new_branch$\" error\n+\t) &&\n+\n+\tcheck_branch hgrepo default one &&\n+\tcheck_branch hgrepo good_branch \"good branch\" &&\n+\tcheck_branch hgrepo bad_branch \"bad branch\" &&\n+\tcheck_branch hgrepo new_branch '' &&\n+\tcheck_bookmark hgrepo good_bmark one &&\n+\tcheck_bookmark hgrepo bad_bmark1 one &&\n+\tcheck_bookmark hgrepo bad_bmark2 one &&\n+\tcheck_bookmark hgrepo new_bmark ''\n+'\n+\n test_done\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217301","messageId":"1368506230-19614-36-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 35/47] remote-hg: add test for failed double push","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:58Z","receivedAt":"2013-05-14T04:36:58Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-hg.sh | 24 ++++++++++++++++++++++++\n 1 file changed, 24 insertions(+)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex d98c7a7..9d62e26 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -426,4 +426,28 @@ test_expect_failure 'remote big push' '\n \tcheck_bookmark hgrepo new_bmark ''\n '\n \n+test_expect_failure 'remote double failed push' '\n+\ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n+\n+\t(\n+\thg init hgrepo &&\n+\tcd hgrepo &&\n+\techo zero > content &&\n+\thg add content &&\n+\thg commit -m zero &&\n+\techo one > content &&\n+\thg commit -m one\n+\t) &&\n+\n+\t(\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\tcd gitrepo &&\n+\tgit reset --hard HEAD^ &&\n+\techo two > content &&\n+\tgit commit -a -m two &&\n+\ttest_expect_code 1 git push &&\n+\ttest_expect_code 1 git push\n+\t)\n+'\n+\n test_done\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217295","messageId":"1368506230-19614-37-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 36/47] remote-hg: reorganize bookmark handling","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:36:59Z","receivedAt":"2013-05-14T04:36:59Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We don't need to update both internal and remote bookmarks, so let's do\none or the other, and move the shared code earlier, so it's simpler.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 52 +++++++++++++++---------------------\n 1 file changed, 21 insertions(+), 31 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 6c7392f..14fadd1 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -870,8 +870,19 @@ def do_export(parser):\n             print \"ok %s\" % ref\n         elif ref.startswith('refs/heads/'):\n             bmark = ref[len('refs/heads/'):]\n-            p_bmarks.append((bmark, node))\n-            continue\n+            new = node\n+            old = bmarks[bmark].hex() if bmark in bmarks else ''\n+\n+            if old == new:\n+                continue\n+\n+            print \"ok %s\" % ref\n+            if bmark == 'master' and 'master' not in parser.repo._bookmarks:\n+                # fake bookmark\n+                pass\n+            else:\n+                p_bmarks.append((ref, bmark, old, new))\n+\n         elif ref.startswith('refs/tags/'):\n             tag = ref[len('refs/tags/'):]\n             tag = hgref(tag)\n@@ -891,39 +902,18 @@ def do_export(parser):\n \n     if peer:\n         parser.repo.push(peer, force=force_push, newbranch=True)\n-        remote_bmarks = peer.listkeys('bookmarks')\n-\n-    # handle bookmarks\n-    for bmark, node in p_bmarks:\n-        ref = 'refs/heads/' + bmark\n-        new = node\n-\n-        if bmark in bmarks:\n-            old = bmarks[bmark].hex()\n-        else:\n-            old = ''\n-\n-        if old == new:\n-            continue\n-\n-        if bmark == 'master' and 'master' not in parser.repo._bookmarks:\n-            # fake bookmark\n-            print \"ok %s\" % ref\n-            continue\n-        elif bookmarks.pushbookmark(parser.repo, bmark, old, new):\n-            # updated locally\n-            pass\n-        else:\n-            print \"error %s\" % ref\n-            continue\n \n-        if peer:\n+        # update remote bookmarks\n+        remote_bmarks = peer.listkeys('bookmarks')\n+        for ref, bmark, old, new in p_bmarks:\n             old = remote_bmarks.get(bmark, '')\n             if not peer.pushkey('bookmarks', bmark, old, new):\n                 print \"error %s\" % ref\n-                continue\n-\n-        print \"ok %s\" % ref\n+    else:\n+        # update local bookmarks\n+        for ref, bmark, old, new in p_bmarks:\n+            if not bookmarks.pushbookmark(parser.repo, bmark, old, new):\n+                print \"error %s\" % ref\n \n     print\n \n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217297","messageId":"1368506230-19614-38-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 37/47] remote-hg: force remote bookmark push selectively","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:37:00Z","receivedAt":"2013-05-14T04:37:00Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"If we update the 'old' node, we might be updating the remote bookmark\neven when our 'new' node is not related at all to what the remote has,\neffectively forcing an update.\n\nLet's do that only when forced push is configured.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 14fadd1..0780679 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -906,7 +906,8 @@ def do_export(parser):\n         # update remote bookmarks\n         remote_bmarks = peer.listkeys('bookmarks')\n         for ref, bmark, old, new in p_bmarks:\n-            old = remote_bmarks.get(bmark, '')\n+            if force_push:\n+                old = remote_bmarks.get(bmark, '')\n             if not peer.pushkey('bookmarks', bmark, old, new):\n                 print \"error %s\" % ref\n     else:\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217294","messageId":"1368506230-19614-39-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 38/47] remote-hg: only update necessary revisions","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:37:01Z","receivedAt":"2013-05-14T04:37:01Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We don't care about the rest, and in fact, we shouldn't try to push\neverything, as there might be garbage from previous failed pushes.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 9 +++++++--\n 1 file changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 0780679..c814188 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -843,6 +843,7 @@ def do_export(parser):\n     global parsed_refs, bmarks, peer\n \n     p_bmarks = []\n+    p_revs = set()\n \n     parser.next()\n \n@@ -867,6 +868,7 @@ def do_export(parser):\n             if branch in branches and bnode in branches[branch]:\n                 # up to date\n                 continue\n+            p_revs.add(bnode)\n             print \"ok %s\" % ref\n         elif ref.startswith('refs/heads/'):\n             bmark = ref[len('refs/heads/'):]\n@@ -883,6 +885,7 @@ def do_export(parser):\n             else:\n                 p_bmarks.append((ref, bmark, old, new))\n \n+            p_revs.add(bnode)\n         elif ref.startswith('refs/tags/'):\n             tag = ref[len('refs/tags/'):]\n             tag = hgref(tag)\n@@ -890,18 +893,20 @@ def do_export(parser):\n             if mode == 'git':\n                 if not msg:\n                     msg = 'Added tag %s for changeset %s' % (tag, node[:12]);\n-                write_tag(parser.repo, tag, node, msg, author)\n+                tagnode = write_tag(parser.repo, tag, node, msg, author)\n+                p_revs.add(tagnode)\n             else:\n                 fp = parser.repo.opener('localtags', 'a')\n                 fp.write('%s %s\\n' % (node, tag))\n                 fp.close()\n+            p_revs.add(bnode)\n             print \"ok %s\" % ref\n         else:\n             # transport-helper/fast-export bugs\n             continue\n \n     if peer:\n-        parser.repo.push(peer, force=force_push, newbranch=True)\n+        parser.repo.push(peer, force=force_push, newbranch=True, revs=list(p_revs))\n \n         # update remote bookmarks\n         remote_bmarks = peer.listkeys('bookmarks')\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217296","messageId":"1368506230-19614-40-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 39/47] remote-hg: implement custom push()","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:37:02Z","receivedAt":"2013-05-14T04:37:02Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The one from mercurial does a ton of things we are not interested in,\nand we need some special modifications which are impossible otherwise.\n\nMost of the code is borrowed from Mercurial, and cleaned up, but should\nbe functionally the same for our purposes.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 52 ++++++++++++++++++++++++++++++++++--\n 1 file changed, 50 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex c814188..b064a3c 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -12,7 +12,7 @@\n # For remote repositories a local clone is stored in\n # \"$GIT_DIR/hg/origin/clone/.hg/\".\n \n-from mercurial import hg, ui, bookmarks, context, encoding, node, error, extensions\n+from mercurial import hg, ui, bookmarks, context, encoding, node, error, extensions, discovery\n \n import re\n import sys\n@@ -839,6 +839,54 @@ def write_tag(repo, tag, node, msg, author):\n \n     return tagnode\n \n+def push_unsafe(repo, remote, parsed_refs, p_revs):\n+\n+    unfi = repo.unfiltered()\n+    force = force_push\n+\n+    fci = discovery.findcommonincoming\n+    commoninc = fci(unfi, remote, force=force)\n+    common, inc, remoteheads = commoninc\n+    fco = discovery.findcommonoutgoing\n+    outgoing = fco(unfi, remote, onlyheads=list(p_revs), commoninc=commoninc, force=force)\n+\n+    if not outgoing.missing:\n+        # nothing to push\n+        return None\n+\n+    if not force:\n+        discovery.checkheads(unfi, remote, outgoing, remoteheads, True, bool(inc))\n+\n+    cg = repo.getlocalbundle('push', outgoing)\n+\n+    unbundle = remote.capable('unbundle')\n+    if unbundle:\n+        if force:\n+            remoteheads = ['force']\n+        return remote.unbundle(cg, remoteheads, 'push')\n+    else:\n+        return remote.addchangegroup(cg, 'push', repo.url())\n+\n+def push(repo, remote, parsed_refs, p_revs):\n+    if not remote.canpush():\n+        print \"error cannot push\"\n+\n+    if not p_revs:\n+        # nothing to push\n+        return\n+\n+    lock = None\n+    unbundle = remote.capable('unbundle')\n+    if not unbundle:\n+        lock = remote.lock()\n+    try:\n+        ret = push_unsafe(repo, remote, parsed_refs, p_revs)\n+    finally:\n+        if lock is not None:\n+            lock.release()\n+\n+    return ret\n+\n def do_export(parser):\n     global parsed_refs, bmarks, peer\n \n@@ -906,7 +954,7 @@ def do_export(parser):\n             continue\n \n     if peer:\n-        parser.repo.push(peer, force=force_push, newbranch=True, revs=list(p_revs))\n+        push(parser.repo, peer, parsed_refs, p_revs)\n \n         # update remote bookmarks\n         remote_bmarks = peer.listkeys('bookmarks')\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217300","messageId":"1368506230-19614-41-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 40/47] remote-hg: implement custom checkheads()","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:37:03Z","receivedAt":"2013-05-14T04:37:03Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The version from Mercurial is extremely inefficient and convoluted, this\nversion achieves basically the same, at least for our purposes.\n\nNo functional changes.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 37 ++++++++++++++++++++++++++++++++++--\n 1 file changed, 35 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex b064a3c..abc0738 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -839,6 +839,39 @@ def write_tag(repo, tag, node, msg, author):\n \n     return tagnode\n \n+def checkheads(repo, remote, p_revs):\n+\n+    remotemap = remote.branchmap()\n+    if not remotemap:\n+        # empty repo\n+        return\n+\n+    new = {}\n+\n+    for node in p_revs:\n+        ctx = repo[node]\n+        branch = ctx.branch()\n+        if not branch in remotemap:\n+            # new branch\n+            continue\n+        new.setdefault(branch, []).append(ctx.rev())\n+\n+    for branch, heads in new.iteritems():\n+        old = [repo.changelog.rev(x) for x in remotemap[branch]]\n+        for rev in heads:\n+            ancestors = repo.changelog.ancestors([rev], stoprev=min(old))\n+            found = False\n+\n+            for x in old:\n+                if x in ancestors:\n+                    found = True\n+                    break\n+\n+            if found:\n+                continue\n+\n+            raise Exception(\"non-fast-forward\")\n+\n def push_unsafe(repo, remote, parsed_refs, p_revs):\n \n     unfi = repo.unfiltered()\n@@ -846,7 +879,7 @@ def push_unsafe(repo, remote, parsed_refs, p_revs):\n \n     fci = discovery.findcommonincoming\n     commoninc = fci(unfi, remote, force=force)\n-    common, inc, remoteheads = commoninc\n+    common, _, remoteheads = commoninc\n     fco = discovery.findcommonoutgoing\n     outgoing = fco(unfi, remote, onlyheads=list(p_revs), commoninc=commoninc, force=force)\n \n@@ -855,7 +888,7 @@ def push_unsafe(repo, remote, parsed_refs, p_revs):\n         return None\n \n     if not force:\n-        discovery.checkheads(unfi, remote, outgoing, remoteheads, True, bool(inc))\n+        checkheads(unfi, remote, p_revs)\n \n     cg = repo.getlocalbundle('push', outgoing)\n \n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217299","messageId":"1368506230-19614-42-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 41/47] remote-hg: pass around revision refs","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:37:04Z","receivedAt":"2013-05-14T04:37:04Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"So that when a diverge is detected, we know which ref to report an error\nfor.\n\nAlso, since we are not throwing an exception, return a proper error\ncode.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 34 +++++++++++++++++++++-------------\n contrib/remote-helpers/test-hg.sh    |  6 +++---\n 2 files changed, 24 insertions(+), 16 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex abc0738..5a5667d 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -837,18 +837,19 @@ def write_tag(repo, tag, node, msg, author):\n \n     encoding.encoding = tmp\n \n-    return tagnode\n+    return (tagnode, branch)\n \n def checkheads(repo, remote, p_revs):\n \n     remotemap = remote.branchmap()\n     if not remotemap:\n         # empty repo\n-        return\n+        return True\n \n     new = {}\n+    ret = True\n \n-    for node in p_revs:\n+    for node, ref in p_revs.iteritems():\n         ctx = repo[node]\n         branch = ctx.branch()\n         if not branch in remotemap:\n@@ -870,7 +871,11 @@ def checkheads(repo, remote, p_revs):\n             if found:\n                 continue\n \n-            raise Exception(\"non-fast-forward\")\n+            node = repo.changelog.node(rev)\n+            print \"error %s non-fast forward\" % p_revs[node]\n+            ret = False\n+\n+    return ret\n \n def push_unsafe(repo, remote, parsed_refs, p_revs):\n \n@@ -887,8 +892,8 @@ def push_unsafe(repo, remote, parsed_refs, p_revs):\n         # nothing to push\n         return None\n \n-    if not force:\n-        checkheads(unfi, remote, p_revs)\n+    if not force and not checkheads(unfi, remote, p_revs):\n+        return None\n \n     cg = repo.getlocalbundle('push', outgoing)\n \n@@ -924,7 +929,7 @@ def do_export(parser):\n     global parsed_refs, bmarks, peer\n \n     p_bmarks = []\n-    p_revs = set()\n+    p_revs = {}\n \n     parser.next()\n \n@@ -949,7 +954,7 @@ def do_export(parser):\n             if branch in branches and bnode in branches[branch]:\n                 # up to date\n                 continue\n-            p_revs.add(bnode)\n+            p_revs[bnode] = ref\n             print \"ok %s\" % ref\n         elif ref.startswith('refs/heads/'):\n             bmark = ref[len('refs/heads/'):]\n@@ -966,7 +971,7 @@ def do_export(parser):\n             else:\n                 p_bmarks.append((ref, bmark, old, new))\n \n-            p_revs.add(bnode)\n+            p_revs[bnode] = ref\n         elif ref.startswith('refs/tags/'):\n             tag = ref[len('refs/tags/'):]\n             tag = hgref(tag)\n@@ -974,20 +979,23 @@ def do_export(parser):\n             if mode == 'git':\n                 if not msg:\n                     msg = 'Added tag %s for changeset %s' % (tag, node[:12]);\n-                tagnode = write_tag(parser.repo, tag, node, msg, author)\n-                p_revs.add(tagnode)\n+                tagnode, branch = write_tag(parser.repo, tag, node, msg, author)\n+                p_revs[tagnode] = 'refs/heads/branches/' + gitref(branch)\n             else:\n                 fp = parser.repo.opener('localtags', 'a')\n                 fp.write('%s %s\\n' % (node, tag))\n                 fp.close()\n-            p_revs.add(bnode)\n+            p_revs[bnode] = ref\n             print \"ok %s\" % ref\n         else:\n             # transport-helper/fast-export bugs\n             continue\n \n     if peer:\n-        push(parser.repo, peer, parsed_refs, p_revs)\n+        if not push(parser.repo, peer, parsed_refs, p_revs):\n+            # do not update bookmarks\n+            print\n+            return\n \n         # update remote bookmarks\n         remote_bmarks = peer.listkeys('bookmarks')\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 9d62e26..4f6fd4c 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -268,7 +268,7 @@ test_expect_success 'remote new bookmark' '\n \tcheck_bookmark hgrepo feature-b feature-b\n '\n \n-test_expect_failure 'remote push diverged' '\n+test_expect_success 'remote push diverged' '\n \ttest_when_finished \"rm -rf gitrepo*\" &&\n \n \tgit clone \"hg::hgrepo\" gitrepo &&\n@@ -291,7 +291,7 @@ test_expect_failure 'remote push diverged' '\n \tcheck_branch hgrepo default bump\n '\n \n-test_expect_failure 'remote update bookmark diverge' '\n+test_expect_success 'remote update bookmark diverge' '\n \ttest_when_finished \"rm -rf gitrepo*\" &&\n \n \t(\n@@ -338,7 +338,7 @@ test_expect_failure 'remote new bookmark multiple branch head' '\n # cleanup previous stuff\n rm -rf hgrepo\n \n-test_expect_failure 'remote big push' '\n+test_expect_success 'remote big push' '\n \ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n \n \t(\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217302","messageId":"1368506230-19614-43-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 42/47] remote-hg: check diverged bookmarks","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:37:05Z","receivedAt":"2013-05-14T04:37:05Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"So that we can report a proper error.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 24 ++++++++++++++++++++++++\n contrib/remote-helpers/test-hg.sh    |  2 +-\n 2 files changed, 25 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 5a5667d..df3b9a4 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -839,6 +839,23 @@ def write_tag(repo, tag, node, msg, author):\n \n     return (tagnode, branch)\n \n+def checkheads_bmark(ref, ctx):\n+    if force_push:\n+        return True\n+\n+    bmark = ref[len('refs/heads/'):]\n+    if not bmark in bmarks:\n+        # new bmark\n+        return True\n+\n+    ctx_old = bmarks[bmark]\n+    ctx_new = ctx\n+    if not ctx_old.descendant(ctx_new):\n+        print \"error %s non-fast forward\" % ref\n+        return False\n+\n+    return True\n+\n def checkheads(repo, remote, p_revs):\n \n     remotemap = remote.branchmap()\n@@ -855,6 +872,13 @@ def checkheads(repo, remote, p_revs):\n         if not branch in remotemap:\n             # new branch\n             continue\n+        if not ref.startswith('refs/heads/branches'):\n+            if ref.startswith('refs/heads/'):\n+                if not checkheads_bmark(ref, ctx):\n+                    ret = False\n+\n+            # only check branches\n+            continue\n         new.setdefault(branch, []).append(ctx.rev())\n \n     for branch, heads in new.iteritems():\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 4f6fd4c..ecf7bd4 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -320,7 +320,7 @@ test_expect_success 'remote update bookmark diverge' '\n \tcheck_bookmark hgrepo diverge \"bump bookmark\"\n '\n \n-test_expect_failure 'remote new bookmark multiple branch head' '\n+test_expect_success 'remote new bookmark multiple branch head' '\n \ttest_when_finished \"rm -rf gitrepo*\" &&\n \n \t(\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217303","messageId":"1368506230-19614-44-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 43/47] remote-hg: simplify branch_tip()","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:37:06Z","receivedAt":"2013-05-14T04:37:06Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"It simply picks the last head that is not closed, but we have a stored\nlist of open heads.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 12 ++++--------\n 1 file changed, 4 insertions(+), 8 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex df3b9a4..aff1161 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -541,12 +541,8 @@ def do_capabilities(parser):\n \n     print\n \n-def branch_tip(repo, branch):\n-    # older versions of mercurial don't have this\n-    if hasattr(repo, 'branchtip'):\n-        return repo.branchtip(branch)\n-    else:\n-        return repo.branchtags()[branch]\n+def branch_tip(branch):\n+    return branches[branch][-1]\n \n def get_branch_tip(repo, branch):\n     global branches\n@@ -558,7 +554,7 @@ def get_branch_tip(repo, branch):\n     # verify there's only one head\n     if (len(heads) > 1):\n         warn(\"Branch '%s' has more than one head, consider merging\" % branch)\n-        return branch_tip(repo, hgref(branch))\n+        return branch_tip(hgref(branch))\n \n     return heads[0]\n \n@@ -808,7 +804,7 @@ def parse_tag(parser):\n \n def write_tag(repo, tag, node, msg, author):\n     branch = repo[node].branch()\n-    tip = branch_tip(repo, branch)\n+    tip = branch_tip(branch)\n     tip = repo[tip]\n \n     def getfilectx(repo, memctx, f):\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217307","messageId":"1368506230-19614-45-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 44/47] remote-hg: improve branch listing","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:37:07Z","receivedAt":"2013-05-14T04:37:07Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We want to show the remote heads, not the internal ones, which might\nhave garbage.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 9 ++++++---\n 1 file changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex aff1161..cacf2da 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -585,9 +585,12 @@ def do_list(parser):\n     list_head(repo, cur)\n \n     if track_branches:\n-        for branch in repo.branchmap():\n-            heads = repo.branchheads(branch)\n-            if len(heads):\n+        orig = peer if peer else repo\n+\n+        for branch, heads in orig.branchmap().iteritems():\n+            # only open heads\n+            heads = [h for h in heads if not repo[h].closesbranch()]\n+            if heads:\n                 branches[branch] = heads\n \n         for branch in branches:\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217304","messageId":"1368506230-19614-46-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 45/47] remote-hg: use remote 'default' not local one","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:37:08Z","receivedAt":"2013-05-14T04:37:08Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 19 +++++++++----------\n contrib/remote-helpers/test-hg.sh    |  2 +-\n 2 files changed, 10 insertions(+), 11 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex cacf2da..ff38fac 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -561,11 +561,11 @@ def get_branch_tip(repo, branch):\n def list_head(repo, cur):\n     global g_head, bmarks\n \n-    if 'default' not in repo:\n+    if 'default' not in branches:\n         # empty repo\n         return\n \n-    node = repo['default']\n+    node = repo[branch_tip('default')]\n     head = 'master' if not 'master' in bmarks else 'default'\n     bmarks[head] = node\n \n@@ -581,18 +581,17 @@ def do_list(parser):\n         bmarks[bmark] = repo[node]\n \n     cur = repo.dirstate.branch()\n+    orig = peer if peer else repo\n+\n+    for branch, heads in orig.branchmap().iteritems():\n+        # only open heads\n+        heads = [h for h in heads if not repo[h].closesbranch()]\n+        if heads:\n+            branches[branch] = heads\n \n     list_head(repo, cur)\n \n     if track_branches:\n-        orig = peer if peer else repo\n-\n-        for branch, heads in orig.branchmap().iteritems():\n-            # only open heads\n-            heads = [h for h in heads if not repo[h].closesbranch()]\n-            if heads:\n-                branches[branch] = heads\n-\n         for branch in branches:\n             print \"? refs/heads/branches/%s\" % gitref(branch)\n \ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex ecf7bd4..b3422c4 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -426,7 +426,7 @@ test_expect_success 'remote big push' '\n \tcheck_bookmark hgrepo new_bmark ''\n '\n \n-test_expect_failure 'remote double failed push' '\n+test_expect_success 'remote double failed push' '\n \ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n \n \t(\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217306","messageId":"1368506230-19614-47-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 46/47] remote-hg: improve lightweight tag author","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:37:09Z","receivedAt":"2013-05-14T04:37:09Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Use git's committer.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 18 ++++++++++++++----\n 1 file changed, 14 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex ff38fac..24100df 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -820,13 +820,23 @@ def write_tag(repo, tag, node, msg, author):\n \n     p1 = tip.hex()\n     p2 = '0' * 40\n-    if not author:\n-        author = (None, 0, 0)\n-    user, date, tz = author\n+    if author:\n+        user, date, tz = author\n+        date_tz = (date, tz)\n+    else:\n+        cmd = ['git', 'var', 'GIT_COMMITTER_IDENT']\n+        process = subprocess.Popen(cmd, stdout=subprocess.PIPE)\n+        output, _ = process.communicate()\n+        m = re.match('^.* <.*>', output)\n+        if m:\n+            user = m.group(0)\n+        else:\n+            user = repo.ui.username()\n+        date_tz = None\n \n     ctx = context.memctx(repo, (p1, p2), msg,\n             ['.hgtags'], getfilectx,\n-            user, (date, tz), {'branch' : branch})\n+            user, date_tz, {'branch' : branch})\n \n     tmp = encoding.encoding\n     encoding.encoding = 'utf-8'\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217305","messageId":"1368506230-19614-48-git-send-email-felipe.contreras@gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 47/47] remote-hg: remove files before modifications","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-14T04:37:10Z","receivedAt":"2013-05-14T04:37:10Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Otherwise replacing a file with a directory doesn't work.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 24100df..6c7439e 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -491,10 +491,10 @@ def export_ref(repo, name, kind, head):\n             if len(parents) > 1:\n                 print \"merge :%s\" % (rev_to_mark(parents[1]))\n \n-        for f in modified_final:\n-            print \"M %s :%u %s\" % f\n         for f in removed:\n             print \"D %s\" % (fix_file_path(f))\n+        for f in modified_final:\n+            print \"M %s :%u %s\" % f\n         print\n \n         progress = (rev - tip)\n-- \n1.8.3.rc1.579.g184e698\n"},{"id":"217374","messageId":"CAPig+cS0eA8wZfUWz2MQooUzrdw8h4RWcaR4haeZHQJkL+nS9g@mail.gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-34-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH 33/47] remote-hg: add test for new bookmark special","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-05-14T21:09:31Z","receivedAt":"2013-05-14T21:09:31Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, May 14, 2013 at 12:36 AM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> From the point of view of Mercurial, this creates a new branch head, and\n> requires a forced push.\n>\n> Ideally, whoever, we would want it to work just like in git; new\n\nDid you mean s/whoever/however/ ?\n\n> branches can be pushed without problems.\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n"},{"id":"217375","messageId":"CAPig+cROU5mDp3A=3ZQzcstyo7WD4rQd+K49G1AmngNEAxDktw@mail.gmail.com","threadId":"33815","inReplyTo":"1368506230-19614-17-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH 16/47] remote-hg: load all extensions","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-05-14T21:12:32Z","receivedAt":"2013-05-14T21:12:32Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, May 14, 2013 at 12:36 AM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> The user might have then configured differently, plus, all of them will\n\nDid you mean s/then/them/ ?\n\n> be loaded anyway later on.\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n"}]}