libbe.command.merge

class libbe.command.merge.Merge(*args, **kwargs)

Merge duplicate bugs

>>> import sys
>>> import libbe.bugdir
>>> import libbe.comment
>>> bd = libbe.bugdir.SimpleBugDir(memory=False)
>>> io = libbe.command.StringInputOutput()
>>> io.stdout = sys.stdout
>>> ui = libbe.command.UserInterface(io=io)
>>> ui.storage_callbacks.set_bugdir(bd)
>>> cmd = Merge(ui=ui)
>>> a = bd.bug_from_uuid('a')
>>> a.comment_root.time = 0
>>> dummy = a.new_comment('Testing')
>>> dummy.time = 1
>>> dummy = dummy.new_reply('Testing...')
>>> dummy.time = 2
>>> b = bd.bug_from_uuid('b')
>>> b.status = 'open'
>>> b.comment_root.time = 0
>>> dummy = b.new_comment('1 2')
>>> dummy.time = 1
>>> dummy = dummy.new_reply('1 2 3 4')
>>> dummy.time = 2
>>> ret = ui.run(cmd, args=['/a', '/b'])
Merged bugs #abc/a# and #abc/b#
>>> bd.flush_reload()
>>> a = bd.bug_from_uuid('a')
>>> a.load_comments()
>>> a_comments = sorted([c for c in a.comments()],
...                     cmp=libbe.comment.cmp_time)
>>> mergeA = a_comments[0]
>>> mergeA.time = 3
>>> print a.string(show_comments=True) 
          ID : a
  Short name : abc/a
    Severity : minor
      Status : open
    Assigned : 
    Reporter : 
     Creator : John Doe <jdoe@example.com>
     Created : ...
Bug A
--------- Comment ---------
Name: abc/a/...
From: ...
Date: ...

Testing
  --------- Comment ---------
  Name: abc/a/...
  From: ...
  Date: ...

  Testing...
--------- Comment ---------
Name: abc/a/...
From: ...
Date: ...

Merged from bug #abc/b#
  --------- Comment ---------
  Name: abc/a/...
  From: ...
  Date: ...

  1 2
    --------- Comment ---------
    Name: abc/a/...
    From: ...
    Date: ...

    1 2 3 4
>>> b = bd.bug_from_uuid('b')
>>> b.load_comments()
>>> b_comments = sorted([c for c in b.comments()],
...                     libbe.comment.cmp_time)
>>> mergeB = b_comments[0]
>>> mergeB.time = 3
>>> print b.string(show_comments=True) 
          ID : b
  Short name : abc/b
    Severity : minor
      Status : closed
    Assigned : 
    Reporter : 
     Creator : Jane Doe <jdoe@example.com>
     Created : ...
Bug B
--------- Comment ---------
Name: abc/b/...
From: ...
Date: ...

1 2
  --------- Comment ---------
  Name: abc/b/...
  From: ...
  Date: ...

  1 2 3 4
--------- Comment ---------
Name: abc/b/...
From: ...
Date: ...

Merged into bug #abc/a#
>>> print b.status
closed
>>> ui.cleanup()
>>> bd.cleanup()

Methods

cleanup()
complete([argument, fragment])
help(*args)
run([options, args])
usage()
name = 'merge'

This Page