comparison hgext3rd/topic/stack.py @ 2939:7759d040d48d

topic: provide more information when behind count cannot be computed The behind count has been confusing for various user and the associated error message is even worth. We try to clarify it to see if that helps.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 17 Sep 2017 19:59:25 +0200
parents 9872526fc39f
children a61634f52742
comparison
equal deleted inserted replaced
2938:9872526fc39f 2939:7759d040d48d
28 28
29 def __init__(self, repo, branch=None, topic=None): 29 def __init__(self, repo, branch=None, topic=None):
30 self._repo = repo 30 self._repo = repo
31 self.branch = branch 31 self.branch = branch
32 self.topic = topic 32 self.topic = topic
33 self.behinderror = None
33 if topic is not None and branch is not None: 34 if topic is not None and branch is not None:
34 raise error.ProgrammingError('both branch and topic specified (not defined yet)') 35 raise error.ProgrammingError('both branch and topic specified (not defined yet)')
35 elif topic is not None: 36 elif topic is not None:
36 trevs = repo.revs("topic(%s) - obsolete()", topic) 37 trevs = repo.revs("topic(%s) - obsolete()", topic)
37 elif branch is not None: 38 elif branch is not None:
164 sourceset=minroot, 165 sourceset=minroot,
165 onheadcheck=False) 166 onheadcheck=False)
166 return len(self._repo.revs("only(%d, %ld)", dest, minroot)) 167 return len(self._repo.revs("only(%d, %ld)", dest, minroot))
167 except error.NoMergeDestAbort: 168 except error.NoMergeDestAbort:
168 return 0 169 return 0
169 except error.ManyMergeDestAbort: 170 except error.ManyMergeDestAbort as exc:
171 # XXX we should make it easier for upstream to provide the information
172 self.behinderror = str(exc).split('-', 1)[0].rstrip()
170 return -1 173 return -1
171 return 0 174 return 0
172 175
173 @util.propertycache 176 @util.propertycache
174 def branches(self): 177 def branches(self):
234 label='topic.stack.summary.headcount.multiple') 237 label='topic.stack.summary.headcount.multiple')
235 fm.plain(')') 238 fm.plain(')')
236 else: 239 else:
237 if data['behindcount'] == -1: 240 if data['behindcount'] == -1:
238 fm.plain(', ') 241 fm.plain(', ')
239 fm.plain('ambigious rebase destination', label='topic.stack.summary.behinderror') 242 fm.plain('ambigious rebase destination - %s' % data['behinderror'],
243 label='topic.stack.summary.behinderror')
240 elif data['behindcount']: 244 elif data['behindcount']:
241 fm.plain(', ') 245 fm.plain(', ')
242 fm.plain('%d behind' % data['behindcount'], label='topic.stack.summary.behindcount') 246 fm.plain('%d behind' % data['behindcount'], label='topic.stack.summary.behindcount')
243 fm.plain('\n') 247 fm.plain('\n')
244 248
329 current = stack(repo, branch, topic) 333 current = stack(repo, branch, topic)
330 data['changesetcount'] = current.changesetcount 334 data['changesetcount'] = current.changesetcount
331 data['troubledcount'] = current.troubledcount 335 data['troubledcount'] = current.troubledcount
332 data['headcount'] = len(current.heads) 336 data['headcount'] = len(current.heads)
333 data['behindcount'] = current.behindcount 337 data['behindcount'] = current.behindcount
338 data['behinderror'] = current.behinderror
334 data['branches'] = current.branches 339 data['branches'] = current.branches
335 return data 340 return data