# HG changeset patch # User Martin Geisler # Date 2011-04-19 13:19:54 # Node ID 141f88ae52769b790da6497bc36055f389a7eb4a # Parent ffb5c09ba8221ffef5b370e5e5f7682c268f726c # Parent 71f51cc716528f161a6897c0a954b72223031151 merge with stable diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -22,6 +22,12 @@ On Unix, these files are read: - ``/etc/mercurial/hgrc`` - ``/etc/mercurial/hgrc.d/*.rc`` +These files do not exist by default and you will have to create the +appropriate configuration files yourself: global configuration like +the username setting is typically put into +``%USERPROFILE%\mercurial.ini`` or ``$HOME/.hgrc`` and local +configuration is put into the per-repository ``/.hg/hgrc`` file. + If there is a per-repository configuration file which is not owned by the active user, Mercurial will warn you that the file is skipped:: diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py --- a/mercurial/hgweb/common.py +++ b/mercurial/hgweb/common.py @@ -105,12 +105,16 @@ def _statusmessage(code): def statusmessage(code, message=None): return '%d %s' % (code, message or _statusmessage(code)) -def get_mtime(spath): +def get_stat(spath): + """stat changelog if it exists, spath otherwise""" cl_path = os.path.join(spath, "00changelog.i") if os.path.exists(cl_path): - return os.stat(cl_path).st_mtime + return os.stat(cl_path) else: - return os.stat(spath).st_mtime + return os.stat(spath) + +def get_mtime(spath): + return get_stat(spath).st_mtime def staticfile(directory, fname, req): """return a file inside directory with guessed Content-Type header diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -8,7 +8,7 @@ import os from mercurial import ui, hg, hook, error, encoding, templater -from common import get_mtime, ErrorResponse, permhooks, caching +from common import get_stat, ErrorResponse, permhooks, caching from common import HTTP_OK, HTTP_NOT_MODIFIED, HTTP_BAD_REQUEST from common import HTTP_NOT_FOUND, HTTP_SERVER_ERROR from request import wsgirequest @@ -39,6 +39,7 @@ class hgweb(object): self.repo.ui.setconfig('ui', 'interactive', 'off') hook.redirect(True) self.mtime = -1 + self.size = -1 self.reponame = name self.archives = 'zip', 'gz', 'bz2' self.stripecount = 1 @@ -63,9 +64,12 @@ class hgweb(object): def refresh(self, request=None): if request: self.repo.ui.environ = request.env - mtime = get_mtime(self.repo.spath) - if mtime != self.mtime: - self.mtime = mtime + st = get_stat(self.repo.spath) + # compare changelog size in addition to mtime to catch + # rollbacks made less than a second ago + if st.st_mtime != self.mtime or st.st_size != self.size: + self.mtime = st.st_mtime + self.size = st.st_size self.repo = hg.repository(self.repo.ui, self.repo.root) self.maxchanges = int(self.config("web", "maxchanges", 10)) self.stripecount = int(self.config("web", "stripes", 1)) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -743,8 +743,8 @@ class localrepository(repo.repository): branch = self.opener("undo.branch").read() self.dirstate.setbranch(branch) except IOError: - self.ui.warn(_("Named branch could not be reset, " - "current branch still is: %s\n") + self.ui.warn(_("named branch could not be reset, " + "current branch is still: %s\n") % self.dirstate.branch()) self.invalidate() self.dirstate.invalidate() diff --git a/tests/test-rollback.t b/tests/test-rollback.t --- a/tests/test-rollback.t +++ b/tests/test-rollback.t @@ -56,7 +56,7 @@ Test rollback of hg before issue 902 was $ rm .hg/undo.branch $ hg rollback repository tip rolled back to revision -1 (undo commit) - Named branch could not be reset, current branch still is: test + named branch could not be reset, current branch is still: test working directory now based on revision -1 $ hg branch test @@ -91,3 +91,29 @@ same thing, but run $EDITOR $ cat .hg/last-message.txt another precious commit message +test rollback on served repository + + $ hg commit -m "precious commit message" + $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log + $ cat hg.pid >> $DAEMON_PIDS + $ cd .. + $ hg clone http://localhost:$HGPORT u + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files + updating to branch test + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ cd u + $ hg id default + 1df294f7b1a2 + +now rollback and observe that 'hg serve' reloads the repository and +presents the correct tip changeset: + + $ hg -R ../t rollback + repository tip rolled back to revision -1 (undo commit) + working directory now based on revision -1 + $ hg id default + 000000000000