Rev 3638: (jam) bzr uncommit now gives the revision id to restore the branch to in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Sat Aug 16 01:09:59 BST 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3638
revision-id: pqm at pqm.ubuntu.com-20080816000954-t0401ff8s3ydnkr6
parent: pqm at pqm.ubuntu.com-20080815054008-1xrwm20d1wv9fyt7
parent: john at arbash-meinel.com-20080815233744-o35vp17viznmo2s8
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2008-08-16 01:09:54 +0100
message:
  (jam) bzr uncommit now gives the revision id to restore the branch to
  	the old tip.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_uncommit.py test_uncommit.py-20051027212835-84944b63adae51be
    ------------------------------------------------------------
    revno: 3629.1.4
    revision-id: john at arbash-meinel.com-20080815233744-o35vp17viznmo2s8
    parent: john at arbash-meinel.com-20080815233711-4duhrsmr9rm9dugp
    parent: pqm at pqm.ubuntu.com-20080815025810-eguaiqf0kwwqo4yp
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: uncommit_ids
    timestamp: Fri 2008-08-15 18:37:44 -0500
    message:
      Merge bzr.dev, resolve NEWS
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/__init__.py             __init__.py-20050309040759-33e65acf91bbcd5d
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/index.py                index.py-20070712131115-lolkarso50vjr64s-1
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/blackbox/test_init.py test_init.py-20060309032856-a292116204d86eb7
      bzrlib/tests/blackbox/test_shared_repository.py test_shared_repository.py-20060317053531-ed30c0d79325e483
      bzrlib/tests/commands/test_init.py test_init.py-20070514074921-audbcdd8o56dpame-1
      bzrlib/tests/commands/test_init_repository.py test_init_repository-20070525163812-87xw0678ky573l27-1
    ------------------------------------------------------------
    revno: 3629.1.3
    revision-id: john at arbash-meinel.com-20080815233711-4duhrsmr9rm9dugp
    parent: john at arbash-meinel.com-20080815171312-ny39eh0hc95j8ytd
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: uncommit_ids
    timestamp: Fri 2008-08-15 18:37:11 -0500
    message:
      NEWS update
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3629.1.2
    revision-id: john at arbash-meinel.com-20080815171312-ny39eh0hc95j8ytd
    parent: john at arbash-meinel.com-20080814160452-9tp32zqblv7iw57x
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: uncommit_ids
    timestamp: Fri 2008-08-15 12:13:12 -0500
    message:
      Change to just display the command to restore the tip,
      rather than showing the revision ids in the log display.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/tests/blackbox/test_uncommit.py test_uncommit.py-20051027212835-84944b63adae51be
    ------------------------------------------------------------
    revno: 3629.1.1
    revision-id: john at arbash-meinel.com-20080814160452-9tp32zqblv7iw57x
    parent: pqm at pqm.ubuntu.com-20080814074117-x0zvzzv7y6mok8pz
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: uncommit_ids
    timestamp: Thu 2008-08-14 11:04:52 -0500
    message:
      Change 'bzr uncommit' to display the revision ids and log them.
      This makes it easier to recover from uncommit if you change your mind.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/tests/blackbox/test_uncommit.py test_uncommit.py-20051027212835-84944b63adae51be
=== modified file 'NEWS'
--- a/NEWS	2008-08-15 04:12:47 +0000
+++ b/NEWS	2008-08-16 00:09:54 +0000
@@ -22,6 +22,11 @@
       ``bzr info`` if it completed successfully.
       (Marius Kruger)
 
+    * ``bzr uncommit`` logs the old tip revision id, and displays how to
+      restore the branch to that tip using ``bzr pull``.  This allows you
+      to recover if you realize you uncommitted the wrong thing.
+      (John Arbash Meinel)
+
   BUG FIXES:
 
     * ``bzr rm`` is now aliased to ``bzr del`` for the convenience of svn

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2008-08-15 04:12:47 +0000
+++ b/bzrlib/builtins.py	2008-08-16 00:09:54 +0000
@@ -3779,8 +3779,12 @@
                     print 'Canceled'
                     return 0
 
+        mutter('Uncommitting from {%s} to {%s}',
+               last_rev_id, rev_id)
         uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
                  revno=revno, local=local)
+        note('You can restore the old tip by running:\n'
+             '  bzr pull . -r revid:%s', last_rev_id)
 
 
 class cmd_break_lock(Command):

=== modified file 'bzrlib/tests/blackbox/test_uncommit.py'
--- a/bzrlib/tests/blackbox/test_uncommit.py	2008-06-04 17:52:58 +0000
+++ b/bzrlib/tests/blackbox/test_uncommit.py	2008-08-15 17:13:12 +0000
@@ -32,7 +32,7 @@
         wt.add(['a', 'b', 'c'])
         wt.commit('initial commit', rev_id='a1')
 
-        open('tree/a', 'wb').write('new contents of a\n')
+        self.build_tree_contents([('tree/a', 'new contents of a\n')])
         wt.commit('second commit', rev_id='a2')
 
         return wt
@@ -213,6 +213,14 @@
 
         self.assertEqual(['a2', 'b3', 'c3'], wt.get_parent_ids())
 
+    def test_uncommit_shows_log_with_revision_id(self):
+        wt = self.create_simple_tree()
+
+        out, err = self.run_bzr('uncommit --force', working_dir='tree')
+        self.assertContainsRe(out, r'second commit')
+        self.assertContainsRe(err, r'You can restore the old tip by running')
+        self.assertContainsRe(err, r'bzr pull . -r revid:a2')
+
     def test_uncommit_octopus_merge(self):
         # Check that uncommit keeps the pending merges in the same order
         # though it will also filter out ones in the ancestry
@@ -223,7 +231,7 @@
 
         tree2.commit('unchanged', rev_id='b3')
         tree3.commit('unchanged', rev_id='c3')
-        
+
         wt.merge_from_branch(tree2.branch)
         wt.merge_from_branch(tree3.branch)
         wt.commit('merge b3, c3', rev_id='a3')




More information about the bazaar-commits mailing list