tests/test-topic-debugcb.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Fri, 01 Sep 2017 12:02:27 +0200
changeset 2903 d16781d7a061
parent 2902 f6e297fda5c6
child 2904 4ae89b5834e6
permissions -rw-r--r--
tests: import section in 'test-topic-debugcb.t' We now have two levels of titles to clarify some aspect of the tests.

==================================================
Test for `hg debugconvertbookmark` added by topics
==================================================

  $ . "$TESTDIR/testlib/topic_setup.sh"

  $ cat << EOF >> $HGRCPATH
  > drawdag=$RUNTESTDIR/drawdag.py
  > [ui]
  > logtemplate = [{rev}:{node|short}] {desc|firstline}\n\
  > {if(bookmarks, "  bookmark: {join(bookmarks,"\n  bookmark:")}\n")}\
  > {if(topics, "  topic: {topics}\n")}
  > EOF

Setting up the things
---------------------

  $ hg init repo
  $ cd repo
  $ echo "Hello" > a
  $ hg commit -Aqm "First commit"
  $ echo "Hello" > b
  $ hg commit -Aqm "Second commit"
  $ hg bookmark "hellos"
  $ hg up 0 -q
  $ echo "Fix 1" > l
  $ hg commit -Aqm "Fixing first"
  $ echo "Fix 2" > m
  $ hg commit -Aqm "Fixing second"
  $ hg bookmark "secondfix"

  $ hg log -G
  @  [3:b985e4fea4a4] Fixing second
  |    bookmark: secondfix
  o  [2:8e79b09248c2] Fixing first
  |
  | o  [1:50634233706a] Second commit
  |/     bookmark: hellos
  o  [0:3caf92e45cfb] First commit
  

Generic tests
=============

Help for the command
--------------------

  $ hg help debugconvertbookmark
  hg debugcb [-b BOOKMARK] [--all]
  
  aliases: debugconvertbookmark
  
  Converts a bookmark to a topic with the same name.
  
  options:
  
   -b --bookmark VALUE bookmark to convert to topic
      --all            convert all bookmarks to topics
  
  (some details hidden, use --verbose to show complete help)

Running without any argument
----------------------------

  $ hg debugconvertbookmark
  abort: you must specify either '--all' or '-b'
  [255]

Changing a particular bookmark to topic
=======================================

  $ hg debugconvertbookmark -b hellos
  changed topic to "hellos" on 1 revisions
  $ hg log -G
  o  [4:ca8825a7eb18] Second commit
  |    topic: hellos
  | @  [3:b985e4fea4a4] Fixing second
  | |    bookmark: secondfix
  | o  [2:8e79b09248c2] Fixing first
  |/
  o  [0:3caf92e45cfb] First commit
  

Changing all bookmarks to topic
===============================

Simple test
-----------

  $ hg debugconvertbookmark --all
  switching to topic secondfix
  changed topic to "secondfix" on 2 revisions
  $ hg log -G
  @  [6:6efc0524f97a] Fixing second
  |    topic: secondfix
  o  [5:0a4244c62a16] Fixing first
  |    topic: secondfix
  | o  [4:ca8825a7eb18] Second commit
  |/     topic: hellos
  o  [0:3caf92e45cfb] First commit
  

Trying with multiple bookmarks on a single changeset
----------------------------------------------------

  $ echo "multiple bookmarks" >> m
  $ hg commit -Aqm "Trying multiple bookmarks"
  $ hg bookmark book1
  $ hg bookmark book2
  $ hg log -G
  @  [7:7c46b4bbdda3] Trying multiple bookmarks
  |    bookmark: book1
  |    bookmark:book2
  |    topic: secondfix
  o  [6:6efc0524f97a] Fixing second
  |    topic: secondfix
  o  [5:0a4244c62a16] Fixing first
  |    topic: secondfix
  | o  [4:ca8825a7eb18] Second commit
  |/     topic: hellos
  o  [0:3caf92e45cfb] First commit
  
  $ hg debugconvertbookmark --all
  skipping '7' as it has multiple bookmarks on it
  $ hg log -G
  @  [7:7c46b4bbdda3] Trying multiple bookmarks
  |    bookmark: book1
  |    bookmark:book2
  |    topic: secondfix
  o  [6:6efc0524f97a] Fixing second
  |    topic: secondfix
  o  [5:0a4244c62a16] Fixing first
  |    topic: secondfix
  | o  [4:ca8825a7eb18] Second commit
  |/     topic: hellos
  o  [0:3caf92e45cfb] First commit
  

Two bookmarks on two different topological branches
---------------------------------------------------

  $ cd ..
  $ rm -rf repo
  $ hg init setup1
  $ cd setup1
  $ echo "Hello" > A
  $ hg commit -Aqm "A"
  $ echo "Hello" > B
  $ hg commit -Aqm "B"
  $ echo "Hello" > C
  $ hg commit -Aqm "C"
  $ echo "Hello" > D
  $ hg commit -Aqm "D"
  $ hg up 'desc(B)'
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ echo "Hello" > E
  $ hg commit -Aqm "E"
  $ echo "Hello" > F
  $ hg commit -Aqm "F"
  $ hg bookmark -r 'desc(D)' bar
  $ hg bookmark -r 'desc(F)' foo

  $ hg log -G
  @  [5:5a63fc519ddc] F
  |    bookmark: foo
  o  [4:a9fc8fb0c70c] E
  |
  | o  [3:e92ae92e366f] D
  | |    bookmark: bar
  | o  [2:9cc6a71c9557] C
  |/
  o  [1:a7922543592c] B
  |
  o  [0:fc58adec4bcd] A
  
  $ hg debugconvertbookmark --all
  changed topic to "bar" on 2 revisions
  switching to topic foo
  changed topic to "foo" on 2 revisions
  $ hg log -G
  @  [9:994cbef2c2d2] F
  |    topic: foo
  o  [8:b9d8ef5d5b8a] E
  |    topic: foo
  | o  [7:e8ba703ef9ab] D
  | |    topic: bar
  | o  [6:6307829aaf11] C
  |/     topic: bar
  o  [1:a7922543592c] B
  |
  o  [0:fc58adec4bcd] A
  

Two bookmarks on top of each other
----------------------------------

  $ cd ..
  $ rm -rf setup1
  $ hg init setup2
  $ cd setup2
  $ echo "Hello" > A
  $ hg commit -Aqm "A"
  $ hg phase --public .
  $ echo "Hello" > B
  $ hg commit -Aqm "B"
  $ echo "Hello" > C
  $ hg commit -Aqm "C"
  $ hg bookmark -r . bar
  $ echo "Hello" > D
  $ hg commit -Aqm "D"
  $ echo "Hello" > E
  $ hg commit -Aqm "E"
  $ hg bookmark -r . foo

  $ hg log -G
  @  [4:ef9d596cf6ea] E
  |    bookmark: foo
  o  [3:e92ae92e366f] D
  |
  o  [2:9cc6a71c9557] C
  |    bookmark: bar
  o  [1:a7922543592c] B
  |
  o  [0:fc58adec4bcd] A
  

XXX: this should bot only put topic 'foo' on 3,4 but also 'bar' on 0,1,2

  $ hg debugconvertbookmark --all
  switching to topic foo
  changed topic to "foo" on 2 revisions

  $ hg log -G
  @  [6:e2bbb25b8882] E
  |    topic: foo
  o  [5:71bced29cbae] D
  |    topic: foo
  o  [2:9cc6a71c9557] C
  |    bookmark: bar
  o  [1:a7922543592c] B
  |
  o  [0:fc58adec4bcd] A