All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] remote-{hg,bzr}: updates
@ 2013-08-28 19:23 Felipe Contreras
  2013-08-28 19:23 ` [PATCH 1/8] remote-bzr: fix export of utf-8 authors Felipe Contreras
                   ` (7 more replies)
  0 siblings, 8 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 19:23 UTC (permalink / raw)
  To: git; +Cc: Antoine Pelisse, Felipe Contreras

Felipe Contreras (8):
  remote-bzr: fix export of utf-8 authors
  remote-bzr: make bzr branches configurable per-repo
  remote-hg: fix test
  remote-hg: add missing &&s in the test
  remote-hg: improve basic test
  remote-helpers: trivial style fixes
  remote-helpers: cleanup more global variables
  remote-hg: support for notes

 contrib/remote-helpers/git-remote-bzr | 47 +++++++------------------
 contrib/remote-helpers/git-remote-hg  | 65 +++++++++++++++++++----------------
 contrib/remote-helpers/test-bzr.sh    | 30 ++++++++++++++++
 contrib/remote-helpers/test-hg.sh     | 10 +++---
 4 files changed, 82 insertions(+), 70 deletions(-)

-- 
1.8.4-fc

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-28 19:23 [PATCH 0/8] remote-{hg,bzr}: updates Felipe Contreras
@ 2013-08-28 19:23 ` Felipe Contreras
  2013-08-28 20:05   ` Matthieu Moy
  2013-08-28 20:35   ` Eric Sunshine
  2013-08-28 19:23 ` [PATCH 2/8] remote-bzr: make bzr branches configurable per-repo Felipe Contreras
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 19:23 UTC (permalink / raw)
  To: git; +Cc: Antoine Pelisse, Felipe Contreras

Reported-by: Joakim Verona <joakim@verona.se>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr |  1 +
 contrib/remote-helpers/test-bzr.sh    | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index c3a3cac..08b0b61 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -168,6 +168,7 @@ class Parser:
         if not m:
             return None
         _, name, email, date, tz = m.groups()
+        name = name.decode('utf-8')
         committer = '%s <%s>' % (name, email)
         tz = int(tz)
         tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh
index dce281f..ef8992a 100755
--- a/contrib/remote-helpers/test-bzr.sh
+++ b/contrib/remote-helpers/test-bzr.sh
@@ -358,4 +358,34 @@ test_expect_success 'strip' '
 	test_cmp expected actual
 '
 
+test_expect_success 'export utf-8 authors' '
+	test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && unset GIT_COMMITTER_NAME" &&
+
+	LC_ALL=en_US.UTF-8
+	export LC_ALL
+
+	GIT_COMMITTER_NAME="Grégoire"
+	export GIT_COMMITTER_NAME
+
+	bzr init bzrrepo &&
+
+	(
+	git init gitrepo &&
+	cd gitrepo &&
+	echo greg >> content &&
+	git add content &&
+	git commit -m one
+	git remote add bzr "bzr::../bzrrepo" &&
+	git push bzr
+	) &&
+
+	(
+	cd bzrrepo &&
+	bzr log | grep "^committer: " > ../actual
+	) &&
+
+	echo "committer: Grégoire <committer@example.com>" > expected &&
+	test_cmp expected actual
+'
+
 test_done
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 2/8] remote-bzr: make bzr branches configurable per-repo
  2013-08-28 19:23 [PATCH 0/8] remote-{hg,bzr}: updates Felipe Contreras
  2013-08-28 19:23 ` [PATCH 1/8] remote-bzr: fix export of utf-8 authors Felipe Contreras
@ 2013-08-28 19:23 ` Felipe Contreras
  2013-08-28 19:23 ` [PATCH 3/8] remote-hg: fix test Felipe Contreras
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 19:23 UTC (permalink / raw)
  To: git; +Cc: Antoine Pelisse, Felipe Contreras

Different repositories have different branches, some are are even
branches themselves.

Reported-by: Peter Niederlag <netservice@niekom.de>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 08b0b61..a7d2ac9 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -13,8 +13,11 @@
 # or
 # % git clone bzr::lp:myrepo
 #
-# If you want to specify which branches you want track (per repo):
-# git config remote-bzr.branches 'trunk, devel, test'
+# If you want to specify which branches you want to track (per repo):
+# % git config remote.origin.bzr-branches 'trunk, devel, test'
+#
+# Where 'origin' is the name of the repository you want to specify the
+# branches.
 #
 
 import sys
@@ -852,9 +855,13 @@ def get_repo(url, alias):
             except bzrlib.errors.NoRepositoryPresent:
                 pass
 
-    wanted = get_config('remote-bzr.branches').rstrip().split(', ')
+    wanted = get_config('remote.%s.bzr-branches' % alias).rstrip().split(', ')
     # stupid python
     wanted = [e for e in wanted if e]
+    if not wanted:
+        wanted = get_config('remote-bzr.branches').rstrip().split(', ')
+        # stupid python
+        wanted = [e for e in wanted if e]
 
     if not wanted:
         try:
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 3/8] remote-hg: fix test
  2013-08-28 19:23 [PATCH 0/8] remote-{hg,bzr}: updates Felipe Contreras
  2013-08-28 19:23 ` [PATCH 1/8] remote-bzr: fix export of utf-8 authors Felipe Contreras
  2013-08-28 19:23 ` [PATCH 2/8] remote-bzr: make bzr branches configurable per-repo Felipe Contreras
@ 2013-08-28 19:23 ` Felipe Contreras
  2013-08-28 19:23 ` [PATCH 4/8] remote-hg: add missing &&s in the test Felipe Contreras
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 19:23 UTC (permalink / raw)
  To: git; +Cc: Antoine Pelisse, Felipe Contreras

It wasn't being checked properly before; those refs never existed.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/test-hg.sh | 2 --
 1 file changed, 2 deletions(-)

diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index f7ce8aa..cbf8617 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -580,8 +580,6 @@ test_expect_success 'remote big push fetch first' '
 	check_push 1 --all <<-EOF
 	master
 	good_bmark
-	new_bmark:new
-	new_branch:new
 	bad_bmark:fetch-first
 	branches/bad_branch:festch-first
 	EOF
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 4/8] remote-hg: add missing &&s in the test
  2013-08-28 19:23 [PATCH 0/8] remote-{hg,bzr}: updates Felipe Contreras
                   ` (2 preceding siblings ...)
  2013-08-28 19:23 ` [PATCH 3/8] remote-hg: fix test Felipe Contreras
@ 2013-08-28 19:23 ` Felipe Contreras
  2013-08-28 19:23 ` [PATCH 5/8] remote-hg: improve basic test Felipe Contreras
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 19:23 UTC (permalink / raw)
  To: git; +Cc: Antoine Pelisse, Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/test-hg.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index cbf8617..94b0bba 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -577,7 +577,7 @@ test_expect_success 'remote big push fetch first' '
 	echo five > content &&
 	git commit -q -a -m five &&
 
-	check_push 1 --all <<-EOF
+	check_push 1 --all <<-EOF &&
 	master
 	good_bmark
 	bad_bmark:fetch-first
@@ -633,7 +633,7 @@ test_expect_failure 'remote big push dry-run' '
 	(
 	cd gitrepo &&
 
-	check_push 0 --dry-run --all <<-EOF
+	check_push 1 --dry-run --all <<-EOF &&
 	master
 	good_bmark
 	branches/good_branch
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 5/8] remote-hg: improve basic test
  2013-08-28 19:23 [PATCH 0/8] remote-{hg,bzr}: updates Felipe Contreras
                   ` (3 preceding siblings ...)
  2013-08-28 19:23 ` [PATCH 4/8] remote-hg: add missing &&s in the test Felipe Contreras
@ 2013-08-28 19:23 ` Felipe Contreras
  2013-08-28 19:23 ` [PATCH 6/8] remote-helpers: trivial style fixes Felipe Contreras
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 19:23 UTC (permalink / raw)
  To: git; +Cc: Antoine Pelisse, Felipe Contreras

It appears 'let' is not present in all shells.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/test-hg.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index 94b0bba..5a6f745 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -75,10 +75,10 @@ check_push () {
 			grep "^   [a-f0-9]*\.\.[a-f0-9]* *${branch} -> ${branch}$" error || ref_ret=1
 			;;
 		esac
-		let 'ref_ret' && echo "match for '$branch' failed" && break
+		test $ref_ret -ne 0 && echo "match for '$branch' failed" && break
 	done
 
-	if let 'expected_ret != ret || ref_ret'
+	if test $expected_ret -ne $ret -o $ref_ret -ne 0
 	then
 		return 1
 	fi
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 6/8] remote-helpers: trivial style fixes
  2013-08-28 19:23 [PATCH 0/8] remote-{hg,bzr}: updates Felipe Contreras
                   ` (4 preceding siblings ...)
  2013-08-28 19:23 ` [PATCH 5/8] remote-hg: improve basic test Felipe Contreras
@ 2013-08-28 19:23 ` Felipe Contreras
  2013-08-28 19:23 ` [PATCH 7/8] remote-helpers: cleanup more global variables Felipe Contreras
  2013-08-28 19:23 ` [PATCH 8/8] remote-hg: support for notes Felipe Contreras
  7 siblings, 0 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 19:23 UTC (permalink / raw)
  To: git; +Cc: Antoine Pelisse, Felipe Contreras

In accordance with pep8.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr | 4 ++--
 contrib/remote-helpers/git-remote-hg  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index a7d2ac9..e4fdfb0 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -488,7 +488,7 @@ class CustomTree():
             add_entry(fid, dirname, 'directory')
             return fid
 
-        def add_entry(fid, path, kind, mode = None):
+        def add_entry(fid, path, kind, mode=None):
             dirname, basename = os.path.split(path)
             parent_fid = get_parent(dirname, basename)
 
@@ -509,7 +509,7 @@ class CustomTree():
             self.files[path] = [change[0], None]
             changes.append(change)
 
-        def update_entry(fid, path, kind, mode = None):
+        def update_entry(fid, path, kind, mode=None):
             dirname, basename = os.path.split(path)
             parent_fid = get_parent(dirname, basename)
 
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index d2ff0e2..178a5a5 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -1079,7 +1079,7 @@ def do_export(parser):
             author, msg = parsed_tags.get(tag, (None, None))
             if mode == 'git':
                 if not msg:
-                    msg = 'Added tag %s for changeset %s' % (tag, node[:12]);
+                    msg = 'Added tag %s for changeset %s' % (tag, node[:12])
                 tagnode, branch = write_tag(parser.repo, tag, node, msg, author)
                 p_revs[tagnode] = 'refs/heads/branches/' + gitref(branch)
             else:
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 7/8] remote-helpers: cleanup more global variables
  2013-08-28 19:23 [PATCH 0/8] remote-{hg,bzr}: updates Felipe Contreras
                   ` (5 preceding siblings ...)
  2013-08-28 19:23 ` [PATCH 6/8] remote-helpers: trivial style fixes Felipe Contreras
@ 2013-08-28 19:23 ` Felipe Contreras
  2013-08-28 19:23 ` [PATCH 8/8] remote-hg: support for notes Felipe Contreras
  7 siblings, 0 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 19:23 UTC (permalink / raw)
  To: git; +Cc: Antoine Pelisse, Felipe Contreras

They don't need to be specified if they are not going to be set.

Suggested-by: Dusty Phillips <dusty@linux.ca>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr | 29 -----------------------------
 contrib/remote-helpers/git-remote-hg  | 30 ++----------------------------
 2 files changed, 2 insertions(+), 57 deletions(-)

diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index e4fdfb0..42cec58 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -178,11 +178,9 @@ class Parser:
         return (committer, int(date), tz)
 
 def rev_to_mark(rev):
-    global marks
     return marks.from_rev(rev)
 
 def mark_to_rev(mark):
-    global marks
     return marks.to_rev(mark)
 
 def fixup_user(user):
@@ -237,8 +235,6 @@ def get_filechanges(cur, prev):
     return modified, removed
 
 def export_files(tree, files):
-    global marks, filenodes
-
     final = []
     for path, fid in files.iteritems():
         kind = tree.kind(fid)
@@ -280,8 +276,6 @@ def export_files(tree, files):
     return final
 
 def export_branch(repo, name):
-    global prefix
-
     ref = '%s/heads/%s' % (prefix, name)
     tip = marks.get_tip(name)
 
@@ -382,16 +376,12 @@ def export_branch(repo, name):
     marks.set_tip(name, revid)
 
 def export_tag(repo, name):
-    global tags, prefix
-
     ref = '%s/tags/%s' % (prefix, name)
     print "reset %s" % ref
     print "from :%u" % rev_to_mark(tags[name])
     print
 
 def do_import(parser):
-    global dirname
-
     repo = parser.repo
     path = os.path.join(dirname, 'marks-git')
 
@@ -417,8 +407,6 @@ def do_import(parser):
     sys.stdout.flush()
 
 def parse_blob(parser):
-    global blob_marks
-
     parser.next()
     mark = parser.get_mark()
     parser.next()
@@ -429,8 +417,6 @@ def parse_blob(parser):
 class CustomTree():
 
     def __init__(self, branch, revid, parents, files):
-        global files_cache
-
         self.updates = {}
         self.branch = branch
 
@@ -587,9 +573,6 @@ def c_style_unescape(string):
     return string
 
 def parse_commit(parser):
-    global marks, blob_marks, parsed_refs
-    global mode
-
     parents = []
 
     ref = parser[1]
@@ -661,8 +644,6 @@ def parse_commit(parser):
     marks.new_mark(revid, commit_mark)
 
 def parse_reset(parser):
-    global parsed_refs
-
     ref = parser[1]
     parser.next()
 
@@ -678,8 +659,6 @@ def parse_reset(parser):
     parsed_refs[ref] = mark_to_rev(from_mark)
 
 def do_export(parser):
-    global parsed_refs, dirname
-
     parser.next()
 
     for line in parser.each_block('done'):
@@ -728,8 +707,6 @@ def do_export(parser):
     print
 
 def do_capabilities(parser):
-    global dirname
-
     print "import"
     print "export"
     print "refspec refs/heads/*:%s/heads/*" % prefix
@@ -747,8 +724,6 @@ def ref_is_valid(name):
     return not True in [c in name for c in '~^: \\']
 
 def do_list(parser):
-    global tags
-
     master_branch = None
 
     for name in branches:
@@ -782,8 +757,6 @@ def clone(path, remote_branch):
     return remote_branch.sprout(bdir, repository=repo)
 
 def get_remote_branch(name):
-    global dirname, branches
-
     remote_branch = bzrlib.branch.Branch.open(branches[name])
     if isinstance(remote_branch.user_transport, bzrlib.transport.local.LocalTransport):
         return remote_branch
@@ -825,8 +798,6 @@ def find_branches(repo):
             yield name, branch.base
 
 def get_repo(url, alias):
-    global dirname, peer, branches
-
     normal_url = bzrlib.urlutils.normalize_url(url)
     origin = bzrlib.bzrdir.BzrDir.open(url)
     is_local = isinstance(origin.transport, bzrlib.transport.local.LocalTransport)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 178a5a5..307d82c 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -227,8 +227,6 @@ class Parser:
         return sys.stdin.read(size)
 
     def get_author(self):
-        global bad_mail
-
         ex = None
         m = RAW_AUTHOR_RE.match(self.line)
         if not m:
@@ -261,8 +259,6 @@ def fix_file_path(path):
     return os.path.relpath(path, '/')
 
 def export_files(files):
-    global marks, filenodes
-
     final = []
     for f in files:
         fid = node.hex(f.filenode())
@@ -344,8 +340,6 @@ def fixup_user_hg(user):
     return (name, mail)
 
 def fixup_user(user):
-    global mode, bad_mail
-
     if mode == 'git':
         name, mail = fixup_user_git(user)
     else:
@@ -374,7 +368,7 @@ def updatebookmarks(repo, peer):
         bookmarks.write(repo)
 
 def get_repo(url, alias):
-    global dirname, peer
+    global peer
 
     myui = ui.ui()
     myui.setconfig('ui', 'interactive', 'off')
@@ -429,16 +423,12 @@ def get_repo(url, alias):
     return repo
 
 def rev_to_mark(rev):
-    global marks
     return marks.from_rev(rev.hex())
 
 def mark_to_rev(mark):
-    global marks
     return marks.to_rev(mark)
 
 def export_ref(repo, name, kind, head):
-    global prefix, marks, mode
-
     ename = '%s/%s' % (kind, name)
     try:
         tip = marks.get_tip(ename)
@@ -550,12 +540,9 @@ def export_branch(repo, branch):
     export_ref(repo, branch, 'branches', head)
 
 def export_head(repo):
-    global g_head
     export_ref(repo, g_head[0], 'bookmarks', g_head[1])
 
 def do_capabilities(parser):
-    global prefix, dirname
-
     print "import"
     print "export"
     print "refspec refs/heads/branches/*:%s/branches/*" % prefix
@@ -575,8 +562,6 @@ def branch_tip(branch):
     return branches[branch][-1]
 
 def get_branch_tip(repo, branch):
-    global branches
-
     heads = branches.get(hgref(branch), None)
     if not heads:
         return None
@@ -589,7 +574,7 @@ def get_branch_tip(repo, branch):
     return heads[0]
 
 def list_head(repo, cur):
-    global g_head, bmarks, fake_bmark
+    global g_head, fake_bmark
 
     if 'default' not in branches:
         # empty repo
@@ -605,8 +590,6 @@ def list_head(repo, cur):
     g_head = (head, node)
 
 def do_list(parser):
-    global branches, bmarks, track_branches
-
     repo = parser.repo
     for bmark, node in bookmarks.listbookmarks(repo).iteritems():
         bmarks[bmark] = repo[node]
@@ -674,8 +657,6 @@ def do_import(parser):
     print 'done'
 
 def parse_blob(parser):
-    global blob_marks
-
     parser.next()
     mark = parser.get_mark()
     parser.next()
@@ -692,9 +673,6 @@ def get_merge_files(repo, p1, p2, files):
             files[e] = f
 
 def parse_commit(parser):
-    global marks, blob_marks, parsed_refs
-    global mode
-
     from_mark = merge_mark = None
 
     ref = parser[1]
@@ -812,8 +790,6 @@ def parse_commit(parser):
     marks.new_mark(node, commit_mark)
 
 def parse_reset(parser):
-    global parsed_refs
-
     ref = parser[1]
     parser.next()
     # ugh
@@ -1006,8 +982,6 @@ def check_tip(ref, kind, name, heads):
         return tip in heads
 
 def do_export(parser):
-    global parsed_refs, bmarks, peer
-
     p_bmarks = []
     p_revs = {}
 
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 8/8] remote-hg: support for notes
  2013-08-28 19:23 [PATCH 0/8] remote-{hg,bzr}: updates Felipe Contreras
                   ` (6 preceding siblings ...)
  2013-08-28 19:23 ` [PATCH 7/8] remote-helpers: cleanup more global variables Felipe Contreras
@ 2013-08-28 19:23 ` Felipe Contreras
  2013-08-29 18:45   ` Junio C Hamano
  7 siblings, 1 reply; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 19:23 UTC (permalink / raw)
  To: git; +Cc: Antoine Pelisse, Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-hg | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 307d82c..0dbda75 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -23,6 +23,7 @@ import subprocess
 import urllib
 import atexit
 import urlparse, hashlib
+import time as ptime
 
 #
 # If you are not in hg-git-compat mode and want to disable the tracking of
@@ -126,6 +127,7 @@ class Marks:
         self.rev_marks = {}
         self.last_mark = 0
         self.version = 0
+        self.last_note = 0
 
     def load(self):
         if not os.path.exists(self.path):
@@ -137,6 +139,7 @@ class Marks:
         self.marks = tmp['marks']
         self.last_mark = tmp['last-mark']
         self.version = tmp.get('version', 1)
+        self.last_note = tmp.get('last-note', 0)
 
         for rev, mark in self.marks.iteritems():
             self.rev_marks[mark] = rev
@@ -150,7 +153,7 @@ class Marks:
         self.version = 2
 
     def dict(self):
-        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version }
+        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version, 'last-note' : self.last_note }
 
     def store(self):
         json.dump(self.dict(), open(self.path, 'w'))
@@ -525,6 +528,31 @@ def export_ref(repo, name, kind, head):
     print "from :%u" % rev_to_mark(head)
     print
 
+    pending_revs = set(revs) - notes
+    if pending_revs:
+        note_mark = marks.next_mark()
+        ref = "refs/notes/hg"
+
+        print "commit %s" % ref
+        print "mark :%d" % (note_mark)
+        print "committer remote-hg <> %s" % (ptime.strftime('%s %z'))
+        desc = "Notes for %s\n" % (name)
+        print "data %d" % (len(desc))
+        print desc
+        if marks.last_note:
+            print "from :%u" % marks.last_note
+
+        for rev in pending_revs:
+            notes.add(rev)
+            c = repo[rev]
+            print "N inline :%u" % rev_to_mark(c)
+            msg = c.hex()
+            print "data %d" % (len(msg))
+            print msg
+        print
+
+        marks.last_note = note_mark
+
     marks.set_tip(ename, head.hex())
 
 def export_tag(repo, tag):
@@ -629,6 +657,7 @@ def do_import(parser):
         print "feature import-marks=%s" % path
     print "feature export-marks=%s" % path
     print "feature force"
+    print "feature notes"
     sys.stdout.flush()
 
     tmp = encoding.encoding
@@ -1126,6 +1155,7 @@ def main(args):
     global filenodes
     global fake_bmark, hg_version
     global dry_run
+    global notes, alias
 
     alias = args[1]
     url = args[2]
@@ -1165,6 +1195,7 @@ def main(args):
     except:
         hg_version = None
     dry_run = False
+    notes = set()
 
     repo = get_repo(url, alias)
     prefix = 'refs/hg/%s' % alias
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-28 19:23 ` [PATCH 1/8] remote-bzr: fix export of utf-8 authors Felipe Contreras
@ 2013-08-28 20:05   ` Matthieu Moy
  2013-08-28 20:48     ` Felipe Contreras
  2013-08-28 20:35   ` Eric Sunshine
  1 sibling, 1 reply; 32+ messages in thread
From: Matthieu Moy @ 2013-08-28 20:05 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git, Antoine Pelisse

Felipe Contreras <felipe.contreras@gmail.com> writes:

> +	echo greg >> content &&
> +	git add content &&
> +	git commit -m one

test_commit would make it shorter.

> +	bzr log | grep "^committer: " > ../actual
> +	) &&
> +
> +	echo "committer: Grégoire <committer@example.com>" > expected &&

Git's source code usually says >../actual and >expected, without space
after '>'.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-28 19:23 ` [PATCH 1/8] remote-bzr: fix export of utf-8 authors Felipe Contreras
  2013-08-28 20:05   ` Matthieu Moy
@ 2013-08-28 20:35   ` Eric Sunshine
  2013-08-28 21:14     ` [PATCH v2] " Felipe Contreras
  1 sibling, 1 reply; 32+ messages in thread
From: Eric Sunshine @ 2013-08-28 20:35 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Git List, Antoine Pelisse

On Wed, Aug 28, 2013 at 3:23 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> Reported-by: Joakim Verona <joakim@verona.se>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  contrib/remote-helpers/git-remote-bzr |  1 +
>  contrib/remote-helpers/test-bzr.sh    | 30 ++++++++++++++++++++++++++++++
>  2 files changed, 31 insertions(+)
>
> diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh
> index dce281f..ef8992a 100755
> --- a/contrib/remote-helpers/test-bzr.sh
> +++ b/contrib/remote-helpers/test-bzr.sh
> @@ -358,4 +358,34 @@ test_expect_success 'strip' '
>         test_cmp expected actual
>  '
>
> +test_expect_success 'export utf-8 authors' '
> +       test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && unset GIT_COMMITTER_NAME" &&
> +
> +       LC_ALL=en_US.UTF-8
> +       export LC_ALL
> +
> +       GIT_COMMITTER_NAME="Grégoire"
> +       export GIT_COMMITTER_NAME
> +
> +       bzr init bzrrepo &&
> +
> +       (
> +       git init gitrepo &&
> +       cd gitrepo &&
> +       echo greg >> content &&
> +       git add content &&
> +       git commit -m one

Broken &&-chain.

> +       git remote add bzr "bzr::../bzrrepo" &&
> +       git push bzr
> +       ) &&
> +
> +       (
> +       cd bzrrepo &&
> +       bzr log | grep "^committer: " > ../actual
> +       ) &&
> +
> +       echo "committer: Grégoire <committer@example.com>" > expected &&
> +       test_cmp expected actual
> +'
> +
>  test_done
> --

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-28 20:05   ` Matthieu Moy
@ 2013-08-28 20:48     ` Felipe Contreras
  2013-08-28 20:54       ` Antoine Pelisse
  2013-08-28 21:05       ` Matthieu Moy
  0 siblings, 2 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 20:48 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git, Antoine Pelisse

On Wed, Aug 28, 2013 at 3:05 PM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> +     echo greg >> content &&
>> +     git add content &&
>> +     git commit -m one
>
> test_commit would make it shorter.

And it would make it inconsistent with the rest of the script.

>> +     bzr log | grep "^committer: " > ../actual
>> +     ) &&
>> +
>> +     echo "committer: Grégoire <committer@example.com>" > expected &&
>
> Git's source code usually says >../actual and >expected, without space
> after '>'.

Not that usually:

% git grep ' > ' t/*.sh | wc -l
1943

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-28 20:48     ` Felipe Contreras
@ 2013-08-28 20:54       ` Antoine Pelisse
  2013-08-28 21:21         ` Felipe Contreras
  2013-08-28 21:05       ` Matthieu Moy
  1 sibling, 1 reply; 32+ messages in thread
From: Antoine Pelisse @ 2013-08-28 20:54 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Matthieu Moy, git

On Wed, Aug 28, 2013 at 10:48 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> On Wed, Aug 28, 2013 at 3:05 PM, Matthieu Moy
> <Matthieu.Moy@grenoble-inp.fr> wrote:
>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>
>>> +     echo greg >> content &&
>>> +     git add content &&
>>> +     git commit -m one
>>
>> test_commit would make it shorter.
>
> And it would make it inconsistent with the rest of the script.
>
>>> +     bzr log | grep "^committer: " > ../actual
>>> +     ) &&
>>> +
>>> +     echo "committer: Grégoire <committer@example.com>" > expected &&
>>
>> Git's source code usually says >../actual and >expected, without space
>> after '>'.
>
> Not that usually:
>
> % git grep ' > ' t/*.sh | wc -l
> 1943

There are many false positive in that count.

As in this one:
$ git grep ' >[^ ]' -- t/*.sh | wc -l
10354

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-28 20:48     ` Felipe Contreras
  2013-08-28 20:54       ` Antoine Pelisse
@ 2013-08-28 21:05       ` Matthieu Moy
  2013-08-28 21:21         ` Felipe Contreras
  2013-08-28 21:58         ` Junio C Hamano
  1 sibling, 2 replies; 32+ messages in thread
From: Matthieu Moy @ 2013-08-28 21:05 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git, Antoine Pelisse

Felipe Contreras <felipe.contreras@gmail.com> writes:

> On Wed, Aug 28, 2013 at 3:05 PM, Matthieu Moy
> <Matthieu.Moy@grenoble-inp.fr> wrote:
>
>>> +     bzr log | grep "^committer: " > ../actual
>>> +     ) &&
>>> +
>>> +     echo "committer: Grégoire <committer@example.com>" > expected &&
>>
>> Git's source code usually says >../actual and >expected, without space
>> after '>'.
>
> Not that usually:
>
> % git grep ' > ' t/*.sh | wc -l
> 1943

Do I really need to quote the paragraph in CodingGuidelines?

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH v2] remote-bzr: fix export of utf-8 authors
  2013-08-28 20:35   ` Eric Sunshine
@ 2013-08-28 21:14     ` Felipe Contreras
  0 siblings, 0 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 21:14 UTC (permalink / raw)
  To: git; +Cc: Antoine Pelisse, Eric Sunshine, Felipe Contreras

Reported-by: Joakim Verona <joakim@verona.se>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr |  1 +
 contrib/remote-helpers/test-bzr.sh    | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index c3a3cac..08b0b61 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -168,6 +168,7 @@ class Parser:
         if not m:
             return None
         _, name, email, date, tz = m.groups()
+        name = name.decode('utf-8')
         committer = '%s <%s>' % (name, email)
         tz = int(tz)
         tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh
index dce281f..b0d70fd 100755
--- a/contrib/remote-helpers/test-bzr.sh
+++ b/contrib/remote-helpers/test-bzr.sh
@@ -358,4 +358,34 @@ test_expect_success 'strip' '
 	test_cmp expected actual
 '
 
+test_expect_success 'export utf-8 authors' '
+	test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && unset GIT_COMMITTER_NAME" &&
+
+	LC_ALL=en_US.UTF-8
+	export LC_ALL
+
+	GIT_COMMITTER_NAME="Grégoire"
+	export GIT_COMMITTER_NAME
+
+	bzr init bzrrepo &&
+
+	(
+	git init gitrepo &&
+	cd gitrepo &&
+	echo greg >> content &&
+	git add content &&
+	git commit -m one &&
+	git remote add bzr "bzr::../bzrrepo" &&
+	git push bzr
+	) &&
+
+	(
+	cd bzrrepo &&
+	bzr log | grep "^committer: " > ../actual
+	) &&
+
+	echo "committer: Grégoire <committer@example.com>" > expected &&
+	test_cmp expected actual
+'
+
 test_done
-- 
1.8.4-fc-3-g64bc480

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-28 20:54       ` Antoine Pelisse
@ 2013-08-28 21:21         ` Felipe Contreras
  2013-08-28 21:38           ` Felipe Contreras
  0 siblings, 1 reply; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 21:21 UTC (permalink / raw)
  To: Antoine Pelisse; +Cc: Matthieu Moy, git

On Wed, Aug 28, 2013 at 3:54 PM, Antoine Pelisse <apelisse@gmail.com> wrote:
> On Wed, Aug 28, 2013 at 10:48 PM, Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
>> On Wed, Aug 28, 2013 at 3:05 PM, Matthieu Moy
>> <Matthieu.Moy@grenoble-inp.fr> wrote:
>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>>
>>>> +     echo greg >> content &&
>>>> +     git add content &&
>>>> +     git commit -m one
>>>
>>> test_commit would make it shorter.
>>
>> And it would make it inconsistent with the rest of the script.
>>
>>>> +     bzr log | grep "^committer: " > ../actual
>>>> +     ) &&
>>>> +
>>>> +     echo "committer: Grégoire <committer@example.com>" > expected &&
>>>
>>> Git's source code usually says >../actual and >expected, without space
>>> after '>'.
>>
>> Not that usually:
>>
>> % git grep ' > ' t/*.sh | wc -l
>> 1943
>
> There are many false positive in that count.
>
> As in this one:
> $ git grep ' >[^ ]' -- t/*.sh | wc -l
> 10354

Ten thousand is still a lot, and the claim remains: it's far from
unusual to follow this style.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-28 21:05       ` Matthieu Moy
@ 2013-08-28 21:21         ` Felipe Contreras
  2013-08-28 21:58         ` Junio C Hamano
  1 sibling, 0 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 21:21 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git, Antoine Pelisse

On Wed, Aug 28, 2013 at 4:05 PM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> On Wed, Aug 28, 2013 at 3:05 PM, Matthieu Moy
>> <Matthieu.Moy@grenoble-inp.fr> wrote:
>>
>>>> +     bzr log | grep "^committer: " > ../actual
>>>> +     ) &&
>>>> +
>>>> +     echo "committer: Grégoire <committer@example.com>" > expected &&
>>>
>>> Git's source code usually says >../actual and >expected, without space
>>> after '>'.
>>
>> Not that usually:
>>
>> % git grep ' > ' t/*.sh | wc -l
>> 1943
>
> Do I really need to quote the paragraph in CodingGuidelines?

Do I need to explain what a guideline is?

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-28 21:21         ` Felipe Contreras
@ 2013-08-28 21:38           ` Felipe Contreras
  0 siblings, 0 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 21:38 UTC (permalink / raw)
  To: Antoine Pelisse; +Cc: Matthieu Moy, git

On Wed, Aug 28, 2013 at 4:21 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> On Wed, Aug 28, 2013 at 3:54 PM, Antoine Pelisse <apelisse@gmail.com> wrote:
>> On Wed, Aug 28, 2013 at 10:48 PM, Felipe Contreras
>> <felipe.contreras@gmail.com> wrote:
>>> On Wed, Aug 28, 2013 at 3:05 PM, Matthieu Moy
>>> <Matthieu.Moy@grenoble-inp.fr> wrote:
>>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>>>
>>>>> +     echo greg >> content &&
>>>>> +     git add content &&
>>>>> +     git commit -m one
>>>>
>>>> test_commit would make it shorter.
>>>
>>> And it would make it inconsistent with the rest of the script.
>>>
>>>>> +     bzr log | grep "^committer: " > ../actual
>>>>> +     ) &&
>>>>> +
>>>>> +     echo "committer: Grégoire <committer@example.com>" > expected &&
>>>>
>>>> Git's source code usually says >../actual and >expected, without space
>>>> after '>'.
>>>
>>> Not that usually:
>>>
>>> % git grep ' > ' t/*.sh | wc -l
>>> 1943
>>
>> There are many false positive in that count.
>>
>> As in this one:
>> $ git grep ' >[^ ]' -- t/*.sh | wc -l
>> 10354
>
> Ten thousand is still a lot, and the claim remains: it's far from
> unusual to follow this style.

Er, I read that command wrong, but whatever the actual number is, the
point is that there's a lot.

In fact, I could only count 43 false positives in that command:

t/annotate-tests.sh:test_expect_success 'blame -L X (X > nlines)' '
t/annotate-tests.sh:test_expect_success 'blame -L ,Y (Y > nlines)' '
t/lib-diff-alternative.sh:    if(n > 1)
t/lib-diff-alternative.sh:    if(n > 2)
t/lib-diff-alternative.sh:+    if(n > 2)
t/lib-diff-alternative.sh:-    if(n > 1)
t/t3800-mktag.sh: > 0 +0000
t/t4041-diff-submodule-option.sh:  > Add foo3 ($added foo3)
t/t4041-diff-submodule-option.sh:  > Add foo3 ($added foo3)
t/t4041-diff-submodule-option.sh:  > Add foo3 ($added foo3)
t/t4041-diff-submodule-option.sh:  > Add foo5 ($added foo5)
t/t4041-diff-submodule-option.sh:  > Add foo4 ($added foo4)
t/t4041-diff-submodule-option.sh:  > change
t/t4041-diff-submodule-option.sh:  > change
t/t4041-diff-submodule-option.sh:  > change
t/t4041-diff-submodule-option.sh:  > change
t/t4041-diff-submodule-option.sh:  > change
t/t4041-diff-submodule-option.sh:  > change
t/t4041-diff-submodule-option.sh:  > change
t/t4041-diff-submodule-option.sh:  > change
t/t7401-submodule-summary.sh:  > Add foo2
t/t7401-submodule-summary.sh:  > Add foo2
t/t7401-submodule-summary.sh:  > Add foo2
t/t7401-submodule-summary.sh:  > Add foo3
t/t7401-submodule-summary.sh:  > Add foo3
t/t7401-submodule-summary.sh:  > Add foo5
t/t7401-submodule-summary.sh:  > Add foo4
t/t7401-submodule-summary.sh:  > Add foo5
t/t7401-submodule-summary.sh:  > Add foo4
t/t7401-submodule-summary.sh:  > Add foo5
t/t7401-submodule-summary.sh:  > Add foo7
t/t7401-submodule-summary.sh:  > Add foo9
t/t7401-submodule-summary.sh:  > Add foo9
t/t7401-submodule-summary.sh:  > Add foo9
t/t7401-submodule-summary.sh:#   > Add foo9
t/t7508-status.sh:#   > Add foo
t/t7508-status.sh:#   > Add foo
t/t7508-status.sh:#   > Add bar
t/t7508-status.sh:#   > Add bar
t/t7508-status.sh:#   > Add bar
t/t7508-status.sh:#   > 2nd commit
t/t7508-status.sh:;   > Add bar
t/t7508-status.sh:;   > 2nd commit

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-28 21:05       ` Matthieu Moy
  2013-08-28 21:21         ` Felipe Contreras
@ 2013-08-28 21:58         ` Junio C Hamano
  2013-08-28 22:25           ` Felipe Contreras
  2013-08-29 21:24           ` Re* " Junio C Hamano
  1 sibling, 2 replies; 32+ messages in thread
From: Junio C Hamano @ 2013-08-28 21:58 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Felipe Contreras, git, Antoine Pelisse

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> On Wed, Aug 28, 2013 at 3:05 PM, Matthieu Moy
>> <Matthieu.Moy@grenoble-inp.fr> wrote:
>>
>>>> +     bzr log | grep "^committer: " > ../actual
>>>> +     ) &&
>>>> +
>>>> +     echo "committer: Grégoire <committer@example.com>" > expected &&
>>>
>>> Git's source code usually says >../actual and >expected, without space
>>> after '>'.
>>
>> Not that usually:
>>
>> % git grep ' > ' t/*.sh | wc -l
>> 1943
>
> Do I really need to quote the paragraph in CodingGuidelines?

Existing violations are not an excuse to make things worse by adding
more.  I think with these comments we can expect a reroll coming,
and it should be trivial for any contributor to fix it while at it.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-28 21:58         ` Junio C Hamano
@ 2013-08-28 22:25           ` Felipe Contreras
  2013-08-29 21:24           ` Re* " Junio C Hamano
  1 sibling, 0 replies; 32+ messages in thread
From: Felipe Contreras @ 2013-08-28 22:25 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthieu Moy, git, Antoine Pelisse

On Wed, Aug 28, 2013 at 4:58 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>
>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>
>>> On Wed, Aug 28, 2013 at 3:05 PM, Matthieu Moy
>>> <Matthieu.Moy@grenoble-inp.fr> wrote:
>>>
>>>>> +     bzr log | grep "^committer: " > ../actual
>>>>> +     ) &&
>>>>> +
>>>>> +     echo "committer: Grégoire <committer@example.com>" > expected &&
>>>>
>>>> Git's source code usually says >../actual and >expected, without space
>>>> after '>'.
>>>
>>> Not that usually:
>>>
>>> % git grep ' > ' t/*.sh | wc -l
>>> 1943
>>
>> Do I really need to quote the paragraph in CodingGuidelines?
>
> Existing violations are not an excuse to make things worse by adding
> more.

1)

By definition following a guideline is not mandatory:
https://en.wikipedia.org/wiki/Guideline

Violation is a too strong word for not following something that is not
mandatory in the first place; deviation is a more appropriate word.

2)

This code is part of the 'contrib' area, and part of the tests, most
of the code in this area doesn't even have tests.

3)

Blindly following guidelines is not a good idea.

cmd >out
cmd >out 2>err
if (n > 1)
cmd1 | cmd2

Clearly, those are inconsistent.

cmd > out
cmd > out 2> err
if (n > 1)
cmd1 | cmd2

Those are not.

Fortunately since these rules are only guidelines, there's no need to
engage in bike-sheding argumentation if the code deviates from
guideline, specially for this insignificantly trivial issue.

Blocking a patch that would be obviously advantageous for the users on
the basis of a single white-space on the tests which aren't even run
by default is simply stupid.

> I think with these comments we can expect a reroll coming,
> and it should be trivial for any contributor to fix it while at it.

I already send the update, I do not see the need for any more changes,
so no more changes will come from me unless there is valid feedback.

If it makes you happier, apply this:

From 7db40fa6b2780f9b5787c7d38f0d2dac01b175d3 Mon Sep 17 00:00:00 2001
From: Felipe Contreras <felipe.contreras@gmail.com>
Date: Sun, 4 Aug 2013 19:27:51 -0500
Subject: [PATCH] remote-bzr: fix export of utf-8 authors

Reported-by: Joakim Verona <joakim@verona.se>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/remote-helpers/git-remote-bzr
b/contrib/remote-helpers/git-remote-bzr
index c3a3cac..08b0b61 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -168,6 +168,7 @@ class Parser:
         if not m:
             return None
         _, name, email, date, tz = m.groups()
+        name = name.decode('utf-8')
         committer = '%s <%s>' % (name, email)
         tz = int(tz)
         tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
-- 
1.8.4-fc-3-g64bc480

There, there is no more test GUIDEline "violation".

-- 
Felipe Contreras

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 8/8] remote-hg: support for notes
  2013-08-28 19:23 ` [PATCH 8/8] remote-hg: support for notes Felipe Contreras
@ 2013-08-29 18:45   ` Junio C Hamano
  2013-08-29 21:50     ` [PATCH] " Felipe Contreras
  0 siblings, 1 reply; 32+ messages in thread
From: Junio C Hamano @ 2013-08-29 18:45 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git, Antoine Pelisse

Felipe Contreras <felipe.contreras@gmail.com> writes:

> @@ -629,6 +657,7 @@ def do_import(parser):
>          print "feature import-marks=%s" % path
>      print "feature export-marks=%s" % path
>      print "feature force"
> +    print "feature notes"

The remaining patches in the series seem reasonable, but this patch
seems to rely on an undefined feature "notes", whose design has not
been discussed here.  Will queue without this one for now.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re* [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-28 21:58         ` Junio C Hamano
  2013-08-28 22:25           ` Felipe Contreras
@ 2013-08-29 21:24           ` Junio C Hamano
  2013-08-29 21:25             ` Junio C Hamano
                               ` (2 more replies)
  1 sibling, 3 replies; 32+ messages in thread
From: Junio C Hamano @ 2013-08-29 21:24 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Felipe Contreras, git, Antoine Pelisse

Junio C Hamano <gitster@pobox.com> writes:

> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>
>> Do I really need to quote the paragraph in CodingGuidelines?
>
> Existing violations are not an excuse to make things worse by adding
> more.  I think with these comments we can expect a reroll coming,
> and it should be trivial for any contributor to fix it while at it.

Actually, I think not fixing it inside that 1/8 is good, as there
are many existing "cmd > file" (and worse, "cmd > file-$x") in these
test-*.sh scripts.  Clean-up is better done as a follow-up patch.

Here are two that I noticed.

-- >8 --
Subject: [PATCH 9/8] contrib/remote-helpers: style updates for test scripts

During the review of the main series it was noticed that these test
scripts can use updates to conform to our coding style better, but
fixing the style should be done in a patch separate from the main
series.

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

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

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

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

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 contrib/remote-helpers/test-bzr.sh       | 112 +++++++++++-----------
 contrib/remote-helpers/test-hg-bidi.sh   |  52 ++++++-----
 contrib/remote-helpers/test-hg-hg-git.sh | 156 +++++++++++++++++--------------
 contrib/remote-helpers/test-hg.sh        | 154 +++++++++++++++---------------
 4 files changed, 248 insertions(+), 226 deletions(-)

diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh
index b0d70fd..5c50251 100755
--- a/contrib/remote-helpers/test-bzr.sh
+++ b/contrib/remote-helpers/test-bzr.sh
@@ -7,19 +7,21 @@ test_description='Test remote-bzr'
 
 . ./test-lib.sh
 
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
 	skip_all='skipping remote-bzr tests; python not available'
 	test_done
 fi
 
-if ! python -c 'import bzrlib'; then
+if ! python -c 'import bzrlib'
+then
 	skip_all='skipping remote-bzr tests; bzr not available'
 	test_done
 fi
 
 check () {
-	echo $3 > expected &&
-	git --git-dir=$1/.git log --format='%s' -1 $2 > actual
+	echo $3 >expected &&
+	git --git-dir=$1/.git log --format='%s' -1 $2 >actual
 	test_cmp expected actual
 }
 
@@ -29,7 +31,7 @@ test_expect_success 'cloning' '
 	(
 	bzr init bzrrepo &&
 	cd bzrrepo &&
-	echo one > content &&
+	echo one >content &&
 	bzr add content &&
 	bzr commit -m one
 	) &&
@@ -41,7 +43,7 @@ test_expect_success 'cloning' '
 test_expect_success 'pulling' '
 	(
 	cd bzrrepo &&
-	echo two > content &&
+	echo two >content &&
 	bzr commit -m two
 	) &&
 
@@ -53,13 +55,13 @@ test_expect_success 'pulling' '
 test_expect_success 'pushing' '
 	(
 	cd gitrepo &&
-	echo three > content &&
+	echo three >content &&
 	git commit -a -m three &&
 	git push
 	) &&
 
-	echo three > expected &&
-	cat bzrrepo/content > actual &&
+	echo three >expected &&
+	cat bzrrepo/content >actual &&
 	test_cmp expected actual
 '
 
@@ -67,16 +69,16 @@ test_expect_success 'roundtrip' '
 	(
 	cd gitrepo &&
 	git pull &&
-	git log --format="%s" -1 origin/master > actual
+	git log --format="%s" -1 origin/master >actual
 	) &&
-	echo three > expected &&
+	echo three >expected &&
 	test_cmp expected actual &&
 
 	(cd gitrepo && git push && git pull) &&
 
 	(
 	cd bzrrepo &&
-	echo four > content &&
+	echo four >content &&
 	bzr commit -m four
 	) &&
 
@@ -86,19 +88,19 @@ test_expect_success 'roundtrip' '
 
 	(
 	cd gitrepo &&
-	echo five > content &&
+	echo five >content &&
 	git commit -a -m five &&
 	git push && git pull
 	) &&
 
 	(cd bzrrepo && bzr revert) &&
 
-	echo five > expected &&
-	cat bzrrepo/content > actual &&
+	echo five >expected &&
+	cat bzrrepo/content >actual &&
 	test_cmp expected actual
 '
 
-cat > expected <<EOF
+cat >expected <<\EOF
 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af	content
 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb	executable
 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea	link
@@ -107,7 +109,7 @@ EOF
 test_expect_success 'special modes' '
 	(
 	cd bzrrepo &&
-	echo exec > executable
+	echo exec >executable
 	chmod +x executable &&
 	bzr add executable
 	bzr commit -m exec &&
@@ -122,21 +124,21 @@ test_expect_success 'special modes' '
 	(
 	cd gitrepo &&
 	git pull
-	git ls-tree HEAD > ../actual
+	git ls-tree HEAD >../actual
 	) &&
 
 	test_cmp expected actual &&
 
 	(
 	cd gitrepo &&
-	git cat-file -p HEAD:link > ../actual
+	git cat-file -p HEAD:link >../actual
 	) &&
 
-	printf content > expected &&
+	printf content >expected &&
 	test_cmp expected actual
 '
 
-cat > expected <<EOF
+cat >expected <<\EOF
 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af	content
 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb	executable
 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea	link
@@ -147,8 +149,8 @@ test_expect_success 'moving directory' '
 	(
 	cd bzrrepo &&
 	mkdir movedir &&
-	echo one > movedir/one &&
-	echo two > movedir/two &&
+	echo one >movedir/one &&
+	echo two >movedir/two &&
 	bzr add movedir &&
 	bzr commit -m movedir &&
 	bzr mv movedir movedir-new &&
@@ -158,7 +160,7 @@ test_expect_success 'moving directory' '
 	(
 	cd gitrepo &&
 	git pull &&
-	git ls-tree HEAD > ../actual
+	git ls-tree HEAD >../actual
 	) &&
 
 	test_cmp expected actual
@@ -167,7 +169,7 @@ test_expect_success 'moving directory' '
 test_expect_success 'different authors' '
 	(
 	cd bzrrepo &&
-	echo john >> content &&
+	echo john >>content &&
 	bzr commit -m john \
 	  --author "Jane Rey <jrey@example.com>" \
 	  --author "John Doe <jdoe@example.com>"
@@ -176,10 +178,10 @@ test_expect_success 'different authors' '
 	(
 	cd gitrepo &&
 	git pull &&
-	git show --format="%an <%ae>, %cn <%ce>" --quiet > ../actual
+	git show --format="%an <%ae>, %cn <%ce>" --quiet >../actual
 	) &&
 
-	echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" > expected &&
+	echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" >expected &&
 	test_cmp expected actual
 '
 
@@ -196,12 +198,12 @@ test_expect_success 'fetch utf-8 filenames' '
 	bzr init bzrrepo &&
 	cd bzrrepo &&
 
-	echo test >> "ærø" &&
+	echo test >>"ærø" &&
 	bzr add "ærø" &&
-	echo test >> "ø~?" &&
+	echo test >>"ø~?" &&
 	bzr add "ø~?" &&
 	bzr commit -m add-utf-8 &&
-	echo test >> "ærø" &&
+	echo test >>"ærø" &&
 	bzr commit -m test-utf-8 &&
 	bzr rm "ø~?" &&
 	bzr mv "ærø" "ø~?" &&
@@ -211,9 +213,9 @@ test_expect_success 'fetch utf-8 filenames' '
 	(
 	git clone "bzr::bzrrepo" gitrepo &&
 	cd gitrepo &&
-	git -c core.quotepath=false ls-files > ../actual
+	git -c core.quotepath=false ls-files >../actual
 	) &&
-	echo "ø~?" > expected &&
+	echo "ø~?" >expected &&
 	test_cmp expected actual
 '
 
@@ -229,7 +231,7 @@ test_expect_success 'push utf-8 filenames' '
 	bzr init bzrrepo &&
 	cd bzrrepo &&
 
-	echo one >> content &&
+	echo one >>content &&
 	bzr add content &&
 	bzr commit -m one
 	) &&
@@ -238,15 +240,15 @@ test_expect_success 'push utf-8 filenames' '
 	git clone "bzr::bzrrepo" gitrepo &&
 	cd gitrepo &&
 
-	echo test >> "ærø" &&
+	echo test >>"ærø" &&
 	git add "ærø" &&
 	git commit -m utf-8 &&
 
 	git push
 	) &&
 
-	(cd bzrrepo && bzr ls > ../actual) &&
-	printf "content\nærø\n" > expected &&
+	(cd bzrrepo && bzr ls >../actual) &&
+	printf "content\nærø\n" >expected &&
 	test_cmp expected actual
 '
 
@@ -256,7 +258,7 @@ test_expect_success 'pushing a merge' '
 	(
 	bzr init bzrrepo &&
 	cd bzrrepo &&
-	echo one > content &&
+	echo one >content &&
 	bzr add content &&
 	bzr commit -m one
 	) &&
@@ -265,27 +267,27 @@ test_expect_success 'pushing a merge' '
 
 	(
 	cd bzrrepo &&
-	echo two > content &&
+	echo two >content &&
 	bzr commit -m two
 	) &&
 
 	(
 	cd gitrepo &&
-	echo three > content &&
+	echo three >content &&
 	git commit -a -m three &&
 	git fetch &&
 	git merge origin/master || true &&
-	echo three > content &&
+	echo three >content &&
 	git commit -a --no-edit &&
 	git push
 	) &&
 
-	echo three > expected &&
-	cat bzrrepo/content > actual &&
+	echo three >expected &&
+	cat bzrrepo/content >actual &&
 	test_cmp expected actual
 '
 
-cat > expected <<EOF
+cat >expected <<\EOF
 origin/HEAD
 origin/branch
 origin/trunk
@@ -299,7 +301,7 @@ test_expect_success 'proper bzr repo' '
 	(
 	bzr init bzrrepo/trunk &&
 	cd bzrrepo/trunk &&
-	echo one >> content &&
+	echo one >>content &&
 	bzr add content &&
 	bzr commit -m one
 	) &&
@@ -307,14 +309,14 @@ test_expect_success 'proper bzr repo' '
 	(
 	bzr branch bzrrepo/trunk bzrrepo/branch &&
 	cd bzrrepo/branch &&
-	echo two >> content &&
+	echo two >>content &&
 	bzr commit -m one
 	) &&
 
 	(
 	git clone "bzr::bzrrepo" gitrepo &&
 	cd gitrepo &&
-	git for-each-ref --format "%(refname:short)" refs/remotes/origin > ../actual
+	git for-each-ref --format "%(refname:short)" refs/remotes/origin >../actual
 	) &&
 
 	test_cmp expected actual
@@ -327,11 +329,11 @@ test_expect_success 'strip' '
 	bzr init bzrrepo &&
 	cd bzrrepo &&
 
-	echo one >> content &&
+	echo one >>content &&
 	bzr add content &&
 	bzr commit -m one &&
 
-	echo two >> content &&
+	echo two >>content &&
 	bzr commit -m two
 	) &&
 
@@ -341,18 +343,18 @@ test_expect_success 'strip' '
 	cd bzrrepo &&
 	bzr uncommit --force &&
 
-	echo three >> content &&
+	echo three >>content &&
 	bzr commit -m three &&
 
-	echo four >> content &&
+	echo four >>content &&
 	bzr commit -m four &&
-	bzr log --line | sed -e "s/^[0-9][0-9]*: //" > ../expected
+	bzr log --line | sed -e "s/^[0-9][0-9]*: //" >../expected
 	) &&
 
 	(
 	cd gitrepo &&
 	git fetch &&
-	git log --format="%an %ad %s" --date=short origin/master > ../actual
+	git log --format="%an %ad %s" --date=short origin/master >../actual
 	) &&
 
 	test_cmp expected actual
@@ -372,7 +374,7 @@ test_expect_success 'export utf-8 authors' '
 	(
 	git init gitrepo &&
 	cd gitrepo &&
-	echo greg >> content &&
+	echo greg >>content &&
 	git add content &&
 	git commit -m one &&
 	git remote add bzr "bzr::../bzrrepo" &&
@@ -381,10 +383,10 @@ test_expect_success 'export utf-8 authors' '
 
 	(
 	cd bzrrepo &&
-	bzr log | grep "^committer: " > ../actual
+	bzr log | grep "^committer: " >../actual
 	) &&
 
-	echo "committer: Grégoire <committer@example.com>" > expected &&
+	echo "committer: Grégoire <committer@example.com>" >expected &&
 	test_cmp expected actual
 '
 
diff --git a/contrib/remote-helpers/test-hg-bidi.sh b/contrib/remote-helpers/test-hg-bidi.sh
index f83d67d..e24c51d 100755
--- a/contrib/remote-helpers/test-hg-bidi.sh
+++ b/contrib/remote-helpers/test-hg-bidi.sh
@@ -10,12 +10,14 @@ test_description='Test bidirectionality of remote-hg'
 
 . ./test-lib.sh
 
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
 	skip_all='skipping remote-hg tests; python not available'
 	test_done
 fi
 
-if ! python -c 'import mercurial'; then
+if ! python -c 'import mercurial'
+then
 	skip_all='skipping remote-hg tests; mercurial not available'
 	test_done
 fi
@@ -43,7 +45,7 @@ hg_push () {
 	git checkout -q -b tmp &&
 	git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
 	git checkout -q @{-1} &&
-	git branch -q -D tmp 2> /dev/null || true
+	git branch -q -D tmp 2>/dev/null || true
 	)
 }
 
@@ -62,7 +64,7 @@ setup () {
 	echo "tag = -d \"0 0\""
 	echo "[extensions]"
 	echo "graphlog ="
-	) >> "$HOME"/.hgrc &&
+	) >>"$HOME"/.hgrc &&
 	git config --global remote-hg.hg-git-compat true
 	git config --global remote-hg.track-branches true
 
@@ -81,22 +83,22 @@ test_expect_success 'encoding' '
 	git init -q gitrepo &&
 	cd gitrepo &&
 
-	echo alpha > alpha &&
+	echo alpha >alpha &&
 	git add alpha &&
 	git commit -m "add älphà" &&
 
 	GIT_AUTHOR_NAME="tést èncödîng" &&
 	export GIT_AUTHOR_NAME &&
-	echo beta > beta &&
+	echo beta >beta &&
 	git add beta &&
 	git commit -m "add beta" &&
 
-	echo gamma > gamma &&
+	echo gamma >gamma &&
 	git add gamma &&
 	git commit -m "add gämmâ" &&
 
 	: TODO git config i18n.commitencoding latin-1 &&
-	echo delta > delta &&
+	echo delta >delta &&
 	git add delta &&
 	git commit -m "add déltà"
 	) &&
@@ -105,8 +107,8 @@ test_expect_success 'encoding' '
 	git_clone hgrepo gitrepo2 &&
 	hg_clone gitrepo2 hgrepo2 &&
 
-	HGENCODING=utf-8 hg_log hgrepo > expected &&
-	HGENCODING=utf-8 hg_log hgrepo2 > actual &&
+	HGENCODING=utf-8 hg_log hgrepo >expected &&
+	HGENCODING=utf-8 hg_log hgrepo2 >actual &&
 
 	test_cmp expected actual
 '
@@ -117,14 +119,14 @@ test_expect_success 'file removal' '
 	(
 	git init -q gitrepo &&
 	cd gitrepo &&
-	echo alpha > alpha &&
+	echo alpha >alpha &&
 	git add alpha &&
 	git commit -m "add alpha" &&
-	echo beta > beta &&
+	echo beta >beta &&
 	git add beta &&
 	git commit -m "add beta"
 	mkdir foo &&
-	echo blah > foo/bar &&
+	echo blah >foo/bar &&
 	git add foo &&
 	git commit -m "add foo" &&
 	git rm alpha &&
@@ -137,8 +139,8 @@ test_expect_success 'file removal' '
 	git_clone hgrepo gitrepo2 &&
 	hg_clone gitrepo2 hgrepo2 &&
 
-	hg_log hgrepo > expected &&
-	hg_log hgrepo2 > actual &&
+	hg_log hgrepo >expected &&
+	hg_log hgrepo2 >actual &&
 
 	test_cmp expected actual
 '
@@ -150,12 +152,12 @@ test_expect_success 'git tags' '
 	git init -q gitrepo &&
 	cd gitrepo &&
 	git config receive.denyCurrentBranch ignore &&
-	echo alpha > alpha &&
+	echo alpha >alpha &&
 	git add alpha &&
 	git commit -m "add alpha" &&
 	git tag alpha &&
 
-	echo beta > beta &&
+	echo beta >beta &&
 	git add beta &&
 	git commit -m "add beta" &&
 	git tag -a -m "added tag beta" beta
@@ -165,8 +167,8 @@ test_expect_success 'git tags' '
 	git_clone hgrepo gitrepo2 &&
 	hg_clone gitrepo2 hgrepo2 &&
 
-	hg_log hgrepo > expected &&
-	hg_log hgrepo2 > actual &&
+	hg_log hgrepo >expected &&
+	hg_log hgrepo2 >actual &&
 
 	test_cmp expected actual
 '
@@ -178,7 +180,7 @@ test_expect_success 'hg branch' '
 	git init -q gitrepo &&
 	cd gitrepo &&
 
-	echo alpha > alpha &&
+	echo alpha >alpha &&
 	git add alpha &&
 	git commit -q -m "add alpha" &&
 	git checkout -q -b not-master
@@ -201,8 +203,8 @@ test_expect_success 'hg branch' '
 	: Back to the common revision &&
 	(cd hgrepo && hg checkout default) &&
 
-	hg_log hgrepo > expected &&
-	hg_log hgrepo2 > actual &&
+	hg_log hgrepo >expected &&
+	hg_log hgrepo2 >actual &&
 
 	test_cmp expected actual
 '
@@ -214,7 +216,7 @@ test_expect_success 'hg tags' '
 	git init -q gitrepo &&
 	cd gitrepo &&
 
-	echo alpha > alpha &&
+	echo alpha >alpha &&
 	git add alpha &&
 	git commit -m "add alpha" &&
 	git checkout -q -b not-master
@@ -231,8 +233,8 @@ test_expect_success 'hg tags' '
 	hg_push hgrepo gitrepo &&
 	hg_clone gitrepo hgrepo2 &&
 
-	hg_log hgrepo > expected &&
-	hg_log hgrepo2 > actual &&
+	hg_log hgrepo >expected &&
+	hg_log hgrepo2 >actual &&
 
 	test_cmp expected actual
 '
diff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh
index 2219284..a5123ca 100755
--- a/contrib/remote-helpers/test-hg-hg-git.sh
+++ b/contrib/remote-helpers/test-hg-hg-git.sh
@@ -10,17 +10,20 @@ test_description='Test remote-hg output compared to hg-git'
 
 . ./test-lib.sh
 
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
 	skip_all='skipping remote-hg tests; python not available'
 	test_done
 fi
 
-if ! python -c 'import mercurial'; then
+if ! python -c 'import mercurial'
+then
 	skip_all='skipping remote-hg tests; mercurial not available'
 	test_done
 fi
 
-if ! python -c 'import hggit'; then
+if ! python -c 'import hggit'
+then
 	skip_all='skipping remote-hg tests; hg-git not available'
 	test_done
 fi
@@ -66,7 +69,7 @@ hg_push_git () {
 	git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
 	git branch -D default &&
 	git checkout -q @{-1} &&
-	git branch -q -D tmp 2> /dev/null || true
+	git branch -q -D tmp 2>/dev/null || true
 	)
 }
 
@@ -100,7 +103,7 @@ setup () {
 	echo "hgext.bookmarks ="
 	echo "hggit ="
 	echo "graphlog ="
-	) >> "$HOME"/.hgrc &&
+	) >>"$HOME"/.hgrc &&
 	git config --global receive.denycurrentbranch warn
 	git config --global remote-hg.hg-git-compat true
 	git config --global remote-hg.track-branches false
@@ -121,7 +124,7 @@ test_expect_success 'executable bit' '
 	(
 	git init -q gitrepo &&
 	cd gitrepo &&
-	echo alpha > alpha &&
+	echo alpha >alpha &&
 	chmod 0644 alpha &&
 	git add alpha &&
 	git commit -m "add alpha" &&
@@ -133,17 +136,18 @@ test_expect_success 'executable bit' '
 	git commit -m "clear executable bit"
 	) &&
 
-	for x in hg git; do
+	for x in hg git
+	do
 		(
 		hg_clone_$x gitrepo hgrepo-$x &&
 		cd hgrepo-$x &&
 		hg_log . &&
 		hg manifest -r 1 -v &&
 		hg manifest -v
-		) > output-$x &&
+		) >output-$x &&
 
 		git_clone_$x hgrepo-$x gitrepo2-$x &&
-		git_log gitrepo2-$x > log-$x
+		git_log gitrepo2-$x >log-$x
 	done &&
 
 	test_cmp output-hg output-git &&
@@ -156,7 +160,7 @@ test_expect_success 'symlink' '
 	(
 	git init -q gitrepo &&
 	cd gitrepo &&
-	echo alpha > alpha &&
+	echo alpha >alpha &&
 	git add alpha &&
 	git commit -m "add alpha" &&
 	ln -s alpha beta &&
@@ -164,16 +168,17 @@ test_expect_success 'symlink' '
 	git commit -m "add beta"
 	) &&
 
-	for x in hg git; do
+	for x in hg git
+	do
 		(
 		hg_clone_$x gitrepo hgrepo-$x &&
 		cd hgrepo-$x &&
 		hg_log . &&
 		hg manifest -v
-		) > output-$x &&
+		) >output-$x &&
 
 		git_clone_$x hgrepo-$x gitrepo2-$x &&
-		git_log gitrepo2-$x > log-$x
+		git_log gitrepo2-$x >log-$x
 	done &&
 
 	test_cmp output-hg output-git &&
@@ -186,28 +191,29 @@ test_expect_success 'merge conflict 1' '
 	(
 	hg init hgrepo1 &&
 	cd hgrepo1 &&
-	echo A > afile &&
+	echo A >afile &&
 	hg add afile &&
 	hg ci -m "origin" &&
 
-	echo B > afile &&
+	echo B >afile &&
 	hg ci -m "A->B" &&
 
 	hg up -r0 &&
-	echo C > afile &&
+	echo C >afile &&
 	hg ci -m "A->C" &&
 
 	hg merge -r1 &&
-	echo C > afile &&
+	echo C >afile &&
 	hg resolve -m afile &&
 	hg ci -m "merge to C"
 	) &&
 
-	for x in hg git; do
+	for x in hg git
+	do
 		git_clone_$x hgrepo1 gitrepo-$x &&
 		hg_clone_$x gitrepo-$x hgrepo2-$x &&
-		hg_log hgrepo2-$x > hg-log-$x &&
-		git_log gitrepo-$x > git-log-$x
+		hg_log hgrepo2-$x >hg-log-$x &&
+		git_log gitrepo-$x >git-log-$x
 	done &&
 
 	test_cmp hg-log-hg hg-log-git &&
@@ -220,28 +226,29 @@ test_expect_success 'merge conflict 2' '
 	(
 	hg init hgrepo1 &&
 	cd hgrepo1 &&
-	echo A > afile &&
+	echo A >afile &&
 	hg add afile &&
 	hg ci -m "origin" &&
 
-	echo B > afile &&
+	echo B >afile &&
 	hg ci -m "A->B" &&
 
 	hg up -r0 &&
-	echo C > afile &&
+	echo C >afile &&
 	hg ci -m "A->C" &&
 
 	hg merge -r1 || true &&
-	echo B > afile &&
+	echo B >afile &&
 	hg resolve -m afile &&
 	hg ci -m "merge to B"
 	) &&
 
-	for x in hg git; do
+	for x in hg git
+	do
 		git_clone_$x hgrepo1 gitrepo-$x &&
 		hg_clone_$x gitrepo-$x hgrepo2-$x &&
-		hg_log hgrepo2-$x > hg-log-$x &&
-		git_log gitrepo-$x > git-log-$x
+		hg_log hgrepo2-$x >hg-log-$x &&
+		git_log gitrepo-$x >git-log-$x
 	done &&
 
 	test_cmp hg-log-hg hg-log-git &&
@@ -254,29 +261,30 @@ test_expect_success 'converged merge' '
 	(
 	hg init hgrepo1 &&
 	cd hgrepo1 &&
-	echo A > afile &&
+	echo A >afile &&
 	hg add afile &&
 	hg ci -m "origin" &&
 
-	echo B > afile &&
+	echo B >afile &&
 	hg ci -m "A->B" &&
 
-	echo C > afile &&
+	echo C >afile &&
 	hg ci -m "B->C" &&
 
 	hg up -r0 &&
-	echo C > afile &&
+	echo C >afile &&
 	hg ci -m "A->C" &&
 
 	hg merge -r2 || true &&
 	hg ci -m "merge"
 	) &&
 
-	for x in hg git; do
+	for x in hg git
+	do
 		git_clone_$x hgrepo1 gitrepo-$x &&
 		hg_clone_$x gitrepo-$x hgrepo2-$x &&
-		hg_log hgrepo2-$x > hg-log-$x &&
-		git_log gitrepo-$x > git-log-$x
+		hg_log hgrepo2-$x >hg-log-$x &&
+		git_log gitrepo-$x >git-log-$x
 	done &&
 
 	test_cmp hg-log-hg hg-log-git &&
@@ -290,32 +298,33 @@ test_expect_success 'encoding' '
 	git init -q gitrepo &&
 	cd gitrepo &&
 
-	echo alpha > alpha &&
+	echo alpha >alpha &&
 	git add alpha &&
 	git commit -m "add älphà" &&
 
 	GIT_AUTHOR_NAME="tést èncödîng" &&
 	export GIT_AUTHOR_NAME &&
-	echo beta > beta &&
+	echo beta >beta &&
 	git add beta &&
 	git commit -m "add beta" &&
 
-	echo gamma > gamma &&
+	echo gamma >gamma &&
 	git add gamma &&
 	git commit -m "add gämmâ" &&
 
 	: TODO git config i18n.commitencoding latin-1 &&
-	echo delta > delta &&
+	echo delta >delta &&
 	git add delta &&
 	git commit -m "add déltà"
 	) &&
 
-	for x in hg git; do
+	for x in hg git
+	do
 		hg_clone_$x gitrepo hgrepo-$x &&
 		git_clone_$x hgrepo-$x gitrepo2-$x &&
 
-		HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
-		git_log gitrepo2-$x > git-log-$x
+		HGENCODING=utf-8 hg_log hgrepo-$x >hg-log-$x &&
+		git_log gitrepo2-$x >git-log-$x
 	done &&
 
 	test_cmp hg-log-hg hg-log-git &&
@@ -328,14 +337,14 @@ test_expect_success 'file removal' '
 	(
 	git init -q gitrepo &&
 	cd gitrepo &&
-	echo alpha > alpha &&
+	echo alpha >alpha &&
 	git add alpha &&
 	git commit -m "add alpha" &&
-	echo beta > beta &&
+	echo beta >beta &&
 	git add beta &&
 	git commit -m "add beta"
 	mkdir foo &&
-	echo blah > foo/bar &&
+	echo blah >foo/bar &&
 	git add foo &&
 	git commit -m "add foo" &&
 	git rm alpha &&
@@ -344,17 +353,18 @@ test_expect_success 'file removal' '
 	git commit -m "remove foo/bar"
 	) &&
 
-	for x in hg git; do
+	for x in hg git
+	do
 		(
 		hg_clone_$x gitrepo hgrepo-$x &&
 		cd hgrepo-$x &&
 		hg_log . &&
 		hg manifest -r 3 &&
 		hg manifest
-		) > output-$x &&
+		) >output-$x &&
 
 		git_clone_$x hgrepo-$x gitrepo2-$x &&
-		git_log gitrepo2-$x > log-$x
+		git_log gitrepo2-$x >log-$x
 	done &&
 
 	test_cmp output-hg output-git &&
@@ -368,20 +378,21 @@ test_expect_success 'git tags' '
 	git init -q gitrepo &&
 	cd gitrepo &&
 	git config receive.denyCurrentBranch ignore &&
-	echo alpha > alpha &&
+	echo alpha >alpha &&
 	git add alpha &&
 	git commit -m "add alpha" &&
 	git tag alpha &&
 
-	echo beta > beta &&
+	echo beta >beta &&
 	git add beta &&
 	git commit -m "add beta" &&
 	git tag -a -m "added tag beta" beta
 	) &&
 
-	for x in hg git; do
+	for x in hg git
+	do
 		hg_clone_$x gitrepo hgrepo-$x &&
-		hg_log hgrepo-$x > log-$x
+		hg_log hgrepo-$x >log-$x
 	done &&
 
 	test_cmp log-hg log-git
@@ -390,12 +401,13 @@ test_expect_success 'git tags' '
 test_expect_success 'hg author' '
 	test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
-	for x in hg git; do
+	for x in hg git
+	do
 		(
 		git init -q gitrepo-$x &&
 		cd gitrepo-$x &&
 
-		echo alpha > alpha &&
+		echo alpha >alpha &&
 		git add alpha &&
 		git commit -m "add alpha" &&
 		git checkout -q -b not-master
@@ -406,38 +418,38 @@ test_expect_success 'hg author' '
 		cd hgrepo-$x &&
 
 		hg co master &&
-		echo beta > beta &&
+		echo beta >beta &&
 		hg add beta &&
 		hg commit -u "test" -m "add beta" &&
 
-		echo gamma >> beta &&
+		echo gamma >>beta &&
 		hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
 
-		echo gamma > gamma &&
+		echo gamma >gamma &&
 		hg add gamma &&
 		hg commit -u "<test@example.com>" -m "add gamma" &&
 
-		echo delta > delta &&
+		echo delta >delta &&
 		hg add delta &&
 		hg commit -u "name<test@example.com>" -m "add delta" &&
 
-		echo epsilon > epsilon &&
+		echo epsilon >epsilon &&
 		hg add epsilon &&
 		hg commit -u "name <test@example.com" -m "add epsilon" &&
 
-		echo zeta > zeta &&
+		echo zeta >zeta &&
 		hg add zeta &&
 		hg commit -u " test " -m "add zeta" &&
 
-		echo eta > eta &&
+		echo eta >eta &&
 		hg add eta &&
 		hg commit -u "test < test@example.com >" -m "add eta" &&
 
-		echo theta > theta &&
+		echo theta >theta &&
 		hg add theta &&
 		hg commit -u "test >test@example.com>" -m "add theta" &&
 
-		echo iota > iota &&
+		echo iota >iota &&
 		hg add iota &&
 		hg commit -u "test <test <at> example <dot> com>" -m "add iota"
 		) &&
@@ -445,8 +457,8 @@ test_expect_success 'hg author' '
 		hg_push_$x hgrepo-$x gitrepo-$x &&
 		hg_clone_$x gitrepo-$x hgrepo2-$x &&
 
-		hg_log hgrepo2-$x > hg-log-$x &&
-		git_log gitrepo-$x > git-log-$x
+		hg_log hgrepo2-$x >hg-log-$x &&
+		git_log gitrepo-$x >git-log-$x
 	done &&
 
 	test_cmp hg-log-hg hg-log-git &&
@@ -456,12 +468,13 @@ test_expect_success 'hg author' '
 test_expect_success 'hg branch' '
 	test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
-	for x in hg git; do
+	for x in hg git
+	do
 		(
 		git init -q gitrepo-$x &&
 		cd gitrepo-$x &&
 
-		echo alpha > alpha &&
+		echo alpha >alpha &&
 		git add alpha &&
 		git commit -q -m "add alpha" &&
 		git checkout -q -b not-master
@@ -481,8 +494,8 @@ test_expect_success 'hg branch' '
 		hg_push_$x hgrepo-$x gitrepo-$x &&
 		hg_clone_$x gitrepo-$x hgrepo2-$x &&
 
-		hg_log hgrepo2-$x > hg-log-$x &&
-		git_log gitrepo-$x > git-log-$x
+		hg_log hgrepo2-$x >hg-log-$x &&
+		git_log gitrepo-$x >git-log-$x
 	done &&
 
 	test_cmp hg-log-hg hg-log-git &&
@@ -492,12 +505,13 @@ test_expect_success 'hg branch' '
 test_expect_success 'hg tags' '
 	test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
-	for x in hg git; do
+	for x in hg git
+	do
 		(
 		git init -q gitrepo-$x &&
 		cd gitrepo-$x &&
 
-		echo alpha > alpha &&
+		echo alpha >alpha &&
 		git add alpha &&
 		git commit -m "add alpha" &&
 		git checkout -q -b not-master
@@ -518,7 +532,7 @@ test_expect_success 'hg tags' '
 		git --git-dir=gitrepo-$x/.git tag -l &&
 		hg_log hgrepo2-$x &&
 		cat hgrepo2-$x/.hgtags
-		) > output-$x
+		) >output-$x
 	done &&
 
 	test_cmp output-hg output-git
diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index 5a6f745..72f745d 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -10,40 +10,44 @@ test_description='Test remote-hg'
 
 . ./test-lib.sh
 
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
 	skip_all='skipping remote-hg tests; python not available'
 	test_done
 fi
 
-if ! python -c 'import mercurial'; then
+if ! python -c 'import mercurial'
+then
 	skip_all='skipping remote-hg tests; mercurial not available'
 	test_done
 fi
 
 check () {
-	echo $3 > expected &&
-	git --git-dir=$1/.git log --format='%s' -1 $2 > actual
+	echo $3 >expected &&
+	git --git-dir=$1/.git log --format='%s' -1 $2 >actual
 	test_cmp expected actual
 }
 
 check_branch () {
-	if [ -n "$3" ]; then
-		echo $3 > expected &&
-		hg -R $1 log -r $2 --template '{desc}\n' > actual &&
+	if test -n "$3"
+	then
+		echo $3 >expected &&
+		hg -R $1 log -r $2 --template '{desc}\n' >actual &&
 		test_cmp expected actual
 	else
-		hg -R $1 branches > out &&
+		hg -R $1 branches >out &&
 		! grep $2 out
 	fi
 }
 
 check_bookmark () {
-	if [ -n "$3" ]; then
-		echo $3 > expected &&
-		hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' > actual &&
+	if test -n "$3"
+	then
+		echo $3 >expected &&
+		hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' >actual &&
 		test_cmp expected actual
 	else
-		hg -R $1 bookmarks > out &&
+		hg -R $1 bookmarks >out &&
 		! grep $2 out
 	fi
 }
@@ -52,7 +56,7 @@ check_push () {
 	local expected_ret=$1 ret=0 ref_ret=0 IFS=':'
 
 	shift
-	git push origin "$@" 2> error
+	git push origin "$@" 2>error
 	ret=$?
 	cat error
 
@@ -92,7 +96,7 @@ setup () {
 	echo "username = H G Wells <wells@example.com>"
 	echo "[extensions]"
 	echo "mq ="
-	) >> "$HOME"/.hgrc &&
+	) >>"$HOME"/.hgrc &&
 
 	GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230" &&
 	GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" &&
@@ -107,7 +111,7 @@ test_expect_success 'cloning' '
 	(
 	hg init hgrepo &&
 	cd hgrepo &&
-	echo zero > content &&
+	echo zero >content &&
 	hg add content &&
 	hg commit -m zero
 	) &&
@@ -122,7 +126,7 @@ test_expect_success 'cloning with branches' '
 	(
 	cd hgrepo &&
 	hg branch next &&
-	echo next > content &&
+	echo next >content &&
 	hg commit -m next
 	) &&
 
@@ -137,7 +141,7 @@ test_expect_success 'cloning with bookmarks' '
 	cd hgrepo &&
 	hg checkout default &&
 	hg bookmark feature-a &&
-	echo feature-a > content &&
+	echo feature-a >content &&
 	hg commit -m feature-a
 	) &&
 
@@ -157,7 +161,7 @@ test_expect_success 'update bookmark' '
 	git clone "hg::hgrepo" gitrepo &&
 	cd gitrepo &&
 	git checkout --quiet devel &&
-	echo devel > content &&
+	echo devel >content &&
 	git commit -a -m devel &&
 	git push --quiet
 	) &&
@@ -172,7 +176,7 @@ test_expect_success 'new bookmark' '
 	git clone "hg::hgrepo" gitrepo &&
 	cd gitrepo &&
 	git checkout --quiet -b feature-b &&
-	echo feature-b > content &&
+	echo feature-b >content &&
 	git commit -a -m feature-b &&
 	git push --quiet origin feature-b
 	) &&
@@ -184,9 +188,9 @@ test_expect_success 'new bookmark' '
 rm -rf hgrepo
 
 author_test () {
-	echo $1 >> content &&
+	echo $1 >>content &&
 	hg commit -u "$2" -m "add $1" &&
-	echo "$3" >> ../expected
+	echo "$3" >>../expected
 }
 
 test_expect_success 'authors' '
@@ -199,7 +203,7 @@ test_expect_success 'authors' '
 	touch content &&
 	hg add content &&
 
-	> ../expected &&
+	>../expected &&
 	author_test alpha "" "H G Wells <wells@example.com>" &&
 	author_test beta "test" "test <unknown>" &&
 	author_test beta "test <test@example.com> (comment)" "test <test@example.com>" &&
@@ -214,7 +218,7 @@ test_expect_success 'authors' '
 	) &&
 
 	git clone "hg::hgrepo" gitrepo &&
-	git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" > actual &&
+	git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" >actual &&
 
 	test_cmp expected actual
 '
@@ -226,11 +230,11 @@ test_expect_success 'strip' '
 	hg init hgrepo &&
 	cd hgrepo &&
 
-	echo one >> content &&
+	echo one >>content &&
 	hg add content &&
 	hg commit -m one &&
 
-	echo two >> content &&
+	echo two >>content &&
 	hg commit -m two
 	) &&
 
@@ -240,20 +244,20 @@ test_expect_success 'strip' '
 	cd hgrepo &&
 	hg strip 1 &&
 
-	echo three >> content &&
+	echo three >>content &&
 	hg commit -m three &&
 
-	echo four >> content &&
+	echo four >>content &&
 	hg commit -m four
 	) &&
 
 	(
 	cd gitrepo &&
 	git fetch &&
-	git log --format="%s" origin/master > ../actual
+	git log --format="%s" origin/master >../actual
 	) &&
 
-	hg -R hgrepo log --template "{desc}\n" > expected &&
+	hg -R hgrepo log --template "{desc}\n" >expected &&
 	test_cmp actual expected
 '
 
@@ -263,18 +267,18 @@ test_expect_success 'remote push with master bookmark' '
 	(
 	hg init hgrepo &&
 	cd hgrepo &&
-	echo zero > content &&
+	echo zero >content &&
 	hg add content &&
 	hg commit -m zero &&
 	hg bookmark master &&
-	echo one > content &&
+	echo one >content &&
 	hg commit -m one
 	) &&
 
 	(
 	git clone "hg::hgrepo" gitrepo &&
 	cd gitrepo &&
-	echo two > content &&
+	echo two >content &&
 	git commit -a -m two &&
 	git push
 	) &&
@@ -282,7 +286,7 @@ test_expect_success 'remote push with master bookmark' '
 	check_branch hgrepo default two
 '
 
-cat > expected <<EOF
+cat >expected <<\EOF
 changeset:   0:6e2126489d3d
 tag:         tip
 user:        A U Thor <author@example.com>
@@ -300,13 +304,13 @@ test_expect_success 'remote push from master branch' '
 	git init gitrepo &&
 	cd gitrepo &&
 	git remote add origin "hg::../hgrepo" &&
-	echo one > content &&
+	echo one >content &&
 	git add content &&
 	git commit -a -m one &&
 	git push origin master
 	) &&
 
-	hg -R hgrepo log > actual &&
+	hg -R hgrepo log >actual &&
 	cat actual &&
 	test_cmp expected actual &&
 
@@ -322,7 +326,7 @@ test_expect_success 'remote cloning' '
 	(
 	hg init hgrepo &&
 	cd hgrepo &&
-	echo zero > content &&
+	echo zero >content &&
 	hg add content &&
 	hg commit -m zero
 	) &&
@@ -343,7 +347,7 @@ test_expect_success 'remote update bookmark' '
 	git clone "hg::hgrepo" gitrepo &&
 	cd gitrepo &&
 	git checkout --quiet devel &&
-	echo devel > content &&
+	echo devel >content &&
 	git commit -a -m devel &&
 	git push --quiet
 	) &&
@@ -358,7 +362,7 @@ test_expect_success 'remote new bookmark' '
 	git clone "hg::hgrepo" gitrepo &&
 	cd gitrepo &&
 	git checkout --quiet -b feature-b &&
-	echo feature-b > content &&
+	echo feature-b >content &&
 	git commit -a -m feature-b &&
 	git push --quiet origin feature-b
 	) &&
@@ -374,15 +378,15 @@ test_expect_success 'remote push diverged' '
 	(
 	cd hgrepo &&
 	hg checkout default &&
-	echo bump > content &&
+	echo bump >content &&
 	hg commit -m bump
 	) &&
 
 	(
 	cd gitrepo &&
-	echo diverge > content &&
+	echo diverge >content &&
 	git commit -a -m diverged &&
-	check_push 1 <<-EOF
+	check_push 1 <<-\EOF
 	master:non-fast-forward
 	EOF
 	) &&
@@ -403,16 +407,16 @@ test_expect_success 'remote update bookmark diverge' '
 
 	(
 	cd hgrepo &&
-	echo "bump bookmark" > content &&
+	echo "bump bookmark" >content &&
 	hg commit -m "bump bookmark"
 	) &&
 
 	(
 	cd gitrepo &&
 	git checkout --quiet diverge &&
-	echo diverge > content &&
+	echo diverge >content &&
 	git commit -a -m diverge &&
-	check_push 1 <<-EOF
+	check_push 1 <<-\EOF
 	diverge:fetch-first
 	EOF
 	) &&
@@ -427,7 +431,7 @@ test_expect_success 'remote new bookmark multiple branch head' '
 	git clone "hg::hgrepo" gitrepo &&
 	cd gitrepo &&
 	git checkout --quiet -b feature-c HEAD^ &&
-	echo feature-c > content &&
+	echo feature-c >content &&
 	git commit -a -m feature-c &&
 	git push --quiet origin feature-c
 	) &&
@@ -442,20 +446,20 @@ setup_big_push () {
 	(
 	hg init hgrepo &&
 	cd hgrepo &&
-	echo zero > content &&
+	echo zero >content &&
 	hg add content &&
 	hg commit -m zero &&
 	hg bookmark bad_bmark1 &&
-	echo one > content &&
+	echo one >content &&
 	hg commit -m one &&
 	hg bookmark bad_bmark2 &&
 	hg bookmark good_bmark &&
 	hg bookmark -i good_bmark &&
 	hg -q branch good_branch &&
-	echo "good branch" > content &&
+	echo "good branch" >content &&
 	hg commit -m "good branch" &&
 	hg -q branch bad_branch &&
-	echo "bad branch" > content &&
+	echo "bad branch" >content &&
 	hg commit -m "bad branch"
 	) &&
 
@@ -463,40 +467,40 @@ setup_big_push () {
 
 	(
 	cd gitrepo &&
-	echo two > content &&
+	echo two >content &&
 	git commit -q -a -m two &&
 
 	git checkout -q good_bmark &&
-	echo three > content &&
+	echo three >content &&
 	git commit -q -a -m three &&
 
 	git checkout -q bad_bmark1 &&
 	git reset --hard HEAD^ &&
-	echo four > content &&
+	echo four >content &&
 	git commit -q -a -m four &&
 
 	git checkout -q bad_bmark2 &&
 	git reset --hard HEAD^ &&
-	echo five > content &&
+	echo five >content &&
 	git commit -q -a -m five &&
 
 	git checkout -q -b new_bmark master &&
-	echo six > content &&
+	echo six >content &&
 	git commit -q -a -m six &&
 
 	git checkout -q branches/good_branch &&
-	echo seven > content &&
+	echo seven >content &&
 	git commit -q -a -m seven &&
-	echo eight > content &&
+	echo eight >content &&
 	git commit -q -a -m eight &&
 
 	git checkout -q branches/bad_branch &&
 	git reset --hard HEAD^ &&
-	echo nine > content &&
+	echo nine >content &&
 	git commit -q -a -m nine &&
 
 	git checkout -q -b branches/new_branch master &&
-	echo ten > content &&
+	echo ten >content &&
 	git commit -q -a -m ten
 	)
 }
@@ -509,7 +513,7 @@ test_expect_success 'remote big push' '
 	(
 	cd gitrepo &&
 
-	check_push 1 --all <<-EOF
+	check_push 1 --all <<-\EOF
 	master
 	good_bmark
 	branches/good_branch
@@ -537,17 +541,17 @@ test_expect_success 'remote big push fetch first' '
 	(
 	hg init hgrepo &&
 	cd hgrepo &&
-	echo zero > content &&
+	echo zero >content &&
 	hg add content &&
 	hg commit -m zero &&
 	hg bookmark bad_bmark &&
 	hg bookmark good_bmark &&
 	hg bookmark -i good_bmark &&
 	hg -q branch good_branch &&
-	echo "good branch" > content &&
+	echo "good branch" >content &&
 	hg commit -m "good branch" &&
 	hg -q branch bad_branch &&
-	echo "bad branch" > content &&
+	echo "bad branch" >content &&
 	hg commit -m "bad branch"
 	) &&
 
@@ -556,28 +560,28 @@ test_expect_success 'remote big push fetch first' '
 	(
 	cd hgrepo &&
 	hg bookmark -f bad_bmark &&
-	echo update_bmark > content &&
+	echo update_bmark >content &&
 	hg commit -m "update bmark"
 	) &&
 
 	(
 	cd gitrepo &&
-	echo two > content &&
+	echo two >content &&
 	git commit -q -a -m two &&
 
 	git checkout -q good_bmark &&
-	echo three > content &&
+	echo three >content &&
 	git commit -q -a -m three &&
 
 	git checkout -q bad_bmark &&
-	echo four > content &&
+	echo four >content &&
 	git commit -q -a -m four &&
 
 	git checkout -q branches/bad_branch &&
-	echo five > content &&
+	echo five >content &&
 	git commit -q -a -m five &&
 
-	check_push 1 --all <<-EOF &&
+	check_push 1 --all <<-\EOF &&
 	master
 	good_bmark
 	bad_bmark:fetch-first
@@ -586,7 +590,7 @@ test_expect_success 'remote big push fetch first' '
 
 	git fetch &&
 
-	check_push 1 --all <<-EOF
+	check_push 1 --all <<-\EOF
 	master
 	good_bmark
 	bad_bmark:non-fast-forward
@@ -603,7 +607,7 @@ test_expect_failure 'remote big push force' '
 	(
 	cd gitrepo &&
 
-	check_push 0 --force --all <<-EOF
+	check_push 0 --force --all <<-\EOF
 	master
 	good_bmark
 	branches/good_branch
@@ -633,7 +637,7 @@ test_expect_failure 'remote big push dry-run' '
 	(
 	cd gitrepo &&
 
-	check_push 1 --dry-run --all <<-EOF &&
+	check_push 1 --dry-run --all <<-\EOF &&
 	master
 	good_bmark
 	branches/good_branch
@@ -644,7 +648,7 @@ test_expect_failure 'remote big push dry-run' '
 	branches/bad_branch:non-fast-forward
 	EOF
 
-	check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-EOF
+	check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-\EOF
 	master
 	good_bmark
 	branches/good_branch
@@ -669,10 +673,10 @@ test_expect_success 'remote double failed push' '
 	(
 	hg init hgrepo &&
 	cd hgrepo &&
-	echo zero > content &&
+	echo zero >content &&
 	hg add content &&
 	hg commit -m zero &&
-	echo one > content &&
+	echo one >content &&
 	hg commit -m one
 	) &&
 
@@ -680,7 +684,7 @@ test_expect_success 'remote double failed push' '
 	git clone "hg::hgrepo" gitrepo &&
 	cd gitrepo &&
 	git reset --hard HEAD^ &&
-	echo two > content &&
+	echo two >content &&
 	git commit -a -m two &&
 	test_expect_code 1 git push &&
 	test_expect_code 1 git push
-- 
1.8.4-335-g2c126a6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: Re* [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-29 21:24           ` Re* " Junio C Hamano
@ 2013-08-29 21:25             ` Junio C Hamano
  2013-09-01  4:09               ` Michael Haggerty
  2013-08-29 21:28             ` Antoine Pelisse
  2013-09-01  4:03             ` Michael Haggerty
  2 siblings, 1 reply; 32+ messages in thread
From: Junio C Hamano @ 2013-08-29 21:25 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Felipe Contreras, git, Antoine Pelisse

Junio C Hamano <gitster@pobox.com> writes:

> Actually, I think not fixing it inside that 1/8 is good, as there
> are many existing "cmd > file" (and worse, "cmd > file-$x") in these
> test-*.sh scripts.  Clean-up is better done as a follow-up patch.
>
> Here are two that I noticed.
>
> -- >8 --
> Subject: [PATCH 9/8] contrib/remote-helpers: style updates for test scripts

And here is the second one.

-- >8 --
Subject: [PATCH 10/8] remote-helpers: quote variable references in redirection targets

Even though it is not required by POSIX to double-quote the
redirection target in a variable, our code does so because some
versions of bash issue a warning without the quotes.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 contrib/remote-helpers/test-hg-hg-git.sh | 40 ++++++++++++++++----------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh
index a5123ca..6dcd95d 100755
--- a/contrib/remote-helpers/test-hg-hg-git.sh
+++ b/contrib/remote-helpers/test-hg-hg-git.sh
@@ -144,10 +144,10 @@ test_expect_success 'executable bit' '
 		hg_log . &&
 		hg manifest -r 1 -v &&
 		hg manifest -v
-		) >output-$x &&
+		) >"output-$x" &&
 
 		git_clone_$x hgrepo-$x gitrepo2-$x &&
-		git_log gitrepo2-$x >log-$x
+		git_log gitrepo2-$x >"log-$x"
 	done &&
 
 	test_cmp output-hg output-git &&
@@ -175,10 +175,10 @@ test_expect_success 'symlink' '
 		cd hgrepo-$x &&
 		hg_log . &&
 		hg manifest -v
-		) >output-$x &&
+		) >"output-$x" &&
 
 		git_clone_$x hgrepo-$x gitrepo2-$x &&
-		git_log gitrepo2-$x >log-$x
+		git_log gitrepo2-$x >"log-$x"
 	done &&
 
 	test_cmp output-hg output-git &&
@@ -212,8 +212,8 @@ test_expect_success 'merge conflict 1' '
 	do
 		git_clone_$x hgrepo1 gitrepo-$x &&
 		hg_clone_$x gitrepo-$x hgrepo2-$x &&
-		hg_log hgrepo2-$x >hg-log-$x &&
-		git_log gitrepo-$x >git-log-$x
+		hg_log hgrepo2-$x >"hg-log-$x" &&
+		git_log gitrepo-$x >"git-log-$x"
 	done &&
 
 	test_cmp hg-log-hg hg-log-git &&
@@ -247,8 +247,8 @@ test_expect_success 'merge conflict 2' '
 	do
 		git_clone_$x hgrepo1 gitrepo-$x &&
 		hg_clone_$x gitrepo-$x hgrepo2-$x &&
-		hg_log hgrepo2-$x >hg-log-$x &&
-		git_log gitrepo-$x >git-log-$x
+		hg_log hgrepo2-$x >"hg-log-$x" &&
+		git_log gitrepo-$x >"git-log-$x"
 	done &&
 
 	test_cmp hg-log-hg hg-log-git &&
@@ -283,8 +283,8 @@ test_expect_success 'converged merge' '
 	do
 		git_clone_$x hgrepo1 gitrepo-$x &&
 		hg_clone_$x gitrepo-$x hgrepo2-$x &&
-		hg_log hgrepo2-$x >hg-log-$x &&
-		git_log gitrepo-$x >git-log-$x
+		hg_log hgrepo2-$x >"hg-log-$x" &&
+		git_log gitrepo-$x >"git-log-$x"
 	done &&
 
 	test_cmp hg-log-hg hg-log-git &&
@@ -323,8 +323,8 @@ test_expect_success 'encoding' '
 		hg_clone_$x gitrepo hgrepo-$x &&
 		git_clone_$x hgrepo-$x gitrepo2-$x &&
 
-		HGENCODING=utf-8 hg_log hgrepo-$x >hg-log-$x &&
-		git_log gitrepo2-$x >git-log-$x
+		HGENCODING=utf-8 hg_log hgrepo-$x >"hg-log-$x" &&
+		git_log gitrepo2-$x >"git-log-$x"
 	done &&
 
 	test_cmp hg-log-hg hg-log-git &&
@@ -361,10 +361,10 @@ test_expect_success 'file removal' '
 		hg_log . &&
 		hg manifest -r 3 &&
 		hg manifest
-		) >output-$x &&
+		) >"output-$x" &&
 
 		git_clone_$x hgrepo-$x gitrepo2-$x &&
-		git_log gitrepo2-$x >log-$x
+		git_log gitrepo2-$x >"log-$x"
 	done &&
 
 	test_cmp output-hg output-git &&
@@ -392,7 +392,7 @@ test_expect_success 'git tags' '
 	for x in hg git
 	do
 		hg_clone_$x gitrepo hgrepo-$x &&
-		hg_log hgrepo-$x >log-$x
+		hg_log hgrepo-$x >"log-$x"
 	done &&
 
 	test_cmp log-hg log-git
@@ -457,8 +457,8 @@ test_expect_success 'hg author' '
 		hg_push_$x hgrepo-$x gitrepo-$x &&
 		hg_clone_$x gitrepo-$x hgrepo2-$x &&
 
-		hg_log hgrepo2-$x >hg-log-$x &&
-		git_log gitrepo-$x >git-log-$x
+		hg_log hgrepo2-$x >"hg-log-$x" &&
+		git_log gitrepo-$x >"git-log-$x"
 	done &&
 
 	test_cmp hg-log-hg hg-log-git &&
@@ -494,8 +494,8 @@ test_expect_success 'hg branch' '
 		hg_push_$x hgrepo-$x gitrepo-$x &&
 		hg_clone_$x gitrepo-$x hgrepo2-$x &&
 
-		hg_log hgrepo2-$x >hg-log-$x &&
-		git_log gitrepo-$x >git-log-$x
+		hg_log hgrepo2-$x >"hg-log-$x" &&
+		git_log gitrepo-$x >"git-log-$x"
 	done &&
 
 	test_cmp hg-log-hg hg-log-git &&
@@ -532,7 +532,7 @@ test_expect_success 'hg tags' '
 		git --git-dir=gitrepo-$x/.git tag -l &&
 		hg_log hgrepo2-$x &&
 		cat hgrepo2-$x/.hgtags
-		) >output-$x
+		) >"output-$x"
 	done &&
 
 	test_cmp output-hg output-git
-- 
1.8.4-335-g2c126a6

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: Re* [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-29 21:24           ` Re* " Junio C Hamano
  2013-08-29 21:25             ` Junio C Hamano
@ 2013-08-29 21:28             ` Antoine Pelisse
  2013-08-29 21:42               ` Junio C Hamano
  2013-09-01  4:03             ` Michael Haggerty
  2 siblings, 1 reply; 32+ messages in thread
From: Antoine Pelisse @ 2013-08-29 21:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthieu Moy, Felipe Contreras, git

On Thu, Aug 29, 2013 at 11:24 PM, Junio C Hamano <gitster@pobox.com> wrote:
> -- >8 --
> Subject: [PATCH 9/8] contrib/remote-helpers: style updates for test scripts
>
> During the review of the main series it was noticed that these test
> scripts can use updates to conform to our coding style better, but
> fixing the style should be done in a patch separate from the main
> series.
>
> This updates the test-*.sh scripts only for styles:
>
>  * We do not leave SP between a redirection operator and the
>    filename;
>
>  * We change line before "then", "do", etc. rather than terminating
>    the condition for "if"/"while" and list for "for" with a
>    semicolon;
>
>  * When HERE document does not use any expansion, we quote the end
>    marker (e.g. "cat <<\EOF" not "cat <<EOF") to signal the readers
>    that there is no funny substitution to worry about when reading
>    the code.

May I ask what pattern you used to replace all these or if you went
through manually ?

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Re* [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-29 21:28             ` Antoine Pelisse
@ 2013-08-29 21:42               ` Junio C Hamano
  2013-08-29 21:44                 ` Junio C Hamano
  0 siblings, 1 reply; 32+ messages in thread
From: Junio C Hamano @ 2013-08-29 21:42 UTC (permalink / raw)
  To: Antoine Pelisse; +Cc: Matthieu Moy, Felipe Contreras, git

Antoine Pelisse <apelisse@gmail.com> writes:

> On Thu, Aug 29, 2013 at 11:24 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> -- >8 --
>> Subject: [PATCH 9/8] contrib/remote-helpers: style updates for test scripts
>>
>> During the review of the main series it was noticed that these test
>> scripts can use updates to conform to our coding style better, but
>> fixing the style should be done in a patch separate from the main
>> series.
>>
>> This updates the test-*.sh scripts only for styles:
>>
>>  * We do not leave SP between a redirection operator and the
>>    filename;
>>
>>  * We change line before "then", "do", etc. rather than terminating
>>    the condition for "if"/"while" and list for "for" with a
>>    semicolon;
>>
>>  * When HERE document does not use any expansion, we quote the end
>>    marker (e.g. "cat <<\EOF" not "cat <<EOF") to signal the readers
>>    that there is no funny substitution to worry about when reading
>>    the code.
>
> May I ask what pattern you used to replace all these or if you went
> through manually ?

"M-x query-replace" from "> " to ">" with manual inspection. I never
use full automation myself, as I do not trust that I am careful
enough and it is prone to unexpected changes that I can easily miss.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Re* [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-29 21:42               ` Junio C Hamano
@ 2013-08-29 21:44                 ` Junio C Hamano
  0 siblings, 0 replies; 32+ messages in thread
From: Junio C Hamano @ 2013-08-29 21:44 UTC (permalink / raw)
  To: Antoine Pelisse; +Cc: Matthieu Moy, Felipe Contreras, git

Junio C Hamano <gitster@pobox.com> writes:

>> May I ask what pattern you used to replace all these or if you went
>> through manually ?
>
> "M-x query-replace" from "> " to ">" with manual inspection. I never
> use full automation myself, as I do not trust that I am careful
> enough and it is prone to unexpected changes that I can easily miss.

... I forgot to add:

    An extra pair of eyeballs to make sure I didn't make stupid
    misconversions is greatly appreciated.

Thanks.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH] remote-hg: support for notes
  2013-08-29 18:45   ` Junio C Hamano
@ 2013-08-29 21:50     ` Felipe Contreras
  2013-08-29 22:12       ` Junio C Hamano
  0 siblings, 1 reply; 32+ messages in thread
From: Felipe Contreras @ 2013-08-29 21:50 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-hg | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 307d82c..e49fcfa 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -23,6 +23,7 @@ import subprocess
 import urllib
 import atexit
 import urlparse, hashlib
+import time as ptime
 
 #
 # If you are not in hg-git-compat mode and want to disable the tracking of
@@ -126,6 +127,7 @@ class Marks:
         self.rev_marks = {}
         self.last_mark = 0
         self.version = 0
+        self.last_note = 0
 
     def load(self):
         if not os.path.exists(self.path):
@@ -137,6 +139,7 @@ class Marks:
         self.marks = tmp['marks']
         self.last_mark = tmp['last-mark']
         self.version = tmp.get('version', 1)
+        self.last_note = tmp.get('last-note', 0)
 
         for rev, mark in self.marks.iteritems():
             self.rev_marks[mark] = rev
@@ -150,7 +153,7 @@ class Marks:
         self.version = 2
 
     def dict(self):
-        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version }
+        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version, 'last-note' : self.last_note }
 
     def store(self):
         json.dump(self.dict(), open(self.path, 'w'))
@@ -525,6 +528,31 @@ def export_ref(repo, name, kind, head):
     print "from :%u" % rev_to_mark(head)
     print
 
+    pending_revs = set(revs) - notes
+    if pending_revs:
+        note_mark = marks.next_mark()
+        ref = "refs/notes/hg"
+
+        print "commit %s" % ref
+        print "mark :%d" % (note_mark)
+        print "committer remote-hg <> %s" % (ptime.strftime('%s %z'))
+        desc = "Notes for %s\n" % (name)
+        print "data %d" % (len(desc))
+        print desc
+        if marks.last_note:
+            print "from :%u" % marks.last_note
+
+        for rev in pending_revs:
+            notes.add(rev)
+            c = repo[rev]
+            print "N inline :%u" % rev_to_mark(c)
+            msg = c.hex()
+            print "data %d" % (len(msg))
+            print msg
+        print
+
+        marks.last_note = note_mark
+
     marks.set_tip(ename, head.hex())
 
 def export_tag(repo, tag):
@@ -1126,6 +1154,7 @@ def main(args):
     global filenodes
     global fake_bmark, hg_version
     global dry_run
+    global notes, alias
 
     alias = args[1]
     url = args[2]
@@ -1165,6 +1194,7 @@ def main(args):
     except:
         hg_version = None
     dry_run = False
+    notes = set()
 
     repo = get_repo(url, alias)
     prefix = 'refs/hg/%s' % alias
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH] remote-hg: support for notes
  2013-08-29 21:50     ` [PATCH] " Felipe Contreras
@ 2013-08-29 22:12       ` Junio C Hamano
  2013-08-29 22:29         ` [PATCH v3] " Felipe Contreras
  0 siblings, 1 reply; 32+ messages in thread
From: Junio C Hamano @ 2013-08-29 22:12 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git

Felipe Contreras <felipe.contreras@gmail.com> writes:

> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---

I somehow find this way under-explained to be useful for its users.

Is it clear what "support for notes" means in the context of
remote-hg?  Do we send data stored in our notes when we push back to
Hg?  Does Hg have a mechanism to store additional data out of band,
and we add notes when we pull from Hg?  Or does this "support" do
something else, and if so what does it do?

>  contrib/remote-helpers/git-remote-hg | 32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
> index 307d82c..e49fcfa 100755
> --- a/contrib/remote-helpers/git-remote-hg
> +++ b/contrib/remote-helpers/git-remote-hg
> @@ -23,6 +23,7 @@ import subprocess
>  import urllib
>  import atexit
>  import urlparse, hashlib
> +import time as ptime
>  
>  #
>  # If you are not in hg-git-compat mode and want to disable the tracking of
> @@ -126,6 +127,7 @@ class Marks:
>          self.rev_marks = {}
>          self.last_mark = 0
>          self.version = 0
> +        self.last_note = 0
>  
>      def load(self):
>          if not os.path.exists(self.path):
> @@ -137,6 +139,7 @@ class Marks:
>          self.marks = tmp['marks']
>          self.last_mark = tmp['last-mark']
>          self.version = tmp.get('version', 1)
> +        self.last_note = tmp.get('last-note', 0)
>  
>          for rev, mark in self.marks.iteritems():
>              self.rev_marks[mark] = rev
> @@ -150,7 +153,7 @@ class Marks:
>          self.version = 2
>  
>      def dict(self):
> -        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version }
> +        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version, 'last-note' : self.last_note }
>  
>      def store(self):
>          json.dump(self.dict(), open(self.path, 'w'))
> @@ -525,6 +528,31 @@ def export_ref(repo, name, kind, head):
>      print "from :%u" % rev_to_mark(head)
>      print
>  
> +    pending_revs = set(revs) - notes
> +    if pending_revs:
> +        note_mark = marks.next_mark()
> +        ref = "refs/notes/hg"
> +
> +        print "commit %s" % ref
> +        print "mark :%d" % (note_mark)
> +        print "committer remote-hg <> %s" % (ptime.strftime('%s %z'))
> +        desc = "Notes for %s\n" % (name)
> +        print "data %d" % (len(desc))
> +        print desc
> +        if marks.last_note:
> +            print "from :%u" % marks.last_note
> +
> +        for rev in pending_revs:
> +            notes.add(rev)
> +            c = repo[rev]
> +            print "N inline :%u" % rev_to_mark(c)
> +            msg = c.hex()
> +            print "data %d" % (len(msg))
> +            print msg
> +        print
> +
> +        marks.last_note = note_mark
> +
>      marks.set_tip(ename, head.hex())
>  
>  def export_tag(repo, tag):
> @@ -1126,6 +1154,7 @@ def main(args):
>      global filenodes
>      global fake_bmark, hg_version
>      global dry_run
> +    global notes, alias
>  
>      alias = args[1]
>      url = args[2]
> @@ -1165,6 +1194,7 @@ def main(args):
>      except:
>          hg_version = None
>      dry_run = False
> +    notes = set()
>  
>      repo = get_repo(url, alias)
>      prefix = 'refs/hg/%s' % alias

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH v3] remote-hg: support for notes
  2013-08-29 22:12       ` Junio C Hamano
@ 2013-08-29 22:29         ` Felipe Contreras
  2013-08-29 22:49           ` Junio C Hamano
  0 siblings, 1 reply; 32+ messages in thread
From: Felipe Contreras @ 2013-08-29 22:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Felipe Contreras

Keep track of Mercurial revisions as Git notes under the 'refs/notes/hg'
ref, this way, the user can easily see which Mercurial revision
correspond to certain Git commit.

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

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-hg | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 307d82c..7f50b40 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -23,8 +23,12 @@ import subprocess
 import urllib
 import atexit
 import urlparse, hashlib
+import time as ptime
 
 #
+# If you want to see Mercurial revisions as Git commit notes:
+# git config core.notesRef refs/notes/hg
+#
 # If you are not in hg-git-compat mode and want to disable the tracking of
 # named branches:
 # git config --global remote-hg.track-branches false
@@ -126,6 +130,7 @@ class Marks:
         self.rev_marks = {}
         self.last_mark = 0
         self.version = 0
+        self.last_note = 0
 
     def load(self):
         if not os.path.exists(self.path):
@@ -137,6 +142,7 @@ class Marks:
         self.marks = tmp['marks']
         self.last_mark = tmp['last-mark']
         self.version = tmp.get('version', 1)
+        self.last_note = tmp.get('last-note', 0)
 
         for rev, mark in self.marks.iteritems():
             self.rev_marks[mark] = rev
@@ -150,7 +156,7 @@ class Marks:
         self.version = 2
 
     def dict(self):
-        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version }
+        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version, 'last-note' : self.last_note }
 
     def store(self):
         json.dump(self.dict(), open(self.path, 'w'))
@@ -525,6 +531,31 @@ def export_ref(repo, name, kind, head):
     print "from :%u" % rev_to_mark(head)
     print
 
+    pending_revs = set(revs) - notes
+    if pending_revs:
+        note_mark = marks.next_mark()
+        ref = "refs/notes/hg"
+
+        print "commit %s" % ref
+        print "mark :%d" % (note_mark)
+        print "committer remote-hg <> %s" % (ptime.strftime('%s %z'))
+        desc = "Notes for %s\n" % (name)
+        print "data %d" % (len(desc))
+        print desc
+        if marks.last_note:
+            print "from :%u" % marks.last_note
+
+        for rev in pending_revs:
+            notes.add(rev)
+            c = repo[rev]
+            print "N inline :%u" % rev_to_mark(c)
+            msg = c.hex()
+            print "data %d" % (len(msg))
+            print msg
+        print
+
+        marks.last_note = note_mark
+
     marks.set_tip(ename, head.hex())
 
 def export_tag(repo, tag):
@@ -1126,6 +1157,7 @@ def main(args):
     global filenodes
     global fake_bmark, hg_version
     global dry_run
+    global notes, alias
 
     alias = args[1]
     url = args[2]
@@ -1165,6 +1197,7 @@ def main(args):
     except:
         hg_version = None
     dry_run = False
+    notes = set()
 
     repo = get_repo(url, alias)
     prefix = 'refs/hg/%s' % alias
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH v3] remote-hg: support for notes
  2013-08-29 22:29         ` [PATCH v3] " Felipe Contreras
@ 2013-08-29 22:49           ` Junio C Hamano
  0 siblings, 0 replies; 32+ messages in thread
From: Junio C Hamano @ 2013-08-29 22:49 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git

Felipe Contreras <felipe.contreras@gmail.com> writes:

> Keep track of Mercurial revisions as Git notes under the 'refs/notes/hg'
> ref, this way, the user can easily see which Mercurial revision
> correspond to certain Git commit.
>
> Unfortunately, there's no way to efficiently update the notes after
> doing an export (push), so they'll have to be updated when importing
> (fetching).
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  contrib/remote-helpers/git-remote-hg | 35 ++++++++++++++++++++++++++++++++++-
>  1 file changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
> index 307d82c..7f50b40 100755
> --- a/contrib/remote-helpers/git-remote-hg
> +++ b/contrib/remote-helpers/git-remote-hg
> @@ -23,8 +23,12 @@ import subprocess
>  import urllib
>  import atexit
>  import urlparse, hashlib
> +import time as ptime
>  
>  #
> +# If you want to see Mercurial revisions as Git commit notes:
> +# git config core.notesRef refs/notes/hg
> +#

Yup.  This is better.  Will queue.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Re* [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-29 21:24           ` Re* " Junio C Hamano
  2013-08-29 21:25             ` Junio C Hamano
  2013-08-29 21:28             ` Antoine Pelisse
@ 2013-09-01  4:03             ` Michael Haggerty
  2 siblings, 0 replies; 32+ messages in thread
From: Michael Haggerty @ 2013-09-01  4:03 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthieu Moy, Felipe Contreras, git, Antoine Pelisse

On 08/29/2013 11:24 PM, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> 
>> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>>
>>> Do I really need to quote the paragraph in CodingGuidelines?
>>
>> Existing violations are not an excuse to make things worse by adding
>> more.  I think with these comments we can expect a reroll coming,
>> and it should be trivial for any contributor to fix it while at it.
> 
> Actually, I think not fixing it inside that 1/8 is good, as there
> are many existing "cmd > file" (and worse, "cmd > file-$x") in these
> test-*.sh scripts.  Clean-up is better done as a follow-up patch.
> 
> Here are two that I noticed.
> 
> -- >8 --
> Subject: [PATCH 9/8] contrib/remote-helpers: style updates for test scripts
> 
> During the review of the main series it was noticed that these test
> scripts can use updates to conform to our coding style better, but
> fixing the style should be done in a patch separate from the main
> series.
> 
> This updates the test-*.sh scripts only for styles:

s/styles/style/

> 
>  * We do not leave SP between a redirection operator and the
>    filename;
> 
>  * We change line before "then", "do", etc. rather than terminating
>    the condition for "if"/"while" and list for "for" with a
>    semicolon;
> 
>  * When HERE document does not use any expansion, we quote the end
>    marker (e.g. "cat <<\EOF" not "cat <<EOF") to signal the readers
>    that there is no funny substitution to worry about when reading
>    the code.
> 

Please add

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

, as you made a few such changes as well.

> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  contrib/remote-helpers/test-bzr.sh       | 112 +++++++++++-----------
>  contrib/remote-helpers/test-hg-bidi.sh   |  52 ++++++-----
>  contrib/remote-helpers/test-hg-hg-git.sh | 156 +++++++++++++++++--------------
>  contrib/remote-helpers/test-hg.sh        | 154 +++++++++++++++---------------
>  4 files changed, 248 insertions(+), 226 deletions(-)
> 
> [...]

All of the changes in the patch look good to me.

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Re* [PATCH 1/8] remote-bzr: fix export of utf-8 authors
  2013-08-29 21:25             ` Junio C Hamano
@ 2013-09-01  4:09               ` Michael Haggerty
  0 siblings, 0 replies; 32+ messages in thread
From: Michael Haggerty @ 2013-09-01  4:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthieu Moy, Felipe Contreras, git, Antoine Pelisse

On 08/29/2013 11:25 PM, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> 
>> Actually, I think not fixing it inside that 1/8 is good, as there
>> are many existing "cmd > file" (and worse, "cmd > file-$x") in these
>> test-*.sh scripts.  Clean-up is better done as a follow-up patch.
>>
>> Here are two that I noticed.
>>
>> -- >8 --
>> Subject: [PATCH 9/8] contrib/remote-helpers: style updates for test scripts
> 
> And here is the second one.
> 
> -- >8 --
> Subject: [PATCH 10/8] remote-helpers: quote variable references in redirection targets
> 
> Even though it is not required by POSIX to double-quote the
> redirection target in a variable, our code does so because some
> versions of bash issue a warning without the quotes.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  contrib/remote-helpers/test-hg-hg-git.sh | 40 ++++++++++++++++----------------
>  1 file changed, 20 insertions(+), 20 deletions(-)
> [...]

Looks good.

Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2013-09-01  4:10 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-28 19:23 [PATCH 0/8] remote-{hg,bzr}: updates Felipe Contreras
2013-08-28 19:23 ` [PATCH 1/8] remote-bzr: fix export of utf-8 authors Felipe Contreras
2013-08-28 20:05   ` Matthieu Moy
2013-08-28 20:48     ` Felipe Contreras
2013-08-28 20:54       ` Antoine Pelisse
2013-08-28 21:21         ` Felipe Contreras
2013-08-28 21:38           ` Felipe Contreras
2013-08-28 21:05       ` Matthieu Moy
2013-08-28 21:21         ` Felipe Contreras
2013-08-28 21:58         ` Junio C Hamano
2013-08-28 22:25           ` Felipe Contreras
2013-08-29 21:24           ` Re* " Junio C Hamano
2013-08-29 21:25             ` Junio C Hamano
2013-09-01  4:09               ` Michael Haggerty
2013-08-29 21:28             ` Antoine Pelisse
2013-08-29 21:42               ` Junio C Hamano
2013-08-29 21:44                 ` Junio C Hamano
2013-09-01  4:03             ` Michael Haggerty
2013-08-28 20:35   ` Eric Sunshine
2013-08-28 21:14     ` [PATCH v2] " Felipe Contreras
2013-08-28 19:23 ` [PATCH 2/8] remote-bzr: make bzr branches configurable per-repo Felipe Contreras
2013-08-28 19:23 ` [PATCH 3/8] remote-hg: fix test Felipe Contreras
2013-08-28 19:23 ` [PATCH 4/8] remote-hg: add missing &&s in the test Felipe Contreras
2013-08-28 19:23 ` [PATCH 5/8] remote-hg: improve basic test Felipe Contreras
2013-08-28 19:23 ` [PATCH 6/8] remote-helpers: trivial style fixes Felipe Contreras
2013-08-28 19:23 ` [PATCH 7/8] remote-helpers: cleanup more global variables Felipe Contreras
2013-08-28 19:23 ` [PATCH 8/8] remote-hg: support for notes Felipe Contreras
2013-08-29 18:45   ` Junio C Hamano
2013-08-29 21:50     ` [PATCH] " Felipe Contreras
2013-08-29 22:12       ` Junio C Hamano
2013-08-29 22:29         ` [PATCH v3] " Felipe Contreras
2013-08-29 22:49           ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.