972 elif substatestate in 'r': |
972 elif substatestate in 'r': |
973 changes[2].append('.hgsubstate') |
973 changes[2].append('.hgsubstate') |
974 else: # modified |
974 else: # modified |
975 changes[0].append('.hgsubstate') |
975 changes[0].append('.hgsubstate') |
976 |
976 |
977 def localchangesfound(self, refresh=True): |
977 def checklocalchanges(self, repo, force=False, refresh=True): |
|
978 excsuffix = '' |
978 if refresh: |
979 if refresh: |
979 raise util.Abort(_("local changes found, refresh first")) |
980 excsuffix = ', refresh first' |
980 else: |
981 # plain versions for i18n tool to detect them |
981 raise util.Abort(_("local changes found")) |
982 _("local changes found, refresh first") |
982 |
983 _("local changed subrepos found, refresh first") |
983 def localchangedsubreposfound(self, refresh=True): |
|
984 if refresh: |
|
985 raise util.Abort(_("local changed subrepos found, refresh first")) |
|
986 else: |
|
987 raise util.Abort(_("local changed subrepos found")) |
|
988 |
|
989 def checklocalchanges(self, repo, force=False, refresh=True): |
|
990 cmdutil.checkunfinished(repo) |
984 cmdutil.checkunfinished(repo) |
991 m, a, r, d = repo.status()[:4] |
985 m, a, r, d = repo.status()[:4] |
992 if not force: |
986 if not force: |
993 if (m or a or r or d): |
987 if (m or a or r or d): |
994 self.localchangesfound(refresh) |
988 _("local changes found") # i18n tool detection |
|
989 raise util.Abort(_("local changes found" + excsuffix)) |
995 if self.checksubstate(repo): |
990 if self.checksubstate(repo): |
996 self.localchangedsubreposfound(refresh) |
991 _("local changed subrepos found") # i18n tool detection |
|
992 raise util.Abort(_("local changed subrepos found" + excsuffix)) |
997 return m, a, r, d |
993 return m, a, r, d |
998 |
994 |
999 _reserved = ('series', 'status', 'guards', '.', '..') |
995 _reserved = ('series', 'status', 'guards', '.', '..') |
1000 def checkreservedname(self, name): |
996 def checkreservedname(self, name): |
1001 if name in self._reserved: |
997 if name in self._reserved: |
1447 if d: |
1443 if d: |
1448 raise util.Abort(_("deletions found between repo revs")) |
1444 raise util.Abort(_("deletions found between repo revs")) |
1449 |
1445 |
1450 tobackup = set(a + m + r) & tobackup |
1446 tobackup = set(a + m + r) & tobackup |
1451 if keepchanges and tobackup: |
1447 if keepchanges and tobackup: |
1452 self.localchangesfound() |
1448 raise util.Abort(_("local changes found, refresh first")) |
1453 self.backup(repo, tobackup) |
1449 self.backup(repo, tobackup) |
1454 |
1450 |
1455 for f in a: |
1451 for f in a: |
1456 util.unlinkpath(repo.wjoin(f), ignoremissing=True) |
1452 util.unlinkpath(repo.wjoin(f), ignoremissing=True) |
1457 repo.dirstate.drop(f) |
1453 repo.dirstate.drop(f) |