[PATCH 1 of 3] convert: add function to test if file is from source

Durham Goode durham at fb.com
Sat Aug 15 21:11:16 UTC 2015


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1439671495 25200
#      Sat Aug 15 13:44:55 2015 -0700
# Branch stable
# Node ID 3d65200552e6af37d0f520b45239e7f0afdda7a0
# Parent  ceacdfa1a8b76a1b4e2535b5684bcc67628b50ce
convert: add function to test if file is from source

This adds a base implementation of a function that tests if a given file from a
target repo came from the source repo. This will be used later to detect which
files did not come from the source repo during a merge, so we can merge those
files correctly instead of dropping them.

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -82,6 +82,13 @@ class converter_source(object):
     def after(self):
         pass
 
+    def targetfilebelongstosource(self, targetfilename):
+        """Returns true if the given targetfile belongs to the source repo. This
+        is useful when only a subdirectory of the target belongs to the source
+        repo."""
+        # For normal full repo converts, this is always True.
+        return True
+
     def setrevmap(self, revmap):
         """set the map of already-converted revisions"""
         pass
diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -120,6 +120,9 @@ class progresssource(object):
                          item=file, total=self.filecount)
         return self.source.getfile(file, rev)
 
+    def targetfilebelongstosource(self, targetfilename):
+        return self.source.targetfilebelongstosource(targetfilename)
+
     def lookuprev(self, rev):
         return self.source.lookuprev(rev)
 


More information about the Mercurial-devel mailing list