except Exception, e: logging.error(u"Failed to commit files: %s", e) request.user.message_set.create( message="Failed to commit file: %s" % e) success = False try: hooks.hook(self.project.code, "postcommit", store.file.path, success=success) except: #FIXME: We should not hide the exception - makes development impossible pass post_vc_commit.send(sender=self, store=store, stats=stats, user=request.user, success=success) return success def initialize(self): try: hooks.hook(self.project.code, "initialize", self.real_path, self.language.code) except Exception, e: logging.error(u"Failed to initialize (%s): %s", self.language.code, e) ############################################################################################## def get_archive(self, stores, path=None):
def commit_dir(self, user, directory, request=None): """Commits files under a directory to version control. This does not do permission checking. """ self.sync() total = directory.get_total_wordcount() translated = directory.get_translated_wordcount() fuzzy = directory.get_fuzzy_wordcount() author = user.username siteconfig = load_site_config() message = stats_message_raw("Commit from %s by user %s." % (siteconfig.get('TITLE'), author), total, translated, fuzzy) # Try to append email as well, since some VCS does not allow omitting # it (ie. Git). if user.is_authenticated() and len(user.email): author += " <%s>" % user.email if directory.is_translationproject(): stores = list(self.stores.exclude(file="")) else: stores = list(directory.stores.exclude(file="")) filestocommit = [] from pootle.scripts import hooks for store in stores: try: filestocommit.extend(hooks.hook(self.project.code, "precommit", store.file.name, author=author, message=message) ) except ImportError: # Failed to import the hook - we're going to assume there just # isn't a hook to import. That means we'll commit the original # file. filestocommit.append(store.file.name) success = True try: from pootle_misc import versioncontrol project_path = self.project.get_real_path() versioncontrol.add_files(project_path, filestocommit, message, author) # FIXME: This belongs to views if request is not None: msg = _("Committed all files under <em>%(path)s</em> to " "version control", {'path': directory.pootle_path}) messages.success(request, msg) except Exception as e: logging.exception(u"Failed to commit directory") # FIXME: This belongs to views if request is not None: msg = _("Failed to commit to version control: %(error)s", {'error': e}) messages.error(request, msg) success = False for store in stores: try: hooks.hook(self.project.code, "postcommit", store.file.name, success=success) except: #FIXME: We should not hide the exception - makes development # impossible pass from pootle_app.models.signals import post_vc_commit post_vc_commit.send(sender=self, path_obj=directory, user=user, success=success) return success
def commit_file(self, user, store, request=None): """Commits an individual file to version control. This does not do permission checking. """ store.sync(update_structure=False, update_translation=True, conservative=True) total = store.get_total_wordcount() translated = store.get_translated_wordcount() fuzzy = store.get_fuzzy_wordcount() author = user.username siteconfig = load_site_config() message = stats_message_raw("Commit from %s by user %s." % \ (siteconfig.get('TITLE'), author), total, translated, fuzzy) # Try to append email as well, since some VCS does not allow omitting # it (ie. Git). if user.is_authenticated() and len(user.email): author += " <%s>" % user.email from pootle.scripts import hooks try: filestocommit = hooks.hook(self.project.code, "precommit", store.file.name, author=author, message=message) except ImportError: # Failed to import the hook - we're going to assume there just # isn't a hook to import. That means we'll commit the original # file. filestocommit = [store.file.name] success = True try: from pootle_misc import versioncontrol for file in filestocommit: versioncontrol.commit_file(file, message=message, author=author) # FIXME: This belongs to views if request is not None: msg = _("Committed file <em>%(filename)s</em> to version " "control", {'filename': file}) messages.success(request, msg) except Exception as e: logging.exception(u"Failed to commit file") # FIXME: This belongs to views if request is not None: msg_params = { 'filename': filename, 'error': e, } msg = _("Failed to commit <em>%(filename)s</em> to version " "control: %(error)s", msg_params) messages.error(request, msg) success = False try: hooks.hook(self.project.code, "postcommit", store.file.name, success=success) except: #FIXME: We should not hide the exception - makes development # impossible pass from pootle_app.models.signals import post_vc_commit post_vc_commit.send(sender=self, path_obj=store, user=user, success=success) return success
) messages.error(request, msg) success = False for store in stores: try: hooks.hook(self.project.code, "postcommit", store.file.name, success=success) except: #FIXME: We should not hide the exception - makes development # impossible pass from pootle_app.models.signals import post_vc_commit post_vc_commit.send(sender=self, path_obj=directory, stats=stats, user=user, success=success) return success def commit_file(self, user, store, request=None): """Commits an individual file to version control. This does not do permission checking. """ store.sync(update_structure=False, update_translation=True, conservative=True) stats = store.getquickstats() author = user.username message = stats_message_raw("Commit from %s by user %s." % \ (settings.TITLE, author), stats)
success = True try: for file in filestocommit: versioncontrol.commitfile(file, message=message, author=author) request.user.message_set.create(message="Committed file: <em>%s</em>" % file) except Exception, e: logging.error("Failed to commit files: %s", e) request.user.message_set.create(message="Failed to commit file: %s" % e) success = False try: hooks.hook(self.project.code, "postcommit", store.file.path, success=success) except: # FIXME: We should not hide the exception - makes development impossible pass post_vc_commit.send(sender=self, store=store, stats=stats, user=request.user, success=success) return success def initialize(self): try: hooks.hook(self.project.code, "initialize", self.real_path, self.language.code) except Exception, e: logging.error("Failed to initialize (%s): %s", self.language.code, e) ############################################################################################## def get_archive(self, stores): """returns an archive of the given filenames""" tempzipfile = None try: # using zip command line is fast
for store in stores: try: hooks.hook(self.project.code, "postcommit", store.file.name, success=success) except: #FIXME: We should not hide the exception - makes development # impossible pass from pootle_app.models.signals import post_vc_commit post_vc_commit.send(sender=self, path_obj=directory, stats=stats, user=user, success=success) return success def commit_file(self, user, store, request=None): """Commits an individual file to version control. This does not do permission checking. """ store.sync(update_structure=False, update_translation=True, conservative=True) stats = store.getquickstats() author = user.username
def commit_file(self, user, store, request=None): """Commits an individual file to version control. This does not do permission checking. """ store.sync(update_structure=False, update_translation=True, conservative=True) stats = store.getquickstats() author = user.username message = stats_message_raw("Commit from %s by user %s." % \ (settings.TITLE, author), stats) # Try to append email as well, since some VCS does not allow omitting # it (ie. Git). if user.is_authenticated() and len(user.email): author += " <%s>" % user.email from pootle.scripts import hooks try: filestocommit = hooks.hook(self.project.code, "precommit", store.file.name, author=author, message=message) except ImportError: # Failed to import the hook - we're going to assume there just # isn't a hook to import. That means we'll commit the original # file. filestocommit = [store.file.name] success = True try: from pootle_misc import versioncontrol for file in filestocommit: versioncontrol.commit_file(file, message=message, author=author) # FIXME: This belongs to views if request is not None: msg = _( "Committed file <em>%(filename)s</em> to version " "control", {'filename': file}) messages.success(request, msg) except Exception as e: logging.error(u"Failed to commit file: %s", e) # FIXME: This belongs to views if request is not None: msg_params = { 'filename': filename, 'error': e, } msg = _( "Failed to commit <em>%(filename)s</em> to version " "control: %(error)s", msg_params) messages.error(request, msg) success = False try: hooks.hook(self.project.code, "postcommit", store.file.name, success=success) except: #FIXME: We should not hide the exception - makes development # impossible pass from pootle_app.models.signals import post_vc_commit post_vc_commit.send(sender=self, path_obj=store, stats=stats, user=user, success=success) return success
def commit_dir(self, user, directory, request=None): """Commits files under a directory to version control. This does not do permission checking. """ self.sync() stats = self.getquickstats() author = user.username message = stats_message_raw( "Commit from %s by user %s." % (settings.TITLE, author), stats) # Try to append email as well, since some VCS does not allow omitting # it (ie. Git). if user.is_authenticated() and len(user.email): author += " <%s>" % user.email if directory.is_translationproject(): stores = list(self.stores.exclude(file="")) else: stores = list(directory.stores.exclude(file="")) filestocommit = [] from pootle.scripts import hooks for store in stores: try: filestocommit.extend( hooks.hook(self.project.code, "precommit", store.file.name, author=author, message=message)) except ImportError: # Failed to import the hook - we're going to assume there just # isn't a hook to import. That means we'll commit the original # file. filestocommit.append(store.file.name) success = True try: from pootle_misc import versioncontrol project_path = self.project.get_real_path() versioncontrol.add_files(project_path, filestocommit, message, author) # FIXME: This belongs to views if request is not None: msg = _( "Committed all files under <em>%(path)s</em> to " "version control", {'path': directory.pootle_path}) messages.success(request, msg) except Exception as e: logging.error(u"Failed to commit: %s", e) # FIXME: This belongs to views if request is not None: msg = _("Failed to commit to version control: %(error)s", {'error': e}) messages.error(request, msg) success = False for store in stores: try: hooks.hook(self.project.code, "postcommit", store.file.name, success=success) except: #FIXME: We should not hide the exception - makes development # impossible pass from pootle_app.models.signals import post_vc_commit post_vc_commit.send(sender=self, path_obj=directory, stats=stats, user=user, success=success) return success