[PATCH v3 00/10] remote-hg: fixes and cleanups

STALE3715d

Revision v3 of 2 in this series.

23 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH v3 00/10] remote-hg: fixes and cleanups

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:14

Hi,

Since the last series is not merged to master yet, I decided to add more cleanups.

Felipe Contreras (10):
  remote-hg: trivial cleanups
  remote-hg: get rid of unused exception checks
  remote-hg: enable track-branches in hg-git mode
  remote-hg: add new get_config_bool() helper
  remote-hg: fix new branch creation
  remote-hg: disable forced push by default
  remote-hg: don't push fake 'master' bookmark
  remote-hg: update bookmarks when pulling
  remote-hg: test: be a little more quiet
  remote-hg: trivial reorganization

 contrib/remote-helpers/git-remote-hg     | 47 ++++++++++++++++----------------
 contrib/remote-helpers/test-hg-hg-git.sh |  3 +-
 contrib/remote-helpers/test-hg.sh        |  4 +--
 3 files changed, 26 insertions(+), 28 deletions(-)

-- 
1.8.3.rc1.579.g184e698

[PATCH v3 01/10] remote-hg: trivial cleanups

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:14

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg     | 2 +-
 contrib/remote-helpers/test-hg-hg-git.sh | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 96ad30d..d33c7ba 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -538,7 +538,7 @@ def list_head(repo, cur):
     g_head = (head, node)
 
 def do_list(parser):
-    global branches, bmarks, mode, track_branches
+    global branches, bmarks, track_branches
 
     repo = parser.repo
     for bmark, node in bookmarks.listbookmarks(repo).iteritems():
diff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh
index 8440341..0c36573 100755
--- a/contrib/remote-helpers/test-hg-hg-git.sh
+++ b/contrib/remote-helpers/test-hg-hg-git.sh
@@ -455,8 +455,6 @@ test_expect_success 'hg author' '
 		git_log gitrepo-$x > git-log-$x
 	done &&
 
-	test_cmp git-log-hg git-log-git &&
-
 	test_cmp hg-log-hg hg-log-git &&
 	test_cmp git-log-hg git-log-git
 '
-- 
1.8.3.rc1.579.g184e698

[PATCH v3 02/10] remote-hg: get rid of unused exception checks

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:14

We are not calling check_output() anymore.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index d33c7ba..9d6940b 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -327,11 +327,8 @@ def get_repo(url, alias):
     myui.setconfig('ui', 'interactive', 'off')
     myui.fout = sys.stderr
 
-    try:
-        if get_config('remote-hg.insecure') == 'true\n':
-            myui.setconfig('web', 'cacerts', '')
-    except subprocess.CalledProcessError:
-        pass
+    if get_config('remote-hg.insecure') == 'true\n':
+        myui.setconfig('web', 'cacerts', '')
 
     try:
         mod = extensions.load(myui, 'hgext.schemes', None)
@@ -910,16 +907,13 @@ def main(args):
     track_branches = True
     force_push = True
 
-    try:
-        if get_config('remote-hg.hg-git-compat') == 'true\n':
-            hg_git_compat = True
-            track_branches = False
-        if get_config('remote-hg.track-branches') == 'false\n':
-            track_branches = False
-        if get_config('remote-hg.force-push') == 'false\n':
-            force_push = False
-    except subprocess.CalledProcessError:
-        pass
+    if get_config('remote-hg.hg-git-compat') == 'true\n':
+        hg_git_compat = True
+        track_branches = False
+    if get_config('remote-hg.track-branches') == 'false\n':
+        track_branches = False
+    if get_config('remote-hg.force-push') == 'false\n':
+        force_push = False
 
     if hg_git_compat:
         mode = 'hg'
-- 
1.8.3.rc1.579.g184e698

[PATCH v3 03/10] remote-hg: enable track-branches in hg-git mode

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:14

The user can turn this off.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg     | 1 -
 contrib/remote-helpers/test-hg-hg-git.sh | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 9d6940b..de3a96e 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -909,7 +909,6 @@ def main(args):
 
     if get_config('remote-hg.hg-git-compat') == 'true\n':
         hg_git_compat = True
-        track_branches = False
     if get_config('remote-hg.track-branches') == 'false\n':
         track_branches = False
     if get_config('remote-hg.force-push') == 'false\n':
diff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh
index 0c36573..7f579c8 100755
--- a/contrib/remote-helpers/test-hg-hg-git.sh
+++ b/contrib/remote-helpers/test-hg-hg-git.sh
@@ -102,6 +102,7 @@ setup () {
 	) >> "$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
 
 	HGEDITOR=/usr/bin/true
 
-- 
1.8.3.rc1.579.g184e698

[PATCH v3 04/10] remote-hg: add new get_config_bool() helper

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:14

No functional changes.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index de3a96e..4a5c72f 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -87,6 +87,15 @@ def get_config(config):
     output, _ = process.communicate()
     return output
 
+def get_config_bool(config, default=False):
+    value = get_config(config).rstrip('\n')
+    if value == "true":
+        return True
+    elif value == "false":
+        return False
+    else:
+        return default
+
 class Marks:
 
     def __init__(self, path):
@@ -327,7 +336,7 @@ def get_repo(url, alias):
     myui.setconfig('ui', 'interactive', 'off')
     myui.fout = sys.stderr
 
-    if get_config('remote-hg.insecure') == 'true\n':
+    if get_config_bool('remote-hg.insecure'):
         myui.setconfig('web', 'cacerts', '')
 
     try:
@@ -903,16 +912,9 @@ def main(args):
     url = args[2]
     peer = None
 
-    hg_git_compat = False
-    track_branches = True
-    force_push = True
-
-    if get_config('remote-hg.hg-git-compat') == 'true\n':
-        hg_git_compat = True
-    if get_config('remote-hg.track-branches') == 'false\n':
-        track_branches = False
-    if get_config('remote-hg.force-push') == 'false\n':
-        force_push = False
+    hg_git_compat = get_config_bool('remote-hg.hg-git-compat')
+    track_branches = get_config_bool('remote-hg.track-branches', True)
+    force_push = get_config_bool('remote-hg.force-push', True)
 
     if hg_git_compat:
         mode = 'hg'
-- 
1.8.3.rc1.579.g184e698

[PATCH v3 05/10] remote-hg: fix new branch creation

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:14

When force_push is disabled, we need to turn the argument to True.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 4a5c72f..3cf9b4c 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -856,7 +856,7 @@ def do_export(parser):
             continue
 
     if peer:
-        parser.repo.push(peer, force=force_push)
+        parser.repo.push(peer, force=force_push, newbranch=True)
 
     # handle bookmarks
     for bmark, node in p_bmarks:
-- 
1.8.3.rc1.579.g184e698

[PATCH v3 06/10] remote-hg: disable forced push by default

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:14

In certain situations we might end up pushing garbage revisions (e.g. in
a rebase), and the patches to deal with that haven't been merged yet.

So let's disable forced pushes by default.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 3cf9b4c..53412dd 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -914,7 +914,7 @@ def main(args):
 
     hg_git_compat = get_config_bool('remote-hg.hg-git-compat')
     track_branches = get_config_bool('remote-hg.track-branches', True)
-    force_push = get_config_bool('remote-hg.force-push', True)
+    force_push = get_config_bool('remote-hg.force-push')
 
     if hg_git_compat:
         mode = 'hg'
-- 
1.8.3.rc1.579.g184e698

[PATCH v3 07/10] remote-hg: don't push fake 'master' bookmark

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:14

We skip it locally, but not for the remote, so let's do so.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 53412dd..beb864b 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -873,7 +873,8 @@ def do_export(parser):
 
         if bmark == 'master' and 'master' not in parser.repo._bookmarks:
             # fake bookmark
-            pass
+            print "ok %s" % ref
+            continue
         elif bookmarks.pushbookmark(parser.repo, bmark, old, new):
             # updated locally
             pass
-- 
1.8.3.rc1.579.g184e698

[PATCH v3 08/10] remote-hg: update bookmarks when pulling

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:14

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index beb864b..dc276af 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -363,6 +363,9 @@ def get_repo(url, alias):
                 die('Repository error')
             repo.pull(peer, heads=None, force=True)
 
+        rb = peer.listkeys('bookmarks')
+        bookmarks.updatefromremote(myui, repo, rb, url)
+
     return repo
 
 def rev_to_mark(rev):
-- 
1.8.3.rc1.579.g184e698

[PATCH v3 09/10] remote-hg: test: be a little more quiet

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:14

Signed-off-by: Felipe Contreras <redacted>
---
 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 8de2aa7..f8d1f9e 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -109,10 +109,10 @@ test_expect_success 'update bookmark' '
   (
   git clone "hg::$PWD/hgrepo" gitrepo &&
   cd gitrepo &&
-  git checkout devel &&
+  git checkout --quiet devel &&
   echo devel > content &&
   git commit -a -m devel &&
-  git push
+  git push --quiet
   ) &&
 
   hg -R hgrepo bookmarks | egrep "devel[	 ]+3:"
-- 
1.8.3.rc1.579.g184e698

[PATCH v3 10/10] remote-hg: trivial reorganization

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:14

We only need to get the remote dict once.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index dc276af..96bed8d 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -860,6 +860,7 @@ def do_export(parser):
 
     if peer:
         parser.repo.push(peer, force=force_push, newbranch=True)
+        remote_bmarks = peer.listkeys('bookmarks')
 
     # handle bookmarks
     for bmark, node in p_bmarks:
@@ -886,8 +887,7 @@ def do_export(parser):
             continue
 
         if peer:
-            rb = peer.listkeys('bookmarks')
-            old = rb.get(bmark, '')
+            old = remote_bmarks.get(bmark, '')
             if not peer.pushkey('bookmarks', bmark, old, new):
                 print "error %s" % ref
                 continue
-- 
1.8.3.rc1.579.g184e698

RE: [PATCH v3 01/10] remote-hg: trivial cleanups

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:15

This is a trivial cleanup, cannot cause regressions.

Felipe Contreras wrote:
quoted hunk
Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg     | 2 +-
 contrib/remote-helpers/test-hg-hg-git.sh | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 96ad30d..d33c7ba 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -538,7 +538,7 @@ def list_head(repo, cur):
     g_head = (head, node)
 
 def do_list(parser):
-    global branches, bmarks, mode, track_branches
+    global branches, bmarks, track_branches
 
     repo = parser.repo
     for bmark, node in bookmarks.listbookmarks(repo).iteritems():
diff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh
index 8440341..0c36573 100755
--- a/contrib/remote-helpers/test-hg-hg-git.sh
+++ b/contrib/remote-helpers/test-hg-hg-git.sh
@@ -455,8 +455,6 @@ test_expect_success 'hg author' '
 		git_log gitrepo-$x > git-log-$x
 	done &&
 
-	test_cmp git-log-hg git-log-git &&
-
 	test_cmp hg-log-hg hg-log-git &&
 	test_cmp git-log-hg git-log-git
 '
-- 
1.8.3.rc1.579.g184e698


-- 
Felipe Contreras

RE: [PATCH v3 02/10] remote-hg: get rid of unused exception checks

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:15

This is removing an exception check and since that exception is thrown by
check_output() but not Popen(), this doesn't change anything.

Felipe Contreras wrote:
quoted hunk
We are not calling check_output() anymore.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index d33c7ba..9d6940b 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -327,11 +327,8 @@ def get_repo(url, alias):
     myui.setconfig('ui', 'interactive', 'off')
     myui.fout = sys.stderr
 
-    try:
-        if get_config('remote-hg.insecure') == 'true\n':
-            myui.setconfig('web', 'cacerts', '')
-    except subprocess.CalledProcessError:
-        pass
+    if get_config('remote-hg.insecure') == 'true\n':
+        myui.setconfig('web', 'cacerts', '')
 
     try:
         mod = extensions.load(myui, 'hgext.schemes', None)
@@ -910,16 +907,13 @@ def main(args):
     track_branches = True
     force_push = True
 
-    try:
-        if get_config('remote-hg.hg-git-compat') == 'true\n':
-            hg_git_compat = True
-            track_branches = False
-        if get_config('remote-hg.track-branches') == 'false\n':
-            track_branches = False
-        if get_config('remote-hg.force-push') == 'false\n':
-            force_push = False
-    except subprocess.CalledProcessError:
-        pass
+    if get_config('remote-hg.hg-git-compat') == 'true\n':
+        hg_git_compat = True
+        track_branches = False
+    if get_config('remote-hg.track-branches') == 'false\n':
+        track_branches = False
+    if get_config('remote-hg.force-push') == 'false\n':
+        force_push = False
 
     if hg_git_compat:
         mode = 'hg'
-- 
1.8.3.rc1.579.g184e698
-- 
Felipe Contreras

RE: [PATCH v3 03/10] remote-hg: enable track-branches in hg-git mode

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:15

No regression here either, we simply give more power to the user.

Felipe Contreras wrote:
quoted hunk
The user can turn this off.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg     | 1 -
 contrib/remote-helpers/test-hg-hg-git.sh | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 9d6940b..de3a96e 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -909,7 +909,6 @@ def main(args):
 
     if get_config('remote-hg.hg-git-compat') == 'true\n':
         hg_git_compat = True
-        track_branches = False
     if get_config('remote-hg.track-branches') == 'false\n':
         track_branches = False
     if get_config('remote-hg.force-push') == 'false\n':
diff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh
index 0c36573..7f579c8 100755
--- a/contrib/remote-helpers/test-hg-hg-git.sh
+++ b/contrib/remote-helpers/test-hg-hg-git.sh
@@ -102,6 +102,7 @@ setup () {
 	) >> "$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
 
 	HGEDITOR=/usr/bin/true
 
-- 
1.8.3.rc1.579.g184e698
-- 
Felipe Contreras

RE: [PATCH v3 04/10] remote-hg: add new get_config_bool() helper

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:15

This is simply refactoring code, functionally they are the same.

Felipe Contreras wrote:
quoted hunk
No functional changes.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index de3a96e..4a5c72f 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -87,6 +87,15 @@ def get_config(config):
     output, _ = process.communicate()
     return output
 
+def get_config_bool(config, default=False):
+    value = get_config(config).rstrip('\n')
+    if value == "true":
+        return True
+    elif value == "false":
+        return False
+    else:
+        return default
+
 class Marks:
 
     def __init__(self, path):
@@ -327,7 +336,7 @@ def get_repo(url, alias):
     myui.setconfig('ui', 'interactive', 'off')
     myui.fout = sys.stderr
 
-    if get_config('remote-hg.insecure') == 'true\n':
+    if get_config_bool('remote-hg.insecure'):
         myui.setconfig('web', 'cacerts', '')
 
     try:
@@ -903,16 +912,9 @@ def main(args):
     url = args[2]
     peer = None
 
-    hg_git_compat = False
-    track_branches = True
-    force_push = True
-
-    if get_config('remote-hg.hg-git-compat') == 'true\n':
-        hg_git_compat = True
-    if get_config('remote-hg.track-branches') == 'false\n':
-        track_branches = False
-    if get_config('remote-hg.force-push') == 'false\n':
-        force_push = False
+    hg_git_compat = get_config_bool('remote-hg.hg-git-compat')
+    track_branches = get_config_bool('remote-hg.track-branches', True)
+    force_push = get_config_bool('remote-hg.force-push', True)
 
     if hg_git_compat:
         mode = 'hg'
-- 
1.8.3.rc1.579.g184e698


-- 
Felipe Contreras

RE: [PATCH v3 05/10] remote-hg: fix new branch creation

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:15

This is the first fix, but it's obvious this is what we want: if a user creates
a new branch with git:

 % git checkout -b branches/devel

And then pushes this branch

 % git push origin branches/devel

(which is the way to push new mercurial branches)

We obviously want to create a branch, but the command would fail, and the fix
is simple: tell the push that we might create new branches.

This only matters when foce_push=False.

Can't possibly introduce regressions, unless you think of the ability to push
new branches as a regression.

Felipe Contreras wrote:
quoted hunk
When force_push is disabled, we need to turn the argument to True.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 4a5c72f..3cf9b4c 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -856,7 +856,7 @@ def do_export(parser):
             continue
 
     if peer:
-        parser.repo.push(peer, force=force_push)
+        parser.repo.push(peer, force=force_push, newbranch=True)
 
     # handle bookmarks
     for bmark, node in p_bmarks:
-- 
1.8.3.rc1.579.g184e698


-- 
Felipe Contreras

RE: [PATCH v3 06/10] remote-hg: disable forced push by default

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:15

And here is the important fix. We are essentially reverting back to the old
v1.8.2 behavior, to minimize the possibility of regressions, but in a way the
user can configure.

The cleanups before made it so this patch eas easy and simple.

And the fix before this makes it so the new default force_push=False still is
able to push new branches, so we don't disable other v1.8.3 features.

Felipe Contreras wrote:
quoted hunk
In certain situations we might end up pushing garbage revisions (e.g. in
a rebase), and the patches to deal with that haven't been merged yet.

So let's disable forced pushes by default.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 3cf9b4c..53412dd 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -914,7 +914,7 @@ def main(args):
 
     hg_git_compat = get_config_bool('remote-hg.hg-git-compat')
     track_branches = get_config_bool('remote-hg.track-branches', True)
-    force_push = get_config_bool('remote-hg.force-push', True)
+    force_push = get_config_bool('remote-hg.force-push')
 
     if hg_git_compat:
         mode = 'hg'
-- 
1.8.3.rc1.579.g184e698


-- 
Felipe Contreras

RE: [PATCH v3 07/10] remote-hg: don't push fake 'master' bookmark

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:15

We obviously don't want to push our fake 'master' bookmark to the remote. This
is an obvious good change.

Felipe Contreras wrote:
quoted hunk
We skip it locally, but not for the remote, so let's do so.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 53412dd..beb864b 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -873,7 +873,8 @@ def do_export(parser):
 
         if bmark == 'master' and 'master' not in parser.repo._bookmarks:
             # fake bookmark
-            pass
+            print "ok %s" % ref
+            continue
         elif bookmarks.pushbookmark(parser.repo, bmark, old, new):
             # updated locally
             pass
-- 
1.8.3.rc1.579.g184e698
-- 
Felipe Contreras

RE: [PATCH v3 08/10] remote-hg: update bookmarks when pulling

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:15

Without this fix, the user would never ever see new bookmarks, only the ones
that (s)he initially cloned.

Felipe Contreras wrote:
quoted hunk
Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index beb864b..dc276af 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -363,6 +363,9 @@ def get_repo(url, alias):
                 die('Repository error')
             repo.pull(peer, heads=None, force=True)
 
+        rb = peer.listkeys('bookmarks')
+        bookmarks.updatefromremote(myui, repo, rb, url)
+
     return repo
 
 def rev_to_mark(rev):
-- 
1.8.3.rc1.579.g184e698


-- 
Felipe Contreras

RE: [PATCH v3 09/10] remote-hg: test: be a little more quiet

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:15

No-brainer; improve one test.

Felipe Contreras wrote:
quoted hunk
Signed-off-by: Felipe Contreras <redacted>
---
 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 8de2aa7..f8d1f9e 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -109,10 +109,10 @@ test_expect_success 'update bookmark' '
   (
   git clone "hg::$PWD/hgrepo" gitrepo &&
   cd gitrepo &&
-  git checkout devel &&
+  git checkout --quiet devel &&
   echo devel > content &&
   git commit -a -m devel &&
-  git push
+  git push --quiet
   ) &&
 
   hg -R hgrepo bookmarks | egrep "devel[	 ]+3:"
-- 
1.8.3.rc1.579.g184e698


-- 
Felipe Contreras

RE: [PATCH v3 10/10] remote-hg: trivial reorganization

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:15

Another no-brainer; simply shuffling some code.

Felipe Contreras wrote:
quoted hunk
We only need to get the remote dict once.

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/remote-helpers/git-remote-hg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index dc276af..96bed8d 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -860,6 +860,7 @@ def do_export(parser):
 
     if peer:
         parser.repo.push(peer, force=force_push, newbranch=True)
+        remote_bmarks = peer.listkeys('bookmarks')
 
     # handle bookmarks
     for bmark, node in p_bmarks:
@@ -886,8 +887,7 @@ def do_export(parser):
             continue
 
         if peer:
-            rb = peer.listkeys('bookmarks')
-            old = rb.get(bmark, '')
+            old = remote_bmarks.get(bmark, '')
             if not peer.pushkey('bookmarks', bmark, old, new):
                 print "error %s" % ref
                 continue
-- 
1.8.3.rc1.579.g184e698
-- 
Felipe Contreras

Re: [PATCH v3 08/10] remote-hg: update bookmarks when pulling

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:15

Felipe Contreras [off-list ref] writes:
Without this fix, the user would never ever see new bookmarks, only the ones
that (s)he initially cloned.
Now, think again and realize how long it took you (the original
author) to discover issues and come up with these fixes and
explanation since the series was merged before -rc0.

Are we giving the users enough time to discover and complain issues
that these 10 patches may introduce before the final release?  "You
can see these patches are so trivially correct" is not a valid
argument. The original patches would also have been looked correct
when they were sent to the list. Things take time and actual use by
the users to mature.

Having said that, the impression I am getting is that whatever we
pushed out in 1.8.2 and 1.8.3-rc0 was far from ready for real use,
and with your explanations (by the way, I found that many of them
deserve to be in the log message), the end result of applying these
patches, up to 8/10, will still not be as it is very likely that you
and users will discover issues at a similar rate, but at least it
will be much closer to be ready than they currently are.

In other words, it still seems to be in "something is better than
nothing, newer is better than older" stage before stabilization.

And that is to be expected for a contrib/ material; nothing for us
to be ashamed of.  So I changed my mind.  As long as it is clearly
marked as "still experimental, possibly with rough edges", I think
it is better to ship 1.8.3 with these 8 patches than without.

I am unhappy with 3/10, though.  It is spreading existing mistake by
adding another configuration variable with dash in its name, which
goes against the recommended practice, and making it more cumbersome
to eventually fix them, because we would need to break end user's
configuration.

Things like 1/10 and 2/10 that can be characterized as:
This is a trivial cleanup, cannot cause regressions.
may probably be a good clean-up to build the next development cycle
on top, but are not at all urgent for it to deserve to be included
in the upcoming release.  But it seems that 3-8 textually depend on
at least 2, so I'll queue the first eight for 1.8.3 and exclude the
rest for now.  If these are identical to the early part of the
47-patch series (I didn't check; they are for the next cycle), it
would make the next cycle shorter by 8 patches.

Re: [PATCH v3 08/10] remote-hg: update bookmarks when pulling

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:57:15

On Tue, May 14, 2013 at 4:59 PM, Junio C Hamano [off-list ref] wrote:
Felipe Contreras [off-list ref] writes:
quoted
Without this fix, the user would never ever see new bookmarks, only the ones
that (s)he initially cloned.
Now, think again and realize how long it took you (the original
author) to discover issues and come up with these fixes and
explanation since the series was merged before -rc0.
This issue has *always* been there, it's not a regression.
Are we giving the users enough time to discover and complain issues
that these 10 patches may introduce before the final release?
Yes, because the time needed is *zero*.
"You
can see these patches are so trivially correct" is not a valid
argument. The original patches would also have been looked correct
when they were sent to the list. Things take time and actual use by
the users to mature.
There was no original patches that introduced this regression, because
it's not a regression.

When I say these are trivially correct, I mean it; the regressions you
talk about were on patches that were marked as *not* trivially
correct, and potentially dangerous.
Having said that, the impression I am getting is that whatever we
pushed out in 1.8.2 and 1.8.3-rc0 was far from ready for real use,
and with your explanations (by the way, I found that many of them
deserve to be in the log message), the end result of applying these
patches, up to 8/10, will still not be as it is very likely that you
and users will discover issues at a similar rate, but at least it
will be much closer to be ready than they currently are.
Define "ready". It's probably more "ready" than any other bridge tool out there.
In other words, it still seems to be in "something is better than
nothing, newer is better than older" stage before stabilization.
remote-hg is already stable, this patch has nothing to do with
stabilization, neither do any of the 47 patches I sent to the list.
And that is to be expected for a contrib/ material; nothing for us
to be ashamed of.  So I changed my mind.  As long as it is clearly
marked as "still experimental, possibly with rough edges", I think
it is better to ship 1.8.3 with these 8 patches than without.

I am unhappy with 3/10, though.  It is spreading existing mistake by
adding another configuration variable with dash in its name, which
goes against the recommended practice, and making it more cumbersome
to eventually fix them, because we would need to break end user's
configuration.
It's not adding any configuration; remote-hg.track-branches is already
present, even in v1.8.2.
Things like 1/10 and 2/10 that can be characterized as:
quoted
This is a trivial cleanup, cannot cause regressions.
may probably be a good clean-up to build the next development cycle
on top, but are not at all urgent for it to deserve to be included
in the upcoming release.  But it seems that 3-8 textually depend on
at least 2, so I'll queue the first eight for 1.8.3 and exclude the
rest for now.  If these are identical to the early part of the
47-patch series (I didn't check; they are for the next cycle), it
would make the next cycle shorter by 8 patches.
Indeed, they are exactly the same as the first 10 patches of the
47-patch series.

I think this makes sense.

-- 
Felipe Contreras
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help