{"thread":{"id":"33924","subject":"[PATCH v2 00/48] remote-hg: fixes for next","startedAt":"2013-05-25T02:29:16Z","lastAt":"2013-05-25T06:28:22Z","messageCount":51,"participants":["Felipe Contreras","Eric Sunshine"],"isPatch":true,"patchVersion":2,"patchTotal":48},"messages":[{"id":"218429","messageId":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":null,"subject":"[PATCH v2 00/48] remote-hg: fixes for next","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:16Z","receivedAt":"2013-05-25T02:29:16Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nSince v1 there's a few backward compatibility fixes, and new patches at the end\nfor new feature, some which require patches to the remote helper\ninfraestructure.\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\n 5) Much improved push feedback reporting\n\nWith these, we pass all the tests from gitifyhg as well as our own.\n\nFelipe Contreras (48):\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-hg: add tests for 'master' bookmark\n  remote-bzr: simplify test checks\n  remote-hg: add check_bookmark() test helper\n  remote-hg: update bookmarks when using a remote\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  remote-hg: add setup_big_push() helper\n  remote-hg: add check_push() helper\n  remote-helpers: improve marks usage\n  remote-hg: trivial cleanup\n  remote-hg: check if a fetch is needed\n  remote-hg: add support for --dry-run\n  remote-hg: add support for --force\n\n contrib/remote-helpers/git-remote-bzr    |   5 +-\n contrib/remote-helpers/git-remote-hg     | 510 ++++++++++++++++------\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 |  44 +-\n contrib/remote-helpers/test-hg.sh        | 723 +++++++++++++++++++++++++++----\n 6 files changed, 1291 insertions(+), 514 deletions(-)\n\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218430","messageId":"1369449004-17981-2-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 01/48] remote-hg: test: be a little more quiet","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:17Z","receivedAt":"2013-05-25T02:29:17Z","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.rc3.312.g47657de\n"},{"id":"218431","messageId":"1369449004-17981-3-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 02/48] remote-hg: trivial reorganization","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:18Z","receivedAt":"2013-05-25T02:29:18Z","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 1dd3d70..426c1fc 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -857,6 +857,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@@ -883,8 +884,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.rc3.312.g47657de\n"},{"id":"218432","messageId":"1369449004-17981-4-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 03/48] remote-helpers: test: cleanup white-spaces","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:19Z","receivedAt":"2013-05-25T02:29:19Z","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 5dfa070..a3220c8 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][0-9]*: //\" > ../expected\n-  ) &&\n+\techo four >> content &&\n+\tbzr commit -m four &&\n+\tbzr log --line | sed -e \"s/^[0-9][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.rc3.312.g47657de\n"},{"id":"218433","messageId":"1369449004-17981-5-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 04/48] remote-helpers: test: cleanup style","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:20Z","receivedAt":"2013-05-25T02:29:20Z","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 a3220c8..f760110 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][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.rc3.312.g47657de\n"},{"id":"218434","messageId":"1369449004-17981-6-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 05/48] remote-helpers: tests: general improvements","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:21Z","receivedAt":"2013-05-25T02:29:21Z","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 f760110..1ae7376 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.rc3.312.g47657de\n"},{"id":"218435","messageId":"1369449004-17981-7-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 06/48] remote-helpers: test: simplify remote URLs","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:22Z","receivedAt":"2013-05-25T02:29:22Z","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 1ae7376..0276db0 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.rc3.312.g47657de\n"},{"id":"218436","messageId":"1369449004-17981-8-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 07/48] remote-hg: test: simplify previous branch checkout","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:23Z","receivedAt":"2013-05-25T02:29:23Z","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.rc3.312.g47657de\n"},{"id":"218437","messageId":"1369449004-17981-9-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 08/48] remote-hg: load all extensions","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:24Z","receivedAt":"2013-05-25T02:29:24Z","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 426c1fc..21f8acd 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.rc3.312.g47657de\n"},{"id":"218438","messageId":"1369449004-17981-10-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 09/48] remote-hg: use a shared repository store","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:25Z","receivedAt":"2013-05-25T02:29:25Z","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 21f8acd..7507976 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.makedirs(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     return repo\n \n@@ -898,7 +906,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@@ -944,9 +952,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.rc3.312.g47657de\n"},{"id":"218439","messageId":"1369449004-17981-11-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 10/48] remote-hg: shuffle some code","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:26Z","receivedAt":"2013-05-25T02:29:26Z","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 7507976..62520ee 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@@ -401,7 +404,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@@ -450,9 +453,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@@ -466,10 +469,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@@ -739,7 +742,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@@ -763,7 +766,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@@ -788,7 +791,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@@ -832,9 +835,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@@ -848,11 +852,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@@ -866,7 +870,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.rc3.312.g47657de\n"},{"id":"218440","messageId":"1369449004-17981-12-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 11/48] remote-hg: improve node traversing","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:27Z","receivedAt":"2013-05-25T02:29:27Z","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 62520ee..07ea104 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -389,12 +389,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.rc3.312.g47657de\n"},{"id":"218441","messageId":"1369449004-17981-13-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 12/48] remote-hg: add version checks to the marks","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:28Z","receivedAt":"2013-05-25T02:29:28Z","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 07ea104..e2bef7f 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.rc3.312.g47657de\n"},{"id":"218442","messageId":"1369449004-17981-14-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 13/48] remote-hg: switch from revisions to SHA-1 noteids","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:29Z","receivedAt":"2013-05-25T02:29:29Z","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 e2bef7f..ae7699c 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@@ -384,7 +384,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@@ -395,6 +395,10 @@ def export_ref(repo, name, kind, head):\n \n     ename = '%s/%s' % (kind, name)\n     tip = marks.get_tip(ename)\n+    if tip and 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@@ -460,16 +464,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@@ -483,10 +487,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@@ -713,12 +717,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@@ -760,10 +764,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@@ -779,8 +781,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.rc3.312.g47657de\n"},{"id":"218443","messageId":"1369449004-17981-15-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 14/48] remote-hg: upgrade version 1 marks","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:30Z","receivedAt":"2013-05-25T02:29:30Z","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 ae7699c..2e4f7ca 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@@ -973,7 +987,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     if sys.platform == 'win32':\n         import msvcrt\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218446","messageId":"1369449004-17981-16-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 15/48] remote-hg: ensure remote rebasing works","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:31Z","receivedAt":"2013-05-25T02:29: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 |  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 2e4f7ca..e0e68ef 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -621,6 +621,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..431a5d1 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 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.rc3.312.g47657de\n"},{"id":"218444","messageId":"1369449004-17981-17-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 16/48] remote-hg: trivial cleanups","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:32Z","receivedAt":"2013-05-25T02:29: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/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 e0e68ef..ee60dbf 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@@ -734,12 +734,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@@ -826,7 +826,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.rc3.312.g47657de\n"},{"id":"218445","messageId":"1369449004-17981-18-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 17/48] remote-hg: improve progress calculation","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:33Z","receivedAt":"2013-05-25T02:29:33Z","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 ee60dbf..48edf3b 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -415,7 +415,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@@ -423,7 +423,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@@ -495,9 +494,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.rc3.312.g47657de\n"},{"id":"218447","messageId":"1369449004-17981-19-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 18/48] remote-hg: always point HEAD to master","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:34Z","receivedAt":"2013-05-25T02:29:34Z","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     | 30 ++++++++++++---------------\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, 26 insertions(+), 52 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 48edf3b..7c859b8 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -560,22 +560,16 @@ def get_branch_tip(repo, branch):\n     return heads[0]\n \n def list_head(repo, cur):\n-    global g_head, bmarks\n+    global g_head, bmarks, fake_bmark\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+    fake_bmark = head\n+    bmarks[head] = node\n \n     head = gitref(head)\n     print \"@refs/heads/%s HEAD\" % head\n@@ -910,8 +904,8 @@ def do_export(parser):\n         if old == new:\n             continue\n \n-        if bmark == 'master' and 'master' not in parser.repo._bookmarks:\n-            # fake bookmark\n+        if bmark == fake_bmark or \\\n+                bmark == 'master' and 'master' not in parser.repo._bookmarks:\n             print \"ok %s\" % ref\n             continue\n         elif bookmarks.pushbookmark(parser.repo, bmark, old, new):\n@@ -946,6 +940,7 @@ def main(args):\n     global track_branches, force_push, is_tmp\n     global parsed_tags\n     global filenodes\n+    global fake_bmark\n \n     alias = args[1]\n     url = args[2]\n@@ -979,6 +974,7 @@ def main(args):\n     marks = None\n     parsed_tags = {}\n     filenodes = {}\n+    fake_bmark = None\n \n     repo = get_repo(url, alias)\n     prefix = 'refs/hg/%s' % alias\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 431a5d1..78af45d 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.rc3.312.g47657de\n"},{"id":"218448","messageId":"1369449004-17981-20-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 19/48] remote-hg: add tests for 'master' bookmark","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:35Z","receivedAt":"2013-05-25T02:29:35Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We want to make sure everything works correctly, even if there's a\n'master' bookmark in Mercurial.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-hg.sh | 68 ++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 67 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 78af45d..943371a 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -26,13 +26,23 @@ check () {\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 \techo \"username = H G Wells <wells@example.com>\"\n \techo \"[extensions]\"\n \techo \"mq =\"\n-\t) >> \"$HOME\"/.hgrc\n+\t) >> \"$HOME\"/.hgrc &&\n+\n+\tGIT_AUTHOR_DATE=\"2007-01-01 00:00:00 +0230\" &&\n+\tGIT_COMMITTER_DATE=\"$GIT_AUTHOR_DATE\" &&\n+\texport GIT_COMMITTER_DATE GIT_AUTHOR_DATE\n }\n \n setup\n@@ -178,4 +188,60 @@ test_expect_success 'strip' '\n \ttest_cmp actual expected\n '\n \n+test_expect_success 'remote push with master bookmark' '\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 master &&\n+\techo one > content &&\n+\thg commit -m one\n+\t) &&\n+\n+\t(\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\tcd gitrepo &&\n+\techo two > content &&\n+\tgit commit -a -m two &&\n+\tgit push\n+\t) &&\n+\n+\tcheck_branch hgrepo default two\n+'\n+\n+cat > expected <<EOF\n+changeset:   0:6e2126489d3d\n+tag:         tip\n+user:        A U Thor <author@example.com>\n+date:        Mon Jan 01 00:00:00 2007 +0230\n+summary:     one\n+\n+EOF\n+\n+test_expect_success 'remote push from master branch' '\n+\ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n+\n+\thg init hgrepo &&\n+\n+\t(\n+\tgit init gitrepo &&\n+\tcd gitrepo &&\n+\tgit remote add origin \"hg::../hgrepo\" &&\n+\techo one > content &&\n+\tgit add content &&\n+\tgit commit -a -m one &&\n+\tgit push origin master\n+\t) &&\n+\n+\thg -R hgrepo log > actual &&\n+\tcat actual &&\n+\ttest_cmp expected actual &&\n+\n+\tcheck_branch hgrepo default one\n+'\n+\n test_done\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218450","messageId":"1369449004-17981-21-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 20/48] remote-bzr: simplify test checks","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:36Z","receivedAt":"2013-05-25T02:29:36Z","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 0276db0..435b280 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.rc3.312.g47657de\n"},{"id":"218449","messageId":"1369449004-17981-22-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 21/48] remote-hg: add check_bookmark() test helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:37Z","receivedAt":"2013-05-25T02:29:37Z","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 943371a..2f2050c 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -32,6 +32,12 @@ check_branch () {\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@@ -108,7 +114,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.rc3.312.g47657de\n"},{"id":"218453","messageId":"1369449004-17981-23-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 22/48] remote-hg: update bookmarks when using a remote","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:38Z","receivedAt":"2013-05-25T02:29:38Z","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 | 17 +++++++++++++++++\n 1 file changed, 17 insertions(+)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 7c859b8..76438a6 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -356,6 +356,21 @@ def fixup_user(user):\n \n     return '%s <%s>' % (name, mail)\n \n+def updatebookmarks(repo, peer):\n+    remotemarks = peer.listkeys('bookmarks')\n+    localmarks = repo._bookmarks\n+\n+    if not remotemarks:\n+        return\n+\n+    for k, v in remotemarks.iteritems():\n+        localmarks[k] = hgbin(v)\n+\n+    if hasattr(localmarks, 'write'):\n+        localmarks.write()\n+    else:\n+        bookmarks.write(repo)\n+\n def get_repo(url, alias):\n     global dirname, peer\n \n@@ -394,6 +409,8 @@ def get_repo(url, alias):\n             die('Repository error')\n         repo.pull(peer, heads=None, force=True)\n \n+        updatebookmarks(repo, peer)\n+\n     return repo\n \n def rev_to_mark(rev):\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218452","messageId":"1369449004-17981-24-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 23/48] remote-hg: add remote tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:39Z","receivedAt":"2013-05-25T02:29:39Z","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 76438a6..61e6c87 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -383,7 +383,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 2f2050c..d927495 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -250,4 +250,42 @@ test_expect_success 'remote push from master branch' '\n \tcheck_branch hgrepo default one\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.rc3.312.g47657de\n"},{"id":"218451","messageId":"1369449004-17981-25-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 24/48] remote-hg: add test to push new bookmark","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:40Z","receivedAt":"2013-05-25T02:29:40Z","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 d927495..8b5e191 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -117,6 +117,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@@ -288,4 +303,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.rc3.312.g47657de\n"},{"id":"218454","messageId":"1369449004-17981-26-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 25/48] remote-hg: add test for diverged push","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:41Z","receivedAt":"2013-05-25T02:29:41Z","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 | 23 +++++++++++++++++++++++\n 1 file changed, 23 insertions(+)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 8b5e191..252553e 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -318,4 +318,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.rc3.312.g47657de\n"},{"id":"218455","messageId":"1369449004-17981-27-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 26/48] remote-hg: add test for bookmark diverge","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:42Z","receivedAt":"2013-05-25T02:29:42Z","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 252553e..e059bbc 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -341,4 +341,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 checkout tip^ &&\n+\thg bookmark 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.rc3.312.g47657de\n"},{"id":"218456","messageId":"1369449004-17981-28-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 27/48] remote-hg: add test for new bookmark special","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:43Z","receivedAt":"2013-05-25T02:29:43Z","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 e059bbc..64f0849 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -370,4 +370,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.rc3.312.g47657de\n"},{"id":"218457","messageId":"1369449004-17981-29-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 28/48] remote-hg: add test for big push","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:44Z","receivedAt":"2013-05-25T02:29:44Z","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 64f0849..1855d1a 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_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 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 setup () {\n@@ -385,4 +395,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 good_bmark &&\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.rc3.312.g47657de\n"},{"id":"218458","messageId":"1369449004-17981-30-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 29/48] remote-hg: add test for failed double push","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:45Z","receivedAt":"2013-05-25T02:29:45Z","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 1855d1a..c4d98b5 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -486,4 +486,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.rc3.312.g47657de\n"},{"id":"218459","messageId":"1369449004-17981-31-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 30/48] remote-hg: reorganize bookmark handling","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:46Z","receivedAt":"2013-05-25T02:29:46Z","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 | 50 ++++++++++++++----------------------\n 1 file changed, 19 insertions(+), 31 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 61e6c87..99de7c2 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -885,8 +885,17 @@ 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 != fake_bmark and \\\n+                    not (bmark == 'master' and bmark not in parser.repo._bookmarks):\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@@ -906,39 +915,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 == fake_bmark or \\\n-                bmark == 'master' and 'master' not in parser.repo._bookmarks:\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.rc3.312.g47657de\n"},{"id":"218460","messageId":"1369449004-17981-32-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 31/48] remote-hg: force remote bookmark push selectively","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:47Z","receivedAt":"2013-05-25T02:29:47Z","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 99de7c2..4d650b5 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -919,7 +919,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.rc3.312.g47657de\n"},{"id":"218461","messageId":"1369449004-17981-33-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 32/48] remote-hg: only update necessary revisions","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:48Z","receivedAt":"2013-05-25T02:29:48Z","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 4d650b5..7added3 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -858,6 +858,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@@ -882,6 +883,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@@ -896,6 +898,7 @@ def do_export(parser):\n                     not (bmark == 'master' and bmark not in parser.repo._bookmarks):\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@@ -903,18 +906,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.rc3.312.g47657de\n"},{"id":"218463","messageId":"1369449004-17981-34-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 33/48] remote-hg: implement custom push()","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:49Z","receivedAt":"2013-05-25T02:29:49Z","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, except that multiple heads\nare not detected.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 44 ++++++++++++++++++++++++++++++++++--\n 1 file changed, 42 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 7added3..c2c1cb8 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@@ -854,6 +854,46 @@ 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+    force = force_push\n+\n+    fci = discovery.findcommonincoming\n+    commoninc = fci(repo, remote, force=force)\n+    common, _, remoteheads = commoninc\n+\n+    # TODO checkheads\n+\n+    cg = repo.getbundle('push', heads=list(p_revs), common=common)\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 hasattr(remote, 'canpush') and 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@@ -919,7 +959,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.rc3.312.g47657de\n"},{"id":"218464","messageId":"1369449004-17981-35-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 34/48] remote-hg: implement custom checkheads()","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:50Z","receivedAt":"2013-05-25T02:29:50Z","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 | 52 +++++++++++++++++++++++++++++++++---\n 1 file changed, 49 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex c2c1cb8..7eb809b 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, discovery\n+from mercurial import hg, ui, bookmarks, context, encoding, node, error, extensions, discovery, util\n \n import re\n import sys\n@@ -86,6 +86,11 @@ def hgref(ref):\n def gitref(ref):\n     return ref.replace(' ', '___')\n \n+def check_version(*check):\n+    if not hg_version:\n+        return True\n+    return hg_version >= check\n+\n def get_config(config):\n     cmd = ['git', 'config', '--get', config]\n     process = subprocess.Popen(cmd, stdout=subprocess.PIPE)\n@@ -854,6 +859,42 @@ 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+            if check_version(2, 3):\n+                ancestors = repo.changelog.ancestors([rev], stoprev=min(old))\n+            else:\n+                ancestors = repo.changelog.ancestors(rev)\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     force = force_push\n@@ -862,7 +903,8 @@ def push_unsafe(repo, remote, parsed_refs, p_revs):\n     commoninc = fci(repo, remote, force=force)\n     common, _, remoteheads = commoninc\n \n-    # TODO checkheads\n+    if not force:\n+        checkheads(repo, remote, p_revs)\n \n     cg = repo.getbundle('push', heads=list(p_revs), common=common)\n \n@@ -991,7 +1033,7 @@ def main(args):\n     global track_branches, force_push, is_tmp\n     global parsed_tags\n     global filenodes\n-    global fake_bmark\n+    global fake_bmark, hg_version\n \n     alias = args[1]\n     url = args[2]\n@@ -1026,6 +1068,10 @@ def main(args):\n     parsed_tags = {}\n     filenodes = {}\n     fake_bmark = None\n+    try:\n+        hg_version = tuple(int(e) for e in util.version().split('.'))\n+    except:\n+        hg_version = None\n \n     repo = get_repo(url, alias)\n     prefix = 'refs/hg/%s' % alias\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218462","messageId":"1369449004-17981-36-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 35/48] remote-hg: pass around revision refs","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:51Z","receivedAt":"2013-05-25T02:29:51Z","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 7eb809b..b6f85b2 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -857,18 +857,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@@ -893,7 +894,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@@ -903,8 +908,8 @@ def push_unsafe(repo, remote, parsed_refs, p_revs):\n     commoninc = fci(repo, remote, force=force)\n     common, _, remoteheads = commoninc\n \n-    if not force:\n-        checkheads(repo, remote, p_revs)\n+    if not force and not checkheads(repo, remote, p_revs):\n+        return None\n \n     cg = repo.getbundle('push', heads=list(p_revs), common=common)\n \n@@ -940,7 +945,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@@ -965,7 +970,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@@ -980,7 +985,7 @@ def do_export(parser):\n                     not (bmark == 'master' and bmark not in parser.repo._bookmarks):\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@@ -988,20 +993,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 c4d98b5..c4e4a1a 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -328,7 +328,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@@ -351,7 +351,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@@ -398,7 +398,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.rc3.312.g47657de\n"},{"id":"218468","messageId":"1369449004-17981-37-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 36/48] remote-hg: check diverged bookmarks","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:52Z","receivedAt":"2013-05-25T02:29:52Z","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 b6f85b2..e8ebc17 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -859,6 +859,23 @@ def write_tag(repo, tag, node, msg, author):\n \n     return (tagnode, branch)\n \n+def checkheads_bmark(repo, 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 repo.changelog.descendant(ctx_old.rev(), ctx_new.rev()):\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@@ -875,6 +892,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(repo, 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 c4e4a1a..8ea5111 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -380,7 +380,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.rc3.312.g47657de\n"},{"id":"218465","messageId":"1369449004-17981-38-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 37/48] remote-hg: simplify branch_tip()","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:53Z","receivedAt":"2013-05-25T02:29:53Z","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 e8ebc17..8df72d9 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -560,12 +560,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@@ -577,7 +573,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@@ -828,7 +824,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.rc3.312.g47657de\n"},{"id":"218467","messageId":"1369449004-17981-39-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 38/48] remote-hg: improve branch listing","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:54Z","receivedAt":"2013-05-25T02:29:54Z","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 8df72d9..5ad5c1e 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -605,9 +605,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 'close' not in repo.changelog.read(h)[5]]\n+            if heads:\n                 branches[branch] = heads\n \n         for branch in branches:\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218466","messageId":"1369449004-17981-40-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 39/48] remote-hg: use remote 'default' not local one","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:55Z","receivedAt":"2013-05-25T02:29: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/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 5ad5c1e..a1b22f7 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -580,11 +580,11 @@ def get_branch_tip(repo, branch):\n def list_head(repo, cur):\n     global g_head, bmarks, fake_bmark\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     fake_bmark = head\n     bmarks[head] = node\n@@ -601,18 +601,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 'close' not in repo.changelog.read(h)[5]]\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 'close' not in repo.changelog.read(h)[5]]\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 8ea5111..84df1c3 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -486,7 +486,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.rc3.312.g47657de\n"},{"id":"218472","messageId":"1369449004-17981-41-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 40/48] remote-hg: improve lightweight tag author","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:56Z","receivedAt":"2013-05-25T02:29:56Z","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 a1b22f7..fa76b3f 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -840,13 +840,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.rc3.312.g47657de\n"},{"id":"218470","messageId":"1369449004-17981-42-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 41/48] remote-hg: remove files before modifications","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:57Z","receivedAt":"2013-05-25T02:29:57Z","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 fa76b3f..bd545aa 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -510,10 +510,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.rc3.312.g47657de\n"},{"id":"218469","messageId":"1369449004-17981-43-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 42/48] remote-hg: add setup_big_push() helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:58Z","receivedAt":"2013-05-25T02:29:58Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"So we don't duplicate these commands.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/test-hg.sh | 15 +++++++++++----\n 1 file changed, 11 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 84df1c3..f594584 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -398,9 +398,7 @@ test_expect_success 'remote new bookmark multiple branch head' '\n # cleanup previous stuff\n rm -rf hgrepo\n \n-test_expect_success 'remote big push' '\n-\ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n-\n+setup_big_push () {\n \t(\n \thg init hgrepo &&\n \tcd hgrepo &&\n@@ -459,8 +457,17 @@ test_expect_success 'remote big push' '\n \n \tgit checkout -q -b branches/new_branch master &&\n \techo ten > content &&\n-\tgit commit -q -a -m ten &&\n+\tgit commit -q -a -m ten\n+\t)\n+}\n \n+test_expect_success 'remote big push' '\n+\ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n+\n+\tsetup_big_push\n+\n+\t(\n+\tcd gitrepo &&\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-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218473","messageId":"1369449004-17981-44-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 43/48] remote-hg: add check_push() helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:29:59Z","receivedAt":"2013-05-25T02:29:59Z","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 | 66 +++++++++++++++++++++++++++++----------\n 1 file changed, 49 insertions(+), 17 deletions(-)\n\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex f594584..aeab48a 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -48,6 +48,38 @@ check_bookmark () {\n \tfi\n }\n \n+check_push () {\n+\tlocal expected_ret=$1 ret=0 ref_ret=0 IFS=':'\n+\n+\tshift\n+\tgit push origin \"$@\" 2> error\n+\tret=$?\n+\tcat error\n+\n+\twhile read branch kind\n+\tdo\n+\t\tcase \"$kind\" in\n+\t\t'new')\n+\t\t\tgrep \"^ \\* \\[new branch\\] *${branch} -> ${branch}$\" error || ref_ret=1\n+\t\t\t;;\n+\t\t'non-fast-forward')\n+\t\t\tgrep \"^ ! \\[rejected\\] *${branch} -> ${branch} (non-fast-forward)$\" error || ref_ret=1\n+\t\t\t;;\n+\t\t'')\n+\t\t\tgrep \"^   [a-f0-9]*\\.\\.[a-f0-9]* *${branch} -> ${branch}$\" error || ref_ret=1\n+\t\t\t;;\n+\t\tesac\n+\t\tlet 'ref_ret' && echo \"match for '$branch' failed\" && break\n+\tdone\n+\n+\tif let 'expected_ret != ret || ref_ret'\n+\tthen\n+\t\treturn 1\n+\tfi\n+\n+\treturn 0\n+}\n+\n setup () {\n \t(\n \techo \"[ui]\"\n@@ -344,8 +376,9 @@ test_expect_success 'remote push diverged' '\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+\tcheck_push 1 <<-EOF\n+\tmaster:non-fast-forward\n+\tEOF\n \t) &&\n \n \tcheck_branch hgrepo default bump\n@@ -373,8 +406,9 @@ test_expect_success 'remote update bookmark diverge' '\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+\tcheck_push 1 <<-EOF\n+\tdiverge:non-fast-forward\n+\tEOF\n \t) &&\n \n \tcheck_bookmark hgrepo diverge \"bump bookmark\"\n@@ -468,19 +502,17 @@ test_expect_success 'remote big push' '\n \n \t(\n \tcd gitrepo &&\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+\n+\tcheck_push 1 --all <<-EOF\n+\tmaster\n+\tgood_bmark\n+\tbranches/good_branch\n+\tnew_bmark:new\n+\tbranches/new_branch:new\n+\tbad_bmark1:non-fast-forward\n+\tbad_bmark2:non-fast-forward\n+\tbranches/bad_branch:non-fast-forward\n+\tEOF\n \t) &&\n \n \tcheck_branch hgrepo default one &&\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218471","messageId":"1369449004-17981-45-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 44/48] remote-helpers: improve marks usage","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:30:00Z","receivedAt":"2013-05-25T02:30:00Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Always convert to strings (they are unicode because they come from JSON).\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-bzr | 5 ++++-\n contrib/remote-helpers/git-remote-hg  | 7 +++++--\n 2 files changed, 9 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr\nindex 10300c6..f0e5be1 100755\n--- a/contrib/remote-helpers/git-remote-bzr\n+++ b/contrib/remote-helpers/git-remote-bzr\n@@ -116,7 +116,10 @@ class Marks:\n         self.last_mark = mark\n \n     def get_tip(self, branch):\n-        return self.tips.get(branch, None)\n+        try:\n+            return str(self.tips[branch])\n+        except KeyError:\n+            return None\n \n     def set_tip(self, branch, tip):\n         self.tips[branch] = tip\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex bd545aa..1e61f43 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -165,7 +165,7 @@ class Marks:\n         return self.marks[rev]\n \n     def to_rev(self, mark):\n-        return self.rev_marks[mark]\n+        return str(self.rev_marks[mark])\n \n     def next_mark(self):\n         self.last_mark += 1\n@@ -185,7 +185,10 @@ class Marks:\n         return rev in self.marks\n \n     def get_tip(self, branch):\n-        return self.tips.get(branch, None)\n+        try:\n+            return str(self.tips[branch])\n+        except KeyError:\n+            return None\n \n     def set_tip(self, branch, tip):\n         self.tips[branch] = tip\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218475","messageId":"1369449004-17981-46-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 45/48] remote-hg: trivial cleanup","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:30:01Z","receivedAt":"2013-05-25T02:30:01Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"It's better to catch the exception later on.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 11 ++++-------\n 1 file changed, 4 insertions(+), 7 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 1e61f43..b08f909 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -185,10 +185,7 @@ class Marks:\n         return rev in self.marks\n \n     def get_tip(self, branch):\n-        try:\n-            return str(self.tips[branch])\n-        except KeyError:\n-            return None\n+        return str(self.tips[branch])\n \n     def set_tip(self, branch, tip):\n         self.tips[branch] = tip\n@@ -433,10 +430,10 @@ def export_ref(repo, name, kind, head):\n     global prefix, marks, mode\n \n     ename = '%s/%s' % (kind, name)\n-    tip = marks.get_tip(ename)\n-    if tip and tip in repo:\n+    try:\n+        tip = marks.get_tip(ename)\n         tip = repo[tip].rev()\n-    else:\n+    except:\n         tip = 0\n \n     revs = xrange(tip, head.rev() + 1)\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218474","messageId":"1369449004-17981-47-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 46/48] remote-hg: check if a fetch is needed","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:30:02Z","receivedAt":"2013-05-25T02:30:02Z","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 | 39 ++++++++++++++++++++\n contrib/remote-helpers/test-hg.sh    | 71 +++++++++++++++++++++++++++++++++++-\n 2 files changed, 109 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex b08f909..b983627 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -973,6 +973,15 @@ def push(repo, remote, parsed_refs, p_revs):\n \n     return ret\n \n+def check_tip(ref, kind, name, heads):\n+    try:\n+        ename = '%s/%s' % (kind, name)\n+        tip = marks.get_tip(ename)\n+    except KeyError:\n+        return True\n+    else:\n+        return tip in heads\n+\n def do_export(parser):\n     global parsed_refs, bmarks, peer\n \n@@ -995,6 +1004,8 @@ def do_export(parser):\n         else:\n             die('unhandled export command: %s' % line)\n \n+    need_fetch = False\n+\n     for ref, node in parsed_refs.iteritems():\n         bnode = hgbin(node)\n         if ref.startswith('refs/heads/branches'):\n@@ -1002,6 +1013,16 @@ def do_export(parser):\n             if branch in branches and bnode in branches[branch]:\n                 # up to date\n                 continue\n+\n+            if peer:\n+                remotemap = peer.branchmap()\n+                if remotemap and branch in remotemap:\n+                    heads = [hghex(e) for e in remotemap[branch]]\n+                    if not check_tip(ref, 'branches', branch, heads):\n+                        print \"error %s fetch first\" % ref\n+                        need_fetch = True\n+                        continue\n+\n             p_revs[bnode] = ref\n             print \"ok %s\" % ref\n         elif ref.startswith('refs/heads/'):\n@@ -1017,6 +1038,14 @@ def do_export(parser):\n                     not (bmark == 'master' and bmark not in parser.repo._bookmarks):\n                 p_bmarks.append((ref, bmark, old, new))\n \n+            if peer:\n+                remote_old = peer.listkeys('bookmarks').get(bmark)\n+                if remote_old:\n+                    if not check_tip(ref, 'bookmarks', bmark, remote_old):\n+                        print \"error %s fetch first\" % ref\n+                        need_fetch = True\n+                        continue\n+\n             p_revs[bnode] = ref\n         elif ref.startswith('refs/tags/'):\n             tag = ref[len('refs/tags/'):]\n@@ -1037,6 +1066,16 @@ def do_export(parser):\n             # transport-helper/fast-export bugs\n             continue\n \n+    if need_fetch:\n+        print\n+        return\n+\n+    if dry_run:\n+        if peer and not force_push:\n+            checkheads(parser.repo, peer, p_revs)\n+        print\n+        return\n+\n     if peer:\n         if not push(parser.repo, peer, parsed_refs, p_revs):\n             # do not update bookmarks\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex aeab48a..91ddac7 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -65,6 +65,9 @@ check_push () {\n \t\t'non-fast-forward')\n \t\t\tgrep \"^ ! \\[rejected\\] *${branch} -> ${branch} (non-fast-forward)$\" error || ref_ret=1\n \t\t\t;;\n+\t\t'fetch-first')\n+\t\t\tgrep \"^ ! \\[rejected\\] *${branch} -> ${branch} (fetch first)$\" error || ref_ret=1\n+\t\t\t;;\n \t\t'')\n \t\t\tgrep \"^   [a-f0-9]*\\.\\.[a-f0-9]* *${branch} -> ${branch}$\" error || ref_ret=1\n \t\t\t;;\n@@ -407,7 +410,7 @@ test_expect_success 'remote update bookmark diverge' '\n \techo diverge > content &&\n \tgit commit -a -m diverge &&\n \tcheck_push 1 <<-EOF\n-\tdiverge:non-fast-forward\n+\tdiverge:fetch-first\n \tEOF\n \t) &&\n \n@@ -525,6 +528,72 @@ test_expect_success 'remote big push' '\n \tcheck_bookmark hgrepo new_bmark ''\n '\n \n+test_expect_success 'remote big push fetch first' '\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_bmark &&\n+\thg bookmark good_bmark &&\n+\thg bookmark -i good_bmark &&\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 hgrepo &&\n+\thg bookmark -f bad_bmark &&\n+\techo update_bmark > content &&\n+\thg commit -m \"update bmark\"\n+\t) &&\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_bmark &&\n+\techo four > content &&\n+\tgit commit -q -a -m four &&\n+\n+\tgit checkout -q branches/bad_branch &&\n+\techo five > content &&\n+\tgit commit -q -a -m five &&\n+\n+\tcheck_push 1 --all <<-EOF\n+\tmaster\n+\tgood_bmark\n+\tnew_bmark:new\n+\tnew_branch:new\n+\tbad_bmark:fetch-first\n+\tbranches/bad_branch:festch-first\n+\tEOF\n+\n+\tgit fetch &&\n+\n+\tcheck_push 1 --all <<-EOF\n+\tmaster\n+\tgood_bmark\n+\tbad_bmark:non-fast-forward\n+\tbranches/bad_branch:non-fast-forward\n+\tEOF\n+\t)\n+'\n+\n test_expect_success 'remote double failed push' '\n \ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n \n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218477","messageId":"1369449004-17981-48-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 47/48] remote-hg: add support for --dry-run","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:30:03Z","receivedAt":"2013-05-25T02:30:03Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This needs a specific patch from Git not applied yet.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 29 +++++++++++++++++++++++++--\n contrib/remote-helpers/test-hg.sh    | 38 ++++++++++++++++++++++++++++++++++++\n 2 files changed, 65 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex b983627..20abb34 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -557,6 +557,7 @@ def do_capabilities(parser):\n     if os.path.exists(path):\n         print \"*import-marks %s\" % path\n     print \"*export-marks %s\" % path\n+    print \"option\"\n \n     print\n \n@@ -724,6 +725,11 @@ def parse_commit(parser):\n             die('Unknown file command: %s' % line)\n         files[path] = f\n \n+    # only export the commits if we are on an internal proxy repo\n+    if dry_run and not peer:\n+        parsed_refs[ref] = None\n+        return\n+\n     def getfilectx(repo, memctx, f):\n         of = files[f]\n         if 'deleted' in of:\n@@ -809,7 +815,10 @@ def parse_reset(parser):\n     from_mark = parser.get_mark()\n     parser.next()\n \n-    rev = mark_to_rev(from_mark)\n+    try:\n+        rev = mark_to_rev(from_mark)\n+    except KeyError:\n+        rev = None\n     parsed_refs[ref] = rev\n \n def parse_tag(parser):\n@@ -1007,7 +1016,7 @@ def do_export(parser):\n     need_fetch = False\n \n     for ref, node in parsed_refs.iteritems():\n-        bnode = hgbin(node)\n+        bnode = hgbin(node) if node else None\n         if ref.startswith('refs/heads/branches'):\n             branch = ref[len('refs/heads/branches/'):]\n             if branch in branches and bnode in branches[branch]:\n@@ -1048,6 +1057,9 @@ def do_export(parser):\n \n             p_revs[bnode] = ref\n         elif ref.startswith('refs/tags/'):\n+            if dry_run:\n+                print \"ok %s\" % ref\n+                continue\n             tag = ref[len('refs/tags/'):]\n             tag = hgref(tag)\n             author, msg = parsed_tags.get(tag, (None, None))\n@@ -1097,6 +1109,15 @@ def do_export(parser):\n \n     print\n \n+def do_option(parser):\n+    global dry_run\n+    _, key, value = parser.line.split(' ')\n+    if key == 'dry-run':\n+        dry_run = (value == 'true')\n+        print 'ok'\n+    else:\n+        print 'unsupported'\n+\n def fix_path(alias, repo, orig_url):\n     url = urlparse.urlparse(orig_url, 'file')\n     if url.scheme != 'file' or os.path.isabs(url.path):\n@@ -1113,6 +1134,7 @@ def main(args):\n     global parsed_tags\n     global filenodes\n     global fake_bmark, hg_version\n+    global dry_run\n \n     alias = args[1]\n     url = args[2]\n@@ -1151,6 +1173,7 @@ def main(args):\n         hg_version = tuple(int(e) for e in util.version().split('.'))\n     except:\n         hg_version = None\n+    dry_run = False\n \n     repo = get_repo(url, alias)\n     prefix = 'refs/hg/%s' % alias\n@@ -1175,6 +1198,8 @@ def main(args):\n             do_import(parser)\n         elif parser.check('export'):\n             do_export(parser)\n+        elif parser.check('option'):\n+            do_option(parser)\n         else:\n             die('unhandled command: %s' % line)\n         sys.stdout.flush()\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 91ddac7..bf3635e 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -594,6 +594,44 @@ test_expect_success 'remote big push fetch first' '\n \t)\n '\n \n+test_expect_failure 'remote big push dry-run' '\n+\ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n+\n+\tsetup_big_push\n+\n+\t(\n+\tcd gitrepo &&\n+\n+\tcheck_push 0 --dry-run --all <<-EOF\n+\tmaster\n+\tgood_bmark\n+\tbranches/good_branch\n+\tnew_bmark:new\n+\tbranches/new_branch:new\n+\tbad_bmark1:non-fast-forward\n+\tbad_bmark2:non-fast-forward\n+\tbranches/bad_branch:non-fast-forward\n+\tEOF\n+\n+\tcheck_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-EOF\n+\tmaster\n+\tgood_bmark\n+\tbranches/good_branch\n+\tnew_bmark:new\n+\tbranches/new_branch:new\n+\tEOF\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_expect_success 'remote double failed push' '\n \ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n \n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218476","messageId":"1369449004-17981-49-git-send-email-felipe.contreras@gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 48/48] remote-hg: add support for --force","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-25T02:30:04Z","receivedAt":"2013-05-25T02:30:04Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"And get rid of the remote-hg.force-push option hack.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 30 +++++++++++++++++-------------\n contrib/remote-helpers/test-hg.sh    | 33 +++++++++++++++++++++++++++++++++\n 2 files changed, 50 insertions(+), 13 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 20abb34..0194c67 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -29,9 +29,6 @@ import urlparse, hashlib\n # named branches:\n # git config --global remote-hg.track-branches false\n #\n-# If you don't want to force pushes (and thus risk creating new remote heads):\n-# git config --global remote-hg.force-push false\n-#\n # If you want the equivalent of hg's clone/pull--insecure option:\n # git config --global remote-hg.insecure true\n #\n@@ -877,9 +874,6 @@ def write_tag(repo, tag, node, msg, author):\n     return (tagnode, branch)\n \n def checkheads_bmark(repo, 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@@ -888,8 +882,11 @@ def checkheads_bmark(repo, ref, ctx):\n     ctx_old = bmarks[bmark]\n     ctx_new = ctx\n     if not repo.changelog.descendant(ctx_old.rev(), ctx_new.rev()):\n-        print \"error %s non-fast forward\" % ref\n-        return False\n+        if force_push:\n+            print \"ok %s forced update\" % ref\n+        else:\n+            print \"error %s non-fast forward\" % ref\n+            return False\n \n     return True\n \n@@ -936,8 +933,12 @@ def checkheads(repo, remote, p_revs):\n                 continue\n \n             node = repo.changelog.node(rev)\n-            print \"error %s non-fast forward\" % p_revs[node]\n-            ret = False\n+            ref = p_revs[node]\n+            if force_push:\n+                print \"ok %s forced update\" % ref\n+            else:\n+                print \"error %s non-fast forward\" % ref\n+                ret = False\n \n     return ret\n \n@@ -949,7 +950,7 @@ def push_unsafe(repo, remote, parsed_refs, p_revs):\n     commoninc = fci(repo, remote, force=force)\n     common, _, remoteheads = commoninc\n \n-    if not force and not checkheads(repo, remote, p_revs):\n+    if not checkheads(repo, remote, p_revs):\n         return None\n \n     cg = repo.getbundle('push', heads=list(p_revs), common=common)\n@@ -1110,11 +1111,14 @@ def do_export(parser):\n     print\n \n def do_option(parser):\n-    global dry_run\n+    global dry_run, force_push\n     _, key, value = parser.line.split(' ')\n     if key == 'dry-run':\n         dry_run = (value == 'true')\n         print 'ok'\n+    elif key == 'force':\n+        force_push = (value == 'true')\n+        print 'ok'\n     else:\n         print 'unsupported'\n \n@@ -1142,7 +1146,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')\n+    force_push = False\n \n     if hg_git_compat:\n         mode = 'hg'\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex bf3635e..30f4ff6 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -68,6 +68,9 @@ check_push () {\n \t\t'fetch-first')\n \t\t\tgrep \"^ ! \\[rejected\\] *${branch} -> ${branch} (fetch first)$\" error || ref_ret=1\n \t\t\t;;\n+\t\t'forced-update')\n+\t\t\tgrep \"^ + [a-f0-9]*\\.\\.\\.[a-f0-9]* *${branch} -> ${branch} (forced update)$\" error || ref_ret=1\n+\t\t\t;;\n \t\t'')\n \t\t\tgrep \"^   [a-f0-9]*\\.\\.[a-f0-9]* *${branch} -> ${branch}$\" error || ref_ret=1\n \t\t\t;;\n@@ -594,6 +597,36 @@ test_expect_success 'remote big push fetch first' '\n \t)\n '\n \n+test_expect_failure 'remote big push force' '\n+\ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n+\n+\tsetup_big_push\n+\n+\t(\n+\tcd gitrepo &&\n+\n+\tcheck_push 0 --force --all <<-EOF\n+\tmaster\n+\tgood_bmark\n+\tbranches/good_branch\n+\tnew_bmark:new\n+\tbranches/new_branch:new\n+\tbad_bmark1:forced-update\n+\tbad_bmark2:forced-update\n+\tbranches/bad_branch:forced-update\n+\tEOF\n+\t) &&\n+\n+\tcheck_branch hgrepo default six &&\n+\tcheck_branch hgrepo good_branch eight &&\n+\tcheck_branch hgrepo bad_branch nine &&\n+\tcheck_branch hgrepo new_branch ten &&\n+\tcheck_bookmark hgrepo good_bmark three &&\n+\tcheck_bookmark hgrepo bad_bmark1 four &&\n+\tcheck_bookmark hgrepo bad_bmark2 five &&\n+\tcheck_bookmark hgrepo new_bmark six\n+'\n+\n test_expect_failure 'remote big push dry-run' '\n \ttest_when_finished \"rm -rf hgrepo gitrepo*\" &&\n \n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218505","messageId":"CAPig+cRMj-xyFzf22emEHfhOzfFn7MC-t1aaCDU9uBA6Qi3+SA@mail.gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-28-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2 27/48] remote-hg: add test for new bookmark special","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-05-25T06:27:44Z","receivedAt":"2013-05-25T06:27:44Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, May 24, 2013 at 10:29 PM, 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\ns/whoever/however/\n\n> branches can be pushed without problems.\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n"},{"id":"218506","messageId":"CAPig+cTjxX032icuoh0Do-zEJqSYO0ftbHKERms9eSAUbH63sw@mail.gmail.com","threadId":"33924","inReplyTo":"1369449004-17981-26-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2 25/48] remote-hg: add test for diverged push","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-05-25T06:28:22Z","receivedAt":"2013-05-25T06:28:22Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, May 24, 2013 at 10:29 PM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> Neither mercurial nor git allows pushing to a remote when it's a\n> non-fast-forward push. We should be able to detect theses errors and\n\ns/theses/these/\n\n> report them properly.\n>\n> As opposed to throwing an exception stack-trace.\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n"}]}