comparison src/topic/destination.py @ 1892:b1fadc089b82

update: change default update destination to take topic in account When within a branch update to ngtip(branch). When within a topic update to the top topic.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sun, 13 Mar 2016 12:29:43 +0000
parents 077c40f206d1
children 27ea12c05e99
comparison
equal deleted inserted replaced
1891:077c40f206d1 1892:b1fadc089b82
1 from mercurial import error 1 from mercurial import error
2 from mercurial import util 2 from mercurial import util
3 from mercurial import destutil 3 from mercurial import destutil
4 from mercurial import extensions 4 from mercurial import extensions
5 from mercurial import bookmarks
5 from mercurial.i18n import _ 6 from mercurial.i18n import _
6 7
7 def _destmergebranch(orig, repo, action='merge', sourceset=None, onheadcheck=True): 8 def _destmergebranch(orig, repo, action='merge', sourceset=None, onheadcheck=True):
8 p1 = repo['.'] 9 p1 = repo['.']
9 top = p1.topic() 10 top = p1.topic()
40 if orig.func_default: # version above hg-3.7 41 if orig.func_default: # version above hg-3.7
41 return orig(repo, action, sourceset, onheadcheck) 42 return orig(repo, action, sourceset, onheadcheck)
42 else: 43 else:
43 return orig(repo) 44 return orig(repo)
44 45
46 def _destupdatetopic(repo, clean, check):
47 """decide on an update destination from current topic"""
48 movemark = node = None
49 topic = repo.currenttopic
50 revs = repo.revs('.::topic("%s")' % topic)
51 if not revs:
52 return None, None, None
53 node = revs.last()
54 if bookmarks.isactivewdirparent(repo):
55 movemark = repo['.'].node()
56 return node, movemark, None
57
45 def setupdest(): 58 def setupdest():
46 if util.safehasattr(destutil, '_destmergebranch'): 59 if util.safehasattr(destutil, '_destmergebranch'):
47 extensions.wrapfunction(destutil, '_destmergebranch', _destmergebranch) 60 extensions.wrapfunction(destutil, '_destmergebranch', _destmergebranch)
48 rebase = extensions.find('rebase') 61 rebase = extensions.find('rebase')
49 if (util.safehasattr(rebase, '_destrebase') 62 if (util.safehasattr(rebase, '_destrebase')
50 # logic not shared with merge yet < hg-3.8 63 # logic not shared with merge yet < hg-3.8
51 and not util.safehasattr(rebase, '_definesets')): 64 and not util.safehasattr(rebase, '_definesets')):
52 extensions.wrapfunction(rebase, '_destrebase', _destmergebranch) 65 extensions.wrapfunction(rebase, '_destrebase', _destmergebranch)
66 if util.safehasattr(destutil, 'destupdatesteps'):
67 bridx = destutil.destupdatesteps.index('branch')
68 destutil.destupdatesteps.insert(bridx, 'topic')
69 destutil.destupdatestepmap['topic'] = _destupdatetopic
53 70
54 def ngtip(repo, branch, all=False): 71 def ngtip(repo, branch, all=False):
55 """tip new generation""" 72 """tip new generation"""
56 ## search for untopiced heads of branch 73 ## search for untopiced heads of branch
57 # could be heads((::branch(x) - topic())) 74 # could be heads((::branch(x) - topic()))