[PATCH 2 of 7 PoC] largefiles: use standintolargefiles decorator for rollback

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Sep 24 08:42:12 CDT 2014


On Mon, 22 Sep 2014 11:13:35 +0200, Mads Kiilerich <mads at kiilerich.com> wrote:

> # HG changeset patch
> # User Mads Kiilerich <madski at unity3d.com>
> # Date 1411377060 -7200
> #      Mon Sep 22 11:11:00 2014 +0200
> # Node ID 5d277c50fc0e0b9788634518671b7afbd15611bb
> # Parent  0a6268c1e3ef11406fbaf186f5941069a08e2073
> largefiles: use standintolargefiles decorator for rollback
> 
> diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
> --- a/hgext/largefiles/overrides.py
> +++ b/hgext/largefiles/overrides.py
> @@ -1134,45 +1134,9 @@ def overridepurge(orig, ui, repo, *dirs,
>      orig(ui, repo, *dirs, **opts)
>      repo.status = oldstatus
>  
> + at lfutil.standintolargefiles(printmessage=False)
>  def overriderollback(orig, ui, repo, **opts):
> -    wlock = repo.wlock()
> -    try:
> -        before = repo.dirstate.parents()
> -        orphans = set(f for f in repo.dirstate
> -                      if lfutil.isstandin(f) and repo.dirstate[f] != 'r')
> -        result = orig(ui, repo, **opts)
> -        after = repo.dirstate.parents()
> -        if before == after:
> -            return result # no need to restore standins
> -
> -        pctx = repo['.']
> -        for f in repo.dirstate:
> -            if lfutil.isstandin(f):
> -                orphans.discard(f)
> -                if repo.dirstate[f] == 'r':
> -                    repo.wvfs.unlinkpath(f, ignoremissing=True)
> -                elif f in pctx:
> -                    fctx = pctx[f]
> -                    repo.wwrite(f, fctx.data(), fctx.flags())
> -                else:
> -                    # content of standin is not so important in 'a',
> -                    # 'm' or 'n' (coming from the 2nd parent) cases
> -                    lfutil.writestandin(repo, f, '', False)
> -        for standin in orphans:
> -            repo.wvfs.unlinkpath(standin, ignoremissing=True)
> -
> -        lfdirstate = lfutil.openlfdirstate(ui, repo)
> -        orphans = set(lfdirstate)
> -        lfiles = lfutil.listlfiles(repo)
> -        for file in lfiles:
> -            lfutil.synclfdirstate(repo, lfdirstate, file, True)
> -            orphans.discard(file)
> -        for lfile in orphans:
> -            lfdirstate.drop(lfile)
> -        lfdirstate.write()
> -    finally:
> -        wlock.release()
> -    return result
> +    return orig(ui, repo, **opts)
>  
>  @lfutil.standintolargefiles(printmessage=True)
>  def overridetransplant(orig, ui, repo, *revs, **opts):
> diff --git a/tests/test-largefiles-update.t b/tests/test-largefiles-update.t
> --- a/tests/test-largefiles-update.t
> +++ b/tests/test-largefiles-update.t
> @@ -126,6 +126,7 @@ Test that "hg rollback" restores status 
>    $ hg rollback
>    repository tip rolled back to revision 3 (undo commit)
>    working directory now based on revision 3
> +(largeY as added was incorrectly lost ... and other weird things happens)
>    $ hg status -A large1
>    R large1
>    $ test -f .hglf/large1
> @@ -137,11 +138,10 @@ Test that "hg rollback" restores status 
>    $ hg status -A largeX
>    A largeX
>    $ cat .hglf/largeX
> -  
> +  fa44618ea25181aff4f48b70428294790cec9f61
>    $ hg status -A largeY
>    ? largeY
>    $ test -f .hglf/largeY
> -  [1]

This orphan standin may cause unexpected conflict at following "hg
merge", as you commented.

Unlinking orphan standins below in the discarded "overriderollback"
code path seems not to be covered by "standintolargefiles" decorator.

> -        for standin in orphans:
> -            repo.wvfs.unlinkpath(standin, ignoremissing=True)

Is this omitting intentional ? or just ignored to avoid deeply
researching for quick proof of concept ?


BTW, I'm also working for putting dirstate-like files
(e.g. ".hg/largefiles/dirstate") into rollbacking targets of
transaction, and it achieves rollbacking with largefiles in another
way: dirstate/updating problems fixed by my previous serieses were
found while this work :-)


  
>  Test that "hg rollback" restores standins correctly
>  
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

-- 
----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp



More information about the Mercurial-devel mailing list