Patchwork bookmarks: don't allow pushing new head for existing mark with -B (issue4400)

login
register
mail settings
Submitter Matt Mackall
Date Oct. 22, 2015, 12:09 p.m.
Message ID <8a871c635792dd04611d.1445515777@ruin.waste.org>
Download mbox | patch
Permalink /patch/11216/
State Accepted
Headers show

Comments

Matt Mackall - Oct. 22, 2015, 12:09 p.m.
# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 1445462487 18000
#      Wed Oct 21 16:21:27 2015 -0500
# Branch stable
# Node ID 8a871c635792dd04611d2e2cfc5a2478a1227076
# Parent  a64b6e391d0657708d87b4113c08e770d7a78b1c
bookmarks: don't allow pushing new head for existing mark with -B (issue4400)
Augie Fackler - Oct. 22, 2015, 2:27 p.m.
On Thu, Oct 22, 2015 at 01:09:37PM +0100, Matt Mackall wrote:
> # HG changeset patch
> # User Matt Mackall <mpm@selenic.com>
> # Date 1445462487 18000
> #      Wed Oct 21 16:21:27 2015 -0500
> # Branch stable
> # Node ID 8a871c635792dd04611d2e2cfc5a2478a1227076
> # Parent  a64b6e391d0657708d87b4113c08e770d7a78b1c
> bookmarks: don't allow pushing new head for existing mark with -B (issue4400)

This is queued, thanks.

>
> diff -r a64b6e391d06 -r 8a871c635792 mercurial/discovery.py
> --- a/mercurial/discovery.py	Tue Oct 20 18:46:00 2015 -0400
> +++ b/mercurial/discovery.py	Wed Oct 21 16:21:27 2015 -0500
> @@ -279,7 +279,7 @@
>              if bookmarks.validdest(repo, rctx, lctx):
>                  bookmarkedheads.add(lctx.node())
>          else:
> -            if bm in newbookmarks:
> +            if bm in newbookmarks and bm not in remotebookmarks:
>                  bookmarkedheads.add(repo[bm].node())
>
>      # 3. Check for new heads.
> diff -r a64b6e391d06 -r 8a871c635792 tests/test-bookmarks-pushpull.t
> --- a/tests/test-bookmarks-pushpull.t	Tue Oct 20 18:46:00 2015 -0400
> +++ b/tests/test-bookmarks-pushpull.t	Wed Oct 21 16:21:27 2015 -0500
> @@ -678,6 +678,26 @@
>    $ hg -R ../b id -r W
>    cc978a373a53 tip W
>
> +pushing an existing but divergent bookmark with -B still requires -f
> +
> +  $ hg clone -q . r
> +  $ hg up -q X
> +  $ echo 1 > f2
> +  $ hg ci -qAml
> +
> +  $ cd r
> +  $ hg up -q X
> +  $ echo 2 > f2
> +  $ hg ci -qAmr
> +  $ hg push -B X
> +  pushing to $TESTTMP/addmarks
> +  searching for changes
> +  remote has heads on branch 'default' that are not known locally: a2a606d9ff1b
> +  abort: push creates new remote head 54694f811df9 with bookmark 'X'!
> +  (pull and merge or see "hg help push" for details about pushing new heads)
> +  [255]
> +  $ cd ..
> +
>  Check summary output for incoming/outgoing bookmarks
>
>    $ hg bookmarks -d X
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Augie Fackler - Oct. 22, 2015, 2:29 p.m.
On Thu, Oct 22, 2015 at 01:09:37PM +0100, Matt Mackall wrote:
> # HG changeset patch
> # User Matt Mackall <mpm@selenic.com>
> # Date 1445462487 18000
> #      Wed Oct 21 16:21:27 2015 -0500
> # Branch stable
> # Node ID 8a871c635792dd04611d2e2cfc5a2478a1227076
> # Parent  a64b6e391d0657708d87b4113c08e770d7a78b1c
> bookmarks: don't allow pushing new head for existing mark with -B (issue4400)

test-check-code-hg.t sends you a postcard of Big Ben BTW

>
> diff -r a64b6e391d06 -r 8a871c635792 mercurial/discovery.py
> --- a/mercurial/discovery.py	Tue Oct 20 18:46:00 2015 -0400
> +++ b/mercurial/discovery.py	Wed Oct 21 16:21:27 2015 -0500
> @@ -279,7 +279,7 @@
>              if bookmarks.validdest(repo, rctx, lctx):
>                  bookmarkedheads.add(lctx.node())
>          else:
> -            if bm in newbookmarks:
> +            if bm in newbookmarks and bm not in remotebookmarks:
>                  bookmarkedheads.add(repo[bm].node())
>
>      # 3. Check for new heads.
> diff -r a64b6e391d06 -r 8a871c635792 tests/test-bookmarks-pushpull.t
> --- a/tests/test-bookmarks-pushpull.t	Tue Oct 20 18:46:00 2015 -0400
> +++ b/tests/test-bookmarks-pushpull.t	Wed Oct 21 16:21:27 2015 -0500
> @@ -678,6 +678,26 @@
>    $ hg -R ../b id -r W
>    cc978a373a53 tip W
>
> +pushing an existing but divergent bookmark with -B still requires -f
> +
> +  $ hg clone -q . r
> +  $ hg up -q X
> +  $ echo 1 > f2
> +  $ hg ci -qAml
> +
> +  $ cd r
> +  $ hg up -q X
> +  $ echo 2 > f2
> +  $ hg ci -qAmr
> +  $ hg push -B X
> +  pushing to $TESTTMP/addmarks
> +  searching for changes
> +  remote has heads on branch 'default' that are not known locally: a2a606d9ff1b
> +  abort: push creates new remote head 54694f811df9 with bookmark 'X'!
> +  (pull and merge or see "hg help push" for details about pushing new heads)
> +  [255]
> +  $ cd ..
> +
>  Check summary output for incoming/outgoing bookmarks
>
>    $ hg bookmarks -d X
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r a64b6e391d06 -r 8a871c635792 mercurial/discovery.py
--- a/mercurial/discovery.py	Tue Oct 20 18:46:00 2015 -0400
+++ b/mercurial/discovery.py	Wed Oct 21 16:21:27 2015 -0500
@@ -279,7 +279,7 @@ 
             if bookmarks.validdest(repo, rctx, lctx):
                 bookmarkedheads.add(lctx.node())
         else:
-            if bm in newbookmarks:
+            if bm in newbookmarks and bm not in remotebookmarks:
                 bookmarkedheads.add(repo[bm].node())
 
     # 3. Check for new heads.
diff -r a64b6e391d06 -r 8a871c635792 tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t	Tue Oct 20 18:46:00 2015 -0400
+++ b/tests/test-bookmarks-pushpull.t	Wed Oct 21 16:21:27 2015 -0500
@@ -678,6 +678,26 @@ 
   $ hg -R ../b id -r W
   cc978a373a53 tip W
 
+pushing an existing but divergent bookmark with -B still requires -f
+
+  $ hg clone -q . r
+  $ hg up -q X
+  $ echo 1 > f2
+  $ hg ci -qAml
+
+  $ cd r
+  $ hg up -q X
+  $ echo 2 > f2
+  $ hg ci -qAmr
+  $ hg push -B X
+  pushing to $TESTTMP/addmarks
+  searching for changes
+  remote has heads on branch 'default' that are not known locally: a2a606d9ff1b
+  abort: push creates new remote head 54694f811df9 with bookmark 'X'!
+  (pull and merge or see "hg help push" for details about pushing new heads)
+  [255]
+  $ cd ..
+
 Check summary output for incoming/outgoing bookmarks
 
   $ hg bookmarks -d X