changeset 13959:141f88ae5276

merge with stable
author Martin Geisler <mg@lazybytes.net>
date Tue, 19 Apr 2011 15:19:54 +0200
parents ffb5c09ba822 (current diff) 71f51cc71652 (diff)
children 190e5f2043d9
files mercurial/hgweb/common.py mercurial/hgweb/hgweb_mod.py mercurial/localrepo.py tests/test-rollback.t
diffstat 5 files changed, 50 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help/config.txt	Tue Apr 19 12:04:44 2011 +0200
+++ b/mercurial/help/config.txt	Tue Apr 19 15:19:54 2011 +0200
@@ -22,6 +22,12 @@
 - ``<install-root>/etc/mercurial/hgrc``
 - ``<install-root>/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 ``<repo>/.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::
 
--- a/mercurial/hgweb/common.py	Tue Apr 19 12:04:44 2011 +0200
+++ b/mercurial/hgweb/common.py	Tue Apr 19 15:19:54 2011 +0200
@@ -105,12 +105,16 @@
 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
--- a/mercurial/hgweb/hgweb_mod.py	Tue Apr 19 12:04:44 2011 +0200
+++ b/mercurial/hgweb/hgweb_mod.py	Tue Apr 19 15:19:54 2011 +0200
@@ -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 @@
         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 @@
     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))
--- a/mercurial/localrepo.py	Tue Apr 19 12:04:44 2011 +0200
+++ b/mercurial/localrepo.py	Tue Apr 19 15:19:54 2011 +0200
@@ -743,8 +743,8 @@
                     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()
--- a/tests/test-rollback.t	Tue Apr 19 12:04:44 2011 +0200
+++ b/tests/test-rollback.t	Tue Apr 19 15:19:54 2011 +0200
@@ -56,7 +56,7 @@
   $ 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 @@
   $ 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