Commits

Patrick Mézard committed 0d87b1f

obsolete: handle rebase removing empty changesets

The new revision identifier returned by concludenode() was None and was
not correctly translated to nullid.

  • Participants
  • Parent commits fa0b9b8

Comments (0)

Files changed (2)

hgext/obsolete.py

     """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
 

tests/test-obsolete-rebase.t

+  $ 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