[PATCH 2 of 3 V2] localrepo: use dirstate restorebackup instead of copying dirstate manually

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu May 12 21:52:36 EDT 2016


At Wed, 11 May 2016 14:30:43 -0700,
Mateusz Kwapich wrote:
> 
> # HG changeset patch
> # User Mateusz Kwapich <mitrandir at fb.com>
> # Date 1463002211 25200
> #      Wed May 11 14:30:11 2016 -0700
> # Node ID ff880d9c73800358230da3a7ff447e12a5a91b3c
> # Parent  a1b956549c45a0191956bc074f276bd18afd40c1
> localrepo: use dirstate restorebackup instead of copying dirstate manually
> 
> This is one step towards having dirstate manage its own storage. It will
> be useful for the implementation of sqldirstate [1].
> 
> I'm deleting of one of the dirstate.invalidate() calls because restorebackup
> method does that for us.
> 
> [1] https://www.mercurial-scm.org/wiki/SQLDirstatePlan
> 
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -1047,7 +1047,7 @@ class localrepository(object):
>  
>                  # discard all changes (including ones already written
>                  # out) in this transaction
> -                repo.vfs.rename('journal.dirstate', 'dirstate')
> +                repo.dirstate.restorebackup(None, prefix='journal.')

This restoring makes dirstate.invalidate() immediately preceding in
releasefn() (but out of this patch chunk) meaningless, because
restorebackup() does so internally, doesn't it ?

LGTM, other of this series.

>  
>                  repo.invalidate(clearfilecache=True)
>  
> @@ -1189,7 +1189,7 @@ class localrepository(object):
>              # prevent dirstateguard from overwriting already restored one
>              dsguard.close()
>  
> -            self.vfs.rename('undo.dirstate', 'dirstate')
> +            self.dirstate.restorebackup(None, prefix='undo.')
>              try:
>                  branch = self.vfs.read('undo.branch')
>                  self.dirstate.setbranch(encoding.tolocal(branch))
> @@ -1198,7 +1198,6 @@ class localrepository(object):
>                            'current branch is still \'%s\'\n')
>                          % self.dirstate.branch())
>  
> -            self.dirstate.invalidate()
>              parents = tuple([p.rev() for p in self[None].parents()])
>              if len(parents) > 1:
>                  ui.status(_('working directory now based on '
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

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


More information about the Mercurial-devel mailing list