# HG changeset patch # User Pierre-Yves David # Date 1335370556 -7200 # Node ID a140d1857931ddf0cd8669ff81fa3b32865c8a98 # Parent ea4aa1890b1620ac4e42f1575b044a57abb657f5 obsolete: do not warn about unpushed extinct changeset. diff -r ea4aa1890b16 -r a140d1857931 hgext/obsolete.py --- a/hgext/obsolete.py Tue Apr 24 15:56:31 2012 +0200 +++ b/hgext/obsolete.py Wed Apr 25 18:15:56 2012 +0200 @@ -280,6 +280,30 @@ pushkey.register('obsolete', pushobsolete, listobsolete) +### Discovery wrapping +############################# + +class blist(list, object): + """silly class to have non False but empty list""" + + def __nonzero__(self): + return bool(len(self.orig)) + +def wrapfindcommonoutgoing(orig, repo, *args, **kwargs): + """wrap mercurial.discovery.findcommonoutgoing to remove extinct changeset + + Such excluded changeset are removed from excluded and will *not* appear + are excluded secret changeset. + """ + outgoing = orig(repo, *args, **kwargs) + orig = outgoing.excluded + outgoing.excluded = blist(n for n in orig if not repo[n].extinct()) + # when no revision is specified (push everything) a shortcut is taken when + # nothign was exclude. taking this code path when extinct changeset have + # been excluded leads to repository corruption. + outgoing.excluded.orig = orig + return outgoing + ### New commands ############################# @@ -307,6 +331,7 @@ def uisetup(ui): extensions.wrapcommand(commands.table, "update", wrapmayobsoletewc) extensions.wrapcommand(commands.table, "pull", wrapmayobsoletewc) + extensions.wrapfunction(discovery, 'findcommonoutgoing', wrapfindcommonoutgoing) ### serialisation ############################# diff -r ea4aa1890b16 -r a140d1857931 tests/test-corrupt.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-corrupt.t Wed Apr 25 18:15:56 2012 +0200 @@ -0,0 +1,122 @@ + + $ cat >> $HGRCPATH < [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" + > } + + $ hg init local + $ hg init other + $ cd local + $ touch 1 2 3 4 5 6 7 8 9 0 + $ hg add 1 2 3 4 5 6 7 8 9 0 + $ mkcommit A + $ mkcommit B + $ mkcommit C + $ hg glog + @ changeset: 2:829b19580856 + | tag: tip + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: add C + | + o changeset: 1:97b8f02ab29e + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: add B + | + o changeset: 0:5d8dabd3961b + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: add A + + $ hg push ../other + pushing to ../other + searching for changes + adding changesets + adding manifests + adding file changes + added 3 changesets with 13 changes to 13 files + + + $ hg -R ../other verify + checking changesets + checking manifests + crosschecking files in changesets and manifests + checking files + 13 files, 3 changesets, 13 total revisions + $ mkcommit D + $ mkcommit E + $ hg up -q .^^ + $ hg revert -r tip -a -q + $ hg ci -m 'coin' -q + $ hg glog + @ changeset: 5:8313a6afebbb + | tag: tip + | parent: 2:829b19580856 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: coin + | + | o changeset: 4:076ec8ade1ac + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: add E + | | + | o changeset: 3:824d9bb109f6 + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: add D + | + o changeset: 2:829b19580856 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: add C + | + o changeset: 1:97b8f02ab29e + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: add B + | + o changeset: 0:5d8dabd3961b + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: add A + + + $ hg kill -n -1 -- -2 -3 + $ hg push ../other + pushing to ../other + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + $ hg -R ../other verify + checking changesets + checking manifests + crosschecking files in changesets and manifests + checking files + 15 files, 4 changesets, 15 total revisions + + + diff -r ea4aa1890b16 -r a140d1857931 tests/test-obsolete.t --- a/tests/test-obsolete.t Tue Apr 24 15:56:31 2012 +0200 +++ b/tests/test-obsolete.t Wed Apr 25 18:15:56 2012 +0200 @@ -124,6 +124,7 @@ adding manifests adding file changes added 5 changesets with 5 changes to 5 files (+1 heads) + $ qlog -R ../other-new verify $ qlog -R ../other-new -r 'obsolete()' 2 - 0d3f46688ccc @@ -178,6 +179,15 @@ $ qlog -R ../other-new -r 'obsolete()' 2 - 0d3f46688ccc + +Pushing again does not advertise extinct changeset + + $ hg push ../other-new + pushing to ../other-new + searching for changes + no changes found + [1] + $ hg up -q .^ # 3 Working directory parent is obsolete $ mkcommit "obsol_d'" # 7