# [PATCH v2 1/6] remote-hg: disable forced push by default

8 messages from 2013-05-10 to 2013-05-13. Participants: Felipe Contreras.
Thread: https://gitlist.dev/t/33781

## Felipe Contreras, 2013-05-10 20:59

Subject: [PATCH v2 0/6] remote-hg: fixes and cleanups
Message-ID: <1368219566-1399-1-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1368219566-1399-1-git-send-email-felipe.contreras%40gmail.com

```
Hi,

A few fixes since last series, plus a few more patches. Simple no-brainers.

Felipe Contreras (6):
  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: fix new branch creation
  remote-hg: trivial reorganization

 contrib/remote-helpers/git-remote-hg | 18 +++++++++++-------
 contrib/remote-helpers/test-hg.sh    |  4 ++--
 2 files changed, 13 insertions(+), 9 deletions(-)

-- 
1.8.3.rc1.579.g184e698

```

## Felipe Contreras, 2013-05-10 20:59

Subject: [PATCH v2 1/6] remote-hg: disable forced push by default
Message-ID: <1368219566-1399-2-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1368219566-1399-2-git-send-email-felipe.contreras%40gmail.com
In-Reply-To: <1368219566-1399-1-git-send-email-felipe.contreras@gmail.com>

```
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 <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-hg | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 96ad30d..84901e9 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -908,7 +908,7 @@ def main(args):
 
     hg_git_compat = False
     track_branches = True
-    force_push = True
+    force_push = False
 
     try:
         if get_config('remote-hg.hg-git-compat') == 'true\n':
@@ -916,8 +916,8 @@ def main(args):
             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 get_config('remote-hg.force-push') == 'true\n':
+            force_push = True
     except subprocess.CalledProcessError:
         pass
 
-- 
1.8.3.rc1.579.g184e698

```

## Felipe Contreras, 2013-05-10 20:59

Subject: [PATCH v2 2/6] remote-hg: don't push fake 'master' bookmark
Message-ID: <1368219566-1399-3-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1368219566-1399-3-git-send-email-felipe.contreras%40gmail.com
In-Reply-To: <1368219566-1399-1-git-send-email-felipe.contreras@gmail.com>

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

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 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 84901e9..14e7395 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -867,7 +867,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, 2013-05-10 20:59

Subject: [PATCH v2 3/6] remote-hg: update bookmarks when pulling
Message-ID: <1368219566-1399-4-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1368219566-1399-4-git-send-email-felipe.contreras%40gmail.com
In-Reply-To: <1368219566-1399-1-git-send-email-felipe.contreras@gmail.com>

```
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 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 14e7395..c84a7b4 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -357,6 +357,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, 2013-05-10 20:59

Subject: [PATCH v2 4/6] remote-hg: test: be a little more quiet
Message-ID: <1368219566-1399-5-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1368219566-1399-5-git-send-email-felipe.contreras%40gmail.com
In-Reply-To: <1368219566-1399-1-git-send-email-felipe.contreras@gmail.com>

```
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 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, 2013-05-10 20:59

Subject: [PATCH v2 5/6] remote-hg: fix new branch creation
Message-ID: <1368219566-1399-6-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1368219566-1399-6-git-send-email-felipe.contreras%40gmail.com
In-Reply-To: <1368219566-1399-1-git-send-email-felipe.contreras@gmail.com>

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

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 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 c84a7b4..50ead38 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -853,7 +853,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, 2013-05-10 20:59

Subject: [PATCH v2 6/6] remote-hg: trivial reorganization
Message-ID: <1368219566-1399-7-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1368219566-1399-7-git-send-email-felipe.contreras%40gmail.com
In-Reply-To: <1368219566-1399-1-git-send-email-felipe.contreras@gmail.com>

```
We only need to get the remote dict once.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 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 50ead38..40da4b0 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -854,6 +854,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:
@@ -880,8 +881,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, 2013-05-13 23:15

Subject: Re: [PATCH v2 0/6] remote-hg: fixes and cleanups
Message-ID: <CAMP44s0ArwaQ7GmwnP8r5DyqxDShJDkSJnUYQsGSzU589o2Quw@mail.gmail.com>
URL: https://gitlist.dev/e/CAMP44s0ArwaQ7GmwnP8r5DyqxDShJDkSJnUYQsGSzU589o2Quw%40mail.gmail.com
In-Reply-To: <1368219566-1399-1-git-send-email-felipe.contreras@gmail.com>

```
On Fri, May 10, 2013 at 3:59 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:

> A few fixes since last series, plus a few more patches. Simple no-brainers.
>
> Felipe Contreras (6):
>   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: fix new branch creation
>   remote-hg: trivial reorganization
>
>  contrib/remote-helpers/git-remote-hg | 18 +++++++++++-------
>  contrib/remote-helpers/test-hg.sh    |  4 ++--
>  2 files changed, 13 insertions(+), 9 deletions(-)

I was expecting these to be merged to 'master', but since they are
still not merged, I decided to send more cleanups.

-- 
Felipe Contreras

```
