##// END OF EJS Templates
batchget: add support for backing up files...
Siddharth Agarwal -
r27656:57c0d488 default
parent child Browse files
Show More
@@ -26,6 +26,7 b' from . import ('
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,
@@ -971,12 +972,27 b' def batchget(repo, mctx, actions):'
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
General Comments 0
You need to be logged in to leave comments. Login now