merge with stable
authorSune Foldager <cryo@cyanite.org>
Fri, 09 Apr 2010 10:35:53 +0200
changeset 10876 24ed7a541f23
parent 10871 3f30190781a3 (current diff)
parent 10875 a9702c47a19f (diff)
child 10877 dc097666de01
merge with stable
hgext/mq.py
mercurial/localrepo.py
--- a/hgext/mq.py	Tue Apr 06 08:54:18 2010 -0500
+++ b/hgext/mq.py	Fri Apr 09 10:35:53 2010 +0200
@@ -1170,12 +1170,10 @@
                     raise util.Abort(_("deletions found between repo revs"))
                 for f in a:
                     try:
-                        os.unlink(repo.wjoin(f))
+                        util.unlink(repo.wjoin(f))
                     except OSError, e:
                         if e.errno != errno.ENOENT:
                             raise
-                    try: os.removedirs(os.path.dirname(repo.wjoin(f)))
-                    except: pass
                     repo.dirstate.forget(f)
                 for f in m + r:
                     fctx = ctx[f]
--- a/mercurial/copies.py	Tue Apr 06 08:54:18 2010 -0500
+++ b/mercurial/copies.py	Fri Apr 09 10:35:53 2010 +0200
@@ -117,8 +117,23 @@
     diverge = {}
 
     def related(f1, f2, limit):
+        # Walk back to common ancestor to see if the two files originate
+        # from the same file. Since workingfilectx's rev() is None it messes
+        # up the integer comparison logic, hence the pre-step check for
+        # None (f1 and f2 can only be workingfilectx's initially).
+
+        if f1 == f2:
+            return f1 # a match
+
         g1, g2 = f1.ancestors(), f2.ancestors()
         try:
+            f1r, f2r = f1.rev(), f2.rev()
+
+            if f1r is None:
+                f1 = g1.next()
+            if f2r is None:
+                f2 = g2.next()
+
             while 1:
                 f1r, f2r = f1.rev(), f2.rev()
                 if f1r > f2r:
--- a/mercurial/localrepo.py	Tue Apr 06 08:54:18 2010 -0500
+++ b/mercurial/localrepo.py	Fri Apr 09 10:35:53 2010 +0200
@@ -1517,8 +1517,15 @@
             if len(lheads) > len(rheads):
                 warn = 1
             else:
+                # add local heads involved in the push
+                updatelheads = [self.changelog.heads(x, lheads)
+                                for x in update]
+                newheads = set(sum(updatelheads, [])) & set(lheads)
+
+                if not newheads:
+                    return True
+
                 # add heads we don't have or that are not involved in the push
-                newheads = set(lheads)
                 for r in rheads:
                     if r in self.changelog.nodemap:
                         desc = self.changelog.heads(r, heads)
--- a/tests/test-push-warn	Tue Apr 06 08:54:18 2010 -0500
+++ b/tests/test-push-warn	Fri Apr 09 10:35:53 2010 +0200
@@ -1,5 +1,8 @@
 #!/bin/sh
 
+echo "[extensions]" >> $HGRCPATH
+echo "graphlog=" >> $HGRCPATH
+
 mkdir a
 cd a
 hg init
@@ -193,5 +196,72 @@
 hg -q merge 3
 hg -q ci -d '0 0' -mma
 hg push ../l -b b
+cd ..
+
+echo % check prepush with new branch head on former topo non-head
+hg init n
+cd n
+hg branch A
+echo a >a
+hg ci -Ama
+hg branch B
+echo b >b
+hg ci -Amb
+# b is now branch head of B, and a topological head
+# a is now branch head of A, but not a topological head
+hg clone . inner
+cd inner
+hg up B
+echo b1 >b1
+hg ci -Amb1
+# in the clone b1 is now the head of B
+cd ..
+hg up 0
+echo a2 >a2
+hg ci -Ama2
+# a2 is now the new branch head of A, and a new topological head
+# it replaces a former inner branch head, so it should at most warn about A, not B
+echo %% glog of local
+hg glog --template "{rev}: {branches} {desc}\n"
+echo %% glog of remote
+hg glog -R inner --template "{rev}: {branches} {desc}\n"
+echo %% outgoing
+hg out inner --template "{rev}: {branches} {desc}\n"
+hg push inner
+cd ..
+
+echo % check prepush with new branch head on former topo head
+hg init o
+cd o
+hg branch A
+echo a >a
+hg ci -Ama
+hg branch B
+echo b >b
+hg ci -Amb
+# b is now branch head of B, and a topological head
+hg up 0
+echo a1 >a1
+hg ci -Ama1
+# a1 is now branch head of A, and a topological head
+hg clone . inner
+cd inner
+hg up B
+echo b1 >b1
+hg ci -Amb1
+# in the clone b1 is now the head of B
+cd ..
+echo a2 >a2
+hg ci -Ama2
+# a2 is now the new branch head of A, and a topological head
+# it replaces a former topological and branch head, so this should not warn
+echo %% glog of local
+hg glog --template "{rev}: {branches} {desc}\n"
+echo %% glog of remote
+hg glog -R inner --template "{rev}: {branches} {desc}\n"
+echo %% outgoing
+hg out inner --template "{rev}: {branches} {desc}\n"
+hg push inner
+cd ..
 
 exit 0
--- a/tests/test-push-warn.out	Tue Apr 06 08:54:18 2010 -0500
+++ b/tests/test-push-warn.out	Fri Apr 09 10:35:53 2010 +0200
@@ -175,3 +175,82 @@
 searching for changes
 abort: push creates new remote heads on branch 'a'!
 (did you forget to merge? use push -f to force)
+% check prepush with new branch head on former topo non-head
+marked working directory as branch A
+adding a
+marked working directory as branch B
+adding b
+updating to branch B
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+adding b1
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+adding a2
+created new head
+%% glog of local
+@  2: A a2
+|
+| o  1: B b
+|/
+o  0: A a
+
+%% glog of remote
+@  2: B b1
+|
+o  1: B b
+|
+o  0: A a
+
+%% outgoing
+comparing with inner
+searching for changes
+2: A a2
+pushing to inner
+searching for changes
+note: unsynced remote changes!
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files (+1 heads)
+% check prepush with new branch head on former topo head
+marked working directory as branch A
+adding a
+marked working directory as branch B
+adding b
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+adding a1
+created new head
+updating to branch A
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+adding b1
+adding a2
+%% glog of local
+@  3: A a2
+|
+o  2: A a1
+|
+| o  1: B b
+|/
+o  0: A a
+
+%% glog of remote
+@  3: B b1
+|
+| o  2: A a1
+| |
+o |  1: B b
+|/
+o  0: A a
+
+%% outgoing
+comparing with inner
+searching for changes
+3: A a2
+pushing to inner
+searching for changes
+note: unsynced remote changes!
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-update-renames	Fri Apr 09 10:35:53 2010 +0200
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# test update logic when there are renames
+
+
+# update with local changes across a file rename
+hg init a
+cd a
+echo a > a
+hg add a
+hg ci -m a
+hg mv a b
+hg ci -m rename
+echo b > b
+hg ci -m change
+hg up -q 0
+echo c > a
+hg up
+cd ..
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-update-renames.out	Fri Apr 09 10:35:53 2010 +0200
@@ -0,0 +1,5 @@
+merging a and b to b
+warning: conflicts during merge.
+merging b failed!
+0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+use 'hg resolve' to retry unresolved file merges