Martin Geisler avatar Martin Geisler committed 9c9211a

Handle and test "hg pull -r"

Comments (0)

Files changed (2)

      ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
      ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
      ('b', 'branch', [], _('a specific branch you would like to pull'),
-@@ -3745,7 +3748,8 @@
+@@ -3728,6 +3731,11 @@
+     ui.status(_('pulling from %s\n') % util.hidepassword(source))
+     revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
+ 
++    import os
++    if 'DEBUG' in os.environ:
++        print 'revs:', revs
++        print 'checkout:', checkout
++
+     if opts.get('bookmark'):
+         if not revs:
+             revs = []
+@@ -3745,10 +3753,22 @@
                      "so a rev cannot be specified.")
              raise util.Abort(err)
  
 +    modheads = repo.pull(other, heads=revs, force=opts.get('force'),
 +                         abandoned=opts.get('abandoned'))
      bookmarks.updatefromremote(ui, repo, other)
-     if checkout:
-         checkout = str(repo.changelog.rev(other.lookup(checkout)))
-@@ -3768,6 +3772,7 @@
+-    if checkout:
+-        checkout = str(repo.changelog.rev(other.lookup(checkout)))
++
++    # fix checkout to take abandoned changesets into account
++    if revs:
++        for node in revs:
++            try:
++                checkout = str(repo.changelog.rev(node))
++                break
++            except error.LookupError:
++                pass
++
++    if 'DEBUG' in os.environ:
++        print 'checkout:', checkout
++
+     repo._subtoppath = source
+     try:
+         ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
+@@ -3768,6 +3788,7 @@
  
  @command('^push',
      [('f', 'force', None, _('force push')),
      ('r', 'rev', [],
       _('a changeset intended to be included in the destination'),
       _('REV')),
-@@ -3836,7 +3841,8 @@
+@@ -3836,7 +3857,8 @@
      finally:
          del repo._subtoppath
      result = repo.push(other, opts.get('force'), revs=revs,
 diff --git a/tests/test-abandoned.t b/tests/test-abandoned.t
 --- a/tests/test-abandoned.t
 +++ b/tests/test-abandoned.t
-@@ -49,3 +49,576 @@
+@@ -49,3 +49,595 @@
    $ hg log --hidden -r 'abandoned()'
    1 0b00c28422ee x
    2 339976ff5010 abandoned
 +  searching for changes
 +  no changes found
 +
++  $ hg pull -r 1 ../repo
++  pulling from ../repo
++  searching for changes
++  no changes found
++
 +testing pull --abandoned with no shared abandoned changesets
 +
 +  $ cd ../empty
 +  0 54dbcd775ef0 init
 +  $ hg rollback -q
 +
++  $ hg pull --abandoned -r 1 ../repo
++  pulling from ../repo
++  searching for changes
++  adding changesets
++  adding manifests
++  adding file changes
++  added 1 changesets with 1 changes to 1 files
++  (run 'hg update' to get a working copy)
++  $ hg log --hidden
++  1 0b00c28422ee x
++  0 54dbcd775ef0 init
++  $ hg rollback -q
++
++
 +testing pull with a shared abandoned changeset
 +
 +  $ cd ../base-x
 # User Martin Geisler <mg@aragost.com>
 # Date 1307125545 -7200
 # Node ID 4ce5dc47d305e9811a662c92a167fccd51363db8
-# Parent  6dcc20e5e7744a50fa5142f47324b3dd8714c669
+# Parent 0a95ab47afdd1def604f733e7f2e5dfa6436343f
 postincoming: output a warning if the working copy is abandoned
 
 diff --git a/mercurial/commands.py b/mercurial/commands.py
      if modheads > 1:
          currentbranchheads = len(repo.branchheads())
          if currentbranchheads == modheads:
-@@ -3748,6 +3750,7 @@
+@@ -3753,6 +3755,7 @@
                      "so a rev cannot be specified.")
              raise util.Abort(err)
  
      modheads = repo.pull(other, heads=revs, force=opts.get('force'),
                           abandoned=opts.get('abandoned'))
      bookmarks.updatefromremote(ui, repo, other)
-@@ -3755,8 +3758,8 @@
-         checkout = str(repo.changelog.rev(other.lookup(checkout)))
+@@ -3772,8 +3775,8 @@
+ 
      repo._subtoppath = source
      try:
 -        ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
      finally:
          del repo._subtoppath
  
-@@ -4982,6 +4985,7 @@
+@@ -4999,6 +5002,7 @@
  
      lock = repo.lock()
      wc = repo['.']
      try:
          for fname in fnames:
              f = url.open(ui, fname)
-@@ -4991,7 +4995,8 @@
+@@ -5008,7 +5012,8 @@
          bookmarks.updatecurrentbookmark(repo, wc.node(), wc.branch())
      finally:
          lock.release()
 diff --git a/tests/test-abandoned.t b/tests/test-abandoned.t
 --- a/tests/test-abandoned.t
 +++ b/tests/test-abandoned.t
-@@ -383,6 +383,7 @@
+@@ -402,6 +402,7 @@
    adding manifests
    adding file changes
    added 1 changesets with 0 changes to 0 files
    (run 'hg update' to get a working copy)
    $ hg log --hidden
    2 339976ff5010 abandoned
-@@ -397,6 +398,7 @@
+@@ -416,6 +417,7 @@
    adding manifests
    adding file changes
    added 1 changesets with 0 changes to 0 files
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.