Mercurial > hg
comparison hgext/mq.py @ 15926:f94513971767
mq: have mq create secret changeset only
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Wed, 18 Jan 2012 16:53:49 +0100 |
parents | 3f132207e92f |
children | 2eec74d7ce95 |
comparison
equal
deleted
inserted
replaced
15925:f9fc46698352 | 15926:f94513971767 |
---|---|
249 for mi in self.message: | 249 for mi in self.message: |
250 while mi != self.comments[ci]: | 250 while mi != self.comments[ci]: |
251 ci += 1 | 251 ci += 1 |
252 del self.comments[ci] | 252 del self.comments[ci] |
253 | 253 |
254 def secretcommit(repo, *args, **kwargs): | |
255 """helper dedicated to ensure a commit are secret | |
256 | |
257 It should be used instead of repo.commit inside the mq source | |
258 """ | |
259 backup = repo.ui.backupconfig('phases', 'new-commit') | |
260 try: | |
261 # ensure we create a secret changeset | |
262 repo.ui.setconfig('phases', 'new-commit', phases.secret) | |
263 return repo.commit(*args, **kwargs) | |
264 finally: | |
265 repo.ui.restoreconfig(backup) | |
266 | |
254 class queue(object): | 267 class queue(object): |
255 def __init__(self, ui, path, patchdir=None): | 268 def __init__(self, ui, path, patchdir=None): |
256 self.basepath = path | 269 self.basepath = path |
257 try: | 270 try: |
258 fh = open(os.path.join(path, 'patches.queue')) | 271 fh = open(os.path.join(path, 'patches.queue')) |
551 | 564 |
552 ctx = repo[rev] | 565 ctx = repo[rev] |
553 ret = hg.merge(repo, rev) | 566 ret = hg.merge(repo, rev) |
554 if ret: | 567 if ret: |
555 raise util.Abort(_("update returned %d") % ret) | 568 raise util.Abort(_("update returned %d") % ret) |
556 n = repo.commit(ctx.description(), ctx.user(), force=True) | 569 n = secretcommit(repo, ctx.description(), ctx.user(), force=True) |
557 if n is None: | 570 if n is None: |
558 raise util.Abort(_("repo commit failed")) | 571 raise util.Abort(_("repo commit failed")) |
559 try: | 572 try: |
560 ph = patchheader(mergeq.join(patch), self.plainmode) | 573 ph = patchheader(mergeq.join(patch), self.plainmode) |
561 except: | 574 except: |
721 repo.dirstate.merge(f) | 734 repo.dirstate.merge(f) |
722 p1, p2 = repo.dirstate.parents() | 735 p1, p2 = repo.dirstate.parents() |
723 repo.dirstate.setparents(p1, merge) | 736 repo.dirstate.setparents(p1, merge) |
724 | 737 |
725 match = scmutil.matchfiles(repo, files or []) | 738 match = scmutil.matchfiles(repo, files or []) |
726 n = repo.commit(message, ph.user, ph.date, match=match, force=True) | 739 n = secretcommit(repo, message, ph.user, ph.date, match=match, |
727 | 740 force=True) |
728 if n is None: | 741 if n is None: |
729 raise util.Abort(_("repository commit failed")) | 742 raise util.Abort(_("repository commit failed")) |
730 | 743 |
731 if update_status: | 744 if update_status: |
732 self.applied.append(statusentry(n, patchname)) | 745 self.applied.append(statusentry(n, patchname)) |
956 if date: | 969 if date: |
957 p.write("# Date %s %s\n\n" % date) | 970 p.write("# Date %s %s\n\n" % date) |
958 if util.safehasattr(msg, '__call__'): | 971 if util.safehasattr(msg, '__call__'): |
959 msg = msg() | 972 msg = msg() |
960 commitmsg = msg and msg or ("[mq]: %s" % patchfn) | 973 commitmsg = msg and msg or ("[mq]: %s" % patchfn) |
961 n = repo.commit(commitmsg, user, date, match=match, force=True) | 974 n = secretcommit(repo, commitmsg, user, date, match=match, |
975 force=True) | |
962 if n is None: | 976 if n is None: |
963 raise util.Abort(_("repo commit failed")) | 977 raise util.Abort(_("repo commit failed")) |
964 try: | 978 try: |
965 self.fullseries[insert:insert] = [patchfn] | 979 self.fullseries[insert:insert] = [patchfn] |
966 self.applied.append(statusentry(n, patchfn)) | 980 self.applied.append(statusentry(n, patchfn)) |
1498 repo.dirstate.invalidate() | 1512 repo.dirstate.invalidate() |
1499 raise | 1513 raise |
1500 | 1514 |
1501 try: | 1515 try: |
1502 # might be nice to attempt to roll back strip after this | 1516 # might be nice to attempt to roll back strip after this |
1503 n = repo.commit(message, user, ph.date, match=match, | 1517 n = secretcommit(repo, message, user, ph.date, match=match, |
1504 force=True) | 1518 force=True) |
1505 # only write patch after a successful commit | 1519 # only write patch after a successful commit |
1506 patchf.close() | 1520 patchf.close() |
1507 self.applied.append(statusentry(n, patchfn)) | 1521 self.applied.append(statusentry(n, patchfn)) |
1508 except: | 1522 except: |
1509 ctx = repo[cparents[0]] | 1523 ctx = repo[cparents[0]] |