Show More
@@ -34,7 +34,9 b' command = cmdutil.command(cmdtable)' | |||||
34 | testedwith = 'internal' |
|
34 | testedwith = 'internal' | |
35 |
|
35 | |||
36 | class shelvedfile(object): |
|
36 | class shelvedfile(object): | |
37 | """Handles common functions on shelve files (.hg/.files/.patch) using |
|
37 | """Helper for the file storing a single shelve | |
|
38 | ||||
|
39 | Handles common functions on shelve files (.hg/.files/.patch) using | |||
38 | the vfs layer""" |
|
40 | the vfs layer""" | |
39 | def __init__(self, repo, name, filetype=None): |
|
41 | def __init__(self, repo, name, filetype=None): | |
40 | self.repo = repo |
|
42 | self.repo = repo | |
@@ -75,7 +77,9 b' class shelvedfile(object):' | |||||
75 | self.name) |
|
77 | self.name) | |
76 |
|
78 | |||
77 | class shelvedstate(object): |
|
79 | class shelvedstate(object): | |
78 | """Handles saving and restoring a shelved state. Ensures that different |
|
80 | """Handle persistences during unshelving operation. | |
|
81 | ||||
|
82 | Handles saving and restoring a shelved state. Ensures that different | |||
79 | versions of a shelved state are possible and handles them appropriate""" |
|
83 | versions of a shelved state are possible and handles them appropriate""" | |
80 | _version = 1 |
|
84 | _version = 1 | |
81 | _filename = 'shelvedstate' |
|
85 | _filename = 'shelvedstate' | |
@@ -116,6 +120,8 b' class shelvedstate(object):' | |||||
116 | util.unlinkpath(repo.join(cls._filename), ignoremissing=True) |
|
120 | util.unlinkpath(repo.join(cls._filename), ignoremissing=True) | |
117 |
|
121 | |||
118 | def createcmd(ui, repo, pats, opts): |
|
122 | def createcmd(ui, repo, pats, opts): | |
|
123 | """subcommand that create a new shelve""" | |||
|
124 | ||||
119 | def publicancestors(ctx): |
|
125 | def publicancestors(ctx): | |
120 | """Compute the heads of the public ancestors of a commit. |
|
126 | """Compute the heads of the public ancestors of a commit. | |
121 |
|
127 | |||
@@ -245,6 +251,8 b' def createcmd(ui, repo, pats, opts):' | |||||
245 | lockmod.release(lock, wlock) |
|
251 | lockmod.release(lock, wlock) | |
246 |
|
252 | |||
247 | def cleanupcmd(ui, repo): |
|
253 | def cleanupcmd(ui, repo): | |
|
254 | """subcommand that delete all shelves""" | |||
|
255 | ||||
248 | wlock = None |
|
256 | wlock = None | |
249 | try: |
|
257 | try: | |
250 | wlock = repo.wlock() |
|
258 | wlock = repo.wlock() | |
@@ -256,6 +264,7 b' def cleanupcmd(ui, repo):' | |||||
256 | lockmod.release(wlock) |
|
264 | lockmod.release(wlock) | |
257 |
|
265 | |||
258 | def deletecmd(ui, repo, pats): |
|
266 | def deletecmd(ui, repo, pats): | |
|
267 | """subcommand that delete a specific shelve""" | |||
259 | if not pats: |
|
268 | if not pats: | |
260 | raise util.Abort(_('no shelved changes specified!')) |
|
269 | raise util.Abort(_('no shelved changes specified!')) | |
261 | wlock = None |
|
270 | wlock = None | |
@@ -273,6 +282,7 b' def deletecmd(ui, repo, pats):' | |||||
273 | lockmod.release(wlock) |
|
282 | lockmod.release(wlock) | |
274 |
|
283 | |||
275 | def listshelves(repo): |
|
284 | def listshelves(repo): | |
|
285 | """return all shelves in repo as list of (time, filename)""" | |||
276 | try: |
|
286 | try: | |
277 | names = repo.vfs.readdir('shelved') |
|
287 | names = repo.vfs.readdir('shelved') | |
278 | except OSError, err: |
|
288 | except OSError, err: | |
@@ -289,6 +299,7 b' def listshelves(repo):' | |||||
289 | return sorted(info, reverse=True) |
|
299 | return sorted(info, reverse=True) | |
290 |
|
300 | |||
291 | def listcmd(ui, repo, pats, opts): |
|
301 | def listcmd(ui, repo, pats, opts): | |
|
302 | """subcommand that display the list of shelve""" | |||
292 | pats = set(pats) |
|
303 | pats = set(pats) | |
293 | width = 80 |
|
304 | width = 80 | |
294 | if not ui.plain(): |
|
305 | if not ui.plain(): | |
@@ -336,15 +347,18 b' def listcmd(ui, repo, pats, opts):' | |||||
336 | fp.close() |
|
347 | fp.close() | |
337 |
|
348 | |||
338 | def readshelvedfiles(repo, basename): |
|
349 | def readshelvedfiles(repo, basename): | |
|
350 | """return the list of file touched in a shelve""" | |||
339 | fp = shelvedfile(repo, basename, 'files').opener() |
|
351 | fp = shelvedfile(repo, basename, 'files').opener() | |
340 | return fp.read().split('\0') |
|
352 | return fp.read().split('\0') | |
341 |
|
353 | |||
342 | def checkparents(repo, state): |
|
354 | def checkparents(repo, state): | |
|
355 | """check parent while resuming an unshelve""" | |||
343 | if state.parents != repo.dirstate.parents(): |
|
356 | if state.parents != repo.dirstate.parents(): | |
344 | raise util.Abort(_('working directory parents do not match unshelve ' |
|
357 | raise util.Abort(_('working directory parents do not match unshelve ' | |
345 | 'state')) |
|
358 | 'state')) | |
346 |
|
359 | |||
347 | def unshelveabort(ui, repo, state, opts): |
|
360 | def unshelveabort(ui, repo, state, opts): | |
|
361 | """subcommand that abort an in-progress unshelve""" | |||
348 | wlock = repo.wlock() |
|
362 | wlock = repo.wlock() | |
349 | lock = None |
|
363 | lock = None | |
350 | try: |
|
364 | try: | |
@@ -375,6 +389,7 b' def unshelveabort(ui, repo, state, opts)' | |||||
375 | lockmod.release(lock, wlock) |
|
389 | lockmod.release(lock, wlock) | |
376 |
|
390 | |||
377 | def unshelvecleanup(ui, repo, name, opts): |
|
391 | def unshelvecleanup(ui, repo, name, opts): | |
|
392 | """remove related file after an unshelve""" | |||
378 | if not opts['keep']: |
|
393 | if not opts['keep']: | |
379 | for filetype in 'hg files patch'.split(): |
|
394 | for filetype in 'hg files patch'.split(): | |
380 | shelvedfile(repo, name, filetype).unlink() |
|
395 | shelvedfile(repo, name, filetype).unlink() | |
@@ -386,6 +401,7 b' def finishmerge(ui, repo, ms, stripnodes' | |||||
386 | shelvedstate.clear(repo) |
|
401 | shelvedstate.clear(repo) | |
387 |
|
402 | |||
388 | def unshelvecontinue(ui, repo, state, opts): |
|
403 | def unshelvecontinue(ui, repo, state, opts): | |
|
404 | """subcommand to continue an in-progress unshelve""" | |||
389 | # We're finishing off a merge. First parent is our original |
|
405 | # We're finishing off a merge. First parent is our original | |
390 | # parent, second is the temporary "fake" commit we're unshelving. |
|
406 | # parent, second is the temporary "fake" commit we're unshelving. | |
391 | wlock = repo.wlock() |
|
407 | wlock = repo.wlock() |
General Comments 0
You need to be logged in to leave comments.
Login now