[PATCH] test-commit-multiple.t: improve committwice.py

Adrian Buehlmann adrian at cadifra.com
Wed Mar 23 17:05:14 CDT 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1300917520 -3600
# Node ID ebbbeb3b4d40c9e74240aa1b75ca12ce920e4798
# Parent  2d53cefb44e3cc8c9d4bedc95894ae173d7b7773
test-commit-multiple.t: improve committwice.py

- fix bug in replacebyte: parameter fn wasn't used (no harm done)
- remove unneeded matcher
- remove unused local n
- increase test coverage a bit with a second file and some sleeping
- show files changed in revisions
- move print statements out of racy path to make sure it's as racy as possible

diff --git a/tests/test-commit-multiple.t b/tests/test-commit-multiple.t
--- a/tests/test-commit-multiple.t
+++ b/tests/test-commit-multiple.t
@@ -81,33 +81,43 @@ transplant bug fixes onto release branch
 now test that we fixed the bug for all scripts/extensions
   $ cat > $TESTTMP/committwice.py <<__EOF__
   > from mercurial import ui, hg, match, node
+  > from time import sleep
   > 
   > def replacebyte(fn, b):
-  >     f = open("file1", "rb+")
+  >     f = open(fn, "rb+")
   >     f.seek(0, 0)
   >     f.write(b)
   >     f.close()
   > 
+  > def printfiles(repo, rev):
+  >     print "revision %s files: %s" % (rev, repo[rev].files())
+  > 
   > repo = hg.repository(ui.ui(), '.')
   > assert len(repo) == 6, \
-  >        "initial: len(repo) == %d, expected 6" % len(repo)
+  >        "initial: len(repo): %d, expected: 6" % len(repo)
+  > 
+  > replacebyte("bugfix", "u")
+  > sleep(2)
   > try:
+  >     print "PRE: len(repo): %d" % len(repo)
   >     wlock = repo.wlock()
   >     lock = repo.lock()
-  >     m = match.exact(repo.root, '', ['file1'])
   >     replacebyte("file1", "x")
-  >     n = repo.commit(text="x", user="test", date=(0, 0), match=m)
-  >     print "commit 1: len(repo) == %d" % len(repo)
+  >     repo.commit(text="x", user="test", date=(0, 0))
   >     replacebyte("file1", "y")
-  >     n = repo.commit(text="y", user="test", date=(0, 0), match=m)
-  >     print "commit 2: len(repo) == %d" % len(repo)
+  >     repo.commit(text="y", user="test", date=(0, 0))
+  >     print "POST: len(repo): %d" % len(repo)
   > finally:
   >     lock.release()
   >     wlock.release()
+  > printfiles(repo, 6)
+  > printfiles(repo, 7)
   > __EOF__
   $ $PYTHON $TESTTMP/committwice.py
-  commit 1: len(repo) == 7
-  commit 2: len(repo) == 8
+  PRE: len(repo): 6
+  POST: len(repo): 8
+  revision 6 files: ['bugfix', 'file1']
+  revision 7 files: ['file1']
 
 Do a size-preserving modification outside of that process
   $ echo abcd > bugfix
@@ -115,5 +125,5 @@ Do a size-preserving modification outsid
   M bugfix
   $ hg log --template "{rev}  {desc}  {files}\n" -r5:
   5  fix 2  bugfix file1
-  6  x  file1
+  6  x  bugfix file1
   7  y  file1


More information about the Mercurial-devel mailing list