Mercurial > hg
changeset 20827:ca5dd216cb62
localrepo: omit ".hgsubstate" also from "added" files
Before this patch, "localrepository.commit()" omits ".hgsubstate" from
"modified" (changes[0]) and "removed" (changes[2]) file list before
checking subrepositories, but leaves one in "added" (changes[1]) as it
is.
Then, "localrepository.commit()" adds ".hgsubstate" into "modified" or
"removed" list forcibly, according to subrepository statuses.
If "added" contains ".hgsubstate", the committed context will contain
two ".hgsubstate" in its "files": one from "added" (not omitted one),
and another from "modified" or "removed" (newly added one).
How many times ".hgsubstate" appears in "files" changes node hash,
even though revision content is same, because node hash calculation
uses the specified "files" directly (without duplication check or so).
This means that node hash of committed revision changes according to
existence of ".hgsubstate" in "added" at "localrepository.commit()".
".hgsubstate" is treated as "added", not only in accidental cases, but
also in the case of "qpush" for the patch adding ".hgsubstate".
This patch omits ".hgsubstate" also from "added" files before checking
subrepositories. This patch also omits ".hgsubstate" exclusion in
"qnew"/"qrefresh" introduced by changeset d666da075b91, because this
patch makes them meaningless.
"hg parents --template '{files}\n'" newly added to "test-mq-subrepo.t"
enhances checking unexpected multiple appearances of ".hgsubstate" in
"files" of created/refreshed MQ revisions.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 22 Mar 2014 23:39:51 +0900 |
parents | 3879ac3858ff |
children | 3210b7930899 |
files | hgext/mq.py mercurial/localrepo.py tests/test-mq-subrepo.t tests/test-subrepo.t |
diffstat | 4 files changed, 64 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Sat Mar 22 14:46:55 2014 -0500 +++ b/hgext/mq.py Sat Mar 22 23:39:51 2014 +0900 @@ -1048,7 +1048,7 @@ changes = self.checklocalchanges(repo, force=True) commitfiles = list(inclsubs) for files in changes[:3]: - commitfiles.extend([f for f in files if f != '.hgsubstate']) + commitfiles.extend(files) match = scmutil.matchfiles(repo, commitfiles) if len(repo[None].parents()) > 1: raise util.Abort(_('cannot manage merge changesets')) @@ -1577,7 +1577,7 @@ files = set(inclsubs) for x in refreshchanges: - files.update([f for f in x if f != '.hgsubstate']) + files.update(x) match = scmutil.matchfiles(repo, files) bmlist = repo[top].bookmarks()
--- a/mercurial/localrepo.py Sat Mar 22 14:46:55 2014 -0500 +++ b/mercurial/localrepo.py Sat Mar 22 23:39:51 2014 +0900 @@ -1193,10 +1193,9 @@ # only manage subrepos and .hgsubstate if .hgsub is present if '.hgsub' in wctx: # we'll decide whether to track this ourselves, thanks - if '.hgsubstate' in changes[0]: - changes[0].remove('.hgsubstate') - if '.hgsubstate' in changes[2]: - changes[2].remove('.hgsubstate') + for c in changes[:3]: + if '.hgsubstate' in c: + c.remove('.hgsubstate') # compare current state to last committed state # build new substate based on last committed state
--- a/tests/test-mq-subrepo.t Sat Mar 22 14:46:55 2014 -0500 +++ b/tests/test-mq-subrepo.t Sat Mar 22 23:39:51 2014 +0900 @@ -435,6 +435,8 @@ +b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub $ hg parents --template '{node}\n' f69e96d86e75a6d4fd88285dc9697acb23951041 + $ hg parents --template '{files}\n' + .hgsub .hgsubstate check also whether qnew not including ".hgsubstate" explicitly causes as same result (in node hash) as one including it. @@ -448,6 +450,8 @@ $ hg qnew -u test -d '0 0' import-at-qnew $ hg parents --template '{node}\n' f69e96d86e75a6d4fd88285dc9697acb23951041 + $ hg parents --template '{files}\n' + .hgsub .hgsubstate check whether qrefresh imports updated .hgsubstate correctly @@ -457,6 +461,8 @@ $ hg qpush applying import-at-qnew now at: import-at-qnew + $ hg parents --template '{files}\n' + .hgsub .hgsubstate $ hg qnew import-at-qrefresh $ echo sb > sub/sb @@ -468,7 +474,7 @@ $ cat .hgsubstate 88ac1bef5ed43b689d1d200b59886b675dec474b sub $ hg diff -c tip - diff -r 44f846335325 -r b3e8c5fa3aaa .hgsubstate + diff -r 05b056bb9c8c -r d987bec230f4 .hgsubstate --- a/.hgsubstate +++ b/.hgsubstate @@ -1,1 +1,1 @@ @@ -478,20 +484,22 @@ # HG changeset patch # Date 0 0 # User test - # Parent 44f846335325209be6be35dc2c9a4be107278c09 + # Parent 05b056bb9c8c05ff15258b84fd42ab3527271033 - diff -r 44f846335325 .hgsubstate + diff -r 05b056bb9c8c .hgsubstate --- a/.hgsubstate +++ b/.hgsubstate @@ -1,1 +1,1 @@ -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub +88ac1bef5ed43b689d1d200b59886b675dec474b sub + $ hg parents --template '{files}\n' + .hgsubstate $ hg qrefresh -u test -d '0 0' $ cat .hgsubstate 88ac1bef5ed43b689d1d200b59886b675dec474b sub $ hg diff -c tip - diff -r 44f846335325 -r b3e8c5fa3aaa .hgsubstate + diff -r 05b056bb9c8c -r d987bec230f4 .hgsubstate --- a/.hgsubstate +++ b/.hgsubstate @@ -1,1 +1,1 @@ @@ -501,14 +509,16 @@ # HG changeset patch # Date 0 0 # User test - # Parent 44f846335325209be6be35dc2c9a4be107278c09 + # Parent 05b056bb9c8c05ff15258b84fd42ab3527271033 - diff -r 44f846335325 .hgsubstate + diff -r 05b056bb9c8c .hgsubstate --- a/.hgsubstate +++ b/.hgsubstate @@ -1,1 +1,1 @@ -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub +88ac1bef5ed43b689d1d200b59886b675dec474b sub + $ hg parents --template '{files}\n' + .hgsubstate $ hg update -C tip 0 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -554,6 +564,8 @@ @@ -1,1 +1,1 @@ -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub +88ac1bef5ed43b689d1d200b59886b675dec474b sub + $ hg parents --template '{files}\n' + .hgsubstate check whether qrefresh not including ".hgsubstate" explicitly causes as same result (in node hash) as one including it. @@ -568,6 +580,8 @@ $ hg qrefresh -u test -d '0 0' $ hg parents --template '{node}\n' 7c48c35501aae6770ed9c2517014628615821a8e + $ hg parents --template '{files}\n' + .hgsub .hgsubstate $ hg qpop -a -q patch queue now empty @@ -579,6 +593,8 @@ $ hg qrefresh -u test -d '0 0' $ hg parents --template '{node}\n' 7c48c35501aae6770ed9c2517014628615821a8e + $ hg parents --template '{files}\n' + .hgsub .hgsubstate $ cd ..
--- a/tests/test-subrepo.t Sat Mar 22 14:46:55 2014 -0500 +++ b/tests/test-subrepo.t Sat Mar 22 23:39:51 2014 +0900 @@ -35,6 +35,18 @@ update: (current) $ hg ci -m1 +test handling .hgsubstate "added" explicitly. + + $ hg parents --template '{node}\n{files}\n' + 7cf8cfea66e410e8e3336508dfeec07b3192de51 + .hgsub .hgsubstate + $ hg rollback -q + $ hg add .hgsubstate + $ hg ci -m1 + $ hg parents --template '{node}\n{files}\n' + 7cf8cfea66e410e8e3336508dfeec07b3192de51 + .hgsub .hgsubstate + Revert subrepo and test subrepo fileset keyword: $ echo b > s/a @@ -99,6 +111,19 @@ commit: (clean) update: (current) +test handling .hgsubstate "modified" explicitly. + + $ hg parents --template '{node}\n{files}\n' + df30734270ae757feb35e643b7018e818e78a9aa + .hgsubstate + $ hg rollback -q + $ hg status -A .hgsubstate + M .hgsubstate + $ hg ci -m2 + $ hg parents --template '{node}\n{files}\n' + df30734270ae757feb35e643b7018e818e78a9aa + .hgsubstate + bump sub rev (and check it is ignored by ui.commitsubrepos) $ echo b > s/a @@ -184,6 +209,18 @@ $ hg ci -m8 # remove sub +test handling .hgsubstate "removed" explicitly. + + $ hg parents --template '{node}\n{files}\n' + 96615c1dad2dc8e3796d7332c77ce69156f7b78e + .hgsub .hgsubstate + $ hg rollback -q + $ hg remove .hgsubstate + $ hg ci -m8 + $ hg parents --template '{node}\n{files}\n' + 96615c1dad2dc8e3796d7332c77ce69156f7b78e + .hgsub .hgsubstate + merge tests $ hg co -C 3