--- a/hgext/mq.py Tue Feb 07 18:47:13 2012 +0100
+++ b/hgext/mq.py Tue Feb 07 18:47:16 2012 +0100
@@ -267,11 +267,15 @@
phase = phases.secret
if phase is not None:
backup = repo.ui.backupconfig('phases', 'new-commit')
+ # Marking the repository as committing an mq patch can be used
+ # to optimize operations like _branchtags().
+ repo._committingpatch = True
try:
if phase is not None:
repo.ui.setconfig('phases', 'new-commit', phase)
return repo.commit(*args, **kwargs)
finally:
+ repo._committingpatch = False
if phase is not None:
repo.ui.restoreconfig(backup)
@@ -3254,16 +3258,20 @@
def _branchtags(self, partial, lrev):
q = self.mq
+ cl = self.changelog
+ qbase = None
if not q.applied:
- return super(mqrepo, self)._branchtags(partial, lrev)
-
- cl = self.changelog
- qbasenode = q.applied[0].node
- try:
- qbase = cl.rev(qbasenode)
- except error.LookupError:
- self.ui.warn(_('mq status file refers to unknown node %s\n')
- % short(qbasenode))
+ if getattr(self, '_committingpatch', False):
+ # Committing a new patch, must be tip
+ qbase = len(cl) - 1
+ else:
+ qbasenode = q.applied[0].node
+ try:
+ qbase = cl.rev(qbasenode)
+ except error.LookupError:
+ self.ui.warn(_('mq status file refers to unknown node %s\n')
+ % short(qbasenode))
+ if qbase is None:
return super(mqrepo, self)._branchtags(partial, lrev)
start = lrev + 1