{"thread":{"id":"32220","subject":"[PATCH 0/4] remote-helpers: general fixes","startedAt":"2012-11-28T01:01:31Z","lastAt":"2012-11-28T02:30:26Z","messageCount":8,"participants":["Felipe Contreras","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"204077","messageId":"1354064495-23171-1-git-send-email-felipe.contreras@gmail.com","threadId":"32220","inReplyTo":null,"subject":"[PATCH 0/4] remote-helpers: general fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-28T01:01:31Z","receivedAt":"2012-11-28T01:01:31Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nThese are general fixes, some for old versions of bazaar, mercurial, and\npython. Some of these have already been sent, but here they go alone so they\nare not missed.\n\nThe bazaar fixes are on top of the series v3 which is still not in 'pu'.\n\nFelipe Contreras (4):\n  remote-hg: fix for files with spaces\n  remote-hg: fix for older versions of python\n  remote-bzr: add support for older versions of bzr\n  remote-bzr: detect local repositories\n\n contrib/remote-helpers/git-remote-bzr | 54 +++++++++++++++++++++--------------\n contrib/remote-helpers/git-remote-hg  | 14 +++++----\n 2 files changed, 42 insertions(+), 26 deletions(-)\n\n-- \n1.8.0\n"},{"id":"204078","messageId":"1354064495-23171-2-git-send-email-felipe.contreras@gmail.com","threadId":"32220","inReplyTo":"1354064495-23171-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 1/4] remote-hg: fix for files with spaces","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-28T01:01:32Z","receivedAt":"2012-11-28T01:01: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 | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 07754bd..62c39db 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -565,7 +565,7 @@ def parse_commit(parser):\n \n     for line in parser:\n         if parser.check('M'):\n-            t, m, mark_ref, path = line.split(' ')\n+            t, m, mark_ref, path = line.split(' ', 3)\n             mark = int(mark_ref[1:])\n             f = { 'mode' : hgmode(m), 'data' : blob_marks[mark] }\n         elif parser.check('D'):\n-- \n1.8.0\n"},{"id":"204079","messageId":"1354064495-23171-3-git-send-email-felipe.contreras@gmail.com","threadId":"32220","inReplyTo":"1354064495-23171-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 2/4] remote-hg: fix for older versions of python","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-28T01:01:33Z","receivedAt":"2012-11-28T01:01:33Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"As Amit Bakshi reported, older versions of python (< 2.7) don't have\nsubprocess.check_output, so let's use subprocess.Popen directly as\nsuggested.\n\nSuggested-by: Amit Bakshi <ambakshi@gmail.com>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 12 ++++++++----\n 1 file changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 62c39db..016cdad 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -56,6 +56,12 @@ def hgmode(mode):\n     m = { '0100755': 'x', '0120000': 'l' }\n     return m.get(mode, '')\n \n+def get_config(config):\n+    cmd = ['git', 'config', '--get', config]\n+    process = subprocess.Popen(cmd, stdout=subprocess.PIPE)\n+    output, _ = process.communicate()\n+    return output\n+\n class Marks:\n \n     def __init__(self, path):\n@@ -727,12 +733,10 @@ def main(args):\n     hg_git_compat = False\n     track_branches = True\n     try:\n-        cmd = ['git', 'config', '--get', 'remote-hg.hg-git-compat']\n-        if subprocess.check_output(cmd) == 'true\\n':\n+        if get_config('remote-hg.hg-git-compat') == 'true\\n':\n             hg_git_compat = True\n             track_branches = False\n-        cmd = ['git', 'config', '--get', 'remote-hg.track-branches']\n-        if subprocess.check_output(cmd) == 'false\\n':\n+        if get_config('remote-hg.track-branches') == 'false\\n':\n             track_branches = False\n     except subprocess.CalledProcessError:\n         pass\n-- \n1.8.0\n"},{"id":"204081","messageId":"1354064495-23171-4-git-send-email-felipe.contreras@gmail.com","threadId":"32220","inReplyTo":"1354064495-23171-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 3/4] remote-bzr: add support for older versions of bzr","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-28T01:01:34Z","receivedAt":"2012-11-28T01:01:34Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"At least as old as 2.0.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-bzr | 14 +++++++++-----\n 1 file changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr\nindex f8919f4..6cdfac6 100755\n--- a/contrib/remote-helpers/git-remote-bzr\n+++ b/contrib/remote-helpers/git-remote-bzr\n@@ -17,7 +17,8 @@\n import sys\n \n import bzrlib\n-bzrlib.initialize()\n+if hasattr(bzrlib, \"initialize\"):\n+    bzrlib.initialize()\n \n import bzrlib.plugin\n bzrlib.plugin.load_plugins()\n@@ -553,7 +554,7 @@ def parse_commit(parser):\n \n     repo.lock_write()\n     try:\n-        builder = repo.get_commit_builder(parents, None, date, tz, committer, props, revid, False)\n+        builder = repo.get_commit_builder(parents, None, date, tz, committer, props, revid)\n         try:\n             list(builder.record_iter_changes(mtree, mtree.last_revision(), changes))\n             builder.finish_inventory()\n@@ -612,7 +613,10 @@ def do_export(parser):\n         if ref == 'refs/heads/master':\n             repo.generate_revision_history(revid, marks.get_tip('master'))\n             revno, revid = repo.last_revision_info()\n-            peer.import_last_revision_info_and_tags(repo, revno, revid)\n+            if hasattr(peer, \"import_last_revision_info_and_tags\"):\n+                peer.import_last_revision_info_and_tags(repo, revno, revid)\n+            else:\n+                peer.import_last_revision_info(repo.repository, revno, revid)\n             wt = peer.bzrdir.open_workingtree()\n             wt.update()\n         print \"ok %s\" % ref\n@@ -646,12 +650,12 @@ def get_repo(url, alias):\n     global dirname, peer\n \n     clone_path = os.path.join(dirname, 'clone')\n-    origin = bzrlib.controldir.ControlDir.open(url)\n+    origin = bzrlib.bzrdir.BzrDir.open(url)\n     remote_branch = origin.open_branch()\n \n     if os.path.exists(clone_path):\n         # pull\n-        d = bzrlib.controldir.ControlDir.open(clone_path)\n+        d = bzrlib.bzrdir.BzrDir.open(clone_path)\n         branch = d.open_branch()\n         result = branch.pull(remote_branch, [], None, False)\n     else:\n-- \n1.8.0\n"},{"id":"204080","messageId":"1354064495-23171-5-git-send-email-felipe.contreras@gmail.com","threadId":"32220","inReplyTo":"1354064495-23171-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 4/4] remote-bzr: detect local repositories","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-28T01:01:35Z","receivedAt":"2012-11-28T01:01:35Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"So we don't create a clone  unnecessarily.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-bzr | 48 ++++++++++++++++++++---------------\n 1 file changed, 28 insertions(+), 20 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr\nindex 6cdfac6..c5822e4 100755\n--- a/contrib/remote-helpers/git-remote-bzr\n+++ b/contrib/remote-helpers/git-remote-bzr\n@@ -24,6 +24,7 @@ import bzrlib.plugin\n bzrlib.plugin.load_plugins()\n \n import bzrlib.generate_ids\n+import bzrlib.transport\n \n import sys\n import os\n@@ -613,11 +614,14 @@ def do_export(parser):\n         if ref == 'refs/heads/master':\n             repo.generate_revision_history(revid, marks.get_tip('master'))\n             revno, revid = repo.last_revision_info()\n-            if hasattr(peer, \"import_last_revision_info_and_tags\"):\n-                peer.import_last_revision_info_and_tags(repo, revno, revid)\n+            if peer:\n+                if hasattr(peer, \"import_last_revision_info_and_tags\"):\n+                    peer.import_last_revision_info_and_tags(repo, revno, revid)\n+                else:\n+                    peer.import_last_revision_info(repo.repository, revno, revid)\n+                wt = peer.bzrdir.open_workingtree()\n             else:\n-                peer.import_last_revision_info(repo.repository, revno, revid)\n-            wt = peer.bzrdir.open_workingtree()\n+                wt = repo.bzrdir.open_workingtree()\n             wt.update()\n         print \"ok %s\" % ref\n     print\n@@ -649,24 +653,28 @@ def do_list(parser):\n def get_repo(url, alias):\n     global dirname, peer\n \n-    clone_path = os.path.join(dirname, 'clone')\n     origin = bzrlib.bzrdir.BzrDir.open(url)\n-    remote_branch = origin.open_branch()\n-\n-    if os.path.exists(clone_path):\n-        # pull\n-        d = bzrlib.bzrdir.BzrDir.open(clone_path)\n-        branch = d.open_branch()\n-        result = branch.pull(remote_branch, [], None, False)\n+    branch = origin.open_branch()\n+\n+    if not isinstance(origin.transport, bzrlib.transport.local.LocalTransport):\n+        clone_path = os.path.join(dirname, 'clone')\n+        remote_branch = branch\n+        if os.path.exists(clone_path):\n+            # pull\n+            d = bzrlib.bzrdir.BzrDir.open(clone_path)\n+            branch = d.open_branch()\n+            result = branch.pull(remote_branch, [], None, False)\n+        else:\n+            # clone\n+            d = origin.sprout(clone_path, None,\n+                    hardlink=True, create_tree_if_local=False,\n+                    source_branch=remote_branch)\n+            branch = d.open_branch()\n+            branch.bind(remote_branch)\n+\n+        peer = remote_branch\n     else:\n-        # clone\n-        d = origin.sprout(clone_path, None,\n-                hardlink=True, create_tree_if_local=False,\n-                source_branch=remote_branch)\n-        branch = d.open_branch()\n-        branch.bind(remote_branch)\n-\n-    peer = remote_branch\n+        peer = None\n \n     return branch\n \n-- \n1.8.0\n"},{"id":"204097","messageId":"7vfw3ujxh8.fsf@alter.siamese.dyndns.org","threadId":"32220","inReplyTo":"1354064495-23171-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH 0/4] remote-helpers: general fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-28T02:02:43Z","receivedAt":"2012-11-28T02:02:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> These are general fixes, some for old versions of bazaar, mercurial, and\n> python. Some of these have already been sent, but here they go alone so they\n> are not missed.\n>\n> The bazaar fixes are on top of the series v3 which is still not in 'pu'.\n\nPlease stop then.  Its v2 has been cooking in 'next' and it won't be\nreplaced.\n"},{"id":"204104","messageId":"CAMP44s0JK8b4bfTyXBeL9Q+cebuMC0qfdz673jkvTc7+Uoy-mw@mail.gmail.com","threadId":"32220","inReplyTo":"7vfw3ujxh8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 0/4] remote-helpers: general fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-28T02:26:43Z","receivedAt":"2012-11-28T02:26:43Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Wed, Nov 28, 2012 at 3:02 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> These are general fixes, some for old versions of bazaar, mercurial, and\n>> python. Some of these have already been sent, but here they go alone so they\n>> are not missed.\n>>\n>> The bazaar fixes are on top of the series v3 which is still not in 'pu'.\n>\n> Please stop then.  Its v2 has been cooking in 'next' and it won't be\n> replaced.\n\nCooking since when? 9 days ago? I sent the series 17 days ago. But\nsuit yourself. I re-rolled for a reason.\n\n-- \nFelipe Contreras\n"},{"id":"204106","messageId":"7vtxsaihml.fsf@alter.siamese.dyndns.org","threadId":"32220","inReplyTo":"7vfw3ujxh8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 0/4] remote-helpers: general fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-28T02:30:26Z","receivedAt":"2012-11-28T02:30:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> These are general fixes, some for old versions of bazaar, mercurial, and\n>> python. Some of these have already been sent, but here they go alone so they\n>> are not missed.\n>>\n>> The bazaar fixes are on top of the series v3 which is still not in 'pu'.\n>\n> Please stop then.  Its v2 has been cooking in 'next' and it won't be\n> replaced.\n\nPicked up the -hg bit.  The other two has to wait until\nfc/remote-bzr gets updated (but see other thread).\n"}]}