Пример #1
0
    def update_file_from_version_control(self, store):
        from pootle.scripts import hooks
        store.sync(update_translation=True)

        try:
            hooks.hook(self.project.code, "preupdate", store.file.name)
        except:
            pass

        # Keep a copy of working files in memory before updating
        oldstats = store.getquickstats()
        working_copy = store.file.store

        try:
            logging.debug(u"Updating %s from version control", store.file.name)
            from pootle_misc import versioncontrol
            versioncontrol.update_file(store.file.name)
            store.file._delete_store_cache()
            store.file._update_store_cache()
        except Exception, e:
            # Something wrong, file potentially modified, bail out
            # and replace with working copy
            logging.error(u"Near fatal catastrophe, exception %s while "
                          u"updating %s from version control",
                          e, store.file.name)
            working_copy.save()

            raise VersionControlError
Пример #2
0
    def update_file_from_version_control(self, store):
        from pootle.scripts import hooks
        store.sync(update_translation=True)

        filetoupdate = store.file.name
        try:
            filetoupdate = hooks.hook(self.project.code, "preupdate",
                                      store.file.name)
        except:
            pass

        # Keep a copy of working files in memory before updating
        oldstats = store.getquickstats()
        working_copy = store.file.store

        try:
            logging.debug(u"Updating %s from version control", store.file.name)
            from pootle_misc import versioncontrol
            versioncontrol.update_file(filetoupdate)
            store.file._delete_store_cache()
            store.file._update_store_cache()
        except Exception, e:
            # Something wrong, file potentially modified, bail out
            # and replace with working copy
            logging.error(
                u"Near fatal catastrophe, exception %s while "
                u"updating %s from version control", e, store.file.name)
            working_copy.save()

            raise VersionControlError
Пример #3
0
    def update_file_from_version_control(self, store):
        from pootle.scripts import hooks
        store.sync(update_translation=True)

        filetoupdate = store.file.name
        try:
            filetoupdate = hooks.hook(self.project.code, "preupdate",
                                      store.file.name)
        except:
            pass

        # Keep a copy of working files in memory before updating
        oldstats = store.getquickstats()
        working_copy = store.file.store

        try:
            logging.debug(u"Updating %s from version control", store.file.name)
            from pootle_misc import versioncontrol
            versioncontrol.update_file(filetoupdate)
            store.file._delete_store_cache()
            store.file._update_store_cache()
        except Exception as e:
            # Something wrong, file potentially modified, bail out
            # and replace with working copy
            logging.error(u"Near fatal catastrophe, exception %s while "
                          u"updating %s from version control",
                          e, store.file.name)
            working_copy.save()

            raise VersionControlError

        try:
            hooks.hook(self.project.code, "postupdate", store.file.name)
        except:
            pass

        try:
            logging.debug(u"Parsing version control copy of %s into db",
                          store.file.name)
            store.update(update_structure=True, update_translation=True)
            remotestats = store.getquickstats()

            #FIXME: try to avoid merging if file was not updated
            logging.debug(u"Merging %s with version control update",
                          store.file.name)
            store.mergefile(working_copy, None, allownewstrings=False,
                            suggestions=True, notranslate=False,
                            obsoletemissing=False)
        except Exception as e:
            logging.error(u"Near fatal catastrophe, exception %s while merging "
                          u"%s with version control copy", e, store.file.name)
            working_copy.save()
            store.update(update_structure=True, update_translation=True)
            raise

        newstats = store.getquickstats()
        return oldstats, remotestats, newstats
Пример #4
0
    def update_file_from_version_control(self, store):
        from pootle.scripts import hooks
        store.sync(update_translation=True)

        filetoupdate = store.file.name
        try:
            filetoupdate = hooks.hook(self.project.code, "preupdate",
                                      store.file.name)
        except:
            pass

        # Keep a copy of working files in memory before updating
        working_copy = store.file.store

        try:
            logging.debug(u"Updating %s from version control", store.file.name)
            from pootle_misc import versioncontrol
            versioncontrol.update_file(filetoupdate)
            store.file._delete_store_cache()
            store.file._update_store_cache()
        except Exception:
            # Something wrong, file potentially modified, bail out
            # and replace with working copy
            logging.exception(
                u"Near fatal catastrophe, while updating %s "
                u"from version control", store.file.name)
            working_copy.save()

            raise VersionControlError

        try:
            hooks.hook(self.project.code, "postupdate", store.file.name)
        except:
            pass

        try:
            logging.debug(u"Parsing version control copy of %s into db",
                          store.file.name)
            store.update(update_structure=True, update_translation=True)

            #FIXME: try to avoid merging if file was not updated
            logging.debug(u"Merging %s with version control update",
                          store.file.name)
            store.mergefile(working_copy,
                            None,
                            allownewstrings=False,
                            suggestions=True,
                            notranslate=False,
                            obsoletemissing=False)
        except Exception:
            logging.exception(
                u"Near fatal catastrophe, while merging %s with "
                u"version control copy", store.file.name)
            working_copy.save()
            store.update(update_structure=True, update_translation=True)
            raise