Mercurial > hg
changeset 22285:85bded43cc80
largefiles: restore standins according to restored dirstate
Before this patch, standins are restored from the NEW parent of the
working directory at "hg rollback", and this causes:
- standins removed in the rollback-ed revision are restored, and
become orphan, because they are already marked as "R" in the
restored dirstate and expected to be unlinked
- standins added in the rollback-ed revision are left as they were
before rollback, because they are not included in the new parent
(this may not be so serious)
This patch replaces the "merge.update" invocation with a specific
implementation to restore standins according to restored dirstate.
This is also the preparation to centralize the logic of updating
largefiles into the function wrapping "merge.update" in the subsequent
patch.
After that patch, "merge.update" will also update largefiles in the
working directory and be redundant for restoring standins only.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sun, 24 Aug 2014 23:47:25 +0900 |
parents | 72b378658cff |
children | 3f3b9483e7ef |
files | hgext/largefiles/overrides.py tests/test-largefiles-update.t |
diffstat | 2 files changed, 25 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py Sun Aug 24 23:47:25 2014 +0900 +++ b/hgext/largefiles/overrides.py Sun Aug 24 23:47:25 2014 +0900 @@ -12,7 +12,7 @@ import copy from mercurial import hg, commands, util, cmdutil, scmutil, match as match_, \ - archival, merge, pathutil, revset + archival, pathutil, revset from mercurial.i18n import _ from mercurial.node import hex from hgext import rebase @@ -1202,8 +1202,18 @@ if before == after: return result # no need to restore standins - merge.update(repo, node='.', branchmerge=False, force=True, - partial=lfutil.isstandin) + pctx = repo['.'] + for f in repo.dirstate: + if lfutil.isstandin(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) lfdirstate = lfutil.openlfdirstate(ui, repo) orphans = set(lfdirstate)
--- a/tests/test-largefiles-update.t Sun Aug 24 23:47:25 2014 +0900 +++ b/tests/test-largefiles-update.t Sun Aug 24 23:47:25 2014 +0900 @@ -103,9 +103,15 @@ $ hg update -C -q $ hg remove large1 + $ test -f .hglf/large1 + [1] $ hg forget large2 + $ test -f .hglf/large2 + [1] $ echo largeX > largeX $ hg add --large largeX + $ cat .hglf/largeX + $ hg commit -m 'will be rollback-ed soon' $ echo largeY > largeY $ hg add --large largeY @@ -122,10 +128,16 @@ working directory now based on revision 3 $ hg status -A large1 R large1 + $ test -f .hglf/large1 + [1] $ hg status -A large2 R large2 + $ test -f .hglf/large2 + [1] $ hg status -A largeX A largeX + $ cat .hglf/largeX + $ hg status -A largeY ? largeY