Mercurial > hg-stable
changeset 23184:3100d1cbce32
largefiles: factor out procedures to update lfdirstate for post-committing
Before this patch, procedures to update lfdirstate for post-committing
are scattered in "lfilesrepo.commit". In the case of "hg commit" with
patterns for target files ("Case 2"), lfdirstate is updated BEFORE
real committing.
This patch factors out procedures to update lfdirstate for
post-committing into "lfutil.markcommitted", and makes it callable via
"markcommitted" of the context passed to "lfilesrepo.commitctx".
"markcommitted" of the context is called, only when it is committed
successfully.
Passing original "markcommitted" of the context is meaningless in this
patch, but required in subsequent one to prepare something before
invocation of it.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 05 Nov 2014 23:24:47 +0900 |
parents | 51c9196a6bd0 |
children | 9870173e0b48 |
files | hgext/largefiles/lfutil.py hgext/largefiles/reposetup.py |
diffstat | 2 files changed, 19 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/lfutil.py Wed Nov 05 23:24:47 2014 +0900 +++ b/hgext/largefiles/lfutil.py Wed Nov 05 23:24:47 2014 +0900 @@ -386,6 +386,18 @@ elif state == '?': lfdirstate.drop(lfile) +def markcommitted(orig, ctx, node): + repo = ctx._repo + + orig(node) + + lfdirstate = openlfdirstate(repo.ui, repo) + for f in ctx.files(): + if isstandin(f): + lfile = splitstandin(f) + synclfdirstate(repo, lfdirstate, lfile, False) + lfdirstate.write() + def getlfilestoupdate(oldstandins, newstandins): changedstandins = set(oldstandins).symmetric_difference(set(newstandins)) filelist = []
--- a/hgext/largefiles/reposetup.py Wed Nov 05 23:24:47 2014 +0900 +++ b/hgext/largefiles/reposetup.py Wed Nov 05 23:24:47 2014 +0900 @@ -243,9 +243,14 @@ # As part of committing, copy all of the largefiles into the # cache. - def commitctx(self, *args, **kwargs): - node = super(lfilesrepo, self).commitctx(*args, **kwargs) + def commitctx(self, ctx, *args, **kwargs): + node = super(lfilesrepo, self).commitctx(ctx, *args, **kwargs) lfutil.copyalltostore(self, node) + class lfilesctx(ctx.__class__): + def markcommitted(self, node): + orig = super(lfilesctx, self).markcommitted + return lfutil.markcommitted(orig, self, node) + ctx.__class__ = lfilesctx return node # Before commit, largefile standins have not had their @@ -270,16 +275,6 @@ getattr(self, "_istransplanting", False): result = orig(text=text, user=user, date=date, match=match, force=force, editor=editor, extra=extra) - - if result: - lfdirstate = lfutil.openlfdirstate(ui, self) - for f in self[result].files(): - if lfutil.isstandin(f): - lfile = lfutil.splitstandin(f) - lfutil.synclfdirstate(self, lfdirstate, lfile, - False) - lfdirstate.write() - return result # Case 1: user calls commit with no specific files or # include/exclude patterns: refresh and commit all files that @@ -308,22 +303,10 @@ if os.path.exists(self.wjoin(lfile)): lfutil.updatestandin(self, lfutil.standin(lfile)) - lfdirstate.normal(lfile) result = orig(text=text, user=user, date=date, match=match, force=force, editor=editor, extra=extra) - if result is not None: - for lfile in lfdirstate: - if lfile in modifiedfiles: - if (not os.path.exists(self.wjoin( - lfutil.standin(lfile)))) or \ - (not os.path.exists(self.wjoin(lfile))): - lfdirstate.drop(lfile) - - # This needs to be after commit; otherwise precommit hooks - # get the wrong status - lfdirstate.write() return result lfiles = lfutil.listlfiles(self) @@ -350,9 +333,6 @@ lfile = lfutil.splitstandin(standin) if lfdirstate[lfile] != 'r': lfutil.updatestandin(self, standin) - lfdirstate.normal(lfile) - else: - lfdirstate.drop(lfile) # Cook up a new matcher that only matches regular files or # standins corresponding to the big files requested by the @@ -386,9 +366,6 @@ match.matchfn = matchfn result = orig(text=text, user=user, date=date, match=match, force=force, editor=editor, extra=extra) - # This needs to be after commit; otherwise precommit hooks - # get the wrong status - lfdirstate.write() return result finally: wlock.release()