1Create a repository: 2 3#if no-extraextensions 4 $ hg config 5 chgserver.idletimeout=60 6 devel.all-warnings=true 7 devel.default-date=0 0 8 extensions.fsmonitor= (fsmonitor !) 9 format.exp-rc-dirstate-v2=1 (dirstate-v2 !) 10 largefiles.usercache=$TESTTMP/.cache/largefiles 11 lfs.usercache=$TESTTMP/.cache/lfs 12 ui.slash=True 13 ui.interactive=False 14 ui.detailed-exit-code=True 15 ui.merge=internal:merge 16 ui.mergemarkers=detailed 17 ui.promptecho=True 18 ui.ssh=* (glob) 19 ui.timeout.warn=15 20 web.address=localhost 21 web\.ipv6=(?:True|False) (re) 22 web.server-header=testing stub value 23#endif 24 25 $ hg init t 26 $ cd t 27 28Prepare a changeset: 29 30 $ echo a > a 31 $ hg add a 32 33 $ hg status 34 A a 35 36Writes to stdio succeed and fail appropriately 37 38#if devfull 39 $ hg status 2>/dev/full 40 A a 41 42 $ hg status >/dev/full 43 abort: No space left on device 44 [255] 45#endif 46 47#if devfull 48 $ hg status >/dev/full 2>&1 49 [255] 50 51 $ hg status ENOENT 2>/dev/full 52 [255] 53#endif 54 55On Python 3, stdio may be None: 56 57 $ hg debuguiprompt --config ui.interactive=true 0<&- 58 abort: Bad file descriptor (no-rhg !) 59 abort: response expected (rhg !) 60 [255] 61 $ hg version -q 0<&- 62 Mercurial Distributed SCM * (glob) 63 64#if py3 no-rhg 65 $ hg version -q 1>&- 66 abort: Bad file descriptor 67 [255] 68#else 69 $ hg version -q 1>&- 70#endif 71 $ hg unknown -q 1>&- 72 hg: unknown command 'unknown' 73 (did you mean debugknown?) 74 [10] 75 76 $ hg version -q 2>&- 77 Mercurial Distributed SCM * (glob) 78 $ hg unknown -q 2>&- 79 [10] 80 81 $ hg commit -m test 82 83This command is ancient: 84 85 $ hg history 86 changeset: 0:acb14030fe0a 87 tag: tip 88 user: test 89 date: Thu Jan 01 00:00:00 1970 +0000 90 summary: test 91 92 93Verify that updating to revision 0 via commands.update() works properly 94 95 $ cat <<EOF > update_to_rev0.py 96 > from mercurial import commands, hg, ui as uimod 97 > myui = uimod.ui.load() 98 > repo = hg.repository(myui, path=b'.') 99 > commands.update(myui, repo, rev=b"0") 100 > EOF 101 $ hg up null 102 0 files updated, 0 files merged, 1 files removed, 0 files unresolved 103 $ "$PYTHON" ./update_to_rev0.py 104 1 files updated, 0 files merged, 0 files removed, 0 files unresolved 105 $ hg identify -n 106 0 107 108 109Poke around at hashes: 110 111 $ hg manifest --debug 112 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 644 a 113 114 $ hg cat a 115 a 116 117Verify should succeed: 118 119 $ hg verify 120 checking changesets 121 checking manifests 122 crosschecking files in changesets and manifests 123 checking files 124 checked 1 changesets with 1 changes to 1 files 125 126Repository root: 127 128 $ hg root 129 $TESTTMP/t 130 $ hg log -l1 -T '{reporoot}\n' 131 $TESTTMP/t 132 $ hg root -Tjson | sed 's|\\\\|\\|g' 133 [ 134 { 135 "hgpath": "$TESTTMP/t/.hg", 136 "reporoot": "$TESTTMP/t", 137 "storepath": "$TESTTMP/t/.hg/store" 138 } 139 ] 140 141At the end... 142 143 $ cd .. 144 145Status message redirection: 146 147 $ hg init empty 148 149 status messages are sent to stdout by default: 150 151 $ hg outgoing -R t empty -Tjson 2>/dev/null 152 comparing with empty 153 searching for changes 154 [ 155 { 156 "bookmarks": [], 157 "branch": "default", 158 "date": [0, 0], 159 "desc": "test", 160 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376", 161 "parents": ["0000000000000000000000000000000000000000"], 162 "phase": "draft", 163 "rev": 0, 164 "tags": ["tip"], 165 "user": "test" 166 } 167 ] 168 169 which can be configured to send to stderr, so the output wouldn't be 170 interleaved: 171 172 $ cat <<'EOF' >> "$HGRCPATH" 173 > [ui] 174 > message-output = stderr 175 > EOF 176 $ hg outgoing -R t empty -Tjson 2>/dev/null 177 [ 178 { 179 "bookmarks": [], 180 "branch": "default", 181 "date": [0, 0], 182 "desc": "test", 183 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376", 184 "parents": ["0000000000000000000000000000000000000000"], 185 "phase": "draft", 186 "rev": 0, 187 "tags": ["tip"], 188 "user": "test" 189 } 190 ] 191 $ hg outgoing -R t empty -Tjson >/dev/null 192 comparing with empty 193 searching for changes 194 195 this option should be turned off by HGPLAIN= since it may break scripting use: 196 197 $ HGPLAIN= hg outgoing -R t empty -Tjson 2>/dev/null 198 comparing with empty 199 searching for changes 200 [ 201 { 202 "bookmarks": [], 203 "branch": "default", 204 "date": [0, 0], 205 "desc": "test", 206 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376", 207 "parents": ["0000000000000000000000000000000000000000"], 208 "phase": "draft", 209 "rev": 0, 210 "tags": ["tip"], 211 "user": "test" 212 } 213 ] 214 215 but still overridden by --config: 216 217 $ HGPLAIN= hg outgoing -R t empty -Tjson --config ui.message-output=stderr \ 218 > 2>/dev/null 219 [ 220 { 221 "bookmarks": [], 222 "branch": "default", 223 "date": [0, 0], 224 "desc": "test", 225 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376", 226 "parents": ["0000000000000000000000000000000000000000"], 227 "phase": "draft", 228 "rev": 0, 229 "tags": ["tip"], 230 "user": "test" 231 } 232 ] 233 234Invalid ui.message-output option: 235 236 $ hg log -R t --config ui.message-output=bad 237 abort: invalid ui.message-output destination: bad 238 [255] 239 240Underlying message streams should be updated when ui.fout/ferr are set: 241 242 $ cat <<'EOF' > capui.py 243 > from mercurial import pycompat, registrar 244 > cmdtable = {} 245 > command = registrar.command(cmdtable) 246 > @command(b'capui', norepo=True) 247 > def capui(ui): 248 > out = ui.fout 249 > ui.fout = pycompat.bytesio() 250 > ui.status(b'status\n') 251 > ui.ferr = pycompat.bytesio() 252 > ui.warn(b'warn\n') 253 > out.write(b'stdout: %s' % ui.fout.getvalue()) 254 > out.write(b'stderr: %s' % ui.ferr.getvalue()) 255 > EOF 256 $ hg --config extensions.capui=capui.py --config ui.message-output=stdio capui 257 stdout: status 258 stderr: warn 259