Mercurial > evolve
view tests/test-evolve.t @ 475:9f69a5e41ab0 stable
[evolve] amend: check phase before starting the transition
We better abort before starting a useless transaction.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Tue, 21 Aug 2012 12:42:09 +0200 |
parents | 5c031e1c90e2 |
children | f17a0f801e0b |
line wrap: on
line source
$ cat >> $HGRCPATH <<EOF > [defaults] > amend=-d "0 0" > [web] > push_ssl = false > allow_push = * > [phases] > publish = False > [alias] > qlog = log --template='{rev} - {node|short} {desc} ({phase})\n' > [diff] > git = 1 > unified = 0 > [extensions] > hgext.rebase= > hgext.graphlog= > EOF $ echo "obsolete=$(echo $(dirname $TESTDIR))/hgext/obsolete.py" >> $HGRCPATH $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext/evolve.py" >> $HGRCPATH $ mkcommit() { > echo "$1" > "$1" > hg add "$1" > hg ci -m "add $1" > } $ glog() { > hg glog --template '{rev}:{node|short}@{branch}({phase}) {desc|firstline}\n' "$@" > } various init $ hg init local $ cd local $ mkcommit a $ mkcommit b $ cat >> .hg/hgrc << EOF > [phases] > publish = True > EOF $ hg pull -q . # make 1 public $ rm .hg/hgrc $ mkcommit c $ mkcommit d $ hg up 1 0 files updated, 0 files merged, 2 files removed, 0 files unresolved $ mkcommit e -q created new head $ mkcommit f $ hg qlog 5 - e44648563c73 add f (draft) 4 - fbb94e3a0ecf add e (draft) 3 - 47d2a3944de8 add d (draft) 2 - 4538525df7e2 add c (draft) 1 - 7c3bad9141dc add b (public) 0 - 1f0dee641bb7 add a (public) test kill and immutable changeset $ hg log -r 1 --template '{rev} {phase} {obsolete}\n' 1 public stable $ hg kill 1 cannot kill immutable changeset 7c3bad9141dc $ hg log -r 1 --template '{rev} {phase} {obsolete}\n' 1 public stable test simple kill $ hg id -n 5 $ hg kill . 0 files updated, 0 files merged, 1 files removed, 0 files unresolved working directory now at fbb94e3a0ecf $ hg qlog 4 - fbb94e3a0ecf add e (draft) 3 - 47d2a3944de8 add d (draft) 2 - 4538525df7e2 add c (draft) 1 - 7c3bad9141dc add b (public) 0 - 1f0dee641bb7 add a (public) test multiple kill $ hg kill 4 3 0 files updated, 0 files merged, 1 files removed, 0 files unresolved working directory now at 7c3bad9141dc $ hg qlog 2 - 4538525df7e2 add c (draft) 1 - 7c3bad9141dc add b (public) 0 - 1f0dee641bb7 add a (public) test kill with dirty changes $ hg up 2 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ echo 4 > g $ hg add g $ hg kill . 0 files updated, 0 files merged, 1 files removed, 0 files unresolved working directory now at 7c3bad9141dc $ hg st A g $ cd .. ########################## importing Parren test ########################## $ cat << EOF >> $HGRCPATH > [ui] > logtemplate = "{rev}\t{bookmarks}: {desc|firstline} - {author|user}\n" > EOF Creating And Updating Changeset =============================== Setup the Base Repo ------------------- We start with a plain base repo:: $ hg init main; cd main $ cat >main-file-1 <<-EOF > One > > Two > > Three > EOF $ echo Two >main-file-2 $ hg add adding main-file-1 adding main-file-2 $ hg commit --message base $ cd .. and clone this into a new repo where we do our work:: $ hg clone main work updating to branch default 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd work Create First Patch ------------------ To begin with, we just do the changes that will be the initial version of the changeset:: $ echo One >file-from-A $ sed -i'' -e s/One/Eins/ main-file-1 $ hg add file-from-A So this is what we would like our changeset to be:: $ hg diff diff --git a/file-from-A b/file-from-A new file mode 100644 --- /dev/null +++ b/file-from-A @@ -0,0 +1,1 @@ +One diff --git a/main-file-1 b/main-file-1 --- a/main-file-1 +++ b/main-file-1 @@ -1,1 +1,1 @@ -One +Eins To commit it we just - commit it:: $ hg commit --message "a nifty feature" and place a bookmark so we can easily refer to it again (which we could have done before the commit):: $ hg book feature-A Create Second Patch ------------------- Let's do this again for the second changeset:: $ echo Two >file-from-B $ sed -i'' -e s/Two/Zwie/ main-file-1 $ hg add file-from-B Before committing, however, we need to switch to a new bookmark for the second changeset. Otherwise we would inadvertently move the bookmark for our first changeset. It is therefore advisable to always set the bookmark before committing:: $ hg book feature-B $ hg commit --message "another feature" So here we are:: $ hg book feature-A 1:568a468b60fc * feature-B 2:7b36850622b2 Fix The Second Patch -------------------- There's a typo in feature-B. We spelled *Zwie* instead of *Zwei*:: $ hg diff --change tip | grep -F Zwie +Zwie Fixing this is very easy. Just change:: $ sed -i'' -e s/Zwie/Zwei/ main-file-1 and **amend**:: $ hg amend --note "fix spelling of Zwei" The `--note` is our commit message for the *update* only. So its only purpose is to document the evolution of the changeset. If we use `--message` with `amend`, it replaces the commit message of the changeset itself. This results in a new single changeset for our amended changeset, and the old changeset plus the updating changeset are hidden from view by default:: $ hg log 4 feature-B: another feature - test 1 feature-A: a nifty feature - test 0 : base - test $ hg up feature-A -q $ hg bookmark -i feature-A $ sed -i'' -e s/Eins/Un/ main-file-1 (amend of public changeset denied) $ hg phase --public 0 -v phase changed for 1 changesets $ hg amend -c 2 abort: cannot amend non ancestor changeset [255] $ hg amend --note 'french looks better' 1 new unstables changesets $ hg log 6 feature-A: a nifty feature - test 4 feature-B: another feature - test 1 : a nifty feature - test 0 : base - test $ hg up -q 0 $ glog --hidden o 6:23409eba69a0@default(draft) a nifty feature | | o 5:e416e48b2742@default(secret) french looks better | | | | o 4:f8111a076f09@default(draft) another feature | |/ | | o 3:524e478d4811@default(secret) fix spelling of Zwei | | | | | o 2:7b36850622b2@default(secret) another feature | |/ | o 1:568a468b60fc@default(draft) a nifty feature |/ @ 0:e55e0562ee93@default(public) base $ hg debugsuccessors 524e478d4811 f8111a076f09 568a468b60fc 23409eba69a0 7b36850622b2 f8111a076f09 e416e48b2742 23409eba69a0 $ hg stabilize move:[4] another feature atop:[6] a nifty feature merging main-file-1 $ hg log 7 feature-B: another feature - test 6 feature-A: a nifty feature - test 0 : base - test Test commit -o options $ hg up 6 1 files updated, 0 files merged, 1 files removed, 0 files unresolved $ hg revert -r 7 --all adding file-from-B reverting main-file-1 $ sed -i'' -e s/Zwei/deux/ main-file-1 $ hg commit -m 'another feature that rox' -o 7 created new head $ hg log 8 feature-B: another feature that rox - test 6 feature-A: a nifty feature - test 0 : base - test phase change turning obsolete changeset public issue a latecomer warning $ hg phase --public 7 1 new latecomers changesets $ cd .. enable general delta $ cat << EOF >> $HGRCPATH > [format] > generaldelta=1 > EOF $ hg init alpha $ cd alpha $ echo 'base' > firstfile $ hg add firstfile $ hg ci -m 'base' $ cd .. $ hg clone -Ur 0 alpha beta adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files $ cd alpha $ cat << EOF > A > We > need > some > kind > of > file > big > enough > to > prevent > snapshot > . > yes > new > lines > are > useless > . > EOF $ hg add A $ hg commit -m 'adding A' $ hg mv A B $ echo '.' >> B $ hg amend -m 'add B' $ hg verify checking changesets checking manifests crosschecking files in changesets and manifests checking files 3 files, 4 changesets, 4 total revisions $ hg --config extensions.hgext.mq= strip 'extinct()' saved backup bundle to $TESTTMP/alpha/.hg/strip-backup/e87767087a57-backup.hg $ hg verify checking changesets checking manifests crosschecking files in changesets and manifests checking files 2 files, 2 changesets, 2 total revisions $ cd .. Clone just this branch $ cd beta $ hg pull -r tip ../alpha pulling from ../alpha searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (run 'hg update' to get a working copy) $ hg up 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd .. Test graft --obsolete/--old-obsolete $ hg init test-graft $ cd test-graft $ mkcommit 0 $ mkcommit 1 $ mkcommit 2 $ mkcommit 3 $ hg up -qC 0 $ mkcommit 4 created new head $ glog --hidden @ 4:ce341209337f@default(draft) add 4 | | o 3:0e84df4912da@default(draft) add 3 | | | o 2:db038628b9e5@default(draft) add 2 | | | o 1:73d38bb17fd7@default(draft) add 1 |/ o 0:8685c6d34325@default(draft) add 0 $ hg graft 3 -O grafting revision 3 $ hg graft 1 -o 2 grafting revision 1 $ glog --hidden @ 6:acb28cd497b7@default(draft) add 1 | o 5:0b9e50c35132@default(draft) add 3 | o 4:ce341209337f@default(draft) add 4 | | o 3:0e84df4912da@default(secret) add 3 | | | o 2:db038628b9e5@default(secret) add 2 | | | o 1:73d38bb17fd7@default(draft) add 1 |/ o 0:8685c6d34325@default(draft) add 0 $ hg debugsuccessors 0e84df4912da 0b9e50c35132 db038628b9e5 acb28cd497b7 Test graft --continue $ hg up -qC 0 $ echo 2 > 1 $ hg ci -Am conflict 1 created new head $ hg up -qC 6 $ hg graft -O 7 grafting revision 7 merging 1 warning: conflicts during merge. merging 1 incomplete! (edit conflicts, then use 'hg resolve --mark') abort: unresolved conflicts, can't continue (use hg resolve and hg graft --continue) [255] $ hg log -r7 --template '{rev}:{node|short} {obsolete}\n' 7:a5bfd90a2f29 stable $ echo 3 > 1 $ hg resolve -m 1 $ hg graft --continue -O grafting revision 7 $ glog --hidden @ 8:920e58bb443b@default(draft) conflict | | o 7:a5bfd90a2f29@default(secret) conflict | | o | 6:acb28cd497b7@default(draft) add 1 | | o | 5:0b9e50c35132@default(draft) add 3 | | o | 4:ce341209337f@default(draft) add 4 |/ | o 3:0e84df4912da@default(secret) add 3 | | | o 2:db038628b9e5@default(secret) add 2 | | | o 1:73d38bb17fd7@default(draft) add 1 |/ o 0:8685c6d34325@default(draft) add 0 $ hg debugsuccessors 0e84df4912da 0b9e50c35132 a5bfd90a2f29 920e58bb443b db038628b9e5 acb28cd497b7 $ cd ..