Show More
@@ -2313,8 +2313,6 b' def summaryhook(ui, repo):' | |||||
2313 |
|
2313 | |||
2314 | def extsetup(ui): |
|
2314 | def extsetup(ui): | |
2315 | cmdutil.summaryhooks.add('histedit', summaryhook) |
|
2315 | cmdutil.summaryhooks.add('histedit', summaryhook) | |
2316 | statemod.unfinishedstates.append( |
|
2316 | statemod.addunfinished('histedit', fname='histedit-state', allowcommit=True) | |
2317 | ['histedit-state', False, True, _('histedit in progress'), |
|
|||
2318 | _("use 'hg histedit --continue' or 'hg histedit --abort'")]) |
|
|||
2319 | cmdutil.afterresolvedstates.append( |
|
2317 | cmdutil.afterresolvedstates.append( | |
2320 | ['histedit-state', _('hg histedit --continue')]) |
|
2318 | ['histedit-state', _('hg histedit --continue')]) |
@@ -1950,8 +1950,6 b' def uisetup(ui):' | |||||
1950 | entry[1].append(('t', 'tool', '', |
|
1950 | entry[1].append(('t', 'tool', '', | |
1951 | _("specify merge tool for rebase"))) |
|
1951 | _("specify merge tool for rebase"))) | |
1952 | cmdutil.summaryhooks.add('rebase', summaryhook) |
|
1952 | cmdutil.summaryhooks.add('rebase', summaryhook) | |
1953 | statemod.unfinishedstates.append( |
|
1953 | statemod.addunfinished('rebase', fname='rebasestate') | |
1954 | ['rebasestate', False, False, _('rebase in progress'), |
|
|||
1955 | _("use 'hg rebase --continue' or 'hg rebase --abort'")]) |
|
|||
1956 | cmdutil.afterresolvedstates.append( |
|
1954 | cmdutil.afterresolvedstates.append( | |
1957 | ['rebasestate', _('hg rebase --continue')]) |
|
1955 | ['rebasestate', _('hg rebase --continue')]) |
@@ -1140,10 +1140,9 b' def shelvecmd(ui, repo, *pats, **opts):' | |||||
1140 | return createcmd(ui, repo, pats, opts) |
|
1140 | return createcmd(ui, repo, pats, opts) | |
1141 |
|
1141 | |||
1142 | def extsetup(ui): |
|
1142 | def extsetup(ui): | |
1143 |
statemod.unfinished |
|
1143 | statemod.addunfinished( | |
1144 |
|
|
1144 | 'unshelve', fname=shelvedstate._filename, | |
1145 |
|
|
1145 | cmdmsg=_('unshelve already in progress') | |
1146 | _("use 'hg unshelve --continue' or 'hg unshelve --abort'")]) |
|
1146 | ) | |
1147 | cmdutil.afterresolvedstates.append( |
|
1147 | cmdutil.afterresolvedstates.append( | |
1148 | [shelvedstate._filename, _('hg unshelve --continue')]) |
|
1148 | [shelvedstate._filename, _('hg unshelve --continue')]) | |
1149 |
|
@@ -758,9 +758,10 b' def kwtransplanted(context, mapping):' | |||||
758 | return n and nodemod.hex(n) or '' |
|
758 | return n and nodemod.hex(n) or '' | |
759 |
|
759 | |||
760 | def extsetup(ui): |
|
760 | def extsetup(ui): | |
761 |
statemod.unfinished |
|
761 | statemod.addunfinished ( | |
762 | ['transplant/journal', True, False, _('transplant in progress'), |
|
762 | 'transplant', fname='transplant/journal', clearable=True, | |
763 |
|
|
763 | cmdhint=_("use 'hg transplant --continue' or 'hg update' to abort") | |
|
764 | ) | |||
764 |
|
765 | |||
765 | # tell hggettext to extract docstrings from these functions: |
|
766 | # tell hggettext to extract docstrings from these functions: | |
766 | i18nfunctions = [revsettransplanted, kwtransplanted] |
|
767 | i18nfunctions = [revsettransplanted, kwtransplanted] |
@@ -3314,6 +3314,7 b' summaryhooks = util.hooks()' | |||||
3314 | # - (desturl, destbranch, destpeer, outgoing) |
|
3314 | # - (desturl, destbranch, destpeer, outgoing) | |
3315 | summaryremotehooks = util.hooks() |
|
3315 | summaryremotehooks = util.hooks() | |
3316 |
|
3316 | |||
|
3317 | ||||
3317 | def checkunfinished(repo, commit=False): |
|
3318 | def checkunfinished(repo, commit=False): | |
3318 | '''Look for an unfinished multistep operation, like graft, and abort |
|
3319 | '''Look for an unfinished multistep operation, like graft, and abort | |
3319 | if found. It's probably good to check this right before |
|
3320 | if found. It's probably good to check this right before | |
@@ -3321,28 +3322,29 b' def checkunfinished(repo, commit=False):' | |||||
3321 | ''' |
|
3322 | ''' | |
3322 | # Check for non-clearable states first, so things like rebase will take |
|
3323 | # Check for non-clearable states first, so things like rebase will take | |
3323 | # precedence over update. |
|
3324 | # precedence over update. | |
3324 |
for |
|
3325 | for state in statemod._unfinishedstates: | |
3325 | if clearable or (commit and allowcommit): |
|
3326 | if state._clearable or (commit and state._allowcommit): | |
3326 | continue |
|
3327 | continue | |
3327 | if repo.vfs.exists(f): |
|
3328 | if state.isunfinished(repo): | |
3328 | raise error.Abort(msg, hint=hint) |
|
3329 | raise error.Abort(state.msg(), hint=state.hint()) | |
3329 |
|
3330 | |||
3330 |
for |
|
3331 | for s in statemod._unfinishedstates: | |
3331 | if not clearable or (commit and allowcommit): |
|
3332 | if not s._clearable or (commit and s._allowcommit): | |
3332 | continue |
|
3333 | continue | |
3333 | if repo.vfs.exists(f): |
|
3334 | if s.isunfinished(repo): | |
3334 | raise error.Abort(msg, hint=hint) |
|
3335 | raise error.Abort(s.msg(), hint=s.hint()) | |
3335 |
|
3336 | |||
3336 | def clearunfinished(repo): |
|
3337 | def clearunfinished(repo): | |
3337 | '''Check for unfinished operations (as above), and clear the ones |
|
3338 | '''Check for unfinished operations (as above), and clear the ones | |
3338 | that are clearable. |
|
3339 | that are clearable. | |
3339 | ''' |
|
3340 | ''' | |
3340 |
for |
|
3341 | for state in statemod._unfinishedstates: | |
3341 |
if not clearable and repo |
|
3342 | if not state._clearable and state.isunfinished(repo): | |
3342 | raise error.Abort(msg, hint=hint) |
|
3343 | raise error.Abort(state.msg(), hint=state.hint()) | |
3343 | for f, clearable, allowcommit, msg, hint in statemod.unfinishedstates: |
|
3344 | ||
3344 | if clearable and repo.vfs.exists(f): |
|
3345 | for s in statemod._unfinishedstates: | |
3345 | util.unlink(repo.vfs.join(f)) |
|
3346 | if s._clearable and s.isunfinished(repo): | |
|
3347 | util.unlink(repo.vfs.join(s._fname)) | |||
3346 |
|
3348 | |||
3347 | afterresolvedstates = [ |
|
3349 | afterresolvedstates = [ | |
3348 | ('graftstate', |
|
3350 | ('graftstate', |
@@ -88,13 +88,70 b' class cmdstate(object):' | |||||
88 | """check whether the state file exists or not""" |
|
88 | """check whether the state file exists or not""" | |
89 | return self._repo.vfs.exists(self.fname) |
|
89 | return self._repo.vfs.exists(self.fname) | |
90 |
|
90 | |||
91 | # A list of state files kept by multistep operations like graft. |
|
91 | class _statecheck(object): | |
92 | # Since graft cannot be aborted, it is considered 'clearable' by update. |
|
92 | """a utility class that deals with multistep operations like graft, | |
93 | # note: bisect is intentionally excluded |
|
93 | histedit, bisect, update etc and check whether such commands | |
94 | # (state file, clearable, allowcommit, error, hint) |
|
94 | are in an unfinished conditition or not and return appropriate message | |
95 | unfinishedstates = [ |
|
95 | and hint. | |
96 | ('graftstate', True, False, _('graft in progress'), |
|
96 | It also has the ability to register and determine the states of any new | |
97 | _("use 'hg graft --continue' or 'hg graft --stop' to stop")), |
|
97 | multistep operation or multistep command extension. | |
98 | ('updatestate', True, False, _('last update was interrupted'), |
|
98 | """ | |
99 | _("use 'hg update' to get a consistent checkout")) |
|
99 | ||
100 | ] |
|
100 | def __init__(self, opname, fname, clearable=False, allowcommit=False, | |
|
101 | cmdmsg="", cmdhint=""): | |||
|
102 | """opname is the name the command or operation | |||
|
103 | fname is the file name in which data should be stored in .hg directory. | |||
|
104 | It is None for merge command. | |||
|
105 | clearable boolean determines whether or not interrupted states can be | |||
|
106 | cleared by running `hg update -C .` which in turn deletes the | |||
|
107 | state file. | |||
|
108 | allowcommit boolean decides whether commit is allowed during interrupted | |||
|
109 | state or not. | |||
|
110 | cmdmsg is used to pass a different status message in case standard | |||
|
111 | message of the format "abort: cmdname in progress" is not desired. | |||
|
112 | cmdhint is used to pass a different hint message in case standard | |||
|
113 | message of the format use 'hg cmdname --continue' or | |||
|
114 | 'hg cmdname --abort'" is not desired. | |||
|
115 | """ | |||
|
116 | self._opname = opname | |||
|
117 | self._fname = fname | |||
|
118 | self._clearable = clearable | |||
|
119 | self._allowcommit = allowcommit | |||
|
120 | self._cmdhint = cmdhint | |||
|
121 | self._cmdmsg = cmdmsg | |||
|
122 | ||||
|
123 | def hint(self): | |||
|
124 | """returns the hint message corresponding to the command""" | |||
|
125 | if not self._cmdhint: | |||
|
126 | return (_("use 'hg %s --continue' or 'hg %s --abort'") % | |||
|
127 | (self._opname, self._opname)) | |||
|
128 | return self._cmdhint | |||
|
129 | ||||
|
130 | def msg(self): | |||
|
131 | """returns the status message corresponding to the command""" | |||
|
132 | if not self._cmdmsg: | |||
|
133 | return _('%s in progress') % (self._opname) | |||
|
134 | return self._cmdmsg | |||
|
135 | ||||
|
136 | def isunfinished(self, repo): | |||
|
137 | """determines whether a multi-step operation is in progress or not""" | |||
|
138 | return repo.vfs.exists(self._fname) | |||
|
139 | ||||
|
140 | # A list of statecheck objects for multistep operations like graft. | |||
|
141 | _unfinishedstates = [] | |||
|
142 | ||||
|
143 | def addunfinished(opname, **kwargs): | |||
|
144 | """this registers a new command or operation to unfinishedstates | |||
|
145 | """ | |||
|
146 | statecheckobj = _statecheck(opname, **kwargs) | |||
|
147 | _unfinishedstates.append(statecheckobj) | |||
|
148 | ||||
|
149 | addunfinished( | |||
|
150 | 'graft', fname='graftstate', clearable=True, | |||
|
151 | cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop") | |||
|
152 | ) | |||
|
153 | addunfinished( | |||
|
154 | 'update', fname='updatestate', clearable=True, | |||
|
155 | cmdmsg=_('last update was interrupted'), | |||
|
156 | cmdhint=_("use 'hg update' to get a consistent checkout") | |||
|
157 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now