comparison hgext/mq.py @ 11064:590b1d6ef50b

mq: qpush --move, reorder patch series and apply only the patch This makes it less necessary to edit .hg/patches/series manually.
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 30 Apr 2010 15:05:51 +0200
parents 5d35f7d93514
children 37d1b20168d1
comparison
equal deleted inserted replaced
11063:eb23c876c111 11064:590b1d6ef50b
976 if i + off < len(self.series): 976 if i + off < len(self.series):
977 return self.series[i + off] 977 return self.series[i + off]
978 raise util.Abort(_("patch %s not in series") % patch) 978 raise util.Abort(_("patch %s not in series") % patch)
979 979
980 def push(self, repo, patch=None, force=False, list=False, 980 def push(self, repo, patch=None, force=False, list=False,
981 mergeq=None, all=False): 981 mergeq=None, all=False, move=False):
982 diffopts = self.diffopts() 982 diffopts = self.diffopts()
983 wlock = repo.wlock() 983 wlock = repo.wlock()
984 try: 984 try:
985 heads = [] 985 heads = []
986 for b, ls in repo.branchmap().iteritems(): 986 for b, ls in repo.branchmap().iteritems():
1031 if start == len(self.series): 1031 if start == len(self.series):
1032 self.ui.warn(_('patch series already fully applied\n')) 1032 self.ui.warn(_('patch series already fully applied\n'))
1033 return 1 1033 return 1
1034 if not force: 1034 if not force:
1035 self.check_localchanges(repo) 1035 self.check_localchanges(repo)
1036
1037 if move:
1038 try:
1039 del self.full_series[self.full_series.index(patch, start)]
1040 except ValueError:
1041 raise util.Abort(_("patch '%s' not found") % patch)
1042 self.full_series.insert(start, patch)
1043 self.parse_series()
1044 self.series_dirty = 1
1036 1045
1037 self.applied_dirty = 1 1046 self.applied_dirty = 1
1038 if start > 0: 1047 if start > 0:
1039 self.check_toppatch(repo) 1048 self.check_toppatch(repo)
1040 if not patch: 1049 if not patch:
2220 ui.warn(_("no saved queues found, please use -n\n")) 2229 ui.warn(_("no saved queues found, please use -n\n"))
2221 return 1 2230 return 1
2222 mergeq = queue(ui, repo.join(""), newpath) 2231 mergeq = queue(ui, repo.join(""), newpath)
2223 ui.warn(_("merging with queue at: %s\n") % mergeq.path) 2232 ui.warn(_("merging with queue at: %s\n") % mergeq.path)
2224 ret = q.push(repo, patch, force=opts['force'], list=opts['list'], 2233 ret = q.push(repo, patch, force=opts['force'], list=opts['list'],
2225 mergeq=mergeq, all=opts.get('all')) 2234 mergeq=mergeq, all=opts.get('all'), move=opts.get('move'))
2226 return ret 2235 return ret
2227 2236
2228 def pop(ui, repo, patch=None, **opts): 2237 def pop(ui, repo, patch=None, **opts):
2229 """pop the current patch off the stack 2238 """pop the current patch off the stack
2230 2239
2733 (push, 2742 (push,
2734 [('f', 'force', None, _('apply if the patch has rejects')), 2743 [('f', 'force', None, _('apply if the patch has rejects')),
2735 ('l', 'list', None, _('list patch name in commit text')), 2744 ('l', 'list', None, _('list patch name in commit text')),
2736 ('a', 'all', None, _('apply all patches')), 2745 ('a', 'all', None, _('apply all patches')),
2737 ('m', 'merge', None, _('merge from another queue (DEPRECATED)')), 2746 ('m', 'merge', None, _('merge from another queue (DEPRECATED)')),
2738 ('n', 'name', '', _('merge queue name (DEPRECATED)'))], 2747 ('n', 'name', '', _('merge queue name (DEPRECATED)')),
2739 _('hg qpush [-f] [-l] [-a] [-m] [-n NAME] [PATCH | INDEX]')), 2748 ('', 'move', None, _('reorder patch series and apply only the patch'))],
2749 _('hg qpush [-f] [-l] [-a] [-m] [-n NAME] [--move] [PATCH | INDEX]')),
2740 "^qrefresh": 2750 "^qrefresh":
2741 (refresh, 2751 (refresh,
2742 [('e', 'edit', None, _('edit commit message')), 2752 [('e', 'edit', None, _('edit commit message')),
2743 ('g', 'git', None, _('use git extended diff format')), 2753 ('g', 'git', None, _('use git extended diff format')),
2744 ('s', 'short', None, 2754 ('s', 'short', None,