# HG changeset patch # User Bryan O'Sullivan # Date 1185482076 25200 # Node ID 89fbb0a5e8e3e1477bb6a65a7d9af6b272f2b6a9 # Parent 30570c2f576fa2e2ead1212e1509886368453107 convert: rename mapfile to revmapfile, so we can map more than just revs diff --git a/hgext/convert/__init__.py b/hgext/convert/__init__.py --- a/hgext/convert/__init__.py +++ b/hgext/convert/__init__.py @@ -41,25 +41,25 @@ def convertsink(ui, path): raise util.Abort('%s: unknown repository type' % path) class convert(object): - def __init__(self, ui, source, dest, mapfile, opts): + def __init__(self, ui, source, dest, revmapfile, opts): self.source = source self.dest = dest self.ui = ui self.opts = opts self.commitcache = {} - self.mapfile = mapfile - self.mapfilefd = None + self.revmapfile = revmapfile + self.revmapfilefd = None self.authors = {} self.authorfile = None self.map = {} try: - origmapfile = open(self.mapfile, 'r') - for l in origmapfile: + origrevmapfile = open(self.revmapfile, 'r') + for l in origrevmapfile: sv, dv = l[:-1].split() self.map[sv] = dv - origmapfile.close() + origrevmapfile.close() except IOError: pass @@ -151,14 +151,14 @@ class convert(object): return s def mapentry(self, src, dst): - if self.mapfilefd is None: + if self.revmapfilefd is None: try: - self.mapfilefd = open(self.mapfile, "a") + self.revmapfilefd = open(self.revmapfile, "a") except IOError, (errno, strerror): - raise util.Abort("Could not open map file %s: %s, %s\n" % (self.mapfile, errno, strerror)) + raise util.Abort("Could not open map file %s: %s, %s\n" % (self.revmapfile, errno, strerror)) self.map[src] = dst - self.mapfilefd.write("%s %s\n" % (src, dst)) - self.mapfilefd.flush() + self.revmapfilefd.write("%s %s\n" % (src, dst)) + self.revmapfilefd.flush() def writeauthormap(self): authorfile = self.authorfile @@ -256,10 +256,10 @@ class convert(object): self.cleanup() def cleanup(self): - if self.mapfilefd: - self.mapfilefd.close() + if self.revmapfilefd: + self.revmapfilefd.close() -def _convert(ui, src, dest=None, mapfile=None, **opts): +def _convert(ui, src, dest=None, revmapfile=None, **opts): """Convert a foreign SCM repository to a Mercurial one. Accepted source formats: @@ -278,8 +278,8 @@ def _convert(ui, src, dest=None, mapfile basename of the source with '-hg' appended. If the destination repository doesn't exist, it will be created. - If isn't given, it will be put in a default location - (/.hg/shamap by default). The is a simple text + If isn't given, it will be put in a default location + (/.hg/shamap by default). The is a simple text file that maps each source commit ID to the destination ID for that revision, like so: @@ -334,13 +334,13 @@ def _convert(ui, src, dest=None, mapfile shutil.rmtree(dest, True) raise - if not mapfile: + if not revmapfile: try: - mapfile = destc.mapfile() + revmapfile = destc.revmapfile() except: - mapfile = os.path.join(destc, "map") + revmapfile = os.path.join(destc, "map") - c = convert(ui, srcc, destc, mapfile, opts) + c = convert(ui, srcc, destc, revmapfile, opts) c.convert() cmdtable = { diff --git a/hgext/convert/common.py b/hgext/convert/common.py --- a/hgext/convert/common.py +++ b/hgext/convert/common.py @@ -81,7 +81,7 @@ class converter_sink(object): """Return a list of this repository's heads""" raise NotImplementedError() - def mapfile(self): + def revmapfile(self): """Path to a file that will contain lines source_rev_id sink_rev_id mapping equivalent revision identifiers for each system.""" diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py --- a/hgext/convert/hg.py +++ b/hgext/convert/hg.py @@ -14,7 +14,7 @@ class convert_mercurial(converter_sink): except: raise NoRepo("could open hg repo %s" % path) - def mapfile(self): + def revmapfile(self): return os.path.join(self.path, ".hg", "shamap") def authorfile(self):