changeset 13323:d8d478f9ee0f

merge with stable
author Martin Geisler <mg@aragost.com>
date Mon, 31 Jan 2011 13:38:00 +0100
parents 0d1dca7d2a04 (current diff) c19b9282d3a7 (diff)
children e5617047c926
files mercurial/merge.py mercurial/subrepo.py
diffstat 4 files changed, 76 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Fri Jan 28 03:09:22 2011 +0100
+++ b/mercurial/merge.py	Mon Jan 31 13:38:00 2011 +0100
@@ -249,7 +249,7 @@
 def actionkey(a):
     return a[1] == 'r' and -1 or 0, a
 
-def applyupdates(repo, action, wctx, mctx, actx):
+def applyupdates(repo, action, wctx, mctx, actx, overwrite):
     """apply the merge action list to the working directory
 
     wctx is the working copy context
@@ -310,7 +310,7 @@
             repo.ui.note(_("removing %s\n") % f)
             audit_path(f)
             if f == '.hgsubstate': # subrepo states need updating
-                subrepo.submerge(repo, wctx, mctx, wctx)
+                subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
             try:
                 util.unlinkpath(repo.wjoin(f))
             except OSError, inst:
@@ -320,7 +320,7 @@
             removed += 1
         elif m == "m": # merge
             if f == '.hgsubstate': # subrepo states need updating
-                subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx))
+                subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), overwrite)
                 continue
             f2, fd, flags, move = a[2:]
             r = ms.resolve(fd, wctx, mctx)
@@ -343,7 +343,7 @@
             t = None
             updated += 1
             if f == '.hgsubstate': # subrepo states need updating
-                subrepo.submerge(repo, wctx, mctx, wctx)
+                subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
         elif m == "d": # directory rename
             f2, fd, flags = a[2:]
             if f:
@@ -534,7 +534,7 @@
         if not partial:
             repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2)
 
-        stats = applyupdates(repo, action, wc, p2, pa)
+        stats = applyupdates(repo, action, wc, p2, pa, overwrite)
 
         if not partial:
             repo.dirstate.setparents(fp1, fp2)
--- a/mercurial/subrepo.py	Fri Jan 28 03:09:22 2011 +0100
+++ b/mercurial/subrepo.py	Mon Jan 31 13:38:00 2011 +0100
@@ -82,7 +82,7 @@
                 ''.join(['%s %s\n' % (state[s][1], s)
                          for s in sorted(state)]), '')
 
-def submerge(repo, wctx, mctx, actx):
+def submerge(repo, wctx, mctx, actx, overwrite):
     """delegated from merge.applyupdates: merging of .hgsubstate file
     in working context, merging context and ancestor context"""
     if mctx == actx: # backwards?
@@ -114,7 +114,7 @@
                 continue
             elif ld == a: # other side changed
                 debug(s, "other changed, get", r)
-                wctx.sub(s).get(r)
+                wctx.sub(s).get(r, overwrite)
                 sm[s] = r
             elif ld[0] != r[0]: # sources differ
                 if repo.ui.promptchoice(
@@ -123,11 +123,11 @@
                       % (s, l[0], r[0]),
                       (_('&Local'), _('&Remote')), 0):
                     debug(s, "prompt changed, get", r)
-                    wctx.sub(s).get(r)
+                    wctx.sub(s).get(r, overwrite)
                     sm[s] = r
             elif ld[1] == a[1]: # local side is unchanged
                 debug(s, "other side changed, get", r)
-                wctx.sub(s).get(r)
+                wctx.sub(s).get(r, overwrite)
                 sm[s] = r
             else:
                 debug(s, "both sides changed, merge with", r)
@@ -263,13 +263,13 @@
         """
         raise NotImplementedError
 
-    def get(self, state):
+    def get(self, state, overwrite=False):
         """run whatever commands are needed to put the subrepo into
         this state
         """
         raise NotImplementedError
 
-    def merge(self, state):
+    def merge(self, state, overwrite=False):
         """merge currently-saved state with the new state."""
         raise NotImplementedError
 
@@ -431,7 +431,7 @@
             other = hg.repository(self._repo.ui, srcurl)
             self._repo.pull(other)
 
-    def get(self, state):
+    def get(self, state, overwrite=False):
         self._get(state)
         source, revision, kind = state
         self._repo.ui.debug("getting subrepo %s\n" % self._path)
@@ -599,7 +599,9 @@
         except OSError:
             pass
 
-    def get(self, state):
+    def get(self, state, overwrite=False):
+        if overwrite:
+            self._svncommand(['revert', '--recursive', self._path])
         status = self._svncommand(['checkout', state[0], '--revision', state[1]])
         if not re.search('Checked out revision [0-9]+.', status):
             raise util.Abort(status.splitlines()[-1])
@@ -749,7 +751,7 @@
         out, code = self._gitdir(['diff-index', '--quiet', 'HEAD'])
         return code == 1
 
-    def get(self, state):
+    def get(self, state, overwrite=False):
         source, revision, kind = state
         self._fetch(source, revision)
         # if the repo was set to be bare, unbare it
--- a/tests/test-subrepo-svn.t	Fri Jan 28 03:09:22 2011 +0100
+++ b/tests/test-subrepo-svn.t	Mon Jan 31 13:38:00 2011 +0100
@@ -264,3 +264,35 @@
   $ hg up null
   0 files updated, 0 files merged, 3 files removed, 0 files unresolved
   $ ls
+
+Check hg update --clean
+  $ cd $TESTTMP/sub/t
+  $ cd s
+  $ echo c0 > alpha
+  $ echo c1 > f1
+  $ echo c1 > f2
+  $ svn add f1 -q
+  $ svn status
+  ?       a
+  X       externals
+  ?       f2
+  M       alpha
+  A       f1
+  
+  Performing status on external item at 'externals'
+  $ cd ..
+  $ hg update -C
+  
+  Fetching external item into '$TESTTMP/sub/t/s/externals'
+  Checked out external at revision 1.
+  
+  Checked out revision 3.
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd s
+  $ svn status
+  ?       a
+  X       externals
+  ?       f1
+  ?       f2
+  
+  Performing status on external item at 'externals'
--- a/tests/test-subrepo.t	Fri Jan 28 03:09:22 2011 +0100
+++ b/tests/test-subrepo.t	Mon Jan 31 13:38:00 2011 +0100
@@ -675,3 +675,31 @@
   committing subrepository subrepo-1
   committing subrepository subrepo-2
   $ hg st subrepo-2/file
+
+Check hg update --clean
+  $ cd $TESTTMP/sub/t
+  $ rm -r t/t.orig
+  $ hg status -S --all
+  C .hgsub
+  C .hgsubstate
+  C a
+  C s/.hgsub
+  C s/.hgsubstate
+  C s/a
+  C s/ss/a
+  C t/t
+  $ echo c1 > s/a
+  $ cd s
+  $ echo c1 > b
+  $ echo c1 > c
+  $ hg add b
+  $ cd ..
+  $ hg status -S
+  M s/a
+  A s/b
+  ? s/c
+  $ hg update -C
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg status -S
+  ? s/b
+  ? s/c