# HG changeset patch # User Matt Mackall # Date 2012-04-06 20:18:14 # Node ID 329887a7074c8e49e73fa76712d8d45aee0d0fd7 # Parent 4417eb761ba828c0671968bbbd61fd7b61a9c4b9 # Parent 709924be3d047ae8982c1f71eb910779a05b4416 merge with stable diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -95,6 +95,8 @@ utestpats = [ "explicit exit code checks unnecessary"), (uprefix + r'set -e', "don't use set -e"), (uprefixc + r'( *)\t', "don't use tabs to indent"), + (uprefixc + r'.*do\s*true;\s*done', + "don't use true as loop body, use sleep 0"), ], # warnings [] diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2438,9 +2438,9 @@ def export(ui, repo, *changesets, **opts Returns 0 on success. """ changesets += tuple(opts.get('rev', [])) - if not changesets: + revs = scmutil.revrange(repo, changesets) + if not revs: raise util.Abort(_("export requires at least one changeset")) - revs = scmutil.revrange(repo, changesets) if len(revs) > 1: ui.note(_('exporting patches:\n')) else: diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -127,7 +127,7 @@ class changectx(object): def phasestr(self): return phases.phasenames[self.phase()] def mutable(self): - return self._repo._phaserev[self._rev] > phases.public + return self.phase() > phases.public def hidden(self): return self._rev in self._repo.changelog.hiddenrevs diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -156,10 +156,10 @@ def diffline(revs, a, b, opts): return ' '.join(parts) + '\n' def unidiff(a, ad, b, bd, fn1, fn2, r=None, opts=defaultopts): - def datetag(date, addtab=True): + def datetag(date, fn=None): if not opts.git and not opts.nodates: return '\t%s\n' % date - if addtab and ' ' in fn1: + if fn and ' ' in fn: return '\t\n' return '\n' @@ -177,19 +177,19 @@ def unidiff(a, ad, b, bd, fn1, fn2, r=No elif not a: b = splitnewlines(b) if a is None: - l1 = '--- /dev/null%s' % datetag(epoch, False) + l1 = '--- /dev/null%s' % datetag(epoch) else: - l1 = "--- %s%s" % ("a/" + fn1, datetag(ad)) - l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd)) + l1 = "--- %s%s" % ("a/" + fn1, datetag(ad, fn1)) + l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd, fn2)) l3 = "@@ -0,0 +1,%d @@\n" % len(b) l = [l1, l2, l3] + ["+" + e for e in b] elif not b: a = splitnewlines(a) - l1 = "--- %s%s" % ("a/" + fn1, datetag(ad)) + l1 = "--- %s%s" % ("a/" + fn1, datetag(ad, fn1)) if b is None: - l2 = '+++ /dev/null%s' % datetag(epoch, False) + l2 = '+++ /dev/null%s' % datetag(epoch) else: - l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd)) + l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd, fn2)) l3 = "@@ -1,%d +0,0 @@\n" % len(a) l = [l1, l2, l3] + ["-" + e for e in a] else: @@ -199,8 +199,8 @@ def unidiff(a, ad, b, bd, fn1, fn2, r=No if not l: return "" - l.insert(0, "--- a/%s%s" % (fn1, datetag(ad))) - l.insert(1, "+++ b/%s%s" % (fn2, datetag(bd))) + l.insert(0, "--- a/%s%s" % (fn1, datetag(ad, fn1))) + l.insert(1, "+++ b/%s%s" % (fn2, datetag(bd, fn2))) for ln in xrange(len(l)): if l[ln][-1] != '\n': diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -483,7 +483,7 @@ class ui(object): if not getattr(self.ferr, 'closed', False): self.ferr.flush() except IOError, inst: - if inst.errno not in (errno.EPIPE, errno.EIO): + if inst.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): raise def flush(self): diff --git a/tests/hghave b/tests/hghave --- a/tests/hghave +++ b/tests/hghave @@ -177,7 +177,6 @@ def has_symlink(): return True except (OSError, AttributeError): return False - return hasattr(os, "symlink") # FIXME: should also check file system and os def has_tla(): return matchoutput('tla --version 2>&1', r'The GNU Arch Revision') diff --git a/tests/test-debugbuilddag.t b/tests/test-debugbuilddag.t --- a/tests/test-debugbuilddag.t +++ b/tests/test-debugbuilddag.t @@ -7,6 +7,7 @@ plain $ hg debugbuilddag '+2:f +3:p2 @temp --config extensions.progress= --config progress.assume-tty=1 \ > --config progress.delay=0 --config progress.refresh=0 \ + > --config progress.format=topic,bar,number \ > --config progress.width=60 2>&1 | \ > python "$TESTDIR/filtercr.py" diff --git a/tests/test-diff-unified.t b/tests/test-diff-unified.t --- a/tests/test-diff-unified.t +++ b/tests/test-diff-unified.t @@ -140,3 +140,54 @@ 0 lines of context hunk header matches g +c3 @@ -3,1 +4,0 @@ c4 -c5 + + $ echo a > f1 + $ hg ci -m movef2 + +Test diff headers terminating with TAB when necessary (issue3357) +Regular diff --nodates, file creation + + $ hg mv f1 'f 1' + $ echo b > 'f 1' + $ hg diff --nodates 'f 1' + diff -r 7574207d0d15 f 1 + --- /dev/null + +++ b/f 1 + @@ -0,0 +1,1 @@ + +b + +Git diff, adding space + + $ hg diff --git + diff --git a/f1 b/f 1 + rename from f1 + rename to f 1 + --- a/f1 + +++ b/f 1 + @@ -1,1 +1,1 @@ + -a + +b + +Regular diff --nodates, file deletion + + $ hg ci -m addspace + $ hg mv 'f 1' f1 + $ echo a > f1 + $ hg diff --nodates 'f 1' + diff -r ca50fe67c9c7 f 1 + --- a/f 1 + +++ /dev/null + @@ -1,1 +0,0 @@ + -b + +Git diff, removing space + + $ hg diff --git + diff --git a/f 1 b/f1 + rename from f 1 + rename to f1 + --- a/f 1 + +++ b/f1 + @@ -1,1 +1,1 @@ + -b + +a diff --git a/tests/test-export.t b/tests/test-export.t --- a/tests/test-export.t +++ b/tests/test-export.t @@ -129,3 +129,17 @@ Checking if only alphanumeric characters exporting patch: ____________0123456789_______ABCDEFGHIJKLMNOPQRSTUVWXYZ______abcdefghijklmnopqrstuvwxyz____.patch +Catch exporting unknown revisions (especially empty revsets, see issue3353) + + $ hg export + abort: export requires at least one changeset + [255] + $ hg export "" + hg: parse error: empty query + [255] + $ hg export 999 + abort: unknown revision '999'! + [255] + $ hg export "not all()" + abort: export requires at least one changeset + [255] diff --git a/tests/test-hup.t b/tests/test-hup.t --- a/tests/test-hup.t +++ b/tests/test-hup.t @@ -11,7 +11,7 @@ Do test while holding fifo open $ ( > echo lock > echo addchangegroup - > while [ ! -s .hg/store/journal ]; do true; done + > while [ ! -s .hg/store/journal ]; do sleep 0; done > kill -HUP $P > ) > p diff --git a/tests/test-mq-qimport.t b/tests/test-mq-qimport.t --- a/tests/test-mq-qimport.t +++ b/tests/test-mq-qimport.t @@ -28,6 +28,14 @@ qimport non-existing-file abort: unable to read file non-existing-file [255] +qimport null revision + + $ hg qimport -r null + abort: revision -1 is not mutable + (see "hg help phases" for details) + [255] + $ hg qseries + import email $ hg qimport --push -n email - < else > kill `cat hg.pid` > fi - > while kill -0 `cat hg.pid` 2>/dev/null; do true; done + > while kill -0 `cat hg.pid` 2>/dev/null; do sleep 0; done > } $ hg init test