Make undo and recover friendlier
authormpm@selenic.com
Thu, 26 May 2005 09:48:50 -0800
changeset 163 f38c90953c2c48eaebe82226167aa86b3106a4b9
parent 162 5dcbe4d9a30c4e5561d34f9d9738df3322384d6d
child 164 2e87f04880ab8f4872f897b2af660dc15d005502
push id1
push usergszorc@mozilla.com
push dateWed, 18 Mar 2015 16:34:57 +0000
Make undo and recover friendlier Add them to the help display, have them report failure
hg
mercurial/hg.py
--- a/hg
+++ b/hg
@@ -31,20 +31,22 @@ def help():
  commit                commit all changes to the repository
  diff [files...]       diff working directory (or selected files)
  dump <file> [rev]     dump the latest or given revision of a file
  dumpmanifest [rev]    dump the latest or given revision of the manifest
  history               show changeset history
  init                  create a new repository in this directory
  log <file>            show revision history of a single file
  merge <path>          merge changes from <path> into local repository
+ recover               rollback an interrupted transaction
  remove [files...]     remove the given files in the next commit
  serve                 export the repository via HTTP
  status                show new, missing, and changed files in working dir
  tags                  show current changeset tags
+ undo                  undo the last transaction
 """
 
 def filterfiles(list, files):
     l = [ x for x in list if x in files ]
 
     for f in files:
         if f[-1] != os.sep: f += os.sep
         l += [ x for x in list if x.startswith(f) ]
@@ -419,21 +421,19 @@ elif cmd == "tags":
     for k, n in i:
         try:
             r = repo.changelog.rev(n)
         except KeyError:
             r = "?"
         print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n))
 
 elif cmd == "recover":
-    ui.status("rolling back any existing journal")
     repo.recover()
 
 elif cmd == "undo":
-    ui.status("rolling back previous transaction")
     repo.recover("undo")
 
 elif cmd == "verify":
     filelinkrevs = {}
     filenodes = {}
     manifestchangeset = {}
     changesets = revisions = files = 0
     errors = 0
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -295,17 +295,20 @@ class localrepository:
 
     def transaction(self):
         return transaction(self.opener, self.join("journal"),
                            self.join("undo"))
 
     def recover(self, f = "journal"):
         self.lock()
         if os.path.exists(self.join(f)):
+            self.ui.status("attempting to rollback %s information\n" % f)
             return rollback(self.opener, self.join(f))
+        else:
+            self.ui.warn("no %s information available\n" % f)
 
     def lock(self, wait = 1):
         try:
             return lock.lock(self.join("lock"), 0)
         except lock.LockHeld, inst:
             if wait:
                 self.ui.warn("waiting for lock held by %s\n" % inst.args[0])
                 return lock.lock(self.join("lock"), wait)