# HG changeset patch # User Michael Bacarella # Date 2012-03-09 20:34:21 # Node ID b9c4302310e560d71270c789881a5ccd34c5ab6e # Parent 55174ab81973f87dc3800565f04cdddac94928e7 localrepo: fix unpushable repos when using bookmarks (issue3317) bookmarks is copied to journal.bookmarks differently from how dirstate is copied to journal.dirstate. The different way is less robust, which can render the repo unpushable by other users if the first pushing user aborts their transaction. The underlying cause is that the copyfile method attempts an unnecessary chmod, which fails if the user is not the owner of the journal.bookmarks file. This patch makes the bookmarks journaling more consistent with the rest of the journaling, and will allow users to update lingering journal.bookmarks files that they're not the owners of. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -772,11 +772,12 @@ class localrepository(repo.repository): self.opener.write("journal.desc", "%d\n%s\n" % (len(self), desc)) - bkname = self.join('bookmarks') - if os.path.exists(bkname): - util.copyfile(bkname, self.join('journal.bookmarks')) - else: - self.opener.write('journal.bookmarks', '') + try: + bk = self.opener.read("bookmarks") + except IOError: + bk = "" + self.opener.write("journal.bookmarks", bk) + phasesname = self.sjoin('phaseroots') if os.path.exists(phasesname): util.copyfile(phasesname, self.sjoin('journal.phaseroots'))