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

View File

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

View File

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