Mercurial > hg
view tests/md5sum.py @ 24183:932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
This follows normal Mercurial rules, and the message is lifted from
workingctx.add(). The file is printed with abs() to be consistent with how it
is printed in workingctx, even though that is inconsistent with how added files
are printed in verbose mode. Further, the 'already tracked' notifications come
after all of the files that are added are printed, like in Mercurial.
As a side effect, we now have the reject list to return to the caller, so that
'hg add' exits with the proper code. It looks like an abort occurs if git fails
to add the file. Prior to touching 'snake.python' in the test, this was the
result of attempting to add the file after a 'git rm':
fatal: pathspec 'snake.python' did not match any files
abort: git add error 128 in s (in subrepo s)
I'm not sure what happens when git is a deep subrepo, but the 'in s' and
'in subrepo s' from @annotatesubrepoerror are redundant here. Maybe we should
stat the files before invoking git to catch this case and print out the prettier
hg message? The other thing missing from workingctx.add() is the call to
scmutil.checkportable(), but that would need to borrow the parent's ui object.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 27 Feb 2015 23:30:42 -0500 |
parents | 1ffeeb91c55d |
children | 328739ea70c3 |
line wrap: on
line source
#!/usr/bin/env python # # Based on python's Tools/scripts/md5sum.py # # This software may be used and distributed according to the terms # of the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2, which is # GPL-compatible. import sys, os try: from hashlib import md5 except ImportError: from md5 import md5 try: import msvcrt msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) except ImportError: pass for filename in sys.argv[1:]: try: fp = open(filename, 'rb') except IOError, msg: sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg)) sys.exit(1) m = md5() try: while True: data = fp.read(8192) if not data: break m.update(data) except IOError, msg: sys.stderr.write('%s: I/O error: %s\n' % (filename, msg)) sys.exit(1) sys.stdout.write('%s %s\n' % (m.hexdigest(), filename)) sys.exit(0)