[PATCH V3] mercurial: fixes update --clean to work on new branch (issue5003)

liscju piotr.listkiewicz at gmail.com
Tue Mar 1 12:41:28 UTC 2016


# HG changeset patch
# User liscju <piotr.listkiewicz at gmail.com>
# Date 1456249877 -3600
#      Tue Feb 23 18:51:17 2016 +0100
# Node ID e613c6bf045f1d3f291867bace4cbe43dbbb53fa
# Parent  c7f89ad87baef87f00c507545dfd4cc824bc3131
mercurial: fixes update --clean to work on new branch (issue5003)

diff -r c7f89ad87bae -r e613c6bf045f mercurial/destutil.py
--- a/mercurial/destutil.py	Mon Feb 29 17:52:17 2016 -0600
+++ b/mercurial/destutil.py	Tue Feb 23 18:51:17 2016 +0100
@@ -99,10 +99,15 @@ def _destupdatebranch(repo, clean, check
         if bookmarks.isactivewdirparent(repo):
             movemark = repo['.'].node()
     else:
-        if currentbranch == 'default': # no default branch!
-            node = repo.lookup('tip') # update to tip
+        if clean:
+            node = repo['.'].node()
+            repo.ui.warn(_('uncommited branch %s does not exist yet, '
+                           'updating to parent\n') % currentbranch)
         else:
-            raise error.Abort(_("branch %s not found") % currentbranch)
+            if currentbranch == 'default': # no default branch!
+                node = repo.lookup('tip') # update to tip
+            else:
+                raise error.Abort(_("branch %s not found") % currentbranch)
     return node, movemark, None
 
 # order in which each step should be evalutated
diff -r c7f89ad87bae -r e613c6bf045f tests/test-newbranch.t
--- a/tests/test-newbranch.t	Mon Feb 29 17:52:17 2016 -0600
+++ b/tests/test-newbranch.t	Tue Feb 23 18:51:17 2016 +0100
@@ -207,6 +207,9 @@ Update with no arguments: tipmost revisi
   $ hg id
   adf1a74a7f7b (foo) tip
 
+  $ hg branch
+  foo
+
   $ hg branch foobar
   marked working directory as branch foobar
 
@@ -214,6 +217,16 @@ Update with no arguments: tipmost revisi
   abort: branch foobar not found
   [255]
 
+  $ hg branch
+  foobar
+
+  $ hg up --clean
+  uncommited branch foobar does not exist yet, updating to parent
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ hg branch
+  foo
+
 Fast-forward merge:
 
   $ hg branch ff


More information about the Mercurial-devel mailing list