hgext/rebase.py
changeset 43787 be8552f25cab
parent 43591 b56c6647f65e
child 43874 c6feee1e4d5b
equal deleted inserted replaced
43786:421ea5772039 43787:be8552f25cab
  1495         repo.dirstate.setbranch(repo[newnode].branch())
  1495         repo.dirstate.setbranch(repo[newnode].branch())
  1496         return newnode
  1496         return newnode
  1497 
  1497 
  1498 
  1498 
  1499 def rebasenode(repo, rev, p1, base, collapse, dest, wctx):
  1499 def rebasenode(repo, rev, p1, base, collapse, dest, wctx):
  1500     b'Rebase a single revision rev on top of p1 using base as merge ancestor'
  1500     """Rebase a single revision rev on top of p1 using base as merge ancestor"""
  1501     # Merge phase
  1501     # Merge phase
  1502     # Update to destination and merge it with local
  1502     # Update to destination and merge it with local
  1503     if wctx.isinmemory():
  1503     if wctx.isinmemory():
  1504         wctx.setbase(repo[p1])
  1504         wctx.setbase(repo[p1])
  1505     else:
  1505     else:
  1851 
  1851 
  1852     return newps[0], newps[1], base
  1852     return newps[0], newps[1], base
  1853 
  1853 
  1854 
  1854 
  1855 def isagitpatch(repo, patchname):
  1855 def isagitpatch(repo, patchname):
  1856     b'Return true if the given patch is in git format'
  1856     """Return true if the given patch is in git format"""
  1857     mqpatch = os.path.join(repo.mq.path, patchname)
  1857     mqpatch = os.path.join(repo.mq.path, patchname)
  1858     for line in patch.linereader(open(mqpatch, b'rb')):
  1858     for line in patch.linereader(open(mqpatch, b'rb')):
  1859         if line.startswith(b'diff --git'):
  1859         if line.startswith(b'diff --git'):
  1860             return True
  1860             return True
  1861     return False
  1861     return False
  1862 
  1862 
  1863 
  1863 
  1864 def updatemq(repo, state, skipped, **opts):
  1864 def updatemq(repo, state, skipped, **opts):
  1865     b'Update rebased mq patches - finalize and then import them'
  1865     """Update rebased mq patches - finalize and then import them"""
  1866     mqrebase = {}
  1866     mqrebase = {}
  1867     mq = repo.mq
  1867     mq = repo.mq
  1868     original_series = mq.fullseries[:]
  1868     original_series = mq.fullseries[:]
  1869     skippedpatches = set()
  1869     skippedpatches = set()
  1870 
  1870 
  1914         mq.seriesdirty = True
  1914         mq.seriesdirty = True
  1915         mq.savedirty()
  1915         mq.savedirty()
  1916 
  1916 
  1917 
  1917 
  1918 def storecollapsemsg(repo, collapsemsg):
  1918 def storecollapsemsg(repo, collapsemsg):
  1919     b'Store the collapse message to allow recovery'
  1919     """Store the collapse message to allow recovery"""
  1920     collapsemsg = collapsemsg or b''
  1920     collapsemsg = collapsemsg or b''
  1921     f = repo.vfs(b"last-message.txt", b"w")
  1921     f = repo.vfs(b"last-message.txt", b"w")
  1922     f.write(b"%s\n" % collapsemsg)
  1922     f.write(b"%s\n" % collapsemsg)
  1923     f.close()
  1923     f.close()
  1924 
  1924 
  1925 
  1925 
  1926 def clearcollapsemsg(repo):
  1926 def clearcollapsemsg(repo):
  1927     b'Remove collapse message file'
  1927     """Remove collapse message file"""
  1928     repo.vfs.unlinkpath(b"last-message.txt", ignoremissing=True)
  1928     repo.vfs.unlinkpath(b"last-message.txt", ignoremissing=True)
  1929 
  1929 
  1930 
  1930 
  1931 def restorecollapsemsg(repo, isabort):
  1931 def restorecollapsemsg(repo, isabort):
  1932     b'Restore previously stored collapse message'
  1932     """Restore previously stored collapse message"""
  1933     try:
  1933     try:
  1934         f = repo.vfs(b"last-message.txt")
  1934         f = repo.vfs(b"last-message.txt")
  1935         collapsemsg = f.readline().strip()
  1935         collapsemsg = f.readline().strip()
  1936         f.close()
  1936         f.close()
  1937     except IOError as err:
  1937     except IOError as err:
  1944             raise error.Abort(_(b'missing .hg/last-message.txt for rebase'))
  1944             raise error.Abort(_(b'missing .hg/last-message.txt for rebase'))
  1945     return collapsemsg
  1945     return collapsemsg
  1946 
  1946 
  1947 
  1947 
  1948 def clearstatus(repo):
  1948 def clearstatus(repo):
  1949     b'Remove the status files'
  1949     """Remove the status files"""
  1950     # Make sure the active transaction won't write the state file
  1950     # Make sure the active transaction won't write the state file
  1951     tr = repo.currenttransaction()
  1951     tr = repo.currenttransaction()
  1952     if tr:
  1952     if tr:
  1953         tr.removefilegenerator(b'rebasestate')
  1953         tr.removefilegenerator(b'rebasestate')
  1954     repo.vfs.unlinkpath(b"rebasestate", ignoremissing=True)
  1954     repo.vfs.unlinkpath(b"rebasestate", ignoremissing=True)
  2125         replacements = {}
  2125         replacements = {}
  2126     scmutil.cleanupnodes(repo, replacements, b'rebase', moves, backup=backup)
  2126     scmutil.cleanupnodes(repo, replacements, b'rebase', moves, backup=backup)
  2127 
  2127 
  2128 
  2128 
  2129 def pullrebase(orig, ui, repo, *args, **opts):
  2129 def pullrebase(orig, ui, repo, *args, **opts):
  2130     b'Call rebase after pull if the latter has been invoked with --rebase'
  2130     """Call rebase after pull if the latter has been invoked with --rebase"""
  2131     if opts.get('rebase'):
  2131     if opts.get('rebase'):
  2132         if ui.configbool(b'commands', b'rebase.requiredest'):
  2132         if ui.configbool(b'commands', b'rebase.requiredest'):
  2133             msg = _(b'rebase destination required by configuration')
  2133             msg = _(b'rebase destination required by configuration')
  2134             hint = _(b'use hg pull followed by hg rebase -d DEST')
  2134             hint = _(b'use hg pull followed by hg rebase -d DEST')
  2135             raise error.Abort(msg, hint=hint)
  2135             raise error.Abort(msg, hint=hint)