Show More
@@ -170,6 +170,23 b' class shelvedfile(object):' | |||
|
170 | 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 | 190 | class shelvedstate(object): |
|
174 | 191 | """Handle persistence during unshelving operations. |
|
175 | 192 | |
@@ -364,7 +381,7 b' def getshelvename(repo, parent, opts):' | |||
|
364 | 381 | label = label.replace(b'.', b'_', 1) |
|
365 | 382 | |
|
366 | 383 | if name: |
|
367 |
if |
|
|
384 | if Shelf(repo, name).exists(): | |
|
368 | 385 | e = _(b"a shelved change named '%s' already exists") % name |
|
369 | 386 | raise error.Abort(e) |
|
370 | 387 | |
@@ -378,7 +395,7 b' def getshelvename(repo, parent, opts):' | |||
|
378 | 395 | |
|
379 | 396 | else: |
|
380 | 397 | for n in gennames(): |
|
381 |
if not |
|
|
398 | if not Shelf(repo, n).exists(): | |
|
382 | 399 | name = n |
|
383 | 400 | break |
|
384 | 401 | |
@@ -595,7 +612,7 b' def deletecmd(ui, repo, pats):' | |||
|
595 | 612 | raise error.InputError(_(b'no shelved changes specified!')) |
|
596 | 613 | with repo.wlock(): |
|
597 | 614 | for name in pats: |
|
598 |
if not |
|
|
615 | if not Shelf(repo, name).exists(): | |
|
599 | 616 | raise error.InputError( |
|
600 | 617 | _(b"shelved change '%s' not found") % name |
|
601 | 618 | ) |
@@ -682,7 +699,7 b' def patchcmds(ui, repo, pats, opts):' | |||
|
682 | 699 | pats = [sname] |
|
683 | 700 | |
|
684 | 701 | for shelfname in pats: |
|
685 |
if not |
|
|
702 | if not Shelf(repo, shelfname).exists(): | |
|
686 | 703 | raise error.Abort(_(b"cannot find shelf %s") % shelfname) |
|
687 | 704 | |
|
688 | 705 | listcmd(ui, repo, pats, opts) |
@@ -1104,7 +1121,7 b' def unshelvecmd(ui, repo, *shelved, **op' | |||
|
1104 | 1121 | else: |
|
1105 | 1122 | basename = shelved[0] |
|
1106 | 1123 | |
|
1107 |
if not |
|
|
1124 | if not Shelf(repo, basename).exists(): | |
|
1108 | 1125 | raise error.InputError(_(b"shelved change '%s' not found") % basename) |
|
1109 | 1126 | |
|
1110 | 1127 | return _dounshelve(ui, repo, basename, opts) |
General Comments 0
You need to be logged in to leave comments.
Login now