Show More
@@ -16,24 +16,36 b'' | |||
|
16 | 16 | # identifier to be stored in the converted revision. This will cause |
|
17 | 17 | # the converted revision to have a different identity than the |
|
18 | 18 | # source. |
|
19 | from __future__ import absolute_import | |
|
19 | 20 | |
|
21 | import cStringIO | |
|
22 | import os | |
|
23 | import re | |
|
24 | import time | |
|
20 | 25 | |
|
21 | import os, time, cStringIO | |
|
26 | from mercurial import ( | |
|
27 | bookmarks, | |
|
28 | context, | |
|
29 | error, | |
|
30 | exchange, | |
|
31 | hg, | |
|
32 | lock as lockmod, | |
|
33 | merge as mergemod, | |
|
34 | node as nodemod, | |
|
35 | phases, | |
|
36 | scmutil, | |
|
37 | util, | |
|
38 | ) | |
|
22 | 39 | from mercurial.i18n import _ |
|
23 | from mercurial.node import bin, hex, nullid | |
|
24 | from mercurial import hg, util, context, bookmarks, error, scmutil, exchange | |
|
25 | from mercurial import phases | |
|
26 | from mercurial import lock as lockmod | |
|
27 | from mercurial import merge as mergemod | |
|
40 | from . import common | |
|
41 | mapfile = common.mapfile | |
|
42 | NoRepo = common.NoRepo | |
|
28 | 43 | |
|
29 | from common import NoRepo, commit, converter_source, converter_sink, mapfile | |
|
30 | ||
|
31 | import re | |
|
32 | 44 | sha1re = re.compile(r'\b[0-9a-f]{12,40}\b') |
|
33 | 45 | |
|
34 | class mercurial_sink(converter_sink): | |
|
46 | class mercurial_sink(common.converter_sink): | |
|
35 | 47 | def __init__(self, ui, path): |
|
36 | converter_sink.__init__(self, ui, path) | |
|
48 | common.converter_sink.__init__(self, ui, path) | |
|
37 | 49 | self.branchnames = ui.configbool('convert', 'hg.usebranchnames', True) |
|
38 | 50 | self.clonebranches = ui.configbool('convert', 'hg.clonebranches', False) |
|
39 | 51 | self.tagsbranch = ui.config('convert', 'hg.tagsbranch', 'default') |
@@ -132,7 +144,7 b' class mercurial_sink(converter_sink):' | |||
|
132 | 144 | continue |
|
133 | 145 | revid = revmap.get(source.lookuprev(s[0])) |
|
134 | 146 | if not revid: |
|
135 |
if s[0] == |
|
|
147 | if s[0] == nodemod.nullhex: | |
|
136 | 148 | revid = s[0] |
|
137 | 149 | else: |
|
138 | 150 | continue |
@@ -148,7 +160,7 b' class mercurial_sink(converter_sink):' | |||
|
148 | 160 | |
|
149 | 161 | revid = s[0] |
|
150 | 162 | subpath = s[1] |
|
151 |
if revid != |
|
|
163 | if revid != nodemod.nullhex: | |
|
152 | 164 | revmap = self.subrevmaps.get(subpath) |
|
153 | 165 | if revmap is None: |
|
154 | 166 | revmap = mapfile(self.ui, |
@@ -250,13 +262,13 b' class mercurial_sink(converter_sink):' | |||
|
250 | 262 | parents = pl |
|
251 | 263 | nparents = len(parents) |
|
252 | 264 | if self.filemapmode and nparents == 1: |
|
253 | m1node = self.repo.changelog.read(bin(parents[0]))[0] | |
|
265 | m1node = self.repo.changelog.read(nodemod.bin(parents[0]))[0] | |
|
254 | 266 | parent = parents[0] |
|
255 | 267 | |
|
256 | 268 | if len(parents) < 2: |
|
257 | parents.append(nullid) | |
|
269 | parents.append(nodemod.nullid) | |
|
258 | 270 | if len(parents) < 2: |
|
259 | parents.append(nullid) | |
|
271 | parents.append(nodemod.nullid) | |
|
260 | 272 | p2 = parents.pop(0) |
|
261 | 273 | |
|
262 | 274 | text = commit.desc |
@@ -283,12 +295,12 b' class mercurial_sink(converter_sink):' | |||
|
283 | 295 | |
|
284 | 296 | # Only transplant stores its reference in binary |
|
285 | 297 | if label == 'transplant_source': |
|
286 | node = hex(node) | |
|
298 | node = nodemod.hex(node) | |
|
287 | 299 | |
|
288 | 300 | newrev = revmap.get(node) |
|
289 | 301 | if newrev is not None: |
|
290 | 302 | if label == 'transplant_source': |
|
291 | newrev = bin(newrev) | |
|
303 | newrev = nodemod.bin(newrev) | |
|
292 | 304 | |
|
293 | 305 | extra[label] = newrev |
|
294 | 306 | |
@@ -302,7 +314,7 b' class mercurial_sink(converter_sink):' | |||
|
302 | 314 | p2 = parents.pop(0) |
|
303 | 315 | p1ctx = self.repo[p1] |
|
304 | 316 | p2ctx = None |
|
305 | if p2 != nullid: | |
|
317 | if p2 != nodemod.nullid: | |
|
306 | 318 | p2ctx = self.repo[p2] |
|
307 | 319 | fileset = set(files) |
|
308 | 320 | if full: |
@@ -324,7 +336,7 b' class mercurial_sink(converter_sink):' | |||
|
324 | 336 | phases.phasenames[commit.phase], 'convert') |
|
325 | 337 | |
|
326 | 338 | with self.repo.transaction("convert") as tr: |
|
327 | node = hex(self.repo.commitctx(ctx)) | |
|
339 | node = nodemod.hex(self.repo.commitctx(ctx)) | |
|
328 | 340 | |
|
329 | 341 | # If the node value has changed, but the phase is lower than |
|
330 | 342 | # draft, set it back to draft since it hasn't been exposed |
@@ -340,7 +352,7 b' class mercurial_sink(converter_sink):' | |||
|
340 | 352 | |
|
341 | 353 | if self.filemapmode and nparents == 1: |
|
342 | 354 | man = self.repo.manifest |
|
343 | mnode = self.repo.changelog.read(bin(p2))[0] | |
|
355 | mnode = self.repo.changelog.read(nodemod.bin(p2))[0] | |
|
344 | 356 | closed = 'close' in commit.extra |
|
345 | 357 | if not closed and not man.cmp(m1node, man.revision(mnode)): |
|
346 | 358 | self.ui.status(_("filtering out empty revision\n")) |
@@ -354,7 +366,7 b' class mercurial_sink(converter_sink):' | |||
|
354 | 366 | tagparent = parentctx.node() |
|
355 | 367 | except error.RepoError: |
|
356 | 368 | parentctx = None |
|
357 | tagparent = nullid | |
|
369 | tagparent = nodemod.nullid | |
|
358 | 370 | |
|
359 | 371 | oldlines = set() |
|
360 | 372 | for branch, heads in self.repo.branchmap().iteritems(): |
@@ -397,7 +409,7 b' class mercurial_sink(converter_sink):' | |||
|
397 | 409 | [".hgtags"], getfilectx, "convert-repo", date, |
|
398 | 410 | extra) |
|
399 | 411 | node = self.repo.commitctx(ctx) |
|
400 | return hex(node), hex(tagparent) | |
|
412 | return nodemod.hex(node), nodemod.hex(tagparent) | |
|
401 | 413 | |
|
402 | 414 | def setfilemapmode(self, active): |
|
403 | 415 | self.filemapmode = active |
@@ -413,7 +425,7 b' class mercurial_sink(converter_sink):' | |||
|
413 | 425 | self.ui.status(_("updating bookmarks\n")) |
|
414 | 426 | destmarks = self.repo._bookmarks |
|
415 | 427 | for bookmark in updatedbookmark: |
|
416 | destmarks[bookmark] = bin(updatedbookmark[bookmark]) | |
|
428 | destmarks[bookmark] = nodemod.bin(updatedbookmark[bookmark]) | |
|
417 | 429 | destmarks.recordchange(tr) |
|
418 | 430 | tr.close() |
|
419 | 431 | finally: |
@@ -430,9 +442,9 b' class mercurial_sink(converter_sink):' | |||
|
430 | 442 | 'are not implemented)') % rev) |
|
431 | 443 | return rev in self.repo |
|
432 | 444 | |
|
433 | class mercurial_source(converter_source): | |
|
445 | class mercurial_source(common.converter_source): | |
|
434 | 446 | def __init__(self, ui, path, revs=None): |
|
435 | converter_source.__init__(self, ui, path, revs) | |
|
447 | common.converter_source.__init__(self, ui, path, revs) | |
|
436 | 448 | self.ignoreerrors = ui.configbool('convert', 'hg.ignoreerrors', False) |
|
437 | 449 | self.ignored = set() |
|
438 | 450 | self.saverev = ui.configbool('convert', 'hg.saverev', False) |
@@ -493,7 +505,7 b' class mercurial_source(converter_source)' | |||
|
493 | 505 | return [p for p in ctx.parents() if p and self.keep(p.node())] |
|
494 | 506 | |
|
495 | 507 | def getheads(self): |
|
496 | return [hex(h) for h in self._heads if self.keep(h)] | |
|
508 | return [nodemod.hex(h) for h in self._heads if self.keep(h)] | |
|
497 | 509 | |
|
498 | 510 | def getfile(self, name, rev): |
|
499 | 511 | try: |
@@ -572,18 +584,23 b' class mercurial_source(converter_source)' | |||
|
572 | 584 | parents = [p.hex() for p in self._parents(ctx)] |
|
573 | 585 | crev = rev |
|
574 | 586 | |
|
575 | return commit(author=ctx.user(), | |
|
576 |
date=util.datestr(ctx.date(), |
|
|
577 | desc=ctx.description(), rev=crev, parents=parents, | |
|
578 | branch=ctx.branch(), extra=ctx.extra(), | |
|
579 |
|
|
|
587 | return common.commit(author=ctx.user(), | |
|
588 | date=util.datestr(ctx.date(), | |
|
589 | '%Y-%m-%d %H:%M:%S %1%2'), | |
|
590 | desc=ctx.description(), | |
|
591 | rev=crev, | |
|
592 | parents=parents, | |
|
593 | branch=ctx.branch(), | |
|
594 | extra=ctx.extra(), | |
|
595 | sortkey=ctx.rev(), | |
|
596 | saverev=self.saverev, | |
|
580 | 597 | phase=ctx.phase()) |
|
581 | 598 | |
|
582 | 599 | def gettags(self): |
|
583 | 600 | # This will get written to .hgtags, filter non global tags out. |
|
584 | 601 | tags = [t for t in self.repo.tagslist() |
|
585 | 602 | if self.repo.tagtype(t[0]) == 'global'] |
|
586 | return dict([(name, hex(node)) for name, node in tags | |
|
603 | return dict([(name, nodemod.hex(node)) for name, node in tags | |
|
587 | 604 | if self.keep(node)]) |
|
588 | 605 | |
|
589 | 606 | def getchangedfiles(self, rev, i): |
@@ -622,7 +639,7 b' class mercurial_source(converter_source)' | |||
|
622 | 639 | |
|
623 | 640 | def lookuprev(self, rev): |
|
624 | 641 | try: |
|
625 | return hex(self.repo.lookup(rev)) | |
|
642 | return nodemod.hex(self.repo.lookup(rev)) | |
|
626 | 643 | except (error.RepoError, error.LookupError): |
|
627 | 644 | return None |
|
628 | 645 |
@@ -29,7 +29,6 b'' | |||
|
29 | 29 | hgext/convert/common.py not using absolute_import |
|
30 | 30 | hgext/convert/convcmd.py not using absolute_import |
|
31 | 31 | hgext/convert/cvs.py not using absolute_import |
|
32 | hgext/convert/hg.py not using absolute_import | |
|
33 | 32 | hgext/convert/monotone.py not using absolute_import |
|
34 | 33 | hgext/convert/p4.py not using absolute_import |
|
35 | 34 | hgext/convert/subversion.py not using absolute_import |
General Comments 0
You need to be logged in to leave comments.
Login now