##// END OF EJS Templates
mq: extract checksubstate from the queue class...
Pierre-Yves David -
r19813:76796fe6 default
parent child Browse files
Show More
@@ -945,23 +945,6 b' class queue(object):'
945 return top, patch
945 return top, patch
946 return None, None
946 return None, None
947
947
948 def checksubstate(self, repo, baserev=None):
949 '''return list of subrepos at a different revision than substate.
950 Abort if any subrepos have uncommitted changes.'''
951 inclsubs = []
952 wctx = repo[None]
953 if baserev:
954 bctx = repo[baserev]
955 else:
956 bctx = wctx.parents()[0]
957 for s in sorted(wctx.substate):
958 if wctx.sub(s).dirty(True):
959 raise util.Abort(
960 _("uncommitted changes in subrepository %s") % s)
961 elif s not in bctx.substate or bctx.sub(s).dirty():
962 inclsubs.append(s)
963 return inclsubs
964
965 def putsubstate2changes(self, substatestate, changes):
948 def putsubstate2changes(self, substatestate, changes):
966 for files in changes[:3]:
949 for files in changes[:3]:
967 if '.hgsubstate' in files:
950 if '.hgsubstate' in files:
@@ -987,7 +970,7 b' class queue(object):'
987 if (m or a or r or d):
970 if (m or a or r or d):
988 _("local changes found") # i18n tool detection
971 _("local changes found") # i18n tool detection
989 raise util.Abort(_("local changes found" + excsuffix))
972 raise util.Abort(_("local changes found" + excsuffix))
990 if self.checksubstate(repo):
973 if checksubstate(repo):
991 _("local changed subrepos found") # i18n tool detection
974 _("local changed subrepos found") # i18n tool detection
992 raise util.Abort(_("local changed subrepos found" + excsuffix))
975 raise util.Abort(_("local changed subrepos found" + excsuffix))
993 return m, a, r, d
976 return m, a, r, d
@@ -1031,7 +1014,7 b' class queue(object):'
1031 diffopts = self.diffopts({'git': opts.get('git')})
1014 diffopts = self.diffopts({'git': opts.get('git')})
1032 if opts.get('checkname', True):
1015 if opts.get('checkname', True):
1033 self.checkpatchname(patchfn)
1016 self.checkpatchname(patchfn)
1034 inclsubs = self.checksubstate(repo)
1017 inclsubs = checksubstate(repo)
1035 if inclsubs:
1018 if inclsubs:
1036 inclsubs.append('.hgsubstate')
1019 inclsubs.append('.hgsubstate')
1037 substatestate = repo.dirstate['.hgsubstate']
1020 substatestate = repo.dirstate['.hgsubstate']
@@ -1505,7 +1488,7 b' class queue(object):'
1505 cparents = repo.changelog.parents(top)
1488 cparents = repo.changelog.parents(top)
1506 patchparent = self.qparents(repo, top)
1489 patchparent = self.qparents(repo, top)
1507
1490
1508 inclsubs = self.checksubstate(repo, hex(patchparent))
1491 inclsubs = checksubstate(repo, hex(patchparent))
1509 if inclsubs:
1492 if inclsubs:
1510 inclsubs.append('.hgsubstate')
1493 inclsubs.append('.hgsubstate')
1511 substatestate = repo.dirstate['.hgsubstate']
1494 substatestate = repo.dirstate['.hgsubstate']
@@ -2931,6 +2914,24 b' def save(ui, repo, **opts):'
2931 q.savedirty()
2914 q.savedirty()
2932 return 0
2915 return 0
2933
2916
2917 def checksubstate(repo, baserev=None):
2918 '''return list of subrepos at a different revision than substate.
2919 Abort if any subrepos have uncommitted changes.'''
2920 inclsubs = []
2921 wctx = repo[None]
2922 if baserev:
2923 bctx = repo[baserev]
2924 else:
2925 bctx = wctx.parents()[0]
2926 for s in sorted(wctx.substate):
2927 if wctx.sub(s).dirty(True):
2928 raise util.Abort(
2929 _("uncommitted changes in subrepository %s") % s)
2930 elif s not in bctx.substate or bctx.sub(s).dirty():
2931 inclsubs.append(s)
2932 return inclsubs
2933
2934
2934 @command("strip",
2935 @command("strip",
2935 [
2936 [
2936 ('r', 'rev', [], _('strip specified revision (optional, '
2937 ('r', 'rev', [], _('strip specified revision (optional, '
General Comments 0
You need to be logged in to leave comments. Login now