Patchwork bookmarks: update only proper bookmarks on push -r/-B (issue 3973)

login
register
mail settings
Submitter Wojciech Lopata
Date July 29, 2013, 9:35 p.m.
Message ID <d40d7bb99a1c0fbef51a.1375133728@dev1179.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1979/
State Accepted
Commit 14c91b18d79877641925f6d3d437083e1e0f8c77
Headers show

Comments

Wojciech Lopata - July 29, 2013, 9:35 p.m.
# HG changeset patch
# User Wojciech Lopata <lopek@fb.com>
# Date 1374870891 25200
#      Fri Jul 26 13:34:51 2013 -0700
# Branch stable
# Node ID d40d7bb99a1c0fbef51a3ca636e9c119d46c7730
# Parent  ca2dfc2f63ebf521f0c3a7b58e860ab1c584f065
bookmarks: update only proper bookmarks on push -r/-B (issue 3973)

Make push -r/-B update only these bookmarks that point to pushed revisions
or their ancestors, so we can be sure that commit pointed by bookmark is
present in the remote reposiory. Previously push tried to update all shared
bookmarks.
Durham Goode - July 30, 2013, 12:41 a.m.
On 7/29/13 2:35 PM, "Wojciech Lopata" <lopek@fb.com> wrote:

># HG changeset patch
># User Wojciech Lopata <lopek@fb.com>
># Date 1374870891 25200
>#      Fri Jul 26 13:34:51 2013 -0700
># Branch stable
># Node ID d40d7bb99a1c0fbef51a3ca636e9c119d46c7730
># Parent  ca2dfc2f63ebf521f0c3a7b58e860ab1c584f065
>bookmarks: update only proper bookmarks on push -r/-B (issue 3973)


Since this is a bug fix and should probably go on the stable branch,
you'll want to send it with the stable flag.  Use 'hg email --flag STABLE
Š' to include the flag when you send the patch.

You can probably wait and include the flag when you send an update
(assuming people request changes).

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1951,6 +1951,9 @@ 
 
         self.ui.debug("checking for updated bookmarks\n")
         rb = remote.listkeys('bookmarks')
+        revnums = map(unfi.changelog.rev, revs or [])
+        ancestors = [
+            a for a in unfi.changelog.ancestors(revnums, inclusive=True)]
         for k in rb.keys():
             if k in unfi._bookmarks:
                 nr, nl = rb[k], hex(self._bookmarks[k])
@@ -1958,6 +1961,8 @@ 
                     cr = unfi[nr]
                     cl = unfi[nl]
                     if bookmarks.validdest(unfi, cr, cl):
+                        if ancestors and cl.rev() not in ancestors:
+                            continue
                         r = remote.pushkey('bookmarks', k, nr, nl)
                         if r:
                             self.ui.status(_("updating bookmark %s\n") % k)
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -422,7 +422,6 @@ 
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
-  updating bookmark @ failed!
   exporting bookmark add-foo
 
   $ cd ..