Show More
@@ -63,6 +63,8 b" testedwith = 'ships-with-hg-core'" | |||
|
63 | 63 | backupdir = 'shelve-backup' |
|
64 | 64 | shelvedir = 'shelved' |
|
65 | 65 | shelvefileextensions = ['hg', 'patch'] |
|
66 | # universal extension is present in all types of shelves | |
|
67 | patchextension = 'patch' | |
|
66 | 68 | |
|
67 | 69 | # we never need the user, so we use a |
|
68 | 70 | # generic user for all shelve operations |
@@ -220,7 +222,8 b' class shelvedstate(object):' | |||
|
220 | 222 | def cleanupoldbackups(repo): |
|
221 | 223 | vfs = scmutil.vfs(repo.join(backupdir)) |
|
222 | 224 | maxbackups = repo.ui.configint('shelve', 'maxbackups', 10) |
|
223 |
hgfiles = [f for f in vfs.listdir() |
|
|
225 | hgfiles = [f for f in vfs.listdir() | |
|
226 | if f.endswith('.' + patchextension)] | |
|
224 | 227 | hgfiles = sorted([(vfs.stat(f).st_mtime, f) for f in hgfiles]) |
|
225 | 228 | if 0 < maxbackups and maxbackups < len(hgfiles): |
|
226 | 229 | bordermtime = hgfiles[-maxbackups][0] |
@@ -230,7 +233,7 b' def cleanupoldbackups(repo):' | |||
|
230 | 233 | if mtime == bordermtime: |
|
231 | 234 | # keep it, because timestamp can't decide exact order of backups |
|
232 | 235 | continue |
|
233 |
base = f[:- |
|
|
236 | base = f[:-(1 + len(patchextension))] | |
|
234 | 237 | for ext in shelvefileextensions: |
|
235 | 238 | try: |
|
236 | 239 | vfs.unlink(base + '.' + ext) |
@@ -264,12 +267,12 b' def getshelvename(repo, parent, opts):' | |||
|
264 | 267 | label = label.replace('/', '_') |
|
265 | 268 | |
|
266 | 269 | if name: |
|
267 |
if shelvedfile(repo, name, |
|
|
270 | if shelvedfile(repo, name, patchextension).exists(): | |
|
268 | 271 | e = _("a shelved change named '%s' already exists") % name |
|
269 | 272 | raise error.Abort(e) |
|
270 | 273 | else: |
|
271 | 274 | for n in gennames(): |
|
272 |
if not shelvedfile(repo, n, |
|
|
275 | if not shelvedfile(repo, n, patchextension).exists(): | |
|
273 | 276 | name = n |
|
274 | 277 | break |
|
275 | 278 | else: |
@@ -337,7 +340,7 b' def _shelvecreatedcommit(repo, node, nam' | |||
|
337 | 340 | bases = list(mutableancestors(repo[node])) |
|
338 | 341 | shelvedfile(repo, name, 'hg').writebundle(bases, node) |
|
339 | 342 | cmdutil.export(repo, [node], |
|
340 |
fp=shelvedfile(repo, name, |
|
|
343 | fp=shelvedfile(repo, name, patchextension).opener('wb'), | |
|
341 | 344 | opts=mdiff.diffopts(git=True)) |
|
342 | 345 | |
|
343 | 346 | def _includeunknownfiles(repo, pats, opts, extra): |
@@ -444,7 +447,7 b' def deletecmd(ui, repo, pats):' | |||
|
444 | 447 | # but the .hg file is optional as in future we |
|
445 | 448 | # will add obsolete shelve with does not create a |
|
446 | 449 | # bundle |
|
447 |
if shfile.exists() or suffix == |
|
|
450 | if shfile.exists() or suffix == patchextension: | |
|
448 | 451 | shfile.movetobackup() |
|
449 | 452 | cleanupoldbackups(repo) |
|
450 | 453 | except OSError as err: |
@@ -463,7 +466,7 b' def listshelves(repo):' | |||
|
463 | 466 | info = [] |
|
464 | 467 | for (name, _type) in names: |
|
465 | 468 | pfx, sfx = name.rsplit('.', 1) |
|
466 |
if not pfx or sfx != |
|
|
469 | if not pfx or sfx != patchextension: | |
|
467 | 470 | continue |
|
468 | 471 | st = shelvedfile(repo, name).stat() |
|
469 | 472 | info.append((st.st_mtime, shelvedfile(repo, pfx).filename())) |
@@ -491,7 +494,7 b' def listcmd(ui, repo, pats, opts):' | |||
|
491 | 494 | ui.write(age, label='shelve.age') |
|
492 | 495 | ui.write(' ' * (12 - len(age))) |
|
493 | 496 | used += 12 |
|
494 |
with open(name + '. |
|
|
497 | with open(name + '.' + patchextension, 'rb') as fp: | |
|
495 | 498 | while True: |
|
496 | 499 | line = fp.readline() |
|
497 | 500 | if not line: |
@@ -519,7 +522,7 b' def singlepatchcmds(ui, repo, pats, opts' | |||
|
519 | 522 | raise error.Abort(_("--%s expects a single shelf") % subcommand) |
|
520 | 523 | shelfname = pats[0] |
|
521 | 524 | |
|
522 |
if not shelvedfile(repo, shelfname, |
|
|
525 | if not shelvedfile(repo, shelfname, patchextension).exists(): | |
|
523 | 526 | raise error.Abort(_("cannot find shelf %s") % shelfname) |
|
524 | 527 | |
|
525 | 528 | listcmd(ui, repo, pats, opts) |
@@ -823,7 +826,7 b' def _dounshelve(ui, repo, *shelved, **op' | |||
|
823 | 826 | else: |
|
824 | 827 | basename = shelved[0] |
|
825 | 828 | |
|
826 |
if not shelvedfile(repo, basename, |
|
|
829 | if not shelvedfile(repo, basename, patchextension).exists(): | |
|
827 | 830 | raise error.Abort(_("shelved change '%s' not found") % basename) |
|
828 | 831 | |
|
829 | 832 | oldquiet = ui.quiet |
@@ -195,12 +195,12 b' apply it and make sure our state is as e' | |||
|
195 | 195 | (this also tests that same timestamp prevents backups from being |
|
196 | 196 | removed, even though there are more than 'maxbackups' backups) |
|
197 | 197 | |
|
198 |
$ f -t .hg/shelve-backup/default.h |
|
|
199 |
.hg/shelve-backup/default.h |
|
|
200 |
$ touch -t 200001010000 .hg/shelve-backup/default.h |
|
|
201 |
$ f -t .hg/shelve-backup/default-1.h |
|
|
202 |
.hg/shelve-backup/default-1.h |
|
|
203 |
$ touch -t 200001010000 .hg/shelve-backup/default-1.h |
|
|
198 | $ f -t .hg/shelve-backup/default.patch | |
|
199 | .hg/shelve-backup/default.patch: file | |
|
200 | $ touch -t 200001010000 .hg/shelve-backup/default.patch | |
|
201 | $ f -t .hg/shelve-backup/default-1.patch | |
|
202 | .hg/shelve-backup/default-1.patch: file | |
|
203 | $ touch -t 200001010000 .hg/shelve-backup/default-1.patch | |
|
204 | 204 | |
|
205 | 205 | $ hg unshelve |
|
206 | 206 | unshelving change 'default-01' |
General Comments 0
You need to be logged in to leave comments.
Login now