[PATCH 1 of 2 V7] update: fix bare update to work on new branch (BC)

liscju piotr.listkiewicz at gmail.com
Mon Apr 11 17:37:16 UTC 2016


# HG changeset patch
# User liscju <piotr.listkiewicz at gmail.com>
# Date 1459832013 -7200
#      Tue Apr 05 06:53:33 2016 +0200
# Node ID 9b92231d66d9e4f41dd36bfc5f34264d8a8e9113
# Parent  c5565fc8848dd084d104ca40c33d1acdfcff8bc6
update: fix bare update to work on new branch (BC)

So far bare update on new branch results in
'abort: branch new-branch not found'. This commit fixes
this by updating to the parent of wctx.

This commit deletes lines:

	if currentbranch == 'default': # no default branch
        	# update to the tipmost non-closed branch head
                node = repo.revs('max(head() and not closed())').first()
        else:
                raise error.Abort(_("branch %s not found") % currentbranch)

They are no longer necessary because when parent of wctx exists,
then it updates to it. When it does not, it means that repo is
newly created(has no changesets), so update should stay on null
parent.

diff -r c5565fc8848d -r 9b92231d66d9 mercurial/destutil.py
--- a/mercurial/destutil.py	Wed Apr 06 22:26:47 2016 -0400
+++ b/mercurial/destutil.py	Tue Apr 05 06:53:33 2016 +0200
@@ -102,11 +102,7 @@ def _destupdatebranch(repo, clean, check
         if bookmarks.isactivewdirparent(repo):
             movemark = repo['.'].node()
     else:
-        if currentbranch == 'default': # no default branch!
-            # update to the tipmost non-closed branch head
-            node = repo.revs('max(head() and not closed())').first()
-        else:
-            raise error.Abort(_("branch %s not found") % currentbranch)
+        node = repo['.'].node()
     return node, movemark, None
 
 def _destupdatebranchfallback(repo, clean, check):
diff -r c5565fc8848d -r 9b92231d66d9 tests/test-newbranch.t
--- a/tests/test-newbranch.t	Wed Apr 06 22:26:47 2016 -0400
+++ b/tests/test-newbranch.t	Tue Apr 05 06:53:33 2016 +0200
@@ -211,8 +211,7 @@ Update with no arguments: tipmost revisi
   marked working directory as branch foobar
 
   $ hg up
-  abort: branch foobar not found
-  [255]
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Fast-forward merge:
 
@@ -345,3 +344,50 @@ 2 branch heads, implicit merge works:
   (branch merge, don't forget to commit)
 
   $ cd ..
+
+We expect that bare update on new branch, updates to parent
+
+  $ hg init bareupdateonnewbranch
+  $ cd bareupdateonnewbranch
+  $ hg update
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ touch a
+  $ hg commit -A -m "a"
+  adding a
+  $ touch b
+  $ hg commit -A -m "b"
+  adding b
+  $ touch c
+  $ hg commit -A -m "c"
+  adding c
+  $ hg update -r 1
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg log -G
+  o  changeset:   2:991a3460af53
+  |  tag:         tip
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     c
+  |
+  @  changeset:   1:0e067c57feba
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     b
+  |
+  o  changeset:   0:3903775176ed
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     a
+  
+  $ hg branch dev
+  marked working directory as branch dev
+  (branches are permanent and global, did you want a bookmark?)
+  $ hg update
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg summary
+  parent: 1:0e067c57feba 
+   b
+  branch: dev
+  commit: (new branch)
+  update: (current)
+  phases: 3 draft


More information about the Mercurial-devel mailing list