changeset 279:0d87b1fbf32b

obsolete: handle rebase removing empty changesets The new revision identifier returned by concludenode() was None and was not correctly translated to nullid.
author Patrick Mezard <patrick@mezard.eu>
date Tue, 19 Jun 2012 18:02:34 +0200
parents fa0b9b8a83c0
children fd43e3908f09
files hgext/obsolete.py tests/test-obsolete-rebase.t
diffstat 2 files changed, 72 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/obsolete.py	Tue Jun 19 10:24:47 2012 +0200
+++ b/hgext/obsolete.py	Tue Jun 19 18:02:34 2012 +0200
@@ -230,7 +230,11 @@
     """wrapper for rebase 's concludenode that set obsolete relation"""
     newrev = orig(repo, rev, *args, **kwargs)
     oldnode = repo[rev].node()
-    newnode = repo[newrev].node()
+    if newrev is not None:
+        newnode = repo[newrev].node()
+    else:
+        # Revision was emptied and removed, there is no successor.
+        newnode = nullid
     repo.addobsolete(newnode, oldnode)
     return newrev
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-obsolete-rebase.t	Tue Jun 19 18:02:34 2012 +0200
@@ -0,0 +1,67 @@
+  $ cat >> $HGRCPATH <<EOF
+  > [defaults]
+  > amend=-d "0 0"
+  > [extensions]
+  > hgext.rebase=
+  > hgext.graphlog=
+  > EOF
+  $ echo "obsolete=$(echo $(dirname $TESTDIR))/hgext/obsolete.py" >> $HGRCPATH
+
+  $ glog() {
+  >   hg glog --template '{rev}:{node|short}@{branch}({phase}) {desc|firstline}\n'\
+  >     "$@"
+  > }
+
+  $ hg init repo
+  $ cd repo
+  $ echo a > a
+  $ hg ci -Am adda
+  adding a
+  $ echo a >> a
+  $ hg ci -m changea
+
+Test regular rebase
+
+  $ hg up 0
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo b > b
+  $ hg ci -Am addb
+  adding b
+  created new head
+  $ hg rebase -d 1
+  $ glog --hidden
+  @  3:03f017c74faa@default(draft) addb
+  |
+  | o  2:102a90ea7b4a@default(secret) addb
+  | |
+  o |  1:540395c44225@default(draft) changea
+  |/
+  o  0:07f494440405@default(draft) adda
+  
+  $ hg debugsuccessors
+  102a90ea7b4a 03f017c74faa
+
+Test rebase with deleted empty revision
+
+  $ hg up 0
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg branch foo
+  marked working directory as branch foo
+  (branches are permanent and global, did you want a bookmark?)
+  $ echo a >> a
+  $ hg ci -m changea
+  $ hg rebase -d 1
+  $ glog --hidden
+  o  4:4e322f7ce8e3@foo(secret) changea
+  |
+  | o  3:03f017c74faa@default(draft) addb
+  | |
+  +---o  2:102a90ea7b4a@default(secret) addb
+  | |
+  | @  1:540395c44225@default(draft) changea
+  |/
+  o  0:07f494440405@default(draft) adda
+  
+  $ hg debugsuccessors
+  102a90ea7b4a 03f017c74faa
+  4e322f7ce8e3 000000000000