def qrevert(ui, repo, rev, **opts): ''' Revert to a past mq state. This updates both the main checkout as well as the patch directory, and leaves either or both at a non-head revision. ''' q = repo.mq if not q or not q.qrepo(): raise error.Abort(_("No revisioned patch queue found")) p = q.qrepo()[q.qrepo().lookup(rev)] desc = p.description() m = qparent_re.search(desc) if not m: raise error.Abort(_("mq commit is missing needed metadata in comment")) qparent = m.group(1) m = top_re.search(desc) if not m: raise error.Abort(_("mq commit is missing needed metadata in comment")) top = m.group(1) # Check the main checkout before updating the mq checkout if repo[None].dirty(merge=False, branch=False): raise error.Abort(_("uncommitted local changes")) # Pop everything first q.pop(repo, None, force=False, all=True, nobackup=True, keepchanges=False) # Update the mq checkout commands.update(ui, q.qrepo(), rev=rev, check=True) # Update the main checkout commands.update(ui, repo, rev=qparent, check=False) # Push until reaching the correct patch if top != "(none)": mq.goto(ui, repo, top) # Needed? q.savedirty()
def qrevert(ui, repo, rev, **opts): ''' Revert to a past mq state. This updates both the main checkout as well as the patch directory, and leaves either or both at a non-head revision. ''' q = repo.mq if not q or not q.qrepo(): raise util.Abort(_("No revisioned patch queue found")) p = q.qrepo()[q.qrepo().lookup(rev)] desc = p.description() m = qparent_re.search(desc) if not m: raise util.Abort(_("mq commit is missing needed metadata in comment")) qparent = m.group(1) m = top_re.search(desc) if not m: raise util.Abort(_("mq commit is missing needed metadata in comment")) top = m.group(1) # Check the main checkout before updating the mq checkout if repo[None].dirty(merge=False, branch=False): raise util.Abort(_("uncommitted local changes")) # Pop everything first q.pop(repo, None, force=False, all=True, nobackup=True, keepchanges=False) # Update the mq checkout commands.update(ui, q.qrepo(), rev=rev, check=True) # Update the main checkout commands.update(ui, repo, rev=qparent, check=False) # Push until reaching the correct patch if top != "(none)": mq.goto(ui, repo, top) # Needed? q.savedirty()
ui.write('Moving patch "%s" to position %i in patch series...\n' % (patch_name.strip(), new_index)) series = [l for l in open(series_path, 'r')] series.remove(patch_name) if new_index > len(series) + 1: series.append(patch_name) else: series.insert(new_index - 1, patch_name) # update the series and status files open(series_path, 'w').writelines(series) open(status_path, 'w').write('') if current_patch: # reapply all patches up to the previously applied patch new_repo = hg.repository(ui, os.path.join(repo.root)) # refresh the series mq.goto(ui, new_repo, current_patch, force=False) def qticket(ui, repo, patch_name, **opts): """Attempts to open a web browser to the location for the ticket that a patch addresses""" q = qrepo(ui, repo) patch = q.lookup(patch_name) import webbrowser ticket_urls = ui.configitems('ticket_urls') for name, magic in ticket_urls: match = MAGIC_RE.search(magic) if match: match_type, pattern, url = match.groups()