def storeuntracked(repo, untracked): if not untracked: return os.mkdir(repo.join('tasks/untrackedbackup')) for f in untracked: shaname = util.sha1(f).hexdigest() util.copyfile(util.pathto(repo.root, None, f), repo.join('tasks/untrackedbackup/%s' % shaname)) util.unlink(util.pathto(repo.root, None, f))
def pathto(self, f, cwd=None): if cwd is None: cwd = self.getcwd() # TODO core dirstate does something about slashes here assert isinstance(f, bytes) r = util.pathto(self._root, cwd, f) return r
def filesha(repo, file): '''returns a sha1 of file contents''' f = util.pathto(repo.root, None, file) if os.path.exists(f): contents = open(f).read() else: contents = '' return util.sha1(contents).hexdigest()
def filesha(repo, file): '''returns a sha1 of file contents''' f = util.pathto(repo.root, None, file) if os.path.exists(f): contents = open(f).read() else: contents = ''; return util.sha1(contents).hexdigest()
def restoreuntracked(repo, untracked): for f in untracked: shaname = util.sha1(f).hexdigest() util.copyfile(repo.join('tasks/untrackedbackup/%s' % shaname), util.pathto(repo.root, None, f))