Kiln » largefiles » Unity
Clone URL:  

revertlfiles: decrease indentation level by pre-filtering the list of largefiles

Changeset 53d9e75793ca

Parent 0c921ab7f3c3

by Profile picture of User 521Andrew Pritchard <andrewp@fogcreek.com>

Changes to one file · Browse files at 53d9e75793ca Showing diff from parent 0c921ab7f3c3 Diff from another changeset...

Change 1 of 1 Show Entire File lfcommands.py Stacked
 
387
388
389
 
 
 
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
 
 
 
 
 
 
 
 
 
 
 
 
 
425
426
427
428
429
430
 
 
431
432
433
434
 
 
 
 
 
 
 
 
 
 
 
435
436
437
 
387
388
389
390
391
392
393
394
395
 
 
396
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
397
398
399
400
401
402
403
404
405
406
407
408
409
410
 
411
412
 
 
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
@@ -387,51 +387,46 @@
    lfiles = lfutil.listlfiles(repo)   + if filelist is not None: + lfiles = [f for f in lfiles if f in filelist] +   if lfiles:   cachelfiles(ui, repo, '.')   - at = 0 - updated = 0   for lfile in lfiles: - if filelist is None or lfile in filelist: - if not os.path.exists(repo.wjoin(lfutil.standin(lfile))): - lfdirstate.remove(lfile) - continue - if os.path.exists(repo.wjoin(lfutil.standin(os.path.join(lfile\ - + '.orig')))): - shutil.copyfile(repo.wjoin(lfile), repo.wjoin(lfile + \ - '.orig')) - at += 1 - expectedhash = repo[None][lfutil.standin(lfile)].data().strip() - mode = os.stat(repo.wjoin(lfutil.standin(lfile))).st_mode - if not os.path.exists(repo.wjoin(lfile)) or expectedhash != \ - lfutil.hashfile(repo.wjoin(lfile)): - path = lfutil.findfile(repo, expectedhash) - if path is not None: - util.makedirs(os.path.dirname(repo.wjoin(lfile))) - shutil.copy(path, repo.wjoin(lfile)) - os.chmod(repo.wjoin(lfile), mode) - updated += 1 - if lfutil.standin(lfile) not in repo['.']: - lfdirstate.add(lfutil.unixpath(lfile)) - elif expectedhash == repo['.'][lfutil.standin(lfile)] \ - .data().strip(): - lfdirstate.normal(lfutil.unixpath(lfile)) - else: - lfutil.dirstate_normaldirty(lfdirstate, - lfutil.unixpath(lfile)) - elif os.path.exists(repo.wjoin(lfile)) and mode != \ - os.stat(repo.wjoin(lfile)).st_mode: + if not os.path.exists(repo.wjoin(lfutil.standin(lfile))): + lfdirstate.remove(lfile) + continue + if os.path.exists(repo.wjoin(lfutil.standin(lfile + '.orig'))): + shutil.copyfile(repo.wjoin(lfile), repo.wjoin(lfile + '.orig')) + expectedhash = repo[None][lfutil.standin(lfile)].data().strip() + mode = os.stat(repo.wjoin(lfutil.standin(lfile))).st_mode + if not os.path.exists(repo.wjoin(lfile)) or expectedhash != \ + lfutil.hashfile(repo.wjoin(lfile)): + path = lfutil.findfile(repo, expectedhash) + if path is not None: + util.makedirs(os.path.dirname(repo.wjoin(lfile))) + shutil.copy(path, repo.wjoin(lfile))   os.chmod(repo.wjoin(lfile), mode) - updated += 1   if lfutil.standin(lfile) not in repo['.']:   lfdirstate.add(lfutil.unixpath(lfile)) - elif expectedhash == \ - repo['.'][lfutil.standin(lfile)].data().strip(): + elif expectedhash == repo['.'][lfutil.standin(lfile)] \ + .data().strip():   lfdirstate.normal(lfutil.unixpath(lfile))   else:   lfutil.dirstate_normaldirty(lfdirstate,   lfutil.unixpath(lfile)) + elif os.path.exists(repo.wjoin(lfile)) and mode != \ + os.stat(repo.wjoin(lfile)).st_mode: + os.chmod(repo.wjoin(lfile), mode) + if lfutil.standin(lfile) not in repo['.']: + lfdirstate.add(lfutil.unixpath(lfile)) + elif expectedhash == \ + repo['.'][lfutil.standin(lfile)].data().strip(): + lfdirstate.normal(lfutil.unixpath(lfile)) + else: + lfutil.dirstate_normaldirty(lfdirstate, + lfutil.unixpath(lfile))     removed = 0   for lfile in lfdirstate: