mirror of
https://github.com/frej/fast-export.git
synced 2025-11-01 17:05:46 +01:00
Adapt to changes in Mercurial 4.6
Starting with Mercurial 4.6 repo.lookup() no longer accepts raw hashes for lookups.
This commit is contained in:
@@ -27,9 +27,9 @@ first time.
|
|||||||
System Requirements
|
System Requirements
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
This project depends on Python 2.7 and the Python mercurial package.
|
This project depends on Python 2.7 and the Mercurial 4.6 package. If
|
||||||
If Python is not installed, install it before proceeding. The
|
Python is not installed, install it before proceeding. The Mercurial
|
||||||
mercurial package can be installed with `pip install mercurial`.
|
package can be installed with `pip install mercurial`.
|
||||||
|
|
||||||
If you're on Windows, run the following commands in git bash (Git for
|
If you're on Windows, run the following commands in git bash (Git for
|
||||||
Windows).
|
Windows).
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
|
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
|
||||||
|
|
||||||
from mercurial import node
|
from mercurial import node
|
||||||
|
from mercurial.scmutil import revsymbol
|
||||||
from hg2git import setup_repo,fixup_user,get_branch,get_changeset
|
from hg2git import setup_repo,fixup_user,get_branch,get_changeset
|
||||||
from hg2git import load_cache,save_cache,get_git_sha1,set_default_branch,set_origin_name
|
from hg2git import load_cache,save_cache,get_git_sha1,set_default_branch,set_origin_name
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
@@ -78,7 +79,7 @@ def get_filechanges(repo,revision,parents,mleft):
|
|||||||
l,c,r=[],[],[]
|
l,c,r=[],[],[]
|
||||||
for p in parents:
|
for p in parents:
|
||||||
if p<0: continue
|
if p<0: continue
|
||||||
mright=repo.changectx(p).manifest()
|
mright=revsymbol(repo,str(p)).manifest()
|
||||||
l,c,r=split_dict(mleft,mright,l,c,r)
|
l,c,r=split_dict(mleft,mright,l,c,r)
|
||||||
l.sort()
|
l.sort()
|
||||||
c.sort()
|
c.sort()
|
||||||
@@ -210,7 +211,7 @@ def export_commit(ui,repo,revision,old_marks,max,count,authors,
|
|||||||
wr(desc)
|
wr(desc)
|
||||||
wr()
|
wr()
|
||||||
|
|
||||||
ctx=repo.changectx(str(revision))
|
ctx=revsymbol(repo,str(revision))
|
||||||
man=ctx.manifest()
|
man=ctx.manifest()
|
||||||
added,changed,removed,type=[],[],[],''
|
added,changed,removed,type=[],[],[],''
|
||||||
|
|
||||||
@@ -225,7 +226,7 @@ def export_commit(ui,repo,revision,old_marks,max,count,authors,
|
|||||||
# later non-merge revision: feed in changed manifest
|
# later non-merge revision: feed in changed manifest
|
||||||
# if we have exactly one parent, just take the changes from the
|
# if we have exactly one parent, just take the changes from the
|
||||||
# manifest without expensively comparing checksums
|
# manifest without expensively comparing checksums
|
||||||
f=repo.status(repo.lookup(parents[0]),revnode)[:3]
|
f=repo.status(parents[0],revnode)[:3]
|
||||||
added,changed,removed=f[1],f[0],f[2]
|
added,changed,removed=f[1],f[0],f[2]
|
||||||
type='simple delta'
|
type='simple delta'
|
||||||
else: # a merge with two parents
|
else: # a merge with two parents
|
||||||
@@ -262,7 +263,7 @@ def export_note(ui,repo,revision,count,authors,encoding,is_first):
|
|||||||
if is_first:
|
if is_first:
|
||||||
wr('from refs/notes/hg^0')
|
wr('from refs/notes/hg^0')
|
||||||
wr('N inline :%d' % (revision+1))
|
wr('N inline :%d' % (revision+1))
|
||||||
hg_hash=repo.changectx(str(revision)).hex()
|
hg_hash=revsymbol(repo,str(revision)).hex()
|
||||||
wr('data %d' % (len(hg_hash)))
|
wr('data %d' % (len(hg_hash)))
|
||||||
wr_no_nl(hg_hash)
|
wr_no_nl(hg_hash)
|
||||||
wr()
|
wr()
|
||||||
|
|||||||
11
hg2git.py
11
hg2git.py
@@ -4,6 +4,9 @@
|
|||||||
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
|
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
|
||||||
|
|
||||||
from mercurial import hg,util,ui,templatefilters
|
from mercurial import hg,util,ui,templatefilters
|
||||||
|
from mercurial import error as hgerror
|
||||||
|
from mercurial.scmutil import revsymbol,binnode
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@@ -69,7 +72,15 @@ def get_branch(name):
|
|||||||
return name
|
return name
|
||||||
|
|
||||||
def get_changeset(ui,repo,revision,authors={},encoding=''):
|
def get_changeset(ui,repo,revision,authors={},encoding=''):
|
||||||
|
# Starting with Mercurial 4.6 lookup no longer accepts raw hashes
|
||||||
|
# for lookups. Work around it by changing our behaviour depending on
|
||||||
|
# how it fails
|
||||||
|
try:
|
||||||
node=repo.lookup(revision)
|
node=repo.lookup(revision)
|
||||||
|
except hgerror.ProgrammingError:
|
||||||
|
node=binnode(revsymbol(repo,str(revision))) # We were given a numeric rev
|
||||||
|
except hgerror.RepoLookupError:
|
||||||
|
node=revision # We got a raw hash
|
||||||
(manifest,user,(time,timezone),files,desc,extra)=repo.changelog.read(node)
|
(manifest,user,(time,timezone),files,desc,extra)=repo.changelog.read(node)
|
||||||
if encoding:
|
if encoding:
|
||||||
user=user.decode(encoding).encode('utf8')
|
user=user.decode(encoding).encode('utf8')
|
||||||
|
|||||||
Reference in New Issue
Block a user