Patchwork [3,of,5] convert: introduce hascommitfrommap sink method

login
register
mail settings
Submitter Mads Kiilerich
Date May 19, 2014, 8:33 p.m.
Message ID <8b9f31e85407fef886a0.1400531611@mk-desktop>
Download mbox | patch
Permalink /patch/4817/
State Accepted
Commit 5f2cc464e502a19312125b645dde5615d2d74416
Headers show

Comments

Mads Kiilerich - May 19, 2014, 8:33 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1400530350 -7200
#      Mon May 19 22:12:30 2014 +0200
# Node ID 8b9f31e85407fef886a08b55be31665f02319fde
# Parent  51fc2a2b012f3b85976c9945cf0e561d77d5df30
convert: introduce hascommitfrommap sink method

Mercurial has stable revision identifiers and rollback and strip. Revisions
referenced in the shamap are thus not necessarily still present but we can
easily check for it.

Subversion do not have stable identifiers and no rollback or strip(?). We must
thus assume that all revisions referenced from a shamap still must be present.

This method is similar to hascommitforsplicemap but different ...

Patch

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -260,6 +260,11 @@  class converter_sink(object):
         """
         pass
 
+    def hascommitfrommap(self, rev):
+        """Return False if a rev mentioned in a filemap is known to not be
+        present."""
+        raise NotImplementedError
+
     def hascommitforsplicemap(self, rev):
         """This method is for the special needs for splicemap handling and not
         for general use. Returns True if the sink contains rev, aborts on some
diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -253,6 +253,10 @@  class mercurial_sink(converter_sink):
             destmarks[bookmark] = bin(updatedbookmark[bookmark])
         destmarks.write()
 
+    def hascommitfrommap(self, rev):
+        # the exact semantics of clonebranches is unclear so we can't say no
+        return rev in self.repo or self.clonebranches
+
     def hascommitforsplicemap(self, rev):
         if rev not in self.repo and self.clonebranches:
             raise util.Abort(_('revision %s not found in destination '
diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -1300,6 +1300,11 @@  class svn_sink(converter_sink, commandli
         self.ui.warn(_('writing Subversion tags is not yet implemented\n'))
         return None, None
 
+    def hascommitfrommap(self, rev):
+        # We trust that revisions referenced in a map still is present
+        # TODO: implement something better if necessary and feasible
+        return True
+
     def hascommitforsplicemap(self, rev):
         # This is not correct as one can convert to an existing subversion
         # repository and childmap would not list all revisions. Too bad.