[PATCH] mq: use repo._bookmarks.write instead of repo._bookmarks.recordchange

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Nov 16 21:18:39 CST 2015



On 11/16/2015 05:21 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon at fb.com>
> # Date 1442624684 25200
> #      Fri Sep 18 18:04:44 2015 -0700
> # Node ID 83fe45f567f48fa9d6ce1497e81a5601e3a21061
> # Parent  2da6a2dbfc42bdec4bcaf47da947c64ff959a59c
> mq: use repo._bookmarks.write instead of repo._bookmarks.recordchange
>
> Before this patch, mq was using repo._bookmarks.write.
> This patch replaces this code with the recommended way of saving bookmarks
> changes: repo._bookmarks.recordchange.

We should move the bookmark in the same transaction as the one creating 
the new commit.

(yes, the transaction does not seems handled by at this scope yet so 
we'll have to add that too.)

>
> diff --git a/hgext/mq.py b/hgext/mq.py
> --- a/hgext/mq.py
> +++ b/hgext/mq.py
> @@ -68,6 +68,7 @@
>   from mercurial import commands, cmdutil, hg, scmutil, util, revset
>   from mercurial import extensions, error, phases
>   from mercurial import patch as patchmod
> +from mercurial import lock as lockmod
>   from mercurial import localrepo
>   from mercurial import subrepo
>   import os, re, errno, shutil
> @@ -1808,7 +1809,14 @@
>                   marks = repo._bookmarks
>                   for bm in bmlist:
>                       marks[bm] = n
> -                marks.write()
> +                lock = tr = None
> +                try:
> +                    lock = repo.lock()
> +                    tr = repo.transaction('bookmark')
> +                    marks.recordchange(tr)
> +                    tr.close()
> +                finally:
> +                    lockmod.release(lock, tr)
>
>                   self.applied.append(statusentry(n, patchfn))
>               except: # re-raises
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list