hg-py3: make amend-to work

Reviewed By: quark-zju

Differential Revision: D19673900

fbshipit-source-id: cfdc985716aec23335eeddef517855be65505576
This commit is contained in:
Aida Getoeva 2020-02-03 10:02:33 -08:00 committed by Facebook Github Bot
parent a8f232e0ab
commit 201a17ca37
3 changed files with 6 additions and 6 deletions

View File

@ -60,6 +60,7 @@ from edenscm.mercurial import (
hintutil,
lock as lockmod,
phases,
pycompat,
registrar,
scmutil,
)
@ -546,9 +547,9 @@ def amendtocommit(ui, repo, commitspec):
try:
found = False
for curcommit in originalcommits:
fp.write("pick " + str(curcommit) + "\n")
fp.write(b"pick %s\n" % bytes(curcommit))
if curcommit == targetcommit:
fp.write("roll " + tempcommithex[:12] + "\n")
fp.write(b"roll %s\n" % pycompat.encodeutf8(tempcommithex[:12]))
found = True
if not found:
raise error.Abort(_("revision '%s' cannot be found") % commitspec)

View File

@ -322,7 +322,7 @@ class histeditstate(object):
def read(self):
"""Load histedit state from disk and set fields appropriately."""
try:
state = self.repo.localvfs.read("histedit-state")
state = pycompat.decodeutf8(self.repo.localvfs.read("histedit-state"))
except IOError as err:
if err.errno != errno.ENOENT:
raise
@ -379,7 +379,7 @@ class histeditstate(object):
def _load(self):
fp = self.repo.localvfs("histedit-state", "r")
lines = [l[:-1] for l in fp.readlines()]
lines = [pycompat.decodeutf8(l[:-1]) for l in fp.readlines()]
index = 0
lines[index] # version number
@ -1140,7 +1140,7 @@ def _readfile(ui, path):
return ui.fin.read()
else:
with open(path, "rb") as f:
return f.read()
return pycompat.decodeutf8(f.read())
def _validateargs(ui, repo, state, freeargs, opts, goal, rules, revs):

View File

@ -1,4 +1,3 @@
#require py2
#chg-compatible
Set up test environment.