cpython: ab0b9107628f (original) (raw)
--- a/Tools/hg/hgtouch.py +++ b/Tools/hg/hgtouch.py @@ -36,12 +36,16 @@ def parse_config(repo): result[o] = inputs return result -def check_rule(ui, repo, modified, output, inputs): +def check_rule(ui, repo, modified, basedir, output, inputs): """Verify that the output is newer than any of the inputs. Return (status, stamp), where status is True if the update succeeded, and stamp is the newest time stamp assigned to any file (might be in
- If basedir is nonempty, it gives a directory in which the tree is to
- be checked.
- """
- f_output = repo.wjoin(os.path.join(basedir, output)) try: o_time = os.stat(f_output).st_mtime except OSError: @@ -51,7 +55,7 @@ def check_rule(ui, repo, modified, outpu backdate = None backdate_source = None for i in inputs:
f_i = repo.wjoin(i)[](#l1.27)
f_i = repo.wjoin(os.path.join(basedir, i))[](#l1.28) try:[](#l1.29) i_time = os.stat(f_i).st_mtime[](#l1.30) except OSError:[](#l1.31)
@@ -79,8 +83,14 @@ def check_rule(ui, repo, modified, outpu # Nothing to update return True, 0 -def do_touch(ui, repo):
+def do_touch(ui, repo, basedir):
- if basedir:
if not os.path.isdir(repo.wjoin(basedir)):[](#l1.40)
ui.warn("Abort: basedir %r does not exist\n" % basedir)[](#l1.41)
return[](#l1.42)
modified = [][](#l1.43)
- else:
dependencies = parse_config(repo) success = True tstamp = 0 # newest time stamp assigned @@ -93,8 +103,8 @@ def do_touch(ui, repo): if i in dependencies: hold_back[output] = inputs continuemodified = repo.status()[0][](#l1.45)
_success, _tstamp = check_rule(ui, repo, modified, output, inputs)[](#l1.53)
sucess = success and _success[](#l1.54)
_success, _tstamp = check_rule(ui, repo, modified, basedir, output, inputs)[](#l1.55)
success = success and _success[](#l1.56) tstamp = max(tstamp, _tstamp)[](#l1.57) # put back held back rules[](#l1.58) dependencies.update(hold_back)[](#l1.59)
@@ -109,11 +119,12 @@ def do_touch(ui, repo): return False return success -def touch(ui, repo): +def touch(ui, repo, basedir): "touch generated files that are older than their sources after an update."