3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
14 #include "VCBackend.h"
17 #include "FuncRequest.h"
19 #include "frontends/alert.h"
20 #include "frontends/Application.h"
22 #include "support/convert.h"
23 #include "support/debug.h"
24 #include "support/filetools.h"
25 #include "support/gettext.h"
26 #include "support/lstrings.h"
27 #include "support/Path.h"
28 #include "support/Systemcall.h"
29 #include "support/regex.h"
34 using namespace lyx::support;
41 int VCS::doVCCommandCall(string const & cmd, FileName const & path)
43 LYXERR(Debug::LYXVC, "doVCCommandCall: " << cmd);
45 support::PathChanger p(path);
46 return one.startscript(Systemcall::Wait, cmd, false);
50 int VCS::doVCCommand(string const & cmd, FileName const & path)
53 owner_->setBusy(true);
55 int const ret = doVCCommandCall(cmd, path);
58 owner_->setBusy(false);
60 frontend::Alert::error(_("Revision control error."),
61 bformat(_("Some problem occured while running the command:\n"
68 /////////////////////////////////////////////////////////////////////
72 /////////////////////////////////////////////////////////////////////
74 RCS::RCS(FileName const & m)
81 FileName const RCS::findFile(FileName const & file)
83 // Check if *,v exists.
84 FileName tmp(file.absFileName() + ",v");
85 LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under rcs: " << tmp);
86 if (tmp.isReadableFile()) {
87 LYXERR(Debug::LYXVC, "Yes, " << file << " is under rcs.");
91 // Check if RCS/*,v exists.
92 tmp = FileName(addName(addPath(onlyPath(file.absFileName()), "RCS"), file.absFileName()) + ",v");
93 LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under rcs: " << tmp);
94 if (tmp.isReadableFile()) {
95 LYXERR(Debug::LYXVC, "Yes, " << file << " is under rcs.");
103 void RCS::retrieve(FileName const & file)
105 LYXERR(Debug::LYXVC, "LyXVC::RCS: retrieve.\n\t" << file);
106 doVCCommandCall("co -q -r " + quoteName(file.toFilesystemEncoding()),
111 void RCS::scanMaster()
116 LYXERR(Debug::LYXVC, "LyXVC::RCS: scanMaster: " << master_);
118 ifstream ifs(master_.toFilesystemEncoding().c_str());
121 bool read_enough = false;
123 while (!read_enough && ifs >> token) {
124 LYXERR(Debug::LYXVC, "LyXVC::scanMaster: current lex text: `"
129 else if (token == "head") {
133 tmv = rtrim(tmv, ";");
135 LYXERR(Debug::LYXVC, "LyXVC: version found to be " << tmv);
136 } else if (contains(token, "access")
137 || contains(token, "symbols")
138 || contains(token, "strict")) {
140 } else if (contains(token, "locks")) {
142 if (contains(token, ';')) {
143 locker_ = "Unlocked";
152 s1 = rtrim(tmpt, ";");
153 // tmp is now in the format <user>:<version>
154 s1 = split(s1, s2, ':');
155 // s2 is user, and s1 is version
156 if (s1 == version_) {
161 } while (!contains(tmpt, ';'));
163 } else if (token == "comment") {
164 // we don't need to read any further than this.
168 LYXERR(Debug::LYXVC, "LyXVC::scanMaster(): unexpected token");
174 void RCS::registrer(string const & msg)
176 string cmd = "ci -q -u -i -t-\"";
179 cmd += quoteName(onlyFileName(owner_->absFileName()));
180 doVCCommand(cmd, FileName(owner_->filePath()));
184 string RCS::checkIn(string const & msg)
186 int ret = doVCCommand("ci -q -u -m\"" + msg + "\" "
187 + quoteName(onlyFileName(owner_->absFileName())),
188 FileName(owner_->filePath()));
189 return ret ? string() : "RCS: Proceeded";
193 bool RCS::checkInEnabled()
195 return owner_ && !owner_->isReadonly();
199 string RCS::checkOut()
202 int ret = doVCCommand("co -q -l " + quoteName(onlyFileName(owner_->absFileName())),
203 FileName(owner_->filePath()));
204 return ret ? string() : "RCS: Proceeded";
208 bool RCS::checkOutEnabled()
210 return owner_ && owner_->isReadonly();
214 string RCS::repoUpdate()
216 lyxerr << "Sorry, not implemented." << endl;
221 bool RCS::repoUpdateEnabled()
227 string RCS::lockingToggle()
229 lyxerr << "Sorry, not implemented." << endl;
234 bool RCS::lockingToggleEnabled()
242 doVCCommand("co -f -u" + version_ + " "
243 + quoteName(onlyFileName(owner_->absFileName())),
244 FileName(owner_->filePath()));
245 // We ignore changes and just reload!
252 LYXERR(Debug::LYXVC, "LyXVC: undoLast");
253 doVCCommand("rcs -o" + version_ + " "
254 + quoteName(onlyFileName(owner_->absFileName())),
255 FileName(owner_->filePath()));
259 bool RCS::undoLastEnabled()
265 void RCS::getLog(FileName const & tmpf)
267 doVCCommand("rlog " + quoteName(onlyFileName(owner_->absFileName()))
268 + " > " + quoteName(tmpf.toFilesystemEncoding()),
269 FileName(owner_->filePath()));
273 bool RCS::toggleReadOnlyEnabled()
275 // This got broken somewhere along lfuns dispatch reorganization.
276 // reloadBuffer would be needed after this, but thats problematic
277 // since we are inside Buffer::dispatch.
282 string RCS::revisionInfo(LyXVC::RevisionInfo const info)
284 if (info == LyXVC::File)
290 bool RCS::prepareFileRevision(string const &revis, string & f)
295 int back = convert<int>(rev);
296 // if positive use as the last number in the whole revision string
299 rsplit(version_, base , '.' );
300 rev = base + "." + rev;
304 // we care about the last number from revision string
305 // in case of backward indexing
308 cur = rsplit(version_, base , '.' );
311 int want = convert<int>(cur) + back;
315 rev = base + "." + convert<string>(want);
319 FileName tmpf = FileName::tempName("lyxvcrev_" + rev + "_");
321 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
322 return N_("Error: Could not generate logfile.");
325 doVCCommand("co -p" + rev + " "
326 + quoteName(onlyFileName(owner_->absFileName()))
327 + " > " + quoteName(tmpf.toFilesystemEncoding()),
328 FileName(owner_->filePath()));
329 if (tmpf.isFileEmpty())
332 f = tmpf.absFileName();
337 bool RCS::prepareFileRevisionEnabled()
343 /////////////////////////////////////////////////////////////////////
347 /////////////////////////////////////////////////////////////////////
349 CVS::CVS(FileName const & m, FileName const & f)
357 FileName const CVS::findFile(FileName const & file)
359 // First we look for the CVS/Entries in the same dir
360 // where we have file.
361 FileName const entries(onlyPath(file.absFileName()) + "/CVS/Entries");
362 string const tmpf = '/' + onlyFileName(file.absFileName()) + '/';
363 LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under cvs in `" << entries
364 << "' for `" << tmpf << '\'');
365 if (entries.isReadableFile()) {
366 // Ok we are at least in a CVS dir. Parse the CVS/Entries
367 // and see if we can find this file. We do a fast and
369 ifstream ifs(entries.toFilesystemEncoding().c_str());
371 while (getline(ifs, line)) {
372 LYXERR(Debug::LYXVC, "\tEntries: " << line);
373 if (contains(line, tmpf))
381 void CVS::scanMaster()
383 LYXERR(Debug::LYXVC, "LyXVC::CVS: scanMaster. \n Checking: " << master_);
384 // Ok now we do the real scan...
385 ifstream ifs(master_.toFilesystemEncoding().c_str());
386 string tmpf = '/' + onlyFileName(file_.absFileName()) + '/';
387 LYXERR(Debug::LYXVC, "\tlooking for `" << tmpf << '\'');
389 static regex const reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
390 while (getline(ifs, line)) {
391 LYXERR(Debug::LYXVC, "\t line: " << line);
392 if (contains(line, tmpf)) {
393 // Ok extract the fields.
396 regex_match(line, sm, reg);
398 //sm[0]; // whole matched string
400 version_ = sm.str(2);
401 string const file_date = sm.str(3);
404 //sm[5]; // tag or tagdate
405 // FIXME: must double check file is stattable/existing
406 time_t mod = file_.lastModified();
407 string mod_date = rtrim(asctime(gmtime(&mod)), "\n");
408 LYXERR(Debug::LYXVC, "Date in Entries: `" << file_date
409 << "'\nModification date of file: `" << mod_date << '\'');
410 //FIXME this whole locking bussiness is not working under cvs and the machinery
411 // conforms to the ci usage, not cvs.
412 if (file_date == mod_date) {
413 locker_ = "Unlocked";
416 // Here we should also do some more checking
417 // to see if there are conflicts or not.
427 void CVS::registrer(string const & msg)
429 doVCCommand("cvs -q add -m \"" + msg + "\" "
430 + quoteName(onlyFileName(owner_->absFileName())),
431 FileName(owner_->filePath()));
435 string CVS::checkIn(string const & msg)
437 int ret = doVCCommand("cvs -q commit -m \"" + msg + "\" "
438 + quoteName(onlyFileName(owner_->absFileName())),
439 FileName(owner_->filePath()));
440 return ret ? string() : "CVS: Proceeded";
444 bool CVS::checkInEnabled()
450 string CVS::checkOut()
452 // cvs update or perhaps for cvs this should be a noop
453 // we need to detect conflict (eg "C" in output)
454 // before we can do this.
455 lyxerr << "Sorry, not implemented." << endl;
460 bool CVS::checkOutEnabled()
466 string CVS::repoUpdate()
468 lyxerr << "Sorry, not implemented." << endl;
473 bool CVS::repoUpdateEnabled()
479 string CVS::lockingToggle()
481 lyxerr << "Sorry, not implemented." << endl;
486 bool CVS::lockingToggleEnabled()
494 // Reverts to the version in CVS repository and
495 // gets the updated version from the repository.
496 string const fil = quoteName(onlyFileName(owner_->absFileName()));
497 // This is sensitive operation, so at lest some check about
498 // existence of cvs program and its file
499 if (doVCCommand("cvs log "+ fil, FileName(owner_->filePath())))
501 FileName f(owner_->absFileName());
503 doVCCommand("cvs update " + fil,
504 FileName(owner_->filePath()));
511 // merge the current with the previous version
512 // in a reverse patch kind of way, so that the
513 // result is to revert the last changes.
514 lyxerr << "Sorry, not implemented." << endl;
518 bool CVS::undoLastEnabled()
524 void CVS::getLog(FileName const & tmpf)
526 doVCCommand("cvs log " + quoteName(onlyFileName(owner_->absFileName()))
527 + " > " + quoteName(tmpf.toFilesystemEncoding()),
528 FileName(owner_->filePath()));
532 bool CVS::toggleReadOnlyEnabled()
538 string CVS::revisionInfo(LyXVC::RevisionInfo const info)
540 if (info == LyXVC::File)
546 bool CVS::prepareFileRevision(string const &, string &)
552 bool CVS::prepareFileRevisionEnabled()
558 /////////////////////////////////////////////////////////////////////
562 /////////////////////////////////////////////////////////////////////
564 SVN::SVN(FileName const & m, FileName const & f)
574 FileName const SVN::findFile(FileName const & file)
576 // First we look for the .svn/entries in the same dir
577 // where we have file.
578 FileName const entries(onlyPath(file.absFileName()) + "/.svn/entries");
579 string const tmpf = onlyFileName(file.absFileName());
580 LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under svn in `" << entries
581 << "' for `" << tmpf << '\'');
582 if (entries.isReadableFile()) {
583 // Ok we are at least in a SVN dir. Parse the .svn/entries
584 // and see if we can find this file. We do a fast and
586 ifstream ifs(entries.toFilesystemEncoding().c_str());
587 string line, oldline;
588 while (getline(ifs, line)) {
589 if (line == "dir" || line == "file")
590 LYXERR(Debug::LYXVC, "\tEntries: " << oldline);
591 if (oldline == tmpf && line == "file")
600 void SVN::scanMaster()
602 // vcstatus code is somewhat superflous, until we want
603 // to implement read-only toggle for svn.
604 vcstatus = NOLOCKING;
605 if (checkLockMode()) {
615 bool SVN::checkLockMode()
617 FileName tmpf = FileName::tempName("lyxvcout");
619 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
620 return N_("Error: Could not generate logfile.");
623 LYXERR(Debug::LYXVC, "Detecting locking mode...");
624 if (doVCCommandCall("svn proplist " + quoteName(file_.onlyFileName())
625 + " > " + quoteName(tmpf.toFilesystemEncoding()),
629 ifstream ifs(tmpf.toFilesystemEncoding().c_str());
635 LYXERR(Debug::LYXVC, line);
636 if (contains(line, "svn:needs-lock"))
639 LYXERR(Debug::LYXVC, "Locking enabled: " << ret);
647 bool SVN::isLocked() const
650 return !file_.isReadOnly();
654 void SVN::registrer(string const & /*msg*/)
656 doVCCommand("svn add -q " + quoteName(onlyFileName(owner_->absFileName())),
657 FileName(owner_->filePath()));
661 string SVN::checkIn(string const & msg)
663 FileName tmpf = FileName::tempName("lyxvcout");
665 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
666 return N_("Error: Could not generate logfile.");
669 doVCCommand("svn commit -m \"" + msg + "\" "
670 + quoteName(onlyFileName(owner_->absFileName()))
671 + " > " + quoteName(tmpf.toFilesystemEncoding()),
672 FileName(owner_->filePath()));
675 string res = scanLogFile(tmpf, log);
677 frontend::Alert::error(_("Revision control error."),
678 _("Error when committing to repository.\n"
679 "You have to manually resolve the problem.\n"
680 "LyX will reopen the document after you press OK."));
682 fileLock(false, tmpf, log);
685 return log.empty() ? string() : "SVN: " + log;
689 bool SVN::checkInEnabled()
698 // FIXME Correctly return code should be checked instead of this.
699 // This would need another solution than just plain startscript.
700 // Hint from Andre': QProcess::readAllStandardError()...
701 string SVN::scanLogFile(FileName const & f, string & status)
703 ifstream ifs(f.toFilesystemEncoding().c_str());
708 LYXERR(Debug::LYXVC, line << "\n");
710 status += line + "; ";
711 if (prefixIs(line, "C ") || prefixIs(line, "CU ")
712 || contains(line, "Commit failed")) {
716 if (contains(line, "svn:needs-lock")) {
726 void SVN::fileLock(bool lock, FileName const & tmpf, string &status)
728 if (!locked_mode_ || (isLocked() == lock))
731 string const arg = lock ? "lock " : "unlock ";
732 doVCCommand("svn "+ arg + quoteName(onlyFileName(owner_->absFileName()))
733 + " > " + quoteName(tmpf.toFilesystemEncoding()),
734 FileName(owner_->filePath()));
736 // Lock error messages go unfortunately on stderr and are unreachible this way.
737 ifstream ifs(tmpf.toFilesystemEncoding().c_str());
741 if (!line.empty()) status += line + "; ";
745 if (!isLocked() && lock)
746 frontend::Alert::error(_("Revision control error."),
747 _("Error while acquiring write lock.\n"
748 "Another user is most probably editing\n"
749 "the current document now!\n"
750 "Also check the access to the repository."));
751 if (isLocked() && !lock)
752 frontend::Alert::error(_("Revision control error."),
753 _("Error while releasing write lock.\n"
754 "Check the access to the repository."));
758 string SVN::checkOut()
760 FileName tmpf = FileName::tempName("lyxvcout");
762 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
763 return N_("Error: Could not generate logfile.");
766 doVCCommand("svn update --non-interactive " + quoteName(onlyFileName(owner_->absFileName()))
767 + " > " + quoteName(tmpf.toFilesystemEncoding()),
768 FileName(owner_->filePath()));
771 string const res = scanLogFile(tmpf, log);
773 frontend::Alert::error(_("Revision control error."),
774 bformat(_("Error when updating from repository.\n"
775 "You have to manually resolve the conflicts NOW!\n'%1$s'.\n\n"
776 "After pressing OK, LyX will try to reopen the resolved document."),
777 from_local8bit(res)));
779 fileLock(true, tmpf, log);
782 return log.empty() ? string() : "SVN: " + log;
786 bool SVN::checkOutEnabled()
795 string SVN::repoUpdate()
797 FileName tmpf = FileName::tempName("lyxvcout");
799 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
800 return N_("Error: Could not generate logfile.");
803 doVCCommand("svn diff " + quoteName(owner_->filePath())
804 + " > " + quoteName(tmpf.toFilesystemEncoding()),
805 FileName(owner_->filePath()));
806 docstring res = tmpf.fileContents("UTF-8");
808 LYXERR(Debug::LYXVC, "Diff detected:\n" << res);
809 docstring const file = from_utf8(owner_->filePath());
810 docstring text = bformat(_("There were detected changes "
811 "in the working directory:\n%1$s\n\n"
812 "In case of file conflict version of the local directory files "
814 "\n\nContinue?"), file);
815 int ret = frontend::Alert::prompt(_("Changes detected"),
816 text, 0, 1, _("&Yes"), _("&No"), _("View &Log ..."));
818 dispatch(FuncRequest(LFUN_DIALOG_SHOW, "file " + tmpf.absFileName()));
819 ret = frontend::Alert::prompt(_("Changes detected"),
820 text, 0, 1, _("&Yes"), _("&No"));
821 hideDialogs("file", 0);
829 // Reverting looks too harsh, see bug #6255.
830 // doVCCommand("svn revert -R " + quoteName(owner_->filePath())
831 // + " > " + quoteName(tmpf.toFilesystemEncoding()),
832 // FileName(owner_->filePath()));
833 // res = "Revert log:\n" + tmpf.fileContents("UTF-8");
834 doVCCommand("svn update --accept mine-full " + quoteName(owner_->filePath())
835 + " > " + quoteName(tmpf.toFilesystemEncoding()),
836 FileName(owner_->filePath()));
837 res += "Update log:\n" + tmpf.fileContents("UTF-8");
839 LYXERR(Debug::LYXVC, res);
845 bool SVN::repoUpdateEnabled()
851 string SVN::lockingToggle()
853 FileName tmpf = FileName::tempName("lyxvcout");
855 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
856 return N_("Error: Could not generate logfile.");
859 int ret = doVCCommand("svn proplist " + quoteName(onlyFileName(owner_->absFileName()))
860 + " > " + quoteName(tmpf.toFilesystemEncoding()),
861 FileName(owner_->filePath()));
866 string res = scanLogFile(tmpf, log);
867 bool locking = contains(res, "svn:needs-lock");
869 ret = doVCCommand("svn propset svn:needs-lock ON "
870 + quoteName(onlyFileName(owner_->absFileName()))
871 + " > " + quoteName(tmpf.toFilesystemEncoding()),
872 FileName(owner_->filePath()));
874 ret = doVCCommand("svn propdel svn:needs-lock "
875 + quoteName(onlyFileName(owner_->absFileName()))
876 + " > " + quoteName(tmpf.toFilesystemEncoding()),
877 FileName(owner_->filePath()));
882 frontend::Alert::warning(_("VCN File Locking"),
883 (locking ? _("Locking property unset.") : _("Locking property set.")) + "\n"
884 + _("Do not forget to commit the locking property into the repository."),
887 return string("SVN: ") + N_("Locking property set.");
891 bool SVN::lockingToggleEnabled()
899 // Reverts to the version in CVS repository and
900 // gets the updated version from the repository.
901 string const fil = quoteName(onlyFileName(owner_->absFileName()));
903 doVCCommand("svn revert -q " + fil,
904 FileName(owner_->filePath()));
911 // merge the current with the previous version
912 // in a reverse patch kind of way, so that the
913 // result is to revert the last changes.
914 lyxerr << "Sorry, not implemented." << endl;
918 bool SVN::undoLastEnabled()
924 string SVN::revisionInfo(LyXVC::RevisionInfo const info)
926 if (info == LyXVC::Tree) {
927 if (rev_tree_cache_.empty())
928 if (!getTreeRevisionInfo())
929 rev_tree_cache_ = "?";
930 if (rev_tree_cache_ == "?")
933 return rev_tree_cache_;
936 // fill the rest of the attributes for a single file
937 if (rev_file_cache_.empty())
938 if (!getFileRevisionInfo())
939 rev_file_cache_ = "?";
943 if (rev_file_cache_ == "?")
945 return rev_file_cache_;
947 return rev_author_cache_;
949 return rev_date_cache_;
951 return rev_time_cache_;
960 bool SVN::getFileRevisionInfo()
962 FileName tmpf = FileName::tempName("lyxvcout");
964 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
965 return N_("Error: Could not generate logfile.");
968 doVCCommand("svn info --xml " + quoteName(onlyFileName(owner_->absFileName()))
969 + " > " + quoteName(tmpf.toFilesystemEncoding()),
970 FileName(owner_->filePath()));
975 ifstream ifs(tmpf.toFilesystemEncoding().c_str());
983 LYXERR(Debug::LYXVC, line);
984 if (prefixIs(line, "<commit"))
986 if (c && prefixIs(line, " revision=\"") && suffixIs(line, "\">")) {
987 string l1 = subst(line, "revision=\"", "");
988 string l2 = trim(subst(l1, "\">", ""));
990 rev_file_cache_ = rev = l2;
992 if (c && prefixIs(line, "<author>") && suffixIs(line, "</author>")) {
993 string l1 = subst(line, "<author>", "");
994 string l2 = subst(l1, "</author>", "");
995 rev_author_cache_ = l2;
997 if (c && prefixIs(line, "<date>") && suffixIs(line, "</date>")) {
998 string l1 = subst(line, "<date>", "");
999 string l2 = subst(l1, "</date>", "");
1000 l2 = split(l2, l1, 'T');
1001 rev_date_cache_ = l1;
1002 l2 = split(l2, l1, '.');
1003 rev_time_cache_ = l1;
1009 return !rev.empty();
1013 bool SVN::getTreeRevisionInfo()
1015 FileName tmpf = FileName::tempName("lyxvcout");
1017 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
1018 return N_("Error: Could not generate logfile.");
1021 doVCCommand("svnversion -n . > " + quoteName(tmpf.toFilesystemEncoding()),
1022 FileName(owner_->filePath()));
1027 // only first line in case something bad happens.
1028 ifstream ifs(tmpf.toFilesystemEncoding().c_str());
1034 rev_tree_cache_ = line;
1035 return !line.empty();
1039 void SVN::getLog(FileName const & tmpf)
1041 doVCCommand("svn log " + quoteName(onlyFileName(owner_->absFileName()))
1042 + " > " + quoteName(tmpf.toFilesystemEncoding()),
1043 FileName(owner_->filePath()));
1047 bool SVN::prepareFileRevision(string const & revis, string & f)
1049 if (!isStrInt(revis))
1052 int rev = convert<int>(revis);
1054 if (!getFileRevisionInfo())
1057 rev = convert<int>(rev_file_cache_);
1058 // go back for minus rev
1060 rev = rev + convert<int>(rev_file_cache_);
1065 string revname = convert<string>(rev);
1066 FileName tmpf = FileName::tempName("lyxvcrev_" + revname + "_");
1068 LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
1069 return N_("Error: Could not generate logfile.");
1072 doVCCommand("svn cat -r " + revname + " "
1073 + quoteName(onlyFileName(owner_->absFileName()))
1074 + " > " + quoteName(tmpf.toFilesystemEncoding()),
1075 FileName(owner_->filePath()));
1076 if (tmpf.isFileEmpty())
1079 f = tmpf.absFileName();
1084 bool SVN::prepareFileRevisionEnabled()
1091 bool SVN::toggleReadOnlyEnabled()