Show More
@@ -170,6 +170,23 b' class shelvedfile(object):' | |||||
170 | return scmutil.simplekeyvaluefile(self.vfs, self.fname).read() |
|
170 | return scmutil.simplekeyvaluefile(self.vfs, self.fname).read() | |
171 |
|
171 | |||
172 |
|
172 | |||
|
173 | class Shelf(object): | |||
|
174 | """Represents a shelf, including possibly multiple files storing it. | |||
|
175 | ||||
|
176 | Old shelves will have a .patch and a .hg file. Newer shelves will | |||
|
177 | also have a .shelve file. This class abstracts away some of the | |||
|
178 | differences and lets you work with the shelf as a whole. | |||
|
179 | """ | |||
|
180 | ||||
|
181 | def __init__(self, repo, name): | |||
|
182 | self.repo = repo | |||
|
183 | self.name = name | |||
|
184 | self.vfs = vfsmod.vfs(repo.vfs.join(shelvedir)) | |||
|
185 | ||||
|
186 | def exists(self): | |||
|
187 | return self.vfs.exists(self.name + b'.' + patchextension) | |||
|
188 | ||||
|
189 | ||||
173 | class shelvedstate(object): |
|
190 | class shelvedstate(object): | |
174 | """Handle persistence during unshelving operations. |
|
191 | """Handle persistence during unshelving operations. | |
175 |
|
192 | |||
@@ -364,7 +381,7 b' def getshelvename(repo, parent, opts):' | |||||
364 | label = label.replace(b'.', b'_', 1) |
|
381 | label = label.replace(b'.', b'_', 1) | |
365 |
|
382 | |||
366 | if name: |
|
383 | if name: | |
367 |
if |
|
384 | if Shelf(repo, name).exists(): | |
368 | e = _(b"a shelved change named '%s' already exists") % name |
|
385 | e = _(b"a shelved change named '%s' already exists") % name | |
369 | raise error.Abort(e) |
|
386 | raise error.Abort(e) | |
370 |
|
387 | |||
@@ -378,7 +395,7 b' def getshelvename(repo, parent, opts):' | |||||
378 |
|
395 | |||
379 | else: |
|
396 | else: | |
380 | for n in gennames(): |
|
397 | for n in gennames(): | |
381 |
if not |
|
398 | if not Shelf(repo, n).exists(): | |
382 | name = n |
|
399 | name = n | |
383 | break |
|
400 | break | |
384 |
|
401 | |||
@@ -595,7 +612,7 b' def deletecmd(ui, repo, pats):' | |||||
595 | raise error.InputError(_(b'no shelved changes specified!')) |
|
612 | raise error.InputError(_(b'no shelved changes specified!')) | |
596 | with repo.wlock(): |
|
613 | with repo.wlock(): | |
597 | for name in pats: |
|
614 | for name in pats: | |
598 |
if not |
|
615 | if not Shelf(repo, name).exists(): | |
599 | raise error.InputError( |
|
616 | raise error.InputError( | |
600 | _(b"shelved change '%s' not found") % name |
|
617 | _(b"shelved change '%s' not found") % name | |
601 | ) |
|
618 | ) | |
@@ -682,7 +699,7 b' def patchcmds(ui, repo, pats, opts):' | |||||
682 | pats = [sname] |
|
699 | pats = [sname] | |
683 |
|
700 | |||
684 | for shelfname in pats: |
|
701 | for shelfname in pats: | |
685 |
if not |
|
702 | if not Shelf(repo, shelfname).exists(): | |
686 | raise error.Abort(_(b"cannot find shelf %s") % shelfname) |
|
703 | raise error.Abort(_(b"cannot find shelf %s") % shelfname) | |
687 |
|
704 | |||
688 | listcmd(ui, repo, pats, opts) |
|
705 | listcmd(ui, repo, pats, opts) | |
@@ -1104,7 +1121,7 b' def unshelvecmd(ui, repo, *shelved, **op' | |||||
1104 | else: |
|
1121 | else: | |
1105 | basename = shelved[0] |
|
1122 | basename = shelved[0] | |
1106 |
|
1123 | |||
1107 |
if not |
|
1124 | if not Shelf(repo, basename).exists(): | |
1108 | raise error.InputError(_(b"shelved change '%s' not found") % basename) |
|
1125 | raise error.InputError(_(b"shelved change '%s' not found") % basename) | |
1109 |
|
1126 | |||
1110 | return _dounshelve(ui, repo, basename, opts) |
|
1127 | return _dounshelve(ui, repo, basename, opts) |
General Comments 0
You need to be logged in to leave comments.
Login now