Vlad Andersen  committed e96e171

Checking if any changes exist in a repository before trying to apply them.

  • Participants
  • Parent commits def903b
  • Branches 1.0
  • Tags 1.0.1

Comments (0)

Files changed (1)

         """checks if a patch exists or not"""
         return os.path.exists(self.join(patch))
+    def haschanges (self, repo, pats=[], opts={}):
+        """checks if repository has changes or not"""
+        return list(patch.diff(repo, match = cmdutil.match(repo, pats, opts), opts = self.diffopts(opts))) != []
     def available(self):
         '''reads all available patches from the attic dir
     so you may want to to hg add untracked files with desired changes.
     s = repo.attic
+    if not s.haschanges (repo, pats, opts):
+        raise util.Abort(_('there is nothing to shelve'))
     if not name and s.currentpatch == 'default':
         name = 'default'
     if opts.get('interactive'):
         interactiveshelve(ui, repo, name, pats, opts)
         ui.status(_('patch %s shelved\n' % (s.currentpatch)))