comparison hgext/mq.py @ 16128:004982e5d782

merge with stable
author Matt Mackall <mpm@selenic.com>
date Thu, 16 Feb 2012 16:40:29 -0600
parents 50682c07a8d0 5de83d9ca79c
children 816211dfa3a5
comparison
equal deleted inserted replaced
16127:14dc2bbba6d2 16128:004982e5d782
1794 rev = scmutil.revrange(repo, rev) 1794 rev = scmutil.revrange(repo, rev)
1795 rev.sort(reverse=True) 1795 rev.sort(reverse=True)
1796 if (len(files) > 1 or len(rev) > 1) and patchname: 1796 if (len(files) > 1 or len(rev) > 1) and patchname:
1797 raise util.Abort(_('option "-n" not valid when importing multiple ' 1797 raise util.Abort(_('option "-n" not valid when importing multiple '
1798 'patches')) 1798 'patches'))
1799 imported = []
1799 if rev: 1800 if rev:
1800 # If mq patches are applied, we can only import revisions 1801 # If mq patches are applied, we can only import revisions
1801 # that form a linear path to qbase. 1802 # that form a linear path to qbase.
1802 # Otherwise, they should form a linear path to a head. 1803 # Otherwise, they should form a linear path to a head.
1803 heads = repo.changelog.heads(repo.changelog.node(rev[-1])) 1804 heads = repo.changelog.heads(repo.changelog.node(rev[-1]))
1846 1847
1847 se = statusentry(n, patchname) 1848 se = statusentry(n, patchname)
1848 self.applied.insert(0, se) 1849 self.applied.insert(0, se)
1849 1850
1850 self.added.append(patchname) 1851 self.added.append(patchname)
1852 imported.append(patchname)
1851 patchname = None 1853 patchname = None
1852 if rev and repo.ui.configbool('mq', 'secret', False): 1854 if rev and repo.ui.configbool('mq', 'secret', False):
1853 # if we added anything with --rev, we must move the secret root 1855 # if we added anything with --rev, we must move the secret root
1854 phases.retractboundary(repo, phases.secret, [n]) 1856 phases.retractboundary(repo, phases.secret, [n])
1855 self.parseseries() 1857 self.parseseries()
1900 self.fullseries[index:index] = [patchname] 1902 self.fullseries[index:index] = [patchname]
1901 self.parseseries() 1903 self.parseseries()
1902 self.seriesdirty = True 1904 self.seriesdirty = True
1903 self.ui.warn(_("adding %s to series file\n") % patchname) 1905 self.ui.warn(_("adding %s to series file\n") % patchname)
1904 self.added.append(patchname) 1906 self.added.append(patchname)
1907 imported.append(patchname)
1905 patchname = None 1908 patchname = None
1906 1909
1907 self.removeundo(repo) 1910 self.removeundo(repo)
1911 return imported
1908 1912
1909 @command("qdelete|qremove|qrm", 1913 @command("qdelete|qremove|qrm",
1910 [('k', 'keep', None, _('keep patch file')), 1914 [('k', 'keep', None, _('keep patch file')),
1911 ('r', 'rev', [], 1915 ('r', 'rev', [],
1912 _('stop managing a revision (DEPRECATED)'), _('REV'))], 1916 _('stop managing a revision (DEPRECATED)'), _('REV'))],
2028 """ 2032 """
2029 lock = repo.lock() # cause this may move phase 2033 lock = repo.lock() # cause this may move phase
2030 try: 2034 try:
2031 q = repo.mq 2035 q = repo.mq
2032 try: 2036 try:
2033 q.qimport(repo, filename, patchname=opts.get('name'), 2037 imported = q.qimport(
2034 existing=opts.get('existing'), force=opts.get('force'), 2038 repo, filename, patchname=opts.get('name'),
2035 rev=opts.get('rev'), git=opts.get('git')) 2039 existing=opts.get('existing'), force=opts.get('force'),
2040 rev=opts.get('rev'), git=opts.get('git'))
2036 finally: 2041 finally:
2037 q.savedirty() 2042 q.savedirty()
2038 2043
2039 2044
2040 if opts.get('push') and not opts.get('rev'): 2045 if imported and opts.get('push') and not opts.get('rev'):
2041 return q.push(repo, None) 2046 return q.push(repo, imported[-1])
2042 finally: 2047 finally:
2043 lock.release() 2048 lock.release()
2044 return 0 2049 return 0
2045 2050
2046 def qinit(ui, repo, create): 2051 def qinit(ui, repo, create):