Mercurial > hg > mercurial-crew-with-dirclash
comparison contrib/darcs2hg.py @ 3044:fcadf7a32425
Merge with mpm
author | Josef "Jeff" Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sun, 03 Sep 2006 06:06:02 -0400 |
parents | d13e4ffaa79d |
children | eb0b4a2d70a9 |
comparison
equal
deleted
inserted
replaced
3043:2a4d4aecb2b4 | 3044:fcadf7a32425 |
---|---|
90 changes = filter(lambda l:l.strip().startswith("* "), changes.split("\n")) | 90 changes = filter(lambda l:l.strip().startswith("* "), changes.split("\n")) |
91 return len(changes) | 91 return len(changes) |
92 | 92 |
93 def darcs_pull(hg_repo, darcs_repo, chash): | 93 def darcs_pull(hg_repo, darcs_repo, chash): |
94 old_tip = darcs_tip(darcs_repo) | 94 old_tip = darcs_tip(darcs_repo) |
95 res = cmd("darcs pull '%s' --all --match='hash %s'" % (darcs_repo, chash), hg_repo) | 95 res = cmd("darcs pull \"%s\" --all --match=\"hash %s\"" % (darcs_repo, chash), hg_repo) |
96 print res | 96 print res |
97 new_tip = darcs_tip(darcs_repo) | 97 new_tip = darcs_tip(darcs_repo) |
98 if not new_tip != old_tip + 1: | 98 if not new_tip != old_tip + 1: |
99 error("Darcs pull did not work as expected: " + res) | 99 error("Darcs pull did not work as expected: " + res) |
100 | 100 |
108 fd, tmpfile = tempfile.mkstemp(prefix="darcs2hg_") | 108 fd, tmpfile = tempfile.mkstemp(prefix="darcs2hg_") |
109 writefile(tmpfile, text) | 109 writefile(tmpfile, text) |
110 old_tip = hg_tip(hg_repo) | 110 old_tip = hg_tip(hg_repo) |
111 cmd("hg add -X _darcs", hg_repo) | 111 cmd("hg add -X _darcs", hg_repo) |
112 cmd("hg remove -X _darcs --after", hg_repo) | 112 cmd("hg remove -X _darcs --after", hg_repo) |
113 res = cmd("hg commit -l %s -u '%s' -d '%s 0'" % (tmpfile, author, date), hg_repo) | 113 res = cmd("hg commit -l %s -u \"%s\" -d \"%s 0\"" % (tmpfile, author, date), hg_repo) |
114 os.close(fd) | |
114 os.unlink(tmpfile) | 115 os.unlink(tmpfile) |
115 new_tip = hg_tip(hg_repo) | 116 new_tip = hg_tip(hg_repo) |
116 if not new_tip == old_tip + 1: | 117 if not new_tip == old_tip + 1: |
117 # Sometimes we may have empty commits, we simply skip them | 118 # Sometimes we may have empty commits, we simply skip them |
118 if res.strip().lower().find("nothing changed") != -1: | 119 if res.strip().lower().find("nothing changed") != -1: |
154 os.mkdir(hg_repo) | 155 os.mkdir(hg_repo) |
155 elif skip == None: | 156 elif skip == None: |
156 print "Given HG repository must not exist when no SKIP is specified." | 157 print "Given HG repository must not exist when no SKIP is specified." |
157 sys.exit(-1) | 158 sys.exit(-1) |
158 if skip == None: | 159 if skip == None: |
159 cmd("hg init '%s'" % (hg_repo)) | 160 cmd("hg init \"%s\"" % (hg_repo)) |
160 cmd("darcs initialize", hg_repo) | 161 cmd("darcs initialize", hg_repo) |
161 # Get the changes from the Darcs repository | 162 # Get the changes from the Darcs repository |
162 change_number = 0 | 163 change_number = 0 |
163 for author, date, summary, chash, description in darcs_changes(darcs_repo): | 164 for author, date, summary, chash, description in darcs_changes(darcs_repo): |
164 print "== changeset", change_number, | 165 print "== changeset", change_number, |