comparison hgext/evolve.py @ 1160:e29a813f6af5 stable

Make next/prev only move bookmarks optionally
author Ryan McElroy <rmcelroy@fb.com>
date Wed, 29 Oct 2014 10:34:08 -0700
parents 5951969400ce
children 5c07f464981e
comparison
equal deleted inserted replaced
1157:5951969400ce 1160:e29a813f6af5
1582 1582
1583 1583
1584 shorttemplate = '[{rev}] {desc|firstline}\n' 1584 shorttemplate = '[{rev}] {desc|firstline}\n'
1585 1585
1586 @command('^previous', 1586 @command('^previous',
1587 [], 1587 [('B', 'move-bookmark', False,
1588 '') 1588 _('Move current active bookmark after update'))],
1589 def cmdprevious(ui, repo): 1589 '[-B]')
1590 def cmdprevious(ui, repo, **opts):
1590 """update to parent and display summary lines""" 1591 """update to parent and display summary lines"""
1591 wkctx = repo[None] 1592 wkctx = repo[None]
1592 wparents = wkctx.parents() 1593 wparents = wkctx.parents()
1593 if len(wparents) != 1: 1594 if len(wparents) != 1:
1594 raise util.Abort('merge in progress') 1595 raise util.Abort('merge in progress')
1596 parents = wparents[0].parents() 1597 parents = wparents[0].parents()
1597 displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) 1598 displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
1598 if len(parents) == 1: 1599 if len(parents) == 1:
1599 p = parents[0] 1600 p = parents[0]
1600 bm = bookmarks.readcurrent(repo) 1601 bm = bookmarks.readcurrent(repo)
1601 shouldmove = bm is not None and bookmarks.iscurrent(repo, bm) 1602 shouldmove = opts.get('move_bookmark') and bm is not None
1602 ret = hg.update(repo, p.rev()) 1603 ret = hg.update(repo, p.rev())
1603 if not ret and shouldmove: 1604 if not ret:
1604 repo._bookmarks[bm] = p.node() 1605 if shouldmove:
1605 repo._bookmarks.write() 1606 repo._bookmarks[bm] = p.node()
1607 repo._bookmarks.write()
1608 else:
1609 bookmarks.unsetcurrent(repo)
1606 displayer.show(p) 1610 displayer.show(p)
1607 return 0 1611 return 0
1608 else: 1612 else:
1609 for p in parents: 1613 for p in parents:
1610 displayer.show(p) 1614 displayer.show(p)
1611 ui.warn(_('multiple parents, explicitly update to one\n')) 1615 ui.warn(_('multiple parents, explicitly update to one\n'))
1612 return 1 1616 return 1
1613 1617
1614 @command('^next', 1618 @command('^next',
1615 [], 1619 [('B', 'move-bookmark', False,
1616 '') 1620 _('Move current active bookmark after update'))],
1617 def cmdnext(ui, repo): 1621 '[-B]')
1622 def cmdnext(ui, repo, **opts):
1618 """update to child and display summary lines""" 1623 """update to child and display summary lines"""
1619 wkctx = repo[None] 1624 wkctx = repo[None]
1620 wparents = wkctx.parents() 1625 wparents = wkctx.parents()
1621 if len(wparents) != 1: 1626 if len(wparents) != 1:
1622 raise util.Abort('merge in progress') 1627 raise util.Abort('merge in progress')
1627 ui.warn(_('no non-obsolete children\n')) 1632 ui.warn(_('no non-obsolete children\n'))
1628 return 1 1633 return 1
1629 if len(children) == 1: 1634 if len(children) == 1:
1630 c = children[0] 1635 c = children[0]
1631 bm = bookmarks.readcurrent(repo) 1636 bm = bookmarks.readcurrent(repo)
1632 shouldmove = bm is not None and bookmarks.iscurrent(repo, bm) 1637 shouldmove = opts.get('move_bookmark') and bm is not None
1633 ret = hg.update(repo, c.rev()) 1638 ret = hg.update(repo, c.rev())
1634 if not ret and shouldmove: 1639 if not ret:
1635 repo._bookmarks[bm] = c.node() 1640 if shouldmove:
1636 repo._bookmarks.write() 1641 repo._bookmarks[bm] = c.node()
1642 repo._bookmarks.write()
1643 else:
1644 bookmarks.unsetcurrent(repo)
1637 displayer.show(c) 1645 displayer.show(c)
1638 return 0 1646 return 0
1639 else: 1647 else:
1640 for c in children: 1648 for c in children:
1641 displayer.show(c) 1649 displayer.show(c)