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

login
register
mail settings
Submitter Durham Goode
Date Aug. 15, 2015, 9:11 p.m.
Message ID <3d65200552e6af37d0f5.1439673076@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/10216/
State Accepted
Delegated to: Augie Fackler
Headers show

Comments

Durham Goode - Aug. 15, 2015, 9:11 p.m.
# HG changeset patch
# User Durham Goode <durham@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.

Patch

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)