Patchwork [evolve-ext] debugobsconvert: make sure obsstore is loaded before version comparison

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 24, 2015, 1:03 p.m.
Message ID <ee150fed6f615512c89b.1443099794@mimosa>
Download mbox | patch
Permalink /patch/10610/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 24, 2015, 1:03 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1442842244 -32400
#      Mon Sep 21 22:30:44 2015 +0900
# Node ID ee150fed6f615512c89bcd5ce9f95b9e05da73ac
# Parent  a55c691f4cc0b960a02bc94b3296403524c8db84
debugobsconvert: make sure obsstore is loaded before version comparison

hg 44918682093f delays loading obsstore, so we have to access _all to get
the correct store version.
Pierre-Yves David - Sept. 24, 2015, 1:07 p.m.
On 09/24/2015 06:03 AM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1442842244 -32400
> #      Mon Sep 21 22:30:44 2015 +0900
> # Node ID ee150fed6f615512c89bcd5ce9f95b9e05da73ac
> # Parent  a55c691f4cc0b960a02bc94b3296403524c8db84
> debugobsconvert: make sure obsstore is loaded before version comparison
>
> hg 44918682093f delays loading obsstore, so we have to access _all to get
> the correct store version.
>
> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -3496,11 +3496,11 @@ def _checkinvalidmarkers(orig, markers):
>       [('', 'new-format', _bestformat, _('Destination format for markers.'))],
>       '')
>   def debugobsconvert(ui, repo, new_format):
> +    origmarkers = repo.obsstore._all  # settle version

I'm not super enthusiastic at accessing a private attribute to trigger a 
suble behavior from an extension. do you have idea for something less 
fragile? (like _version making sure the obsstore is loaded?)

If not, I'll probably take this anyway.
Yuya Nishihara - Sept. 24, 2015, 1:38 p.m.
On Thu, 24 Sep 2015 06:07:28 -0700, Pierre-Yves David wrote:
> On 09/24/2015 06:03 AM, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1442842244 -32400
> > #      Mon Sep 21 22:30:44 2015 +0900
> > # Node ID ee150fed6f615512c89bcd5ce9f95b9e05da73ac
> > # Parent  a55c691f4cc0b960a02bc94b3296403524c8db84
> > debugobsconvert: make sure obsstore is loaded before version comparison
> >
> > hg 44918682093f delays loading obsstore, so we have to access _all to get
> > the correct store version.
> >
> > diff --git a/hgext/evolve.py b/hgext/evolve.py
> > --- a/hgext/evolve.py
> > +++ b/hgext/evolve.py
> > @@ -3496,11 +3496,11 @@ def _checkinvalidmarkers(orig, markers):
> >       [('', 'new-format', _bestformat, _('Destination format for markers.'))],
> >       '')
> >   def debugobsconvert(ui, repo, new_format):
> > +    origmarkers = repo.obsstore._all  # settle version
> 
> I'm not super enthusiastic at accessing a private attribute to trigger a 
> suble behavior from an extension. do you have idea for something less 
> fragile? (like _version making sure the obsstore is loaded?)

We could, but _version is also private so obsstore has no responsibility
to fix up the value.

Should I add public obsstore.version() ?
Pierre-Yves David - Sept. 30, 2015, 1:18 a.m.
On 09/24/2015 06:38 AM, Yuya Nishihara wrote:
> On Thu, 24 Sep 2015 06:07:28 -0700, Pierre-Yves David wrote:
>> On 09/24/2015 06:03 AM, Yuya Nishihara wrote:
>>> # HG changeset patch
>>> # User Yuya Nishihara <yuya@tcha.org>
>>> # Date 1442842244 -32400
>>> #      Mon Sep 21 22:30:44 2015 +0900
>>> # Node ID ee150fed6f615512c89bcd5ce9f95b9e05da73ac
>>> # Parent  a55c691f4cc0b960a02bc94b3296403524c8db84
>>> debugobsconvert: make sure obsstore is loaded before version comparison

That one is pushed to main, thanks.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -3496,11 +3496,11 @@  def _checkinvalidmarkers(orig, markers):
     [('', 'new-format', _bestformat, _('Destination format for markers.'))],
     '')
 def debugobsconvert(ui, repo, new_format):
+    origmarkers = repo.obsstore._all  # settle version
     if new_format == repo.obsstore._version:
         msg = _('New format is the same as the old format, not upgrading!')
         raise util.Abort(msg)
     f = repo.svfs('obsstore', 'wb', atomictemp=True)
-    origmarkers = repo.obsstore._all
     known = set()
     markers = []
     for m in origmarkers: