mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
various fixes to darcs conversion script
1. removed files were missed 2. hidden files in top directory were not added/removed correctly 3. suppressed spurious warning on adding new files. 4. hg changeset now checked in with original author and date 5. __file__ not supported by pdb.py
This commit is contained in:
parent
edc115c48d
commit
cf3a279096
@ -13,7 +13,9 @@
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
import os, sys
|
import os, sys
|
||||||
|
import tempfile
|
||||||
import xml.dom.minidom as xml_dom
|
import xml.dom.minidom as xml_dom
|
||||||
|
from time import strptime, mktime
|
||||||
|
|
||||||
DARCS_REPO = None
|
DARCS_REPO = None
|
||||||
HG_REPO = None
|
HG_REPO = None
|
||||||
@ -25,7 +27,7 @@ USAGE = """\
|
|||||||
HGREPO must not exist, as it will be created and filled up (this will avoid
|
HGREPO must not exist, as it will be created and filled up (this will avoid
|
||||||
overwriting valuable data.
|
overwriting valuable data.
|
||||||
|
|
||||||
""" % (os.path.basename(__file__))
|
""" % (os.path.basename(sys.argv[0]))
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -70,8 +72,9 @@ def darcs_changes(darcsRepo):
|
|||||||
else: name = name[0].childNodes[0].data
|
else: name = name[0].childNodes[0].data
|
||||||
if not comm: comm = ""
|
if not comm: comm = ""
|
||||||
else: comm = comm[0].childNodes[0].data
|
else: comm = comm[0].childNodes[0].data
|
||||||
res.append([name, comm])
|
author = patch_node.getAttribute("author")
|
||||||
return res
|
date = patch_node.getAttribute("date")
|
||||||
|
yield author, date, name, comm
|
||||||
|
|
||||||
def darcs_pull(hg_repo, darcs_repo, change):
|
def darcs_pull(hg_repo, darcs_repo, change):
|
||||||
cmd("darcs pull '%s' --all --patches='%s'" % (darcs_repo, change), hg_repo)
|
cmd("darcs pull '%s' --all --patches='%s'" % (darcs_repo, change), hg_repo)
|
||||||
@ -82,11 +85,13 @@ def darcs_pull(hg_repo, darcs_repo, change):
|
|||||||
#
|
#
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
def hg_commit( hg_repo, text ):
|
def hg_commit( hg_repo, text, author, date ):
|
||||||
writefile("/tmp/msg", text)
|
fd, tmpfile = tempfile.mkstemp(prefix="darcs2hg_")
|
||||||
cmd("hg add -X _darcs *", hg_repo)
|
writefile(tmpfile, text)
|
||||||
cmd("hg commit -l /tmp/msg", hg_repo)
|
cmd("hg add -X _darcs", hg_repo)
|
||||||
os.unlink("/tmp/msg")
|
cmd("hg remove -X _darcs --after", hg_repo)
|
||||||
|
cmd("hg commit -l %s -u '%s' -d '%s 0'" % (tmpfile, author, date), hg_repo)
|
||||||
|
os.unlink(tmpfile)
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -115,10 +120,11 @@ if __name__ == "__main__":
|
|||||||
cmd("hg init '%s'" % (hg_repo))
|
cmd("hg init '%s'" % (hg_repo))
|
||||||
cmd("darcs initialize", hg_repo)
|
cmd("darcs initialize", hg_repo)
|
||||||
# Get the changes from the Darcs repository
|
# Get the changes from the Darcs repository
|
||||||
for summary, description in darcs_changes(darcs_repo):
|
for author, date, summary, description in darcs_changes(darcs_repo):
|
||||||
text = summary + "\n" + description
|
text = summary + "\n" + description
|
||||||
darcs_pull(hg_repo, darcs_repo, summary)
|
darcs_pull(hg_repo, darcs_repo, summary)
|
||||||
hg_commit(hg_repo, text)
|
epoch = int(mktime(strptime(date, '%Y%m%d%H%M%S')))
|
||||||
|
hg_commit(hg_repo, text, author, epoch)
|
||||||
|
|
||||||
# EOF
|
# EOF
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user