Mercurial > hg
view tests/test-default-push.t @ 26631:e077ce385609
localrepo: restore dirstate to one before rollbacking if not parent-gone
'localrepository.rollback()' explicilty restores dirstate, only if at
least one of current parents of the working directory is removed at
rollbacking (a.k.a "parent-gone").
After DirstateTransactionPlan, 'dirstate.write()' will cause marking
'.hg/dirstate' as a file to be restored at rollbacking.
https://mercurial.selenic.com/wiki/DirstateTransactionPlan
Then, 'transaction.rollback()' restores '.hg/dirstate' regardless of
parents of the working directory at that time, and this causes
unexpected dirstate changes if not "parent-gone" (e.g. "hg update" to
another branch after "hg commit" or so, then "hg rollback").
To avoid such situation, this patch restores dirstate to one before
rollbacking if not "parent-gone".
before:
b1. restore dirstate explicitly, if "parent-gone"
after:
a1. save dirstate before actual rollbacking via dirstateguard
a2. restore dirstate via 'transaction.rollback()'
a3. if "parent-gone"
- discard backup (a1)
- restore dirstate from 'undo.dirstate'
a4. otherwise, restore dirstate from backup (a1)
Even though restoring dirstate at (a3) after (a2) seems redundant,
this patch keeps this existing code path, because:
- it isn't ensured that 'dirstate.write()' was invoked at least once
while transaction running
If not, '.hg/dirstate' isn't restored at (a2).
In addition to it, rude 3rd party extension invoking
'dirstate.write()' without 'repo' while transaction running (see
subsequent patches for detail) may break consistency of a file
backup-ed by transaction.
- this patch mainly focuses on changes for DirstateTransactionPlan
Restoring dirstate at (a3) itself should be cheaper enough than
rollbacking itself. Redundancy will be removed in next step.
Newly added test is almost meaningless at this point. It will be used
to detect regression while implementing delayed dirstate write out.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 13 Oct 2015 12:25:43 -0700 |
parents | 663fbc336e22 |
children | 71d5238f92e9 |
line wrap: on
line source
$ hg init a $ echo a > a/a $ hg --cwd a ci -Ama adding a $ hg clone a c updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg clone a b updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ echo b >> b/a $ hg --cwd b ci -mb Push should provide a hint when both 'default' and 'default-push' not set: $ cd c $ hg push --config paths.default= abort: default repository not configured! (see the "path" section in "hg help config") [255] $ cd .. Push should push to 'default' when 'default-push' not set: $ hg --cwd b push pushing to $TESTTMP/a (glob) searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files Push should push to 'default-push' when set: $ echo '[paths]' >> b/.hg/hgrc $ echo 'default-push = ../c' >> b/.hg/hgrc $ hg --cwd b push pushing to $TESTTMP/c (glob) searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files Pushing to a path that isn't defined should not fall back to default $ hg --cwd b push doesnotexist abort: repository doesnotexist does not exist! [255]