def _handle_empty_files(self, diff, base, tip, exclude_files=[]):
        # If the files in the base and tip changesets are the same, no files
        # (empty or otherwise) were added or deleted.
        base_files = self._get_files_in_changeset(base)
        tip_files = self._get_files_in_changeset(tip)

        if base_files == tip_files:
            return diff

        tip_empty_files = self._get_files_in_changeset(tip, get_empty=True)
        added_empty_files = tip_empty_files - base_files

        base_empty_files = self._get_files_in_changeset(base, get_empty=True)
        deleted_empty_files = base_empty_files - tip_files

        if not (added_empty_files or deleted_empty_files):
            return diff

        dates = execute(['hg', 'log', '-r', base, '-r', tip,
                         '--template', '{date|date}\\t'],
                        env=self._hg_env)
        base_date, tip_date = dates.strip().split('\t')

        for filename in added_empty_files:
            if filename not in exclude_files:
                diff += ('diff -r %s -r %s %s\n'
                         '--- %s\t%s\n'
                         '+++ b/%s\t%s\n'
                         % (base, tip, filename,
                            self.PRE_CREATION, self.PRE_CREATION_DATE,
                            filename, tip_date)).encode('utf-8')

        for filename in deleted_empty_files:
            if filename not in exclude_files:
                diff += ('diff -r %s -r %s %s\n'
                         '--- a/%s\t%s\n'
                         '+++ %s\t%s\n'
                         % (base, tip, filename,
                            filename, base_date,
                            self.PRE_CREATION,
                            self.PRE_CREATION_DATE)).encode('utf-8')

        return diff
Add added and deleted 0-length files to the diff output.
dataset/ETHPy150Open reviewboard/rbtools/rbtools/clients/mercurial.py/MercurialClient._handle_empty_files