merge with mpm.
authorVadim Gelfer <vadim.gelfer@gmail.com>
Sun, 30 Jul 2006 22:52:34 -0700
changeset 2739 3248aa10b388
parent 2737 400a4a502001 (diff)
parent 2738 ad4155e757da (current diff)
child 2740 386f04d6ecb3
merge with mpm.
mercurial/commands.py
--- a/contrib/mercurial.el
+++ b/contrib/mercurial.el
@@ -718,7 +718,11 @@ code by typing `M-x find-library mercuri
       (goto-char pos)
       (end-of-line 1)
       (delete-region pos (point)))
-    (cd (hg-root))))
+    (let ((hg-root-dir (hg-root)))
+      (if (not hg-root-dir)
+	  (error "error: %s: directory is not part of a Mercurial repository."
+		 default-directory)
+	(cd (hg-root))))))
 
 (defun hg-add (path)
   "Add PATH to the Mercurial repository on the next commit.
--- a/contrib/vim/hgcommand.vim
+++ b/contrib/vim/hgcommand.vim
@@ -353,13 +353,13 @@ function! s:HGGetStatusVars(revisionVar,
       let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " parents -b  " 
       let statustext=system(hgCommand)
       if(v:shell_error)
-	  return ""
+          return ""
       endif
       let revision=substitute(statustext, '^changeset:\s*\(\d\+\):.*\_$\_.*$', '\1', "")
 
       if a:branchVar != "" && match(statustext, '^\_.*\_^branch:') >= 0
-	let branch=substitute(statustext, '^\_.*\_^branch:\s*\(\S\+\)\n\_.*$', '\1', "")
-	let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'"
+        let branch=substitute(statustext, '^\_.*\_^branch:\s*\(\S\+\)\n\_.*$', '\1', "")
+        let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'"
       endif
     endif
     if (exists('revision'))
@@ -478,111 +478,96 @@ endfunction
 "   1 if new document installed, 0 otherwise.
 " Note: Cleaned and generalized by guo-peng Wen
 "'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+" Helper function to make mkdir as portable as possible
+function! s:HGFlexiMkdir(dir)
+  if exists("*mkdir") " we can use Vim's own mkdir()
+    call mkdir(a:dir)
+  elseif !exists("+shellslash")
+    call system('mkdir -p "'.a:dir.'"')
+  else " M$
+    let l:ssl = &shellslash
+    try
+      set shellslash
+      call system('mkdir "'.a:dir.'"')
+    finally
+      let &shellslash = l:ssl
+    endtry
+  endif
+endfunction
 
 function! s:HGInstallDocumentation(full_name, revision)
-    " Name of the document path based on the system we use:
-    if (has("unix"))
-        " On UNIX like system, using forward slash:
-        let l:slash_char = '/'
-        let l:mkdir_cmd  = ':silent !mkdir -p '
-    else
-        " On M$ system, use backslash. Also mkdir syntax is different.
-        " This should only work on W2K and up.
-        let l:slash_char = '\'
-        let l:mkdir_cmd  = ':silent !mkdir '
+  " Figure out document path based on full name of this script:
+  let l:vim_plugin_path = fnamemodify(a:full_name, ':h')
+  let l:vim_doc_path  = fnamemodify(a:full_name, ':h:h') . "/doc"
+  if filewritable(l:vim_doc_path) != 2
+    echomsg "hgcommand: Trying to update docs at: " . l:vim_doc_path
+    silent! call <SID>HGFlexiMkdir(l:vim_doc_path)
+    if filewritable(l:vim_doc_path) != 2
+      " Try first item in 'runtimepath':
+      let l:vimfiles = matchstr(&runtimepath, '[^,]\+\ze,')
+      let l:vim_doc_path = l:vimfiles . "/doc"
+      if filewritable(l:vim_doc_path) != 2
+        echomsg "hgcommand: Trying to update docs at: " . l:vim_doc_path
+        silent! call <SID>HGFlexiMkdir(l:vim_doc_path)
+        if filewritable(l:vim_doc_path) != 2
+          " Put a warning:
+          echomsg "Unable to open documentation directory"
+          echomsg " type `:help add-local-help' for more information."
+          return 0
+        endif
+      endif
     endif
-
-    let l:doc_path = l:slash_char . 'doc'
-    let l:doc_home = l:slash_char . '.vim' . l:slash_char . 'doc'
+  endif
 
-    " Figure out document path based on full name of this script:
-    let l:vim_plugin_path = fnamemodify(a:full_name, ':h')
-    let l:vim_doc_path    = fnamemodify(a:full_name, ':h:h') . l:doc_path
-    if (!(filewritable(l:vim_doc_path) == 2))
-        echomsg "Doc path: " . l:vim_doc_path
-        execute l:mkdir_cmd . '"' . l:vim_doc_path . '"'
-        if (!(filewritable(l:vim_doc_path) == 2))
-            " Try a default configuration in user home:
-            let l:vim_doc_path = expand("~") . l:doc_home
-            if (!(filewritable(l:vim_doc_path) == 2))
-                execute l:mkdir_cmd . '"' . l:vim_doc_path . '"'
-                if (!(filewritable(l:vim_doc_path) == 2))
-                    " Put a warning:
-                    echomsg "Unable to open documentation directory"
-                    echomsg " type :help add-local-help for more informations."
-                    return 0
-                endif
-            endif
-        endif
-    endif
+  " Full name of script and documentation file:
+  let l:script_name = fnamemodify(a:full_name, ':t')
+  let l:doc_name  = fnamemodify(a:full_name, ':t:r') . '.txt'
+  let l:doc_file  = l:vim_doc_path . "/" . l:doc_name
 
-    " Exit if we have problem to access the document directory:
-    if (!isdirectory(l:vim_plugin_path)
-        \ || !isdirectory(l:vim_doc_path)
-        \ || filewritable(l:vim_doc_path) != 2)
-        return 0
-    endif
-
-    " Full name of script and documentation file:
-    let l:script_name = fnamemodify(a:full_name, ':t')
-    let l:doc_name    = fnamemodify(a:full_name, ':t:r') . '.txt'
-    let l:plugin_file = l:vim_plugin_path . l:slash_char . l:script_name
-    let l:doc_file    = l:vim_doc_path    . l:slash_char . l:doc_name
+  " Bail out if document file is still up to date:
+  if filereadable(l:doc_file)  && getftime(a:full_name) < getftime(l:doc_file)
+    return 0
+  endif
 
-    " Bail out if document file is still up to date:
-    if (filereadable(l:doc_file)  &&
-        \ getftime(l:plugin_file) < getftime(l:doc_file))
-        return 0
-    endif
+  " Create a new buffer & read in the plugin file (me):
+  setl nomodeline
+  1 new!
+  setl noswapfile modifiable
+  sil exe 'read ' . a:full_name
 
-    " Prepare window position restoring command:
-    if (strlen(@%))
-        let l:go_back = 'b ' . bufnr("%")
-    else
-        let l:go_back = 'enew!'
-    endif
+  setl modeline
+  let l:buf = bufnr("%")
 
-    " Create a new buffer & read in the plugin file (me):
-    setl nomodeline
-    exe 'enew!'
-    exe 'r ' . l:plugin_file
+  norm zR
+  norm gg
 
-    setl modeline
-    let l:buf = bufnr("%")
-    setl noswapfile modifiable
-
-    norm zR
-    norm gg
+  " Delete from first line to a line starts with
+  " === START_DOC
+  sil 1,/^=\{3,}\s\+START_DOC\C/ d
 
-    " Delete from first line to a line starts with
-    " === START_DOC
-    1,/^=\{3,}\s\+START_DOC\C/ d
+  " Delete from a line starts with
+  " === END_DOC
+  " to the end of the documents:
+  sil /^=\{3,}\s\+END_DOC\C/,$ d
 
-    " Delete from a line starts with
-    " === END_DOC
-    " to the end of the documents:
-    /^=\{3,}\s\+END_DOC\C/,$ d
-
-    " Remove fold marks:
-    %s/{\{3}[1-9]/    /
+  " Remove fold marks:
+  sil %s/{\{3}[1-9]/  /e
 
-    " Add modeline for help doc: the modeline string is mangled intentionally
-    " to avoid it be recognized by VIM:
-    call append(line('$'), '')
-    call append(line('$'), ' v' . 'im:tw=78:ts=8:ft=help:norl:')
+  " Add modeline for help doc: the modeline string is mangled intentionally
+  " to avoid it be recognized by VIM:
+  call append(line('$'), '')
+  call append(line('$'), ' v' . 'im:tw=78:ts=8:ft=help:norl:')
 
-    " Replace revision:
-    exe "normal :1s/#version#/ v" . a:revision . "/\<CR>"
+  " Replace revision:
+  sil exe "normal :1s/#version#/ v" . a:revision . "/\<CR>"
 
-    " Save the help document:
-    exe 'w! ' . l:doc_file
-    exe l:go_back
-    exe 'bw ' . l:buf
+  " Save the help document and wipe out buffer:
+  sil exe 'wq! ' . l:doc_file . ' | bw ' . l:buf
 
-    " Build help tags:
-    exe 'helptags ' . l:vim_doc_path
+  " Build help tags:
+  sil exe 'helptags ' . l:vim_doc_path
 
-    return 1
+  return 1
 endfunction
 
 " Section: Public functions {{{1
@@ -1185,13 +1170,16 @@ endif
 " Section: Doc installation {{{1
 "
   let s:revision="0.1"
-  silent! let s:install_status =
-      \ s:HGInstallDocumentation(expand('<sfile>:p'), s:revision)
-  if (s:install_status == 1)
-      echom expand("<sfile>:t:r") . ' v' . s:revision .
-		\ ': Help-documentation installed.'
+  if s:HGInstallDocumentation(escape(expand('<sfile>:p'), ' '), s:revision)
+      echom expand('<sfile>:t:r') . ' v' . s:revision .
+                \ ': Help-documentation installed.'
   endif
 
+  " delete one-time vars and functions
+  delfunction <SID>HGInstallDocumentation
+  delfunction <SID>HGFlexiMkdir
+  unlet s:revision
+
 
 " Section: Plugin completion {{{1
 
@@ -1638,7 +1626,7 @@ 5.5 HGCommand buffer management		       
    status' will be invoked at each entry into a buffer (during the |BufEnter| 
    autocommand).
 
-   This mode is enablmed by default.  In order to disable it, set the 
+   This mode is enabled by default.  In order to disable it, set the 
    |HGCommandEnableBufferSetup| variable to a false (zero) value.  Enabling 
    this mode simply provides the buffer variables mentioned above.  The user 
    must explicitly include those in the |'statusline'| option if they are to 
--- a/hgext/hbisect.py
+++ b/hgext/hbisect.py
@@ -50,7 +50,7 @@ class bisect(object):
             if r:
                 self.badrev = hg.bin(r.pop(0))
 
-    def __del__(self):
+    def write(self):
         if not os.path.isdir(self.path):
             return
         f = self.opener(self.good_path, "w")
@@ -288,7 +288,10 @@ for subcommands see "hg bisect help\"
     if len(args) > bisectcmdtable[cmd][1]:
         ui.warn(_("bisect: Too many arguments\n"))
         return help_()
-    return bisectcmdtable[cmd][0](*args)
+    try:
+        return bisectcmdtable[cmd][0](*args)
+    finally:
+        b.write()
 
 cmdtable = {
     "bisect": (bisect_run, [], _("hg bisect [help|init|reset|next|good|bad]")),
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -288,6 +288,7 @@ def patchbomb(ui, repo, *revs, **opts):
             fp.close()
         else:
             ui.status('Sending ', m['Subject'], ' ...\n')
+            m.__delitem__('bcc')
             mail.sendmail(sender, to + bcc + cc, m.as_string(0))
 
 cmdtable = {
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -287,7 +287,8 @@ def make_filename(repo, pat, node,
         if node:
             expander.update(node_expander)
         if node and revwidth is not None:
-            expander['r'] = lambda: str(r.rev(node)).zfill(revwidth)
+            expander['r'] = (lambda:
+                    str(repo.changelog.rev(node)).zfill(revwidth))
         if total is not None:
             expander['N'] = lambda: str(total)
         if seqno is not None:
@@ -1758,7 +1759,7 @@ def import_(ui, repo, patch1, *patches, 
             if user:
                 ui.debug('From: %s\n' % user)
             diffs_seen = 0
-            ok_types = ('text/plain', 'text/x-patch')
+            ok_types = ('application/x-patch', 'text/plain', 'text/x-patch')
             for part in msg.walk():
                 content_type = part.get_content_type()
                 ui.debug('Content-Type: %s\n' % content_type)
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -31,6 +31,8 @@ def hg(ui, path):
 def local_(ui, path, create=0):
     if path.startswith('file:'):
         path = path[5:]
+    if not create and os.path.isfile(path):
+        return bundlerepo.bundlerepository(ui, '', path)
     return localrepo.localrepository(ui, path, create)
 
 def ssh_(ui, path, create=0):
--- a/tests/test-bundle
+++ b/tests/test-bundle
@@ -30,10 +30,14 @@ cd ..
 hg init empty
 hg -R test bundle full.hg empty
 hg -R test unbundle full.hg
-hg -R empty unbundle full.hg
 hg -R empty heads
 hg -R empty verify
 
+hg --cwd test pull ../full.hg
+hg --cwd empty pull ../full.hg
+hg -R empty rollback
+hg --cwd empty pull ../full.hg
+
 rm -rf empty
 hg init empty
 cd empty
--- a/tests/test-bundle.out
+++ b/tests/test-bundle.out
@@ -11,28 +11,34 @@ adding manifests
 adding file changes
 added 0 changesets with 0 changes to 4 files
 (run 'hg update' to get a working copy)
+changeset:   -1:000000000000
+tag:         tip
+user:        
+date:        Thu Jan 01 00:00:00 1970 +0000
+
+checking changesets
+checking manifests
+crosschecking files in changesets and manifests
+checking files
+0 files, 0 changesets, 0 total revisions
+pulling from ../full.hg
+searching for changes
+no changes found
+pulling from ../full.hg
+requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 9 changesets with 7 changes to 4 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
-changeset:   8:836ac62537ab
-tag:         tip
-parent:      3:ac69c658229d
-user:        test
-date:        Mon Jan 12 13:46:40 1970 +0000
-summary:     0.3m
-
-changeset:   7:80fe151401c2
-user:        test
-date:        Mon Jan 12 13:46:40 1970 +0000
-summary:     1.3m
-
-checking changesets
-checking manifests
-crosschecking files in changesets and manifests
-checking files
-4 files, 9 changesets, 7 total revisions
+rolling back last transaction
+pulling from ../full.hg
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 9 changesets with 7 changes to 4 files (+1 heads)
+(run 'hg heads' to see heads, 'hg merge' to merge)
 changeset:   8:836ac62537ab
 tag:         tip
 parent:      3:ac69c658229d