[PATCH V4] bundle: warn when update to revision existing only in a bundle (issue5004)

liscju piotr.listkiewicz at gmail.com
Fri Apr 1 07:48:15 UTC 2016


# HG changeset patch
# User liscju <piotr.listkiewicz at gmail.com>
# Date 1458719722 -3600
#      Wed Mar 23 08:55:22 2016 +0100
# Node ID fe05a7629b7c9dee98e634fada5ccf6e5d17e529
# Parent  345f4fa4cc8912bb722ad3e35d68858487420bc6
bundle: warn when update to revision existing only in a bundle (issue5004)

Now its done silently, so unless user really knows what he is doing
will be suprised to find that after update 'hg status' doesn't work.
This commit makes also merge operation warns about missing parent when
revision to merge exists only in the bundle.

diff -r 345f4fa4cc89 -r fe05a7629b7c mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py	Fri Mar 25 16:23:23 2016 -0500
+++ b/mercurial/bundlerepo.py	Wed Mar 23 08:55:22 2016 +0100
@@ -32,6 +32,7 @@ from . import (
     localrepo,
     manifest,
     mdiff,
+    node as nodemod,
     pathutil,
     phases,
     revlog,
@@ -385,6 +386,17 @@ class bundlerepository(localrepo.localre
     def getcwd(self):
         return os.getcwd() # always outside the repo
 
+    # Check if parents exist in localrepo before setting
+    def setparents(self, p1, p2=nullid):
+        p1rev = self.changelog.rev(p1)
+        p2rev = self.changelog.rev(p2)
+        msg = _("setting parent to node %s that "
+                "only exists in the bundle\n")
+        if self.changelog.repotiprev < p1rev:
+            self.ui.warn(msg % nodemod.hex(p1))
+        if self.changelog.repotiprev < p2rev:
+            self.ui.warn(msg % nodemod.hex(p2))
+        return super(bundlerepository, self).setparents(p1, p2)
 
 def instance(ui, path, create):
     if create:
diff -r 345f4fa4cc89 -r fe05a7629b7c tests/test-bundle.t
--- a/tests/test-bundle.t	Fri Mar 25 16:23:23 2016 -0500
+++ b/tests/test-bundle.t	Wed Mar 23 08:55:22 2016 +0100
@@ -733,3 +733,77 @@ bundle single branch
   $ hg bundle -r 'public()' no-output.hg
   abort: no commits to bundle
   [255]
+
+  $ cd ..
+
+When user merges to the revision existing only in the bundle,
+it should show warning that second parent of the working
+directory does not exist
+
+  $ hg init update2bundled
+  $ cd update2bundled
+  $ cat <<EOF >> .hg/hgrc
+  > [extensions]
+  > strip =
+  > EOF
+  $ echo "aaa" >> a
+  $ hg commit -A -m 0
+  adding a
+  $ echo "bbb" >> b
+  $ hg commit -A -m 1
+  adding b
+  $ echo "ccc" >> c
+  $ hg commit -A -m 2
+  adding c
+  $ hg update -r 1
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo "ddd" >> d
+  $ hg commit -A -m 3
+  adding d
+  created new head
+  $ hg update -r 2
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg log -G
+  o  changeset:   3:8bd3e1f196af
+  |  tag:         tip
+  |  parent:      1:a01eca7af26d
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     3
+  |
+  | @  changeset:   2:4652c276ac4f
+  |/   user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     2
+  |
+  o  changeset:   1:a01eca7af26d
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     1
+  |
+  o  changeset:   0:4fe08cd4693e
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     0
+  
+  $ hg bundle --base 1 -r 3 ../update2bundled.hg
+  1 changesets found
+  $ hg strip -r 3
+  saved backup bundle to $TESTTMP/update2bundled/.hg/strip-backup/8bd3e1f196af-017e56d8-backup.hg (glob)
+  $ hg merge -R ../update2bundled.hg -r 3
+  setting parent to node 8bd3e1f196af289b2b121be08031e76d7ae92098 that only exists in the bundle
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+
+When user updates to the revision existing only in the bundle,
+it should show warning
+
+  $ hg update -R ../update2bundled.hg --clean -r 3
+  setting parent to node 8bd3e1f196af289b2b121be08031e76d7ae92098 that only exists in the bundle
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+
+When user updates to the revision existing in the local repository
+the warning shouldn't be emitted
+
+  $ hg update -R ../update2bundled.hg -r 0
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved


More information about the Mercurial-devel mailing list