Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/merge.py @ 27656:57c0d4888ca8
batchget: add support for backing up files
We're going to use this in an upcoming feature.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Sat, 02 Jan 2016 03:21:01 -0800 |
parents | af13eaf9ab8c |
children | 7b5c8c8a2f8c |
comparison
equal
deleted
inserted
replaced
27655:af13eaf9ab8c | 27656:57c0d4888ca8 |
---|---|
24 copies, | 24 copies, |
25 destutil, | 25 destutil, |
26 error, | 26 error, |
27 filemerge, | 27 filemerge, |
28 obsolete, | 28 obsolete, |
29 scmutil, | |
29 subrepo, | 30 subrepo, |
30 util, | 31 util, |
31 worker, | 32 worker, |
32 ) | 33 ) |
33 | 34 |
969 yields tuples for progress updates | 970 yields tuples for progress updates |
970 """ | 971 """ |
971 verbose = repo.ui.verbose | 972 verbose = repo.ui.verbose |
972 fctx = mctx.filectx | 973 fctx = mctx.filectx |
973 wwrite = repo.wwrite | 974 wwrite = repo.wwrite |
975 ui = repo.ui | |
974 i = 0 | 976 i = 0 |
975 for f, args, msg in actions: | 977 for f, (flags, backup), msg in actions: |
976 repo.ui.debug(" %s: %s -> g\n" % (f, msg)) | 978 repo.ui.debug(" %s: %s -> g\n" % (f, msg)) |
977 if verbose: | 979 if verbose: |
978 repo.ui.note(_("getting %s\n") % f) | 980 repo.ui.note(_("getting %s\n") % f) |
979 wwrite(f, fctx(f).data(), args[0]) | 981 |
982 if backup: | |
983 absf = repo.wjoin(f) | |
984 orig = scmutil.origpath(ui, repo, absf) | |
985 try: | |
986 # TODO Mercurial has always aborted if an untracked directory | |
987 # is replaced by a tracked file, or generally with | |
988 # file/directory merges. This needs to be sorted out. | |
989 if repo.wvfs.isfileorlink(f): | |
990 util.rename(absf, orig) | |
991 except OSError as e: | |
992 if e.errno != errno.ENOENT: | |
993 raise | |
994 | |
995 wwrite(f, fctx(f).data(), flags) | |
980 if i == 100: | 996 if i == 100: |
981 yield i, f | 997 yield i, f |
982 i = 0 | 998 i = 0 |
983 i += 1 | 999 i += 1 |
984 if i > 0: | 1000 if i > 0: |