tests/test-topic-debugcb.t
author Pulkit Goyal <7895pulkit@gmail.com>
Tue, 29 Aug 2017 18:13:33 +0530
changeset 2901 52e6b28704a7
parent 2900 1928e9c802dd
child 2902 f6e297fda5c6
permissions -rw-r--r--
tests: add more tests for debugconvertbookmark

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

  $ 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
  
Another setup
==============

  $ cd ..
  $ rm -rf repo
  $ hg init setup1
  $ cd setup1
  $ hg debugdrawdag <<EOF
  > D F
  > | |
  > C E
  > |/
  > B
  > |
  > A
  > EOF

  $ hg log -G
  o  [5:11abe3fb10b8] F
  |
  | o  [4:f585351a92f8] D
  | |
  o |  [3:49cb92066bfd] E
  | |
  | o  [2:26805aba1e60] C
  |/
  o  [1:112478962961] B
  |
  o  [0:426bada5c675] A
  
  $ hg bookmark -r 5 foo
  $ hg bookmark -r 4 bar
  $ hg debugconvertbookmark --all
  changed topic to "bar" on 2 revisions
  changed topic to "foo" on 2 revisions
  $ hg log -G
  o  [9:f07a5aaa3365] F
  |    topic: foo
  o  [8:00a25ca4fa07] E
  |    topic: foo
  | o  [7:603a45fb0033] D
  | |    topic: bar
  | o  [6:67dd4179b021] C
  |/     topic: bar
  | x  [5:11abe3fb10b8] F
  | |
  | | x  [4:f585351a92f8] D
  | | |
  | x |  [3:49cb92066bfd] E
  |/ /
  | x  [2:26805aba1e60] C
  |/
  o  [1:112478962961] B
  |
  o  [0:426bada5c675] A
  
Another Setup
=============

  $ cd ..
  $ rm -rf setup1
  $ hg init setup2
  $ cd setup2
  $ hg debugdrawdag <<EOF
  > E
  > |
  > D
  > |
  > C
  > |
  > B
  > |
  > A
  > EOF

  $ hg log -G
  o  [4:9bc730a19041] E
  |
  o  [3:f585351a92f8] D
  |
  o  [2:26805aba1e60] C
  |
  o  [1:112478962961] B
  |
  o  [0:426bada5c675] A
  
  $ hg bookmark -r 4 foo
  $ hg bookmark -r 2 bar

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

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

  $ hg log -G
  o  [6:4442f18c04c6] E
  |    topic: foo
  o  [5:0f81d1dec575] D
  |    topic: foo
  | x  [4:9bc730a19041] E
  | |
  | x  [3:f585351a92f8] D
  |/
  o  [2:26805aba1e60] C
  |    bookmark: bar
  o  [1:112478962961] B
  |
  o  [0:426bada5c675] A